1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | |
---|
3 | // Functions and interfaces to manage datasets now that they are in data folders |
---|
4 | // Planned interface |
---|
5 | // - Panel to select/load data and then select operation |
---|
6 | // Planned functions: |
---|
7 | // - Rename a data set - AJJ Done Nov 2009 |
---|
8 | // - Duplicate a data set - AJJ Done Nov 2009 |
---|
9 | // - Subtract one data set from another |
---|
10 | // - Add one data set to another |
---|
11 | // - Divide data sets |
---|
12 | // - Multiply data sets |
---|
13 | // - Save a data folder to file |
---|
14 | |
---|
15 | /////////////////// Data Management Panel /////////////////////////////////////////////////////// |
---|
16 | |
---|
17 | Function MakeDMPanel() |
---|
18 | PauseUpdate; Silent 1 // building window... |
---|
19 | NewPanel /W=(459,44,959,364)/N=DataManagementPanel/K=1 as "Data Set Management" |
---|
20 | ModifyPanel fixedSize=1 |
---|
21 | |
---|
22 | //Main bit of panel |
---|
23 | GroupBox grpBox_0,pos={20,10},size={460,50} |
---|
24 | GroupBox grpBox_1,pos={20,80},size={460,200} |
---|
25 | |
---|
26 | Button DS1_button,pos={300,20},size={150,20},proc=DM_LoadDataSetProc,title="Load 1D Data Set 1" |
---|
27 | PopupMenu DS1_popup,pos={30,21},size={318,20},title="Data Set 1",proc=DMDS_PopMenuProc |
---|
28 | PopupMenu DS1_popup,mode=1,value= #"DM_DataSetPopupList()" |
---|
29 | |
---|
30 | //Management Tab |
---|
31 | Button Rename_button,title="Rename",pos={75,200},size={150,20} |
---|
32 | Button Duplicate_button,title="Duplicate",pos={275,200},size={150,20} |
---|
33 | Button Save_button,title="Save",pos={75,240},size={150,20} |
---|
34 | Button Unload_button,title="Unload",pos={275,240},size={150,20} |
---|
35 | SetVariable OldName_setvar,title="Old Name",pos={50,100},size={400,20} |
---|
36 | SetVariable OldName_setvar,fsize=12,value=_STR:"",noedit=2 |
---|
37 | SetVariable NewName_setvar,title="New Name (max 25 characters)",pos={50,140},size={400,20} |
---|
38 | SetVariable NewName_setvar,fsize=12,value=_STR:"",proc=setvarproc,live=1 |
---|
39 | |
---|
40 | End |
---|
41 | |
---|
42 | //Must follow naming scheme to match buttons to popups |
---|
43 | //"Name_button" goes with "Name_popup" |
---|
44 | Function DM_LoadDataSetProc(ba) : ButtonControl |
---|
45 | STRUCT WMButtonAction &ba |
---|
46 | |
---|
47 | |
---|
48 | switch( ba.eventCode ) |
---|
49 | case 2: // mouse up |
---|
50 | // click code here |
---|
51 | String cmd = "A_LoadOneDDataWithName(\"\","+num2str(0)+")" |
---|
52 | Execute cmd |
---|
53 | |
---|
54 | SVAR gLastFileName = root:packages:NIST:gLastFileName |
---|
55 | |
---|
56 | String windowName = ba.win |
---|
57 | String popupName = StringFromList(0,ba.ctrlName,"_")+"_popup" |
---|
58 | |
---|
59 | ControlUpdate/W=$(windowName) $(popupName) |
---|
60 | //instead of a simple controlUpdate, better to pop the menu to make sure that the other menus follow |
---|
61 | // convoluted method to find the right item and pop the menu. |
---|
62 | |
---|
63 | String list,folderStr |
---|
64 | Variable num |
---|
65 | folderStr = CleanupName(gLastFileName,0) |
---|
66 | list = DM_DataSetPopupList() |
---|
67 | num=WhichListItem(folderStr,list,";",0,0) |
---|
68 | if(num != -1) |
---|
69 | PopupMenu $(popupName),mode=num+1,win=$(windowName) |
---|
70 | ControlUpdate/W=$(windowName) $(popupName) |
---|
71 | |
---|
72 | if (cmpstr(popupName,"DS1_popup") == 0) |
---|
73 | //send fake mouse action to popup to update old name if |
---|
74 | Struct WMPopupAction pa |
---|
75 | pa.eventCode = 2 //fake mouse up |
---|
76 | pa.win = windowName |
---|
77 | pa.ctrlName = "DS1_popup" |
---|
78 | DMDS_PopMenuProc(pa) |
---|
79 | endif |
---|
80 | endif |
---|
81 | break |
---|
82 | endswitch |
---|
83 | |
---|
84 | return 0 |
---|
85 | End |
---|
86 | |
---|
87 | |
---|
88 | Function DMDS_PopMenuProc(pa) : PopupMenuControl |
---|
89 | STRUCT WMPopupAction &pa |
---|
90 | |
---|
91 | switch( pa.eventCode ) |
---|
92 | case 2: // mouse up |
---|
93 | ControlInfo/W=$(pa.win) $(pa.ctrlName) |
---|
94 | SetVariable OldName_setvar,win=$(pa.win),value=_STR:S_Value |
---|
95 | // ControlInfo/W=$(pa.win) DSTabItem_0e |
---|
96 | // SVAR val = S_Value |
---|
97 | // |
---|
98 | // ControlInfo/W=$(pa.win) $(pa.ctrlName) |
---|
99 | // val = S_Value |
---|
100 | |
---|
101 | SetDataFolder root: |
---|
102 | break |
---|
103 | endswitch |
---|
104 | |
---|
105 | return 0 |
---|
106 | End |
---|
107 | |
---|
108 | |
---|
109 | Function/S DMGetDSName(dsNum) |
---|
110 | Variable dsNum |
---|
111 | |
---|
112 | String ctrlName |
---|
113 | if (dsNum == 1) |
---|
114 | ctrlName = "DS1_popup" |
---|
115 | elseif (dsNum == 2) |
---|
116 | ctrlName = "DS2_popup" |
---|
117 | endif |
---|
118 | |
---|
119 | ControlInfo/W=DataManagementPanel $(ctrlName) |
---|
120 | |
---|
121 | Return S_Value |
---|
122 | |
---|
123 | End |
---|
124 | |
---|
125 | |
---|
126 | /////////////////////// Data Arithmetic Panel ///////////////////////////////////////// |
---|
127 | |
---|
128 | Function MakeDAPanel() |
---|
129 | PauseUpdate; Silent 1 // building window... |
---|
130 | DoWindow/K DataArithmeticPanel |
---|
131 | NewPanel /W=(459,44,959,404)/N=DataArithmeticPanel/K=1 as "Data Set Arithmetic" |
---|
132 | ModifyPanel fixedSize=1 |
---|
133 | |
---|
134 | //Main bit of panel |
---|
135 | GroupBox grpBox_0,pos={20,10},size={460,105} |
---|
136 | |
---|
137 | Button DS1_button,pos={300,20},size={150,20},proc=DA_LoadDataSetProc,title="Load 1D Data Set 1" |
---|
138 | Button DS1_button,valueColor=(65535,0,0),userdata="DS1" |
---|
139 | PopupMenu DS1_popup,pos={30,21},size={318,20},title="Data Set 1" |
---|
140 | PopupMenu DS1_popup,mode=1,value= #"DM_DataSetPopupList()" |
---|
141 | PopupMenu DS1_popup,proc=DA_PopupProc |
---|
142 | PopupMenu DS1_popup,fsize=12,fcolor=(65535,0,0),valueColor=(65535,0,0) |
---|
143 | |
---|
144 | Button DS2_button,pos={300,50},size={150,20},proc=DA_LoadDataSetProc,title="Load 1D Data Set 2" |
---|
145 | Button DS2_button,valueColor=(0,0,65535),userdata="DS2" |
---|
146 | PopupMenu DS2_popup,pos={30,51},size={318,20},title="Data Set 2" |
---|
147 | PopupMenu DS2_popup,mode=1,value= #"DM_DataSetPopupList()" |
---|
148 | PopupMenu DS2_popup,proc=DA_PopupProc |
---|
149 | PopupMenu DS2_popup,fsize=12,fcolor=(0,0,65535),valueColor=(0,0,65535) |
---|
150 | |
---|
151 | Button DAPlot_button,title="Plot",pos={175,85},size={150,20} |
---|
152 | Button DAPlot_button,proc=DAPlotButtonProc |
---|
153 | |
---|
154 | |
---|
155 | //Tabs |
---|
156 | TabControl DATabs,pos={20,120},size={460,220},tabLabel(0)="Subtract", proc=DATabsProc |
---|
157 | TabControl DATabs,tablabel(1)="Add",tablabel(2)="Multiply",tablabel(3)="Divide" |
---|
158 | TabControl DATabs,value=0 |
---|
159 | |
---|
160 | Button DACalculate_button,title="Calculate",pos={50,310},size={150,20} |
---|
161 | Button DACalculate_button,proc=DACalculateProc |
---|
162 | Button DASave_button,title="Save Result",pos={300,310},size={150,20} |
---|
163 | Button DASave_button,proc=DASaveProc |
---|
164 | Button DACursors_button,title="Get Matching Range",pos={175,250},size={150,20} |
---|
165 | Button DACursors_button,proc=DACursorButtonProc |
---|
166 | |
---|
167 | SetVariable DAResultName_sv,title="Result Name (max 25 characters)",pos={50,280},size={400,20} |
---|
168 | SetVariable DAResultName_Sv,fsize=12,proc=setvarproc,live=1 |
---|
169 | //Update the result name |
---|
170 | ControlInfo/W=DataArithmeticPanel DS1_popup |
---|
171 | if (cmpstr(S_Value,"No data loaded") == 0) |
---|
172 | SetVariable DAResultName_sv,value=_STR:"SubtractionResult" |
---|
173 | else |
---|
174 | //fake call to popup |
---|
175 | STRUCT WMPopupAction pa |
---|
176 | pa.win = "DataArithmeticPanel" |
---|
177 | pa.ctrlName = "DS1_popup" |
---|
178 | pa.eventCode = 2 |
---|
179 | DA_PopupProc(pa) |
---|
180 | endif |
---|
181 | |
---|
182 | CheckBox DANoDS2_cb,title="Data Set 2 = 1?",pos={300,180} |
---|
183 | CheckBox DANoDS2_cb,proc=DANoDS2Proc |
---|
184 | |
---|
185 | ValDisplay DARangeStar_vd,title="Start",pos={40,220},size={100,20},fsize=12,value=_NUM:0 |
---|
186 | ValDisplay DARangeEnd_vd,title="End ",pos={160,220},size={100,20},fsize=12,value=_NUM:0 |
---|
187 | |
---|
188 | SetVariable DAScale_sv,title="Scale Factor (f)",pos={280,220},size={180,20},fsize=12,value=_NUM:1 |
---|
189 | |
---|
190 | GroupBox grpBox_1,pos={30,210},size={440,70} |
---|
191 | |
---|
192 | NewPanel/HOST=DataArithmeticPanel/N=arithDisplay/W=(50,150,170,190) |
---|
193 | |
---|
194 | //Update the result name |
---|
195 | ControlInfo/W=DataArithmeticPanel DS1_popup |
---|
196 | |
---|
197 | |
---|
198 | |
---|
199 | arithDisplayProc(0) |
---|
200 | |
---|
201 | End |
---|
202 | |
---|
203 | |
---|
204 | Function MakeDAPlotPanel() |
---|
205 | PauseUpdate; Silent 1 // building window... |
---|
206 | DoWindow/K DAPlotPanel |
---|
207 | NewPanel /W=(14,44,454,484)/N=DAPlotPanel/K=1 as "Data Set Arithmetic" |
---|
208 | ModifyPanel fixedSize=1 |
---|
209 | |
---|
210 | Display/HOST=DAPlotPanel/N=DAPlot/W=(0,0,440,400) |
---|
211 | ShowInfo |
---|
212 | SetActiveSubWindow DAPlotPanel |
---|
213 | Checkbox DAPlot_log_cb, title="Log I(q)", pos={20,410},value=0 |
---|
214 | Checkbox DAPlot_log_cb, proc=DALogLinIProc |
---|
215 | |
---|
216 | |
---|
217 | End |
---|
218 | |
---|
219 | Function AddDAPlot(dataset) |
---|
220 | Variable dataset |
---|
221 | |
---|
222 | String win = "DataArithmeticPanel" |
---|
223 | String DS1name,DS2name,ResultName |
---|
224 | |
---|
225 | switch(dataset) |
---|
226 | case 1: |
---|
227 | ControlInfo/W=$(win) DS1_popup |
---|
228 | DS1name = S_Value |
---|
229 | Wave qWave = $("root:"+DS1name+":"+DS1name+"_q") |
---|
230 | Wave iWave = $("root:"+DS1name+":"+DS1name+"_i") |
---|
231 | Wave errWave = $("root:"+DS1name+":"+DS1name+"_s") |
---|
232 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
233 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(DS1name+"_i"), Y wave=(errWave,errWave) |
---|
234 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(DS1name+"_i"))=(65535,0,0) |
---|
235 | ControlInfo/W=$(win) DANoDS2_cb |
---|
236 | // if (V_Value == 1) |
---|
237 | // Cursor/W=DAPlotPanel#DAPlot A, $(DS1name+"_i"), leftx(iWave) |
---|
238 | // Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS1name+"_i"), rightx(iWave) |
---|
239 | // endif |
---|
240 | break |
---|
241 | case 2: |
---|
242 | ControlInfo/W=$(win) DANoDS2_cb |
---|
243 | if (V_Value == 0) |
---|
244 | ControlInfo/W=$(win) DS2_popup |
---|
245 | DS2name = S_Value |
---|
246 | Wave qWave = $("root:"+DS2name+":"+DS2name+"_q") |
---|
247 | Wave iWave = $("root:"+DS2name+":"+DS2name+"_i") |
---|
248 | Wave errWave = $("root:"+DS2name+":"+DS2name+"_s") |
---|
249 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
250 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(DS2name+"_i"), Y wave=(errWave,errWave) |
---|
251 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(DS2name+"_i"))=(0,0,65535) |
---|
252 | Cursor/W=DAPlotPanel#DAPlot A, $(DS2name+"_i"), leftx(iWave) |
---|
253 | Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS2name+"_i"), rightx(iWave) |
---|
254 | else |
---|
255 | ControlInfo/W=$(win) DS1_popup |
---|
256 | DS1name = S_Value |
---|
257 | DuplicateDataSet("root:"+DS1name,"NullSolvent",1) |
---|
258 | Wave qWave =root:NullSolvent:NullSolvent_q |
---|
259 | Wave iWave = root:NullSolvent:NullSolvent_i |
---|
260 | Wave errWave = root:NullSolvent:NullSolvent_s |
---|
261 | iWave = 1 |
---|
262 | errWave = 0 |
---|
263 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
264 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 NullSolvent_i, Y wave=(errWave,errWave) |
---|
265 | ModifyGraph/W=DAPlotPanel#DAPlot rgb(NullSolvent_i)=(0,0,65535) |
---|
266 | Cursor/W=DAPlotPanel#DAPlot A, NullSolvent_i, leftx(iWave) |
---|
267 | Cursor/W=DAPlotPanel#DAPlot/A=0 B, NullSolvent_i, rightx(iWave) |
---|
268 | endif |
---|
269 | break |
---|
270 | case 3: |
---|
271 | ControlInfo/W=$(win) DAResultName_sv |
---|
272 | ResultName = S_Value |
---|
273 | Wave qWave = $("root:"+ResultName+":"+ResultName+"_q") |
---|
274 | Wave iWave = $("root:"+ResultName+":"+ResultName+"_i") |
---|
275 | Wave errWave = $("root:"+ResultName+":"+ResultName+"_s") |
---|
276 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
277 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(ResultName+"_i"), Y wave=(errWave,errWave) |
---|
278 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(ResultName+"_i"))=(0,65535,0) |
---|
279 | break |
---|
280 | endswitch |
---|
281 | |
---|
282 | ControlInfo/W=DAPlotPanel DAPlot_log_cb |
---|
283 | ModifyGraph/W=DAPlotPanel#DAPlot mode=3, msize=2, marker=19, mirror=1, tick=2, log(bottom)=1,log(left)=V_Value |
---|
284 | |
---|
285 | End |
---|
286 | |
---|
287 | Function arithDisplayProc(s) |
---|
288 | Variable s |
---|
289 | |
---|
290 | SetActiveSubWindow DataArithmeticPanel#arithDisplay |
---|
291 | |
---|
292 | switch (s) |
---|
293 | case 0: |
---|
294 | //Subtract |
---|
295 | DrawAction/L=progFront delete |
---|
296 | DrawRect 0,0,120,40 |
---|
297 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
298 | DrawText 10,32,"I" |
---|
299 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
300 | DrawText 20,30,"=" |
---|
301 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
302 | DrawText 35,32,"I" |
---|
303 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
304 | DrawText 95,32,"I" |
---|
305 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
306 | DrawText 52,32,"-" |
---|
307 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
308 | DrawText 75,30,"f" |
---|
309 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
310 | DrawText 85,32,"*" |
---|
311 | break |
---|
312 | case 1: |
---|
313 | //Add |
---|
314 | DrawAction/L=progFront delete |
---|
315 | DrawRect 0,0,120,40 |
---|
316 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
317 | DrawText 10,32,"I" |
---|
318 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
319 | DrawText 20,30,"=" |
---|
320 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
321 | DrawText 35,32,"I" |
---|
322 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
323 | DrawText 95,32,"I" |
---|
324 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
325 | DrawText 52,32,"+" |
---|
326 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
327 | DrawText 75,30,"f" |
---|
328 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
329 | DrawText 85,32,"*" |
---|
330 | break |
---|
331 | case 2: |
---|
332 | //Multiply |
---|
333 | DrawAction/L=progFront delete |
---|
334 | DrawRect 0,0,120,40 |
---|
335 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
336 | DrawText 10,32,"I" |
---|
337 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
338 | DrawText 20,30,"=" |
---|
339 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
340 | DrawText 35,32,"I" |
---|
341 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
342 | DrawText 95,32,"I" |
---|
343 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
344 | DrawText 52,32,"*" |
---|
345 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
346 | DrawText 66,30,"(" |
---|
347 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
348 | DrawText 75,30,"f" |
---|
349 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
350 | DrawText 85,32,"*" |
---|
351 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
352 | DrawText 105,30,")" |
---|
353 | break |
---|
354 | case 3: |
---|
355 | //Divide |
---|
356 | DrawAction/L=progFront delete |
---|
357 | DrawRect 0,0,120,40 |
---|
358 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
359 | DrawText 10,32,"I" |
---|
360 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
361 | DrawText 20,30,"=" |
---|
362 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
363 | DrawText 35,32,"I" |
---|
364 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
365 | DrawText 95,32,"I" |
---|
366 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
367 | DrawText 52,32,"/" |
---|
368 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
369 | DrawText 66,30,"(" |
---|
370 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
371 | DrawText 75,30,"f" |
---|
372 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
373 | DrawText 85,32,"*" |
---|
374 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
375 | DrawText 105,30,")" |
---|
376 | break |
---|
377 | endswitch |
---|
378 | |
---|
379 | SetActiveSubWindow DataArithmeticPanel |
---|
380 | |
---|
381 | return 0 |
---|
382 | End |
---|
383 | |
---|
384 | //Must follow naming scheme to match buttons to popups |
---|
385 | //"Name_button" goes with "Name_popup" |
---|
386 | Function DA_LoadDataSetProc(ba) : ButtonControl |
---|
387 | STRUCT WMButtonAction &ba |
---|
388 | |
---|
389 | switch( ba.eventCode ) |
---|
390 | case 2: // mouse up |
---|
391 | // click code here |
---|
392 | String cmd = "A_LoadOneDDataWithName(\"\","+num2str(0)+")" |
---|
393 | Execute cmd |
---|
394 | |
---|
395 | SVAR gLastFileName = root:packages:NIST:gLastFileName |
---|
396 | |
---|
397 | String windowName = ba.win |
---|
398 | String popupName = StringFromList(0,ba.ctrlName,"_")+"_popup" |
---|
399 | |
---|
400 | ControlUpdate/W=$(windowName) $(popupName) |
---|
401 | //instead of a simple controlUpdate, better to pop the menu to make sure that the other menus follow |
---|
402 | // convoluted method to find the right item and pop the menu. |
---|
403 | |
---|
404 | String list,folderStr |
---|
405 | Variable num |
---|
406 | folderStr = CleanupName(gLastFileName,0) |
---|
407 | list = DM_DataSetPopupList() |
---|
408 | num=WhichListItem(folderStr,list,";",0,0) |
---|
409 | if(num != -1) |
---|
410 | PopupMenu $(popupName),mode=num+1,win=$(windowName) |
---|
411 | ControlUpdate/W=$(windowName) $(popupName) |
---|
412 | |
---|
413 | endif |
---|
414 | //fake call to popup |
---|
415 | STRUCT WMPopupAction pa |
---|
416 | pa.win = ba.win |
---|
417 | pa.ctrlName = "DS1_popup" |
---|
418 | pa.eventCode = 2 |
---|
419 | DA_PopupProc(pa) |
---|
420 | break |
---|
421 | endswitch |
---|
422 | |
---|
423 | return 0 |
---|
424 | End |
---|
425 | |
---|
426 | Function DA_PopupProc(pa) : PopupMenuControl |
---|
427 | STRUCT WMPopupAction &pa |
---|
428 | |
---|
429 | String resultName |
---|
430 | |
---|
431 | switch( pa.eventCode) |
---|
432 | case 2: |
---|
433 | //print "Called by "+pa.ctrlname+" with value "+pa.popStr |
---|
434 | ControlInfo/W=$(pa.win) $(pa.ctrlName) |
---|
435 | String popStr = S_Value |
---|
436 | if (stringmatch(pa.ctrlname,"*DS1*") == 1) |
---|
437 | resultName = stringfromlist(0,popStr,"_")+"_mod" |
---|
438 | |
---|
439 | SetVariable DAResultName_sv win=$(pa.win), value=_STR:resultName |
---|
440 | endif |
---|
441 | break |
---|
442 | endswitch |
---|
443 | |
---|
444 | |
---|
445 | End |
---|
446 | |
---|
447 | // function to control the drawing of buttons in the TabControl on the main panel |
---|
448 | // Naming scheme for the buttons MUST be strictly adhered to... else buttons will |
---|
449 | // appear in odd places... |
---|
450 | // all buttons are named MainButton_NA where N is the tab number and A is the letter denoting |
---|
451 | // the button's position on that particular tab. |
---|
452 | // in this way, buttons will always be drawn correctly.. |
---|
453 | // |
---|
454 | Function DATabsProc(tca) : TabControl |
---|
455 | STRUCT WMTabControlAction &tca |
---|
456 | |
---|
457 | switch (tca.eventCode) |
---|
458 | case 2: |
---|
459 | // Print "name,number",name,tab |
---|
460 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
461 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
462 | for(ii=0;ii<num;ii+=1) |
---|
463 | //items all start w/"DSTabItem_" |
---|
464 | item=StringFromList(ii, ctrlList ,";") |
---|
465 | nameStr=item[0,9] |
---|
466 | if(cmpstr(nameStr,"DATabItem_")==0) |
---|
467 | onTab = str2num(item[10]) |
---|
468 | ControlInfo $item |
---|
469 | switch (V_flag) |
---|
470 | case 1: |
---|
471 | Button $item,disable=(tca.tab!=onTab) |
---|
472 | break |
---|
473 | case 2: |
---|
474 | CheckBox $item,disable=(tca.tab!=onTab) |
---|
475 | break |
---|
476 | case 3: |
---|
477 | PopUpMenu $item,disable=(tca.tab!=onTab) |
---|
478 | break |
---|
479 | case 5: |
---|
480 | SetVariable $item,disable=(tca.tab!=onTab) |
---|
481 | break |
---|
482 | endswitch |
---|
483 | endif |
---|
484 | endfor |
---|
485 | |
---|
486 | arithDisplayProc(tca.tab) |
---|
487 | break |
---|
488 | endswitch |
---|
489 | End |
---|
490 | |
---|
491 | |
---|
492 | Function DACalculateProc(ba) : ButtonControl |
---|
493 | STRUCT WMButtonAction &ba |
---|
494 | |
---|
495 | String DS1,DS2,Resultname |
---|
496 | |
---|
497 | switch(ba.eventCode) |
---|
498 | case 2: |
---|
499 | //Which tab? |
---|
500 | ControlInfo/W=$(ba.win) DATabs |
---|
501 | Variable tabNum = V_value |
---|
502 | //Print "Tab number "+num2str(tabNum) |
---|
503 | |
---|
504 | ControlInfo/W=$(ba.win) DS1_popup |
---|
505 | DS1 = S_Value |
---|
506 | ControlInfo/W=$(ba.win) DANoDS2_cb |
---|
507 | if (V_Value == 0) |
---|
508 | ControlInfo/W=$(ba.win) DS2_popup |
---|
509 | DS2 = S_Value |
---|
510 | else |
---|
511 | DS2 = "NullSolvent" |
---|
512 | endif |
---|
513 | ControlInfo/W=$(ba.win) DAResultName_sv |
---|
514 | Resultname = S_Value |
---|
515 | ControlInfo/W=$(ba.win) DAScale_sv |
---|
516 | Variable Scalefactor = V_Value |
---|
517 | |
---|
518 | switch(tabNum) |
---|
519 | case 0: |
---|
520 | //do subtraction |
---|
521 | //print "Subtraction of "+DS2+" from "+DS1+" with sf "+num2str(scalefactor)+ " into "+Resultname |
---|
522 | SubtractDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
523 | break |
---|
524 | case 1: |
---|
525 | //do addition |
---|
526 | AddDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
527 | break |
---|
528 | case 2: |
---|
529 | //do multiplication |
---|
530 | MultiplyDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
531 | break |
---|
532 | case 3: |
---|
533 | //do division |
---|
534 | DivideDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
535 | break |
---|
536 | endswitch |
---|
537 | |
---|
538 | //Sort out plot |
---|
539 | //Fake button press to DAPlotButtonProc |
---|
540 | STRUCT WMButtonAction ba2 |
---|
541 | ba2.win = ba.win |
---|
542 | ba2.ctrlName = "DAPlot_button" |
---|
543 | ba2.eventCode = 2 |
---|
544 | DAPlotButtonProc(ba2) |
---|
545 | AddDAPlot(3) |
---|
546 | SetActiveSubWindow DAPlotPanel |
---|
547 | DoWindow/F DataArithmeticPanel |
---|
548 | endswitch |
---|
549 | |
---|
550 | |
---|
551 | |
---|
552 | End |
---|
553 | |
---|
554 | Function DAPlotButtonProc(ba) : ButtonControl |
---|
555 | STRUCT WMButtonAction &ba |
---|
556 | |
---|
557 | String win = ba.win |
---|
558 | |
---|
559 | switch (ba.eventCode) |
---|
560 | case 2: |
---|
561 | //mouse up |
---|
562 | //Get folder for DS1 |
---|
563 | DoWindow DAPlotPanel |
---|
564 | if (V_Flag == 0) |
---|
565 | MakeDAPlotPanel() |
---|
566 | else |
---|
567 | DoWindow/HIDE=0/F DAPlotPanel |
---|
568 | do |
---|
569 | String tracename = StringFromList(0,TraceNameList("DAPlotPanel#DAPlot",";",1),";") |
---|
570 | if (cmpstr(tracename,"")==0) |
---|
571 | break |
---|
572 | else |
---|
573 | RemoveFromGraph/W=DAPlotPanel#DAPlot $tracename |
---|
574 | endif |
---|
575 | while(1) |
---|
576 | endif |
---|
577 | |
---|
578 | ControlInfo/W=$(win) DS1_popup |
---|
579 | String DS1 = S_Value |
---|
580 | if (cmpstr(DS1,"") != 0 ) |
---|
581 | AddDAPlot(1) |
---|
582 | endif |
---|
583 | //Get folder for DS2 |
---|
584 | ControlInfo/W=$(win) DS2_popup |
---|
585 | String DS2 = S_Value |
---|
586 | if (cmpstr(DS2,"") != 0) |
---|
587 | AddDAPlot(2) |
---|
588 | endif |
---|
589 | break |
---|
590 | endswitch |
---|
591 | |
---|
592 | return 0 |
---|
593 | End |
---|
594 | |
---|
595 | Function DALogLinIProc(cba) : CheckBoxControl |
---|
596 | STRUCT WMCheckBoxAction &cba |
---|
597 | |
---|
598 | switch(cba.eventcode) |
---|
599 | case 2: |
---|
600 | |
---|
601 | ModifyGraph/W=DAPlotPanel#DAPlot log(left)=cba.checked |
---|
602 | |
---|
603 | endswitch |
---|
604 | |
---|
605 | |
---|
606 | End |
---|
607 | |
---|
608 | Function DACursorButtonProc(ba) : ButtonControl |
---|
609 | STRUCT WMButtonAction &ba |
---|
610 | |
---|
611 | String DS1,DS2 |
---|
612 | |
---|
613 | switch(ba.eventCode) |
---|
614 | case 2: |
---|
615 | |
---|
616 | ControlInfo/W=$(ba.win) DS1_popup |
---|
617 | DS1 = S_Value |
---|
618 | ControlInfo/W=$(ba.win) DANoDS2_cb |
---|
619 | Variable NoDS2 = V_Value |
---|
620 | if (NoDS2 == 0) |
---|
621 | ControlInfo/W=$(ba.win) DS2_popup |
---|
622 | DS2 = S_Value |
---|
623 | else |
---|
624 | DS2 = "NullSolvent" |
---|
625 | endif |
---|
626 | |
---|
627 | //AJJ Nov 2009 - UGLY - Will have to revisit this when we deal with hierarchical folders |
---|
628 | Wave set1_i = $("root:"+DS1+":"+DS1+"_i") |
---|
629 | Wave set1_q = $("root:"+DS1+":"+DS1+"_q") |
---|
630 | Wave set2_i = $("root:"+DS2+":"+DS2+"_i") |
---|
631 | Wave set2_q = $("root:"+DS2+":"+DS2+"_q") |
---|
632 | Duplicate/O set1_i tmp_i |
---|
633 | Duplicate/O set1_q tmp_q |
---|
634 | tmp_i = set1_i / interp(set1_q[p],set2_q,set2_i) |
---|
635 | |
---|
636 | //Get cursors |
---|
637 | Variable q1,q2 |
---|
638 | |
---|
639 | DoWindow/F DAPlotPanel |
---|
640 | SetActiveSubWindow DAPlotPanel#DAPlot |
---|
641 | |
---|
642 | q1 = CsrXWaveRef(A)[pcsr(A)] |
---|
643 | q2 = CsrXWaveRef(B)[pcsr(B)] |
---|
644 | |
---|
645 | //Update value display |
---|
646 | ValDisplay DARangeStar_vd,value=_NUM:q1, win=$(ba.win) |
---|
647 | ValDisplay DARangeEnd_vd,value=_NUM:q2, win=$(ba.win) |
---|
648 | |
---|
649 | //Calculate scalefactor |
---|
650 | |
---|
651 | if (NoDS2 == 1) |
---|
652 | Wave avgWave = set1_i |
---|
653 | else |
---|
654 | Wave avgWave = tmp_i |
---|
655 | endif |
---|
656 | |
---|
657 | Variable p1 = BinarySearch(tmp_q,q1) |
---|
658 | Variable p2 = BinarySearch(tmp_q,q2) |
---|
659 | |
---|
660 | //print avgWave |
---|
661 | |
---|
662 | WaveStats/Q/R=[p1,p2] avgWave |
---|
663 | //print V_avg |
---|
664 | //Update sv control |
---|
665 | SetVariable DAScale_sv, value=_NUM:V_avg, win=$(ba.win) |
---|
666 | |
---|
667 | KillWaves/Z tmp_i,tmp_q |
---|
668 | DoWindow/F DataArithmeticPanel |
---|
669 | endswitch |
---|
670 | |
---|
671 | End |
---|
672 | |
---|
673 | |
---|
674 | Function DANoDS2Proc(cba) : CheckBoxControl |
---|
675 | STRUCT WMCheckBoxAction &cba |
---|
676 | |
---|
677 | |
---|
678 | switch(cba.eventCode) |
---|
679 | case 2: |
---|
680 | if (cba.checked == 1) |
---|
681 | //Disable DS2 popup etc |
---|
682 | PopupMenu DS2_popup win=$(cba.win), disable=2 |
---|
683 | Button DS2_button win=$(cba.win), disable=2 |
---|
684 | else |
---|
685 | //Enable DS2 popup etc |
---|
686 | PopupMenu DS2_popup win=$(cba.win), disable=0 |
---|
687 | Button DS2_button win=$(cba.win), disable=0 |
---|
688 | endif |
---|
689 | //Sort out plot |
---|
690 | //Fake button press to DAPlotButtonProc |
---|
691 | STRUCT WMButtonAction ba2 |
---|
692 | ba2.win = cba.win |
---|
693 | ba2.ctrlName = "DAPlot_button" |
---|
694 | ba2.eventCode = 2 |
---|
695 | DAPlotButtonProc(ba2) |
---|
696 | SetActiveSubWindow DAPlotPanel |
---|
697 | DoWindow/F DataArithmeticPanel |
---|
698 | endswitch |
---|
699 | |
---|
700 | End |
---|
701 | |
---|
702 | Function DASaveProc(ba) : ButtonControl |
---|
703 | STRUCT WMButtonAction &ba |
---|
704 | |
---|
705 | switch(ba.eventCode) |
---|
706 | case 2: |
---|
707 | ControlInfo/W=$(ba.win) DAResultName_sv |
---|
708 | SaveDataSetToFile(S_Value) |
---|
709 | break |
---|
710 | endswitch |
---|
711 | |
---|
712 | |
---|
713 | End |
---|
714 | |
---|
715 | /////////////////////// Common Panel Functions /////////////////////////////////////// |
---|
716 | |
---|
717 | |
---|
718 | // is there a simpler way to do this? I don't think so. |
---|
719 | Function/S DM_DataSetPopupList() |
---|
720 | |
---|
721 | String str=GetAList(4) |
---|
722 | |
---|
723 | if(strlen(str)==0) |
---|
724 | str = "No data loaded" |
---|
725 | endif |
---|
726 | str = SortList(str) |
---|
727 | |
---|
728 | return(str) |
---|
729 | End |
---|
730 | |
---|
731 | |
---|
732 | Function SetVarProc(sva) : SetVariableControl |
---|
733 | STRUCT WMSetVariableAction &sva |
---|
734 | |
---|
735 | switch( sva.eventCode ) |
---|
736 | case 1: // mouse up |
---|
737 | case 2: // Enter key |
---|
738 | case 3: // Live update |
---|
739 | String sv = sva.sval |
---|
740 | if( strlen(sv) > 25 ) |
---|
741 | sv= sv[0,24] |
---|
742 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
743 | Beep |
---|
744 | endif |
---|
745 | break |
---|
746 | endswitch |
---|
747 | return 0 |
---|
748 | End |
---|
749 | |
---|
750 | |
---|
751 | ////////////////////// Functions to do manipulations /////////////////////////////////// |
---|
752 | |
---|
753 | Function RenameDataSet(dataSetFolder, newName) |
---|
754 | String dataSetFolder |
---|
755 | String newName |
---|
756 | |
---|
757 | String dataSetFolderParent,basestr,objName |
---|
758 | Variable index = 0 |
---|
759 | |
---|
760 | //Abuse ParseFilePath to get path without folder name |
---|
761 | dataSetFolderParent = ParseFilePath(1,dataSetFolder,":",1,0) |
---|
762 | //Abuse ParseFilePath to get basestr |
---|
763 | basestr = ParseFilePath(0,dataSetFolder,":",1,0) |
---|
764 | |
---|
765 | // try |
---|
766 | RenameDataFolder $(dataSetFolder) $(newName)//; AbortOnRTE |
---|
767 | |
---|
768 | |
---|
769 | SetDataFolder $(dataSetFolderParent+newName)//; AbortOnRTE |
---|
770 | do |
---|
771 | objName = GetIndexedObjName("",1,index) |
---|
772 | if (strlen(objName) == 0) |
---|
773 | break |
---|
774 | endif |
---|
775 | Rename $(objName) $(ReplaceString(basestr,objName,newName)) |
---|
776 | index+=1 |
---|
777 | while(1) |
---|
778 | SetDataFolder root: |
---|
779 | // catch |
---|
780 | // Print "Aborted: " + num2str(V_AbortCode) |
---|
781 | // SetDataFolder root: |
---|
782 | // endtry |
---|
783 | End |
---|
784 | |
---|
785 | |
---|
786 | Function DuplicateDataSet(dataSetFolder, newName, forceoverwrite) |
---|
787 | String dataSetFolder |
---|
788 | String newName |
---|
789 | Variable forceoverwrite |
---|
790 | |
---|
791 | String dataSetFolderParent,basestr,objName |
---|
792 | Variable index = 0 |
---|
793 | |
---|
794 | //Abuse ParseFilePath to get path without folder name |
---|
795 | dataSetFolderParent = ParseFilePath(1,dataSetFolder,":",1,0) |
---|
796 | //Abuse ParseFilePath to get basestr |
---|
797 | basestr = ParseFilePath(0,dataSetFolder,":",1,0) |
---|
798 | |
---|
799 | print "Duplicating "+dataSetFolder+" as "+newName |
---|
800 | |
---|
801 | SetDataFolder $(dataSetFolderParent) |
---|
802 | |
---|
803 | if (!DataFolderExists(newName)) |
---|
804 | NewDataFolder $(newName) |
---|
805 | else |
---|
806 | if (!forceoverwrite) |
---|
807 | DoAlert 1, "A dataset with the name "+newName+" already exists. Overwrite?" |
---|
808 | if (V_flag == 2) |
---|
809 | return 1 |
---|
810 | endif |
---|
811 | endif |
---|
812 | endif |
---|
813 | |
---|
814 | //If we are here, the folder (now) exists and the user has agreed to overwrite |
---|
815 | //either in the function call or from the alert. |
---|
816 | do |
---|
817 | objName = GetIndexedObjName(basestr,1,index) |
---|
818 | if (strlen(objName) == 0) |
---|
819 | break |
---|
820 | endif |
---|
821 | objname = ":"+basestr+":"+objname |
---|
822 | Duplicate/O $(objName) $(ReplaceString(basestr,objName,newName)) |
---|
823 | index+=1 |
---|
824 | while(1) |
---|
825 | |
---|
826 | SetDataFolder root: |
---|
827 | return 0 |
---|
828 | End |
---|
829 | |
---|
830 | |
---|
831 | // Subtract Set2 From Set1 |
---|
832 | // Use Result_I = Set1_I - f*Set2_I |
---|
833 | Function SubtractDataSets(set1Name,set2Name,set2Scale,resultName) |
---|
834 | String set1Name |
---|
835 | String set2Name |
---|
836 | Variable set2Scale |
---|
837 | String resultName |
---|
838 | |
---|
839 | String set1Path = "root:"+set1Name+":" |
---|
840 | String set2Path = "root:"+set2Name+":" |
---|
841 | String resultPath = "root:"+resultName+":" |
---|
842 | |
---|
843 | SetDataFolder root: |
---|
844 | //Create folder for result |
---|
845 | //UnloadDataSet(resultName) |
---|
846 | //Make the folder |
---|
847 | if (DuplicateDataSet(set1Path,resultName,0)) |
---|
848 | return 1 |
---|
849 | else |
---|
850 | //Do subtraction of I waves - including interpolation if necessary. |
---|
851 | Wave result_i = $(resultPath+resultName+"_i") |
---|
852 | Wave result_s = $(resultPath+resultName+"_s") |
---|
853 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
854 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
855 | Wave set1_s = $(set1Path+set1Name+"_s") |
---|
856 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
857 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
858 | Wave set2_s = $(set2Path+set2Name+"_s") |
---|
859 | |
---|
860 | result_i = set1_i - (set2Scale*interp(set1_q[p],set2_q,set2_i)) |
---|
861 | result_s = sqrt(set1_s^2 + set2Scale^2*interp(set1_q[p],set2_q,set2_s)) |
---|
862 | //Calculate result error wave - can we produce corrected Q error? |
---|
863 | |
---|
864 | //Generate history string to record what was done? |
---|
865 | return 0 |
---|
866 | endif |
---|
867 | End |
---|
868 | |
---|
869 | // Add Set2 to Set1 |
---|
870 | // Use Result_I = Set1_I + f*Set2_I |
---|
871 | Function AddDataSets(set1Name,set2Name,set2Scale,resultName) |
---|
872 | String set1Name |
---|
873 | String set2Name |
---|
874 | Variable set2Scale |
---|
875 | String resultName |
---|
876 | |
---|
877 | String set1Path = "root:"+set1Name+":" |
---|
878 | String set2Path = "root:"+set2Name+":" |
---|
879 | String resultPath = "root:"+resultName+":" |
---|
880 | |
---|
881 | SetDataFolder root: |
---|
882 | //Create folder for result |
---|
883 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
884 | //User said no overwrite |
---|
885 | return 1 |
---|
886 | else |
---|
887 | //Do addition of I waves - including interpolation if necessary. |
---|
888 | Wave result_i = $(resultPath+resultName+"_i") |
---|
889 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
890 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
891 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
892 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
893 | result_i = set1_i + set2Scale*interp(set1_q[p],set2_q,set2_i) |
---|
894 | |
---|
895 | //Calculate result error wave - can we produce corrected Q error? |
---|
896 | |
---|
897 | //Generate history string to record what was done? |
---|
898 | return 0 |
---|
899 | endif |
---|
900 | End |
---|
901 | |
---|
902 | // Multiply Set1 by Set2 |
---|
903 | // Use Result_I = Set1_I * (f*Set2_I) |
---|
904 | Function MultiplyDataSets(set1Name, set2Name, set2Scale, resultName) |
---|
905 | String set1Name |
---|
906 | String set2Name |
---|
907 | Variable set2Scale |
---|
908 | String resultName |
---|
909 | |
---|
910 | String set1Path = "root:"+set1Name+":" |
---|
911 | String set2Path = "root:"+set2Name+":" |
---|
912 | String resultPath = "root:"+resultName+":" |
---|
913 | |
---|
914 | SetDataFolder root: |
---|
915 | //Create folder for result |
---|
916 | //Make the folder |
---|
917 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
918 | //User said no overwrite |
---|
919 | return 1 |
---|
920 | else |
---|
921 | //Do multiplcation of I waves - including interpolation if necessary. |
---|
922 | Wave result_i = $(resultPath+resultName+"_i") |
---|
923 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
924 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
925 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
926 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
927 | result_i = set1_i*set2Scale*interp(set1_q[p],set2_q,set2_i) |
---|
928 | |
---|
929 | |
---|
930 | //Calculate result error wave - can we produce corrected Q error? |
---|
931 | |
---|
932 | //Generate history string to record what was done? |
---|
933 | return 0 |
---|
934 | endif |
---|
935 | End |
---|
936 | |
---|
937 | // Divide Set1 by Set2 |
---|
938 | // Use Result_I = Set1_I / (f*Set2_I) |
---|
939 | Function DivideDataSets(set1Name, set2Name, set2Scale, resultName) |
---|
940 | String set1Name |
---|
941 | String set2Name |
---|
942 | Variable set2Scale |
---|
943 | String resultName |
---|
944 | |
---|
945 | String set1Path = "root:"+set1Name+":" |
---|
946 | String set2Path = "root:"+set2Name+":" |
---|
947 | String resultPath = "root:"+resultName+":" |
---|
948 | |
---|
949 | SetDataFolder root: |
---|
950 | //Create folder for result |
---|
951 | //Make the folder |
---|
952 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
953 | //User said no overwrite |
---|
954 | return 1 |
---|
955 | else |
---|
956 | //Do division of I waves - including interpolation if necessary. |
---|
957 | Wave result_i = $(resultPath+resultName+"_i") |
---|
958 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
959 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
960 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
961 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
962 | result_i = set1_i/(set2Scale*interp(set1_q[p],set2_q,set2_i) ) |
---|
963 | |
---|
964 | //Calculate result error wave - can we produce corrected Q error? |
---|
965 | |
---|
966 | //Generate history string to record what was done? |
---|
967 | return 0 |
---|
968 | endif |
---|
969 | End |
---|
970 | |
---|
971 | |
---|
972 | ///////////////////////////Other Utility functions //////////////////////////// |
---|
973 | |
---|
974 | Function SaveDataSetToFile(folderName) |
---|
975 | String folderName |
---|
976 | |
---|
977 | String protoStr = "" |
---|
978 | //Check for history string in folder |
---|
979 | //If it doesn't exist then |
---|
980 | |
---|
981 | //Do saving of data file. |
---|
982 | |
---|
983 | NVAR gXML_Write = root:Packages:NIST:gXML_Write |
---|
984 | |
---|
985 | if (gXML_Write == 1) |
---|
986 | ReWrite1DXMLData(folderName) |
---|
987 | else |
---|
988 | fReWrite1DData(folderName,"tab","CRLF") |
---|
989 | endif |
---|
990 | |
---|
991 | // NISTSave1DData(folderName,protoStr) |
---|
992 | |
---|
993 | //Include history string to record what was done? |
---|
994 | |
---|
995 | End |
---|
996 | |
---|
997 | |
---|
998 | //This will be hideous |
---|
999 | Function UnloadDataSet(folderName) |
---|
1000 | String folderName |
---|
1001 | |
---|
1002 | |
---|
1003 | End |
---|
1004 | |
---|
1005 | |
---|
1006 | //////////////////// Write data functions //////////////////////////////////// |
---|
1007 | // AJJ Nov 2009 - should move towards unified writer |
---|
1008 | // |
---|
1009 | ////////////////////////////////////////////////////////////////////////// |
---|
1010 | |
---|
1011 | //Function NISTSave1DData(folderPath,protoStr) |
---|
1012 | // String folderPath, protoStr |
---|
1013 | // |
---|
1014 | // //protoStr is string that will be written to either |
---|
1015 | // |
---|
1016 | // |
---|
1017 | //End |
---|