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 | if(cmpstr(DS2name,"No data loaded")==0) |
---|
247 | break //in case someone loads set 1, but not set two, then plots |
---|
248 | endif |
---|
249 | Wave qWave = $("root:"+DS2name+":"+DS2name+"_q") |
---|
250 | Wave iWave = $("root:"+DS2name+":"+DS2name+"_i") |
---|
251 | Wave errWave = $("root:"+DS2name+":"+DS2name+"_s") |
---|
252 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
253 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(DS2name+"_i"), Y wave=(errWave,errWave) |
---|
254 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(DS2name+"_i"))=(0,0,65535) |
---|
255 | Cursor/W=DAPlotPanel#DAPlot A, $(DS2name+"_i"), leftx(iWave) |
---|
256 | Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS2name+"_i"), rightx(iWave) |
---|
257 | else |
---|
258 | ControlInfo/W=$(win) DS1_popup |
---|
259 | DS1name = S_Value |
---|
260 | DuplicateDataSet("root:"+DS1name,"NullSolvent",1) |
---|
261 | Wave qWave =root:NullSolvent:NullSolvent_q |
---|
262 | Wave iWave = root:NullSolvent:NullSolvent_i |
---|
263 | Wave errWave = root:NullSolvent:NullSolvent_s |
---|
264 | Wave iWaveDS1 = $("root:"+DS1name+":"+DS1name+"_i") |
---|
265 | iWave = 1 |
---|
266 | errWave = 0 |
---|
267 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
268 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 NullSolvent_i, Y wave=(errWave,errWave) |
---|
269 | ModifyGraph/W=DAPlotPanel#DAPlot rgb(NullSolvent_i)=(0,0,65535) |
---|
270 | //Cursor/W=DAPlotPanel#DAPlot A, NullSolvent_i, leftx(iWave) |
---|
271 | //Cursor/W=DAPlotPanel#DAPlot/A=0 B, NullSolvent_i, rightx(iWave) |
---|
272 | Cursor/W=DAPlotPanel#DAPlot A, $(DS1Name+"_i"), leftx(iWaveDS1) |
---|
273 | Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS1Name+"_i"), rightx(iWaveDS1) |
---|
274 | endif |
---|
275 | break |
---|
276 | case 3: |
---|
277 | ControlInfo/W=$(win) DAResultName_sv |
---|
278 | ResultName = S_Value |
---|
279 | Wave qWave = $("root:"+ResultName+":"+ResultName+"_q") |
---|
280 | Wave iWave = $("root:"+ResultName+":"+ResultName+"_i") |
---|
281 | Wave errWave = $("root:"+ResultName+":"+ResultName+"_s") |
---|
282 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
283 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(ResultName+"_i"), Y wave=(errWave,errWave) |
---|
284 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(ResultName+"_i"))=(0,65535,0) |
---|
285 | break |
---|
286 | endswitch |
---|
287 | |
---|
288 | ControlInfo/W=DAPlotPanel DAPlot_log_cb |
---|
289 | ModifyGraph/W=DAPlotPanel#DAPlot mode=3, msize=2, marker=19, mirror=1, tick=2, log(bottom)=1,log(left)=V_Value,tickUnit=1 |
---|
290 | End |
---|
291 | |
---|
292 | Function arithDisplayProc(s) |
---|
293 | Variable s |
---|
294 | |
---|
295 | SetActiveSubWindow DataArithmeticPanel#arithDisplay |
---|
296 | |
---|
297 | switch (s) |
---|
298 | case 0: |
---|
299 | //Subtract |
---|
300 | DrawAction/L=progFront delete |
---|
301 | DrawRect 0,0,120,40 |
---|
302 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
303 | DrawText 10,32,"I" |
---|
304 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
305 | DrawText 20,30,"=" |
---|
306 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
307 | DrawText 35,32,"I" |
---|
308 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
309 | DrawText 95,32,"I" |
---|
310 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
311 | DrawText 52,32,"-" |
---|
312 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
313 | DrawText 75,30,"f" |
---|
314 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
315 | DrawText 85,32,"*" |
---|
316 | break |
---|
317 | case 1: |
---|
318 | //Add |
---|
319 | DrawAction/L=progFront delete |
---|
320 | DrawRect 0,0,120,40 |
---|
321 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
322 | DrawText 10,32,"I" |
---|
323 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
324 | DrawText 20,30,"=" |
---|
325 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
326 | DrawText 35,32,"I" |
---|
327 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
328 | DrawText 95,32,"I" |
---|
329 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
330 | DrawText 52,32,"+" |
---|
331 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
332 | DrawText 75,30,"f" |
---|
333 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
334 | DrawText 85,32,"*" |
---|
335 | break |
---|
336 | case 2: |
---|
337 | //Multiply |
---|
338 | DrawAction/L=progFront delete |
---|
339 | DrawRect 0,0,120,40 |
---|
340 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
341 | DrawText 10,32,"I" |
---|
342 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
343 | DrawText 20,30,"=" |
---|
344 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
345 | DrawText 35,32,"I" |
---|
346 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
347 | DrawText 95,32,"I" |
---|
348 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
349 | DrawText 52,32,"*" |
---|
350 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
351 | DrawText 66,30,"(" |
---|
352 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
353 | DrawText 75,30,"f" |
---|
354 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
355 | DrawText 85,32,"*" |
---|
356 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
357 | DrawText 105,30,")" |
---|
358 | break |
---|
359 | case 3: |
---|
360 | //Divide |
---|
361 | DrawAction/L=progFront delete |
---|
362 | DrawRect 0,0,120,40 |
---|
363 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
364 | DrawText 10,32,"I" |
---|
365 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
366 | DrawText 20,30,"=" |
---|
367 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
368 | DrawText 35,32,"I" |
---|
369 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
370 | DrawText 95,32,"I" |
---|
371 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
372 | DrawText 52,32,"/" |
---|
373 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
374 | DrawText 66,30,"(" |
---|
375 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
376 | DrawText 75,30,"f" |
---|
377 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
378 | DrawText 85,32,"*" |
---|
379 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
380 | DrawText 105,30,")" |
---|
381 | break |
---|
382 | endswitch |
---|
383 | |
---|
384 | SetActiveSubWindow DataArithmeticPanel |
---|
385 | |
---|
386 | return 0 |
---|
387 | End |
---|
388 | |
---|
389 | //Must follow naming scheme to match buttons to popups |
---|
390 | //"Name_button" goes with "Name_popup" |
---|
391 | Function DA_LoadDataSetProc(ba) : ButtonControl |
---|
392 | STRUCT WMButtonAction &ba |
---|
393 | |
---|
394 | switch( ba.eventCode ) |
---|
395 | case 2: // mouse up |
---|
396 | // click code here |
---|
397 | String cmd = "A_LoadOneDDataWithName(\"\","+num2str(0)+")" |
---|
398 | Execute cmd |
---|
399 | |
---|
400 | SVAR gLastFileName = root:packages:NIST:gLastFileName |
---|
401 | |
---|
402 | String windowName = ba.win |
---|
403 | String popupName = StringFromList(0,ba.ctrlName,"_")+"_popup" |
---|
404 | |
---|
405 | ControlUpdate/W=$(windowName) $(popupName) |
---|
406 | //instead of a simple controlUpdate, better to pop the menu to make sure that the other menus follow |
---|
407 | // convoluted method to find the right item and pop the menu. |
---|
408 | |
---|
409 | String list,folderStr |
---|
410 | Variable num |
---|
411 | folderStr = CleanupName(gLastFileName,0) |
---|
412 | list = DM_DataSetPopupList() |
---|
413 | num=WhichListItem(folderStr,list,";",0,0) |
---|
414 | if(num != -1) |
---|
415 | PopupMenu $(popupName),mode=num+1,win=$(windowName) |
---|
416 | ControlUpdate/W=$(windowName) $(popupName) |
---|
417 | |
---|
418 | endif |
---|
419 | //fake call to popup |
---|
420 | STRUCT WMPopupAction pa |
---|
421 | pa.win = ba.win |
---|
422 | pa.ctrlName = "DS1_popup" |
---|
423 | pa.eventCode = 2 |
---|
424 | DA_PopupProc(pa) |
---|
425 | break |
---|
426 | endswitch |
---|
427 | |
---|
428 | return 0 |
---|
429 | End |
---|
430 | |
---|
431 | Function DA_PopupProc(pa) : PopupMenuControl |
---|
432 | STRUCT WMPopupAction &pa |
---|
433 | |
---|
434 | String resultName |
---|
435 | |
---|
436 | switch( pa.eventCode) |
---|
437 | case 2: |
---|
438 | //print "Called by "+pa.ctrlname+" with value "+pa.popStr |
---|
439 | ControlInfo/W=$(pa.win) $(pa.ctrlName) |
---|
440 | String popStr = S_Value |
---|
441 | if (stringmatch(pa.ctrlname,"*DS1*") == 1) |
---|
442 | resultName = stringfromlist(0,popStr,"_")+"_mod" |
---|
443 | |
---|
444 | SetVariable DAResultName_sv win=$(pa.win), value=_STR:resultName |
---|
445 | endif |
---|
446 | break |
---|
447 | endswitch |
---|
448 | |
---|
449 | |
---|
450 | End |
---|
451 | |
---|
452 | // function to control the drawing of buttons in the TabControl on the main panel |
---|
453 | // Naming scheme for the buttons MUST be strictly adhered to... else buttons will |
---|
454 | // appear in odd places... |
---|
455 | // all buttons are named MainButton_NA where N is the tab number and A is the letter denoting |
---|
456 | // the button's position on that particular tab. |
---|
457 | // in this way, buttons will always be drawn correctly.. |
---|
458 | // |
---|
459 | Function DATabsProc(tca) : TabControl |
---|
460 | STRUCT WMTabControlAction &tca |
---|
461 | |
---|
462 | switch (tca.eventCode) |
---|
463 | case 2: |
---|
464 | // Print "name,number",name,tab |
---|
465 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
466 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
467 | for(ii=0;ii<num;ii+=1) |
---|
468 | //items all start w/"DSTabItem_" |
---|
469 | item=StringFromList(ii, ctrlList ,";") |
---|
470 | nameStr=item[0,9] |
---|
471 | if(cmpstr(nameStr,"DATabItem_")==0) |
---|
472 | onTab = str2num(item[10]) |
---|
473 | ControlInfo $item |
---|
474 | switch (V_flag) |
---|
475 | case 1: |
---|
476 | Button $item,disable=(tca.tab!=onTab) |
---|
477 | break |
---|
478 | case 2: |
---|
479 | CheckBox $item,disable=(tca.tab!=onTab) |
---|
480 | break |
---|
481 | case 3: |
---|
482 | PopUpMenu $item,disable=(tca.tab!=onTab) |
---|
483 | break |
---|
484 | case 5: |
---|
485 | SetVariable $item,disable=(tca.tab!=onTab) |
---|
486 | break |
---|
487 | endswitch |
---|
488 | endif |
---|
489 | endfor |
---|
490 | |
---|
491 | arithDisplayProc(tca.tab) |
---|
492 | break |
---|
493 | endswitch |
---|
494 | End |
---|
495 | |
---|
496 | |
---|
497 | Function DACalculateProc(ba) : ButtonControl |
---|
498 | STRUCT WMButtonAction &ba |
---|
499 | |
---|
500 | String DS1,DS2,Resultname |
---|
501 | |
---|
502 | switch(ba.eventCode) |
---|
503 | case 2: |
---|
504 | //Which tab? |
---|
505 | ControlInfo/W=$(ba.win) DATabs |
---|
506 | Variable tabNum = V_value |
---|
507 | //Print "Tab number "+num2str(tabNum) |
---|
508 | |
---|
509 | ControlInfo/W=$(ba.win) DS1_popup |
---|
510 | DS1 = S_Value |
---|
511 | ControlInfo/W=$(ba.win) DANoDS2_cb |
---|
512 | if (V_Value == 0) |
---|
513 | ControlInfo/W=$(ba.win) DS2_popup |
---|
514 | DS2 = S_Value |
---|
515 | else |
---|
516 | DS2 = "NullSolvent" |
---|
517 | endif |
---|
518 | ControlInfo/W=$(ba.win) DAResultName_sv |
---|
519 | Resultname = S_Value |
---|
520 | ControlInfo/W=$(ba.win) DAScale_sv |
---|
521 | Variable Scalefactor = V_Value |
---|
522 | |
---|
523 | switch(tabNum) |
---|
524 | case 0: |
---|
525 | //do subtraction |
---|
526 | //print "Subtraction of "+DS2+" from "+DS1+" with sf "+num2str(scalefactor)+ " into "+Resultname |
---|
527 | SubtractDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
528 | break |
---|
529 | case 1: |
---|
530 | //do addition |
---|
531 | AddDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
532 | break |
---|
533 | case 2: |
---|
534 | //do multiplication |
---|
535 | MultiplyDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
536 | break |
---|
537 | case 3: |
---|
538 | //do division |
---|
539 | DivideDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
540 | break |
---|
541 | endswitch |
---|
542 | |
---|
543 | //Sort out plot |
---|
544 | //Fake button press to DAPlotButtonProc |
---|
545 | STRUCT WMButtonAction ba2 |
---|
546 | ba2.win = ba.win |
---|
547 | ba2.ctrlName = "DAPlot_button" |
---|
548 | ba2.eventCode = 2 |
---|
549 | DAPlotButtonProc(ba2) |
---|
550 | AddDAPlot(3) |
---|
551 | DoWindow/F DataArithmeticPanel |
---|
552 | // SetActiveSubWindow DAPlotPanel |
---|
553 | endswitch |
---|
554 | |
---|
555 | End |
---|
556 | |
---|
557 | Function DAPlotButtonProc(ba) : ButtonControl |
---|
558 | STRUCT WMButtonAction &ba |
---|
559 | |
---|
560 | String win = ba.win |
---|
561 | |
---|
562 | switch (ba.eventCode) |
---|
563 | case 2: |
---|
564 | //mouse up |
---|
565 | //Get folder for DS1 |
---|
566 | DoWindow DAPlotPanel |
---|
567 | if (V_Flag == 0) |
---|
568 | MakeDAPlotPanel() |
---|
569 | else |
---|
570 | DoWindow/HIDE=0/F DAPlotPanel |
---|
571 | do |
---|
572 | String tracename = StringFromList(0,TraceNameList("DAPlotPanel#DAPlot",";",1),";") |
---|
573 | if (cmpstr(tracename,"")==0) |
---|
574 | break |
---|
575 | else |
---|
576 | RemoveFromGraph/W=DAPlotPanel#DAPlot $tracename |
---|
577 | endif |
---|
578 | while(1) |
---|
579 | endif |
---|
580 | |
---|
581 | ControlInfo/W=$(win) DS1_popup |
---|
582 | String DS1 = S_Value |
---|
583 | if (cmpstr(DS1,"") != 0 ) |
---|
584 | AddDAPlot(1) |
---|
585 | endif |
---|
586 | //Get folder for DS2 |
---|
587 | ControlInfo/W=$(win) DS2_popup |
---|
588 | String DS2 = S_Value |
---|
589 | if (cmpstr(DS2,"") != 0) |
---|
590 | AddDAPlot(2) |
---|
591 | endif |
---|
592 | break |
---|
593 | endswitch |
---|
594 | |
---|
595 | return 0 |
---|
596 | End |
---|
597 | |
---|
598 | Function DALogLinIProc(cba) : CheckBoxControl |
---|
599 | STRUCT WMCheckBoxAction &cba |
---|
600 | |
---|
601 | switch(cba.eventcode) |
---|
602 | case 2: |
---|
603 | |
---|
604 | ModifyGraph/W=DAPlotPanel#DAPlot log(left)=cba.checked |
---|
605 | |
---|
606 | endswitch |
---|
607 | |
---|
608 | |
---|
609 | End |
---|
610 | |
---|
611 | Function DACursorButtonProc(ba) : ButtonControl |
---|
612 | STRUCT WMButtonAction &ba |
---|
613 | |
---|
614 | String DS1,DS2 |
---|
615 | |
---|
616 | switch(ba.eventCode) |
---|
617 | case 2: |
---|
618 | |
---|
619 | ControlInfo/W=$(ba.win) DS1_popup |
---|
620 | DS1 = S_Value |
---|
621 | ControlInfo/W=$(ba.win) DANoDS2_cb |
---|
622 | Variable NoDS2 = V_Value |
---|
623 | if (NoDS2 == 0) |
---|
624 | ControlInfo/W=$(ba.win) DS2_popup |
---|
625 | DS2 = S_Value |
---|
626 | else |
---|
627 | DS2 = "NullSolvent" |
---|
628 | endif |
---|
629 | |
---|
630 | //AJJ Nov 2009 - UGLY - Will have to revisit this when we deal with hierarchical folders |
---|
631 | Wave set1_i = $("root:"+DS1+":"+DS1+"_i") |
---|
632 | Wave set1_q = $("root:"+DS1+":"+DS1+"_q") |
---|
633 | Wave set2_i = $("root:"+DS2+":"+DS2+"_i") |
---|
634 | Wave set2_q = $("root:"+DS2+":"+DS2+"_q") |
---|
635 | Duplicate/O set1_i tmp_i |
---|
636 | Duplicate/O set1_q tmp_q |
---|
637 | tmp_i = set1_i / interp(set1_q[p],set2_q,set2_i) |
---|
638 | |
---|
639 | //Get cursors |
---|
640 | Variable q1,q2 |
---|
641 | |
---|
642 | DoWindow/F DAPlotPanel |
---|
643 | SetActiveSubWindow DAPlotPanel#DAPlot |
---|
644 | |
---|
645 | q1 = CsrXWaveRef(A)[pcsr(A)] |
---|
646 | q2 = CsrXWaveRef(B)[pcsr(B)] |
---|
647 | |
---|
648 | //Update value display |
---|
649 | ValDisplay DARangeStar_vd,value=_NUM:q1, win=$(ba.win) |
---|
650 | ValDisplay DARangeEnd_vd,value=_NUM:q2, win=$(ba.win) |
---|
651 | |
---|
652 | //Calculate scalefactor |
---|
653 | |
---|
654 | if (NoDS2 == 1) |
---|
655 | Wave avgWave = set1_i |
---|
656 | else |
---|
657 | Wave avgWave = tmp_i |
---|
658 | endif |
---|
659 | |
---|
660 | Variable p1 = BinarySearch(tmp_q,q1) |
---|
661 | Variable p2 = BinarySearch(tmp_q,q2) |
---|
662 | |
---|
663 | //print avgWave |
---|
664 | |
---|
665 | WaveStats/Q/R=[p1,p2] avgWave |
---|
666 | //print V_avg |
---|
667 | //Update sv control |
---|
668 | SetVariable DAScale_sv, value=_NUM:V_avg, win=$(ba.win) |
---|
669 | |
---|
670 | KillWaves/Z tmp_i,tmp_q |
---|
671 | DoWindow/F DataArithmeticPanel |
---|
672 | endswitch |
---|
673 | |
---|
674 | End |
---|
675 | |
---|
676 | |
---|
677 | Function DANoDS2Proc(cba) : CheckBoxControl |
---|
678 | STRUCT WMCheckBoxAction &cba |
---|
679 | |
---|
680 | |
---|
681 | switch(cba.eventCode) |
---|
682 | case 2: |
---|
683 | if (cba.checked == 1) |
---|
684 | //Disable DS2 popup etc |
---|
685 | PopupMenu DS2_popup win=$(cba.win), disable=2 |
---|
686 | Button DS2_button win=$(cba.win), disable=2 |
---|
687 | else |
---|
688 | //Enable DS2 popup etc |
---|
689 | PopupMenu DS2_popup win=$(cba.win), disable=0 |
---|
690 | Button DS2_button win=$(cba.win), disable=0 |
---|
691 | endif |
---|
692 | //Sort out plot |
---|
693 | //Fake button press to DAPlotButtonProc |
---|
694 | STRUCT WMButtonAction ba2 |
---|
695 | ba2.win = cba.win |
---|
696 | ba2.ctrlName = "DAPlot_button" |
---|
697 | ba2.eventCode = 2 |
---|
698 | DAPlotButtonProc(ba2) |
---|
699 | SetActiveSubWindow DAPlotPanel |
---|
700 | DoWindow/F DataArithmeticPanel |
---|
701 | endswitch |
---|
702 | |
---|
703 | End |
---|
704 | |
---|
705 | Function DASaveProc(ba) : ButtonControl |
---|
706 | STRUCT WMButtonAction &ba |
---|
707 | |
---|
708 | switch(ba.eventCode) |
---|
709 | case 2: |
---|
710 | ControlInfo/W=$(ba.win) DAResultName_sv |
---|
711 | SaveDataSetToFile(S_Value) |
---|
712 | break |
---|
713 | endswitch |
---|
714 | |
---|
715 | |
---|
716 | End |
---|
717 | |
---|
718 | /////////////////////// Common Panel Functions /////////////////////////////////////// |
---|
719 | |
---|
720 | |
---|
721 | // is there a simpler way to do this? I don't think so. |
---|
722 | Function/S DM_DataSetPopupList() |
---|
723 | |
---|
724 | String str=GetAList(4) |
---|
725 | |
---|
726 | if(strlen(str)==0) |
---|
727 | str = "No data loaded" |
---|
728 | endif |
---|
729 | str = SortList(str) |
---|
730 | |
---|
731 | return(str) |
---|
732 | End |
---|
733 | |
---|
734 | |
---|
735 | Function SetVarProc(sva) : SetVariableControl |
---|
736 | STRUCT WMSetVariableAction &sva |
---|
737 | |
---|
738 | switch( sva.eventCode ) |
---|
739 | case 1: // mouse up |
---|
740 | case 2: // Enter key |
---|
741 | case 3: // Live update |
---|
742 | String sv = sva.sval |
---|
743 | if( strlen(sv) > 25 ) |
---|
744 | sv= sv[0,24] |
---|
745 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
746 | Beep |
---|
747 | endif |
---|
748 | break |
---|
749 | endswitch |
---|
750 | return 0 |
---|
751 | End |
---|
752 | |
---|
753 | |
---|
754 | ////////////////////// Functions to do manipulations /////////////////////////////////// |
---|
755 | |
---|
756 | Function RenameDataSet(dataSetFolder, newName) |
---|
757 | String dataSetFolder |
---|
758 | String newName |
---|
759 | |
---|
760 | String dataSetFolderParent,basestr,objName |
---|
761 | Variable index = 0 |
---|
762 | |
---|
763 | //Abuse ParseFilePath to get path without folder name |
---|
764 | dataSetFolderParent = ParseFilePath(1,dataSetFolder,":",1,0) |
---|
765 | //Abuse ParseFilePath to get basestr |
---|
766 | basestr = ParseFilePath(0,dataSetFolder,":",1,0) |
---|
767 | |
---|
768 | // try |
---|
769 | RenameDataFolder $(dataSetFolder) $(newName)//; AbortOnRTE |
---|
770 | |
---|
771 | |
---|
772 | SetDataFolder $(dataSetFolderParent+newName)//; AbortOnRTE |
---|
773 | do |
---|
774 | objName = GetIndexedObjName("",1,index) |
---|
775 | if (strlen(objName) == 0) |
---|
776 | break |
---|
777 | endif |
---|
778 | Rename $(objName) $(ReplaceString(basestr,objName,newName)) |
---|
779 | index+=1 |
---|
780 | while(1) |
---|
781 | SetDataFolder root: |
---|
782 | // catch |
---|
783 | // Print "Aborted: " + num2str(V_AbortCode) |
---|
784 | // SetDataFolder root: |
---|
785 | // endtry |
---|
786 | End |
---|
787 | |
---|
788 | |
---|
789 | Function DuplicateDataSet(dataSetFolder, newName, forceoverwrite) |
---|
790 | String dataSetFolder |
---|
791 | String newName |
---|
792 | Variable forceoverwrite |
---|
793 | |
---|
794 | String dataSetFolderParent,basestr,objName |
---|
795 | Variable index = 0 |
---|
796 | |
---|
797 | //Abuse ParseFilePath to get path without folder name |
---|
798 | dataSetFolderParent = ParseFilePath(1,dataSetFolder,":",1,0) |
---|
799 | //Abuse ParseFilePath to get basestr |
---|
800 | basestr = ParseFilePath(0,dataSetFolder,":",1,0) |
---|
801 | |
---|
802 | print "Duplicating "+dataSetFolder+" as "+newName |
---|
803 | |
---|
804 | SetDataFolder $(dataSetFolderParent) |
---|
805 | |
---|
806 | if (!DataFolderExists(newName)) |
---|
807 | NewDataFolder $(newName) |
---|
808 | else |
---|
809 | if (!forceoverwrite) |
---|
810 | DoAlert 1, "A dataset with the name "+newName+" already exists. Overwrite?" |
---|
811 | if (V_flag == 2) |
---|
812 | return 1 |
---|
813 | endif |
---|
814 | endif |
---|
815 | endif |
---|
816 | |
---|
817 | //If we are here, the folder (now) exists and the user has agreed to overwrite |
---|
818 | //either in the function call or from the alert. |
---|
819 | do |
---|
820 | objName = GetIndexedObjName(basestr,1,index) |
---|
821 | if (strlen(objName) == 0) |
---|
822 | break |
---|
823 | endif |
---|
824 | objname = ":"+basestr+":"+objname |
---|
825 | Duplicate/O $(objName) $(ReplaceString(basestr,objName,newName)) |
---|
826 | index+=1 |
---|
827 | while(1) |
---|
828 | |
---|
829 | SetDataFolder root: |
---|
830 | return 0 |
---|
831 | End |
---|
832 | |
---|
833 | |
---|
834 | // Subtract Set2 From Set1 |
---|
835 | // Use Result_I = Set1_I - f*Set2_I |
---|
836 | Function SubtractDataSets(set1Name,set2Name,set2Scale,resultName) |
---|
837 | String set1Name |
---|
838 | String set2Name |
---|
839 | Variable set2Scale |
---|
840 | String resultName |
---|
841 | |
---|
842 | String set1Path = "root:"+set1Name+":" |
---|
843 | String set2Path = "root:"+set2Name+":" |
---|
844 | String resultPath = "root:"+resultName+":" |
---|
845 | |
---|
846 | SetDataFolder root: |
---|
847 | //Create folder for result |
---|
848 | //UnloadDataSet(resultName) |
---|
849 | //Make the folder |
---|
850 | if (DuplicateDataSet(set1Path,resultName,0)) |
---|
851 | return 1 |
---|
852 | else |
---|
853 | //Do subtraction of I waves - including interpolation if necessary. |
---|
854 | Wave result_i = $(resultPath+resultName+"_i") |
---|
855 | Wave result_s = $(resultPath+resultName+"_s") |
---|
856 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
857 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
858 | Wave set1_s = $(set1Path+set1Name+"_s") |
---|
859 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
860 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
861 | Wave set2_s = $(set2Path+set2Name+"_s") |
---|
862 | |
---|
863 | result_i = set1_i - (set2Scale*interp(set1_q[p],set2_q,set2_i)) |
---|
864 | result_s = sqrt(set1_s^2 + set2Scale^2*interp(set1_q[p],set2_q,set2_s)) |
---|
865 | //Calculate result error wave - can we produce corrected Q error? |
---|
866 | |
---|
867 | //Generate history string to record what was done? |
---|
868 | return 0 |
---|
869 | endif |
---|
870 | End |
---|
871 | |
---|
872 | // Add Set2 to Set1 |
---|
873 | // Use Result_I = Set1_I + f*Set2_I |
---|
874 | Function AddDataSets(set1Name,set2Name,set2Scale,resultName) |
---|
875 | String set1Name |
---|
876 | String set2Name |
---|
877 | Variable set2Scale |
---|
878 | String resultName |
---|
879 | |
---|
880 | String set1Path = "root:"+set1Name+":" |
---|
881 | String set2Path = "root:"+set2Name+":" |
---|
882 | String resultPath = "root:"+resultName+":" |
---|
883 | |
---|
884 | SetDataFolder root: |
---|
885 | //Create folder for result |
---|
886 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
887 | //User said no overwrite |
---|
888 | return 1 |
---|
889 | else |
---|
890 | //Do addition of I waves - including interpolation if necessary. |
---|
891 | Wave result_i = $(resultPath+resultName+"_i") |
---|
892 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
893 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
894 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
895 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
896 | result_i = set1_i + set2Scale*interp(set1_q[p],set2_q,set2_i) |
---|
897 | |
---|
898 | //Calculate result error wave - can we produce corrected Q error? |
---|
899 | |
---|
900 | //Generate history string to record what was done? |
---|
901 | return 0 |
---|
902 | endif |
---|
903 | End |
---|
904 | |
---|
905 | // Multiply Set1 by Set2 |
---|
906 | // Use Result_I = Set1_I * (f*Set2_I) |
---|
907 | Function MultiplyDataSets(set1Name, set2Name, set2Scale, resultName) |
---|
908 | String set1Name |
---|
909 | String set2Name |
---|
910 | Variable set2Scale |
---|
911 | String resultName |
---|
912 | |
---|
913 | String set1Path = "root:"+set1Name+":" |
---|
914 | String set2Path = "root:"+set2Name+":" |
---|
915 | String resultPath = "root:"+resultName+":" |
---|
916 | |
---|
917 | SetDataFolder root: |
---|
918 | //Create folder for result |
---|
919 | //Make the folder |
---|
920 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
921 | //User said no overwrite |
---|
922 | return 1 |
---|
923 | else |
---|
924 | //Do multiplcation of I waves - including interpolation if necessary. |
---|
925 | Wave result_i = $(resultPath+resultName+"_i") |
---|
926 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
927 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
928 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
929 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
930 | result_i = set1_i*set2Scale*interp(set1_q[p],set2_q,set2_i) |
---|
931 | |
---|
932 | |
---|
933 | //Calculate result error wave - can we produce corrected Q error? |
---|
934 | |
---|
935 | //Generate history string to record what was done? |
---|
936 | return 0 |
---|
937 | endif |
---|
938 | End |
---|
939 | |
---|
940 | // Divide Set1 by Set2 |
---|
941 | // Use Result_I = Set1_I / (f*Set2_I) |
---|
942 | Function DivideDataSets(set1Name, set2Name, set2Scale, resultName) |
---|
943 | String set1Name |
---|
944 | String set2Name |
---|
945 | Variable set2Scale |
---|
946 | String resultName |
---|
947 | |
---|
948 | String set1Path = "root:"+set1Name+":" |
---|
949 | String set2Path = "root:"+set2Name+":" |
---|
950 | String resultPath = "root:"+resultName+":" |
---|
951 | |
---|
952 | SetDataFolder root: |
---|
953 | //Create folder for result |
---|
954 | //Make the folder |
---|
955 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
956 | //User said no overwrite |
---|
957 | return 1 |
---|
958 | else |
---|
959 | //Do division of I waves - including interpolation if necessary. |
---|
960 | Wave result_i = $(resultPath+resultName+"_i") |
---|
961 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
962 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
963 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
964 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
965 | result_i = set1_i/(set2Scale*interp(set1_q[p],set2_q,set2_i) ) |
---|
966 | |
---|
967 | //Calculate result error wave - can we produce corrected Q error? |
---|
968 | |
---|
969 | //Generate history string to record what was done? |
---|
970 | return 0 |
---|
971 | endif |
---|
972 | End |
---|
973 | |
---|
974 | |
---|
975 | ///////////////////////////Other Utility functions //////////////////////////// |
---|
976 | |
---|
977 | Function SaveDataSetToFile(folderName) |
---|
978 | String folderName |
---|
979 | |
---|
980 | String protoStr = "" |
---|
981 | //Check for history string in folder |
---|
982 | //If it doesn't exist then |
---|
983 | |
---|
984 | //Do saving of data file. |
---|
985 | |
---|
986 | NVAR gXML_Write = root:Packages:NIST:gXML_Write |
---|
987 | |
---|
988 | if (gXML_Write == 1) |
---|
989 | ReWrite1DXMLData(folderName) |
---|
990 | else |
---|
991 | fReWrite1DData(folderName,"tab","CRLF") |
---|
992 | endif |
---|
993 | |
---|
994 | // NISTSave1DData(folderName,protoStr) |
---|
995 | |
---|
996 | //Include history string to record what was done? |
---|
997 | |
---|
998 | End |
---|
999 | |
---|
1000 | |
---|
1001 | //This will be hideous |
---|
1002 | Function UnloadDataSet(folderName) |
---|
1003 | String folderName |
---|
1004 | |
---|
1005 | |
---|
1006 | End |
---|
1007 | |
---|
1008 | |
---|
1009 | //////////////////// Write data functions //////////////////////////////////// |
---|
1010 | // AJJ Nov 2009 - should move towards unified writer |
---|
1011 | // |
---|
1012 | ////////////////////////////////////////////////////////////////////////// |
---|
1013 | |
---|
1014 | //Function NISTSave1DData(folderPath,protoStr) |
---|
1015 | // String folderPath, protoStr |
---|
1016 | // |
---|
1017 | // //protoStr is string that will be written to either |
---|
1018 | // |
---|
1019 | // |
---|
1020 | //End |
---|