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 | // |
---|
18 | Proc MakeDMPanel() |
---|
19 | DoWindow/F DataManagementPanel |
---|
20 | if(V_flag==0) |
---|
21 | fMakeDMPanel() |
---|
22 | endif |
---|
23 | End |
---|
24 | |
---|
25 | Proc fMakeDMPanel() |
---|
26 | PauseUpdate; Silent 1 // building window... |
---|
27 | NewPanel /W=(459,44,959,410)/N=DataManagementPanel/K=2 as "Data Set Management" |
---|
28 | ModifyPanel fixedSize=1,cbRGB=(30000,60000,60000) |
---|
29 | |
---|
30 | //Main bit of panel |
---|
31 | GroupBox grpBox_0,pos={20,10},size={460,100} |
---|
32 | GroupBox grpBox_1,pos={20,130},size={460,70} |
---|
33 | GroupBox grpBox_2,pos={20,220},size={460,40} |
---|
34 | |
---|
35 | GroupBox grpBox_3,pos={20,280},size={460,40} |
---|
36 | |
---|
37 | Button DS_button,title="Load 1D Data Set",pos={300,20},size={150,20} |
---|
38 | Button DS_button,proc=DM_LoadDataSetProc |
---|
39 | Button Unload_button,title="Unload 1D Data Set",pos={300,50},size={150,20} |
---|
40 | Button Unload_button,proc=DM_UnloadProc |
---|
41 | Button Save_button,title="Save 1D Data Set",pos={300,80},size={150,20} |
---|
42 | Button Save_button,proc=DM_SaveProc |
---|
43 | PopupMenu DS_popup,pos={30,40},size={318,20},title="Data Set ",proc=DM_PopupProc |
---|
44 | PopupMenu DS_popup,mode=1,value= #"DM_DataSetPopupList()" |
---|
45 | |
---|
46 | CheckBox XMLStateCtrl,pos={30,82},size={124,14},title="XML Output Enabled (change in Preferences)" |
---|
47 | CheckBox XMLStateCtrl,help={"Default output format is canSAS XML rather than NIST 6 column"} |
---|
48 | CheckBox XMLStateCtrl,value= root:Packages:NIST:gXML_Write,disable=2 |
---|
49 | |
---|
50 | Button Rename_button,title="Rename",pos={75,170},size={150,20} |
---|
51 | Button Rename_button,proc=DM_RenameProc |
---|
52 | Button Duplicate_button,title="Duplicate",pos={275,170},size={150,20} |
---|
53 | Button Duplicate_button,proc=DM_DuplicateProc |
---|
54 | |
---|
55 | SetVariable NewName_setvar,title="New Name (max 25 characters)",pos={50,140},size={400,20} |
---|
56 | SetVariable NewName_setvar,fsize=12,value=_STR:"",proc=DMNameSetvarproc,live=1 |
---|
57 | |
---|
58 | Button SaveAsXML_button,title="Save as canSAS XML",pos={75,230},size={150,20} |
---|
59 | Button SaveAsXML_button,proc=DMSaveAsXMLproc |
---|
60 | |
---|
61 | Button SaveAs6col_button,title="Save as NIST 6 column",pos={275,230},size={150,20} |
---|
62 | Button SaveAs6col_button,proc=DMSaveAs6colproc |
---|
63 | |
---|
64 | Button BatchConvertData_button,title="Convert Format of 1D Data Files",pos={75,290},size={350,20} |
---|
65 | Button BatchConvertData_button,proc=DMBatchConvertProc |
---|
66 | |
---|
67 | Button DMDone_button,title="Done",pos={360,330},size={60,20} |
---|
68 | Button DMDone_button,proc=DMDoneButtonProc |
---|
69 | Button DMHelp_button,title="?",pos={440,330},size={30,20} |
---|
70 | Button DMHelp_button,proc=DMHelpButtonProc |
---|
71 | |
---|
72 | |
---|
73 | ControlInfo/W=DataManagementPanel DS_popup |
---|
74 | if (cmpstr(S_Value,"No data loaded") == 0) |
---|
75 | SetVariable NewName_setvar,value=_STR:"dataset_copy" |
---|
76 | else |
---|
77 | //fake call to popup |
---|
78 | STRUCT WMPopupAction pa |
---|
79 | pa.win = "DataManagementPanel" |
---|
80 | pa.ctrlName = "DS_popup" |
---|
81 | pa.eventCode = 2 |
---|
82 | DM_PopupProc(pa) |
---|
83 | endif |
---|
84 | |
---|
85 | End |
---|
86 | |
---|
87 | Function DMBatchConvertProc(ba) : ButtonControl |
---|
88 | STRUCT WMButtonAction &ba |
---|
89 | |
---|
90 | switch( ba.eventCode) |
---|
91 | case 2: |
---|
92 | Execute "MakeBatchConvertPanel()" |
---|
93 | break |
---|
94 | endswitch |
---|
95 | |
---|
96 | return 0 |
---|
97 | End |
---|
98 | |
---|
99 | |
---|
100 | Function DMNameSetvarproc(sva) : SetVariableControl |
---|
101 | STRUCT WMSetVariableAction &sva |
---|
102 | |
---|
103 | switch( sva.eventCode ) |
---|
104 | case 1: // mouse up |
---|
105 | case 2: // Enter key |
---|
106 | case 3: // Live update |
---|
107 | String sv = sva.sval |
---|
108 | if( strlen(sv) > 25 ) |
---|
109 | sv= sv[0,24] |
---|
110 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
111 | ControlUpdate /W=$(sva.win) $(sva.ctrlName) |
---|
112 | Beep |
---|
113 | endif |
---|
114 | break |
---|
115 | endswitch |
---|
116 | return 0 |
---|
117 | End |
---|
118 | |
---|
119 | Function DM_RenameProc(ba) : ButtonControl |
---|
120 | STRUCT WMButtonAction &ba |
---|
121 | |
---|
122 | String DS,NewName |
---|
123 | |
---|
124 | ControlInfo/W=$(ba.win) DS_popup |
---|
125 | DS = S_Value |
---|
126 | |
---|
127 | ControlInfo/W=$(ba.win) NewName_setvar |
---|
128 | NewName = CleanupName(S_Value, 0 ) //clean up any bad characters, and put the cleaned string back |
---|
129 | SetVariable NewName_setvar,value=_STR:NewName |
---|
130 | |
---|
131 | switch (ba.eventcode) |
---|
132 | case 2: // mouse up |
---|
133 | RenameDataSet(DS,NewName) |
---|
134 | ControlUpdate /W=$(ba.win) DS_Popup |
---|
135 | break |
---|
136 | endswitch |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | return 0 |
---|
141 | end |
---|
142 | |
---|
143 | Function DM_DuplicateProc(ba) : ButtonControl |
---|
144 | STRUCT WMButtonAction &ba |
---|
145 | |
---|
146 | String DS,NewName |
---|
147 | |
---|
148 | ControlInfo/W=$(ba.win) DS_popup |
---|
149 | DS = S_Value |
---|
150 | |
---|
151 | ControlInfo/W=$(ba.win) NewName_setvar |
---|
152 | NewName = CleanupName(S_Value, 0 ) //clean up any bad characters, and put the cleaned string back |
---|
153 | SetVariable NewName_setvar,value=_STR:NewName |
---|
154 | |
---|
155 | switch (ba.eventcode) |
---|
156 | case 2: // mouse up |
---|
157 | DuplicateDataSet(DS,NewName,0) |
---|
158 | ControlUpdate /W=$(ba.win) DS_Popup |
---|
159 | break |
---|
160 | endswitch |
---|
161 | |
---|
162 | return 0 |
---|
163 | end |
---|
164 | |
---|
165 | Function DM_SaveProc(ba) : ButtonControl |
---|
166 | STRUCT WMButtonAction &ba |
---|
167 | |
---|
168 | switch(ba.eventCode) |
---|
169 | case 2: |
---|
170 | ControlInfo/W=$(ba.win) DS_popup |
---|
171 | SaveDataSetToFile(S_Value) |
---|
172 | break |
---|
173 | endswitch |
---|
174 | |
---|
175 | return 0 |
---|
176 | end |
---|
177 | |
---|
178 | Function DM_UnloadProc(ba) : ButtonControl |
---|
179 | STRUCT WMButtonAction &ba |
---|
180 | |
---|
181 | switch (ba.eventcode) |
---|
182 | case 2: // mouse up |
---|
183 | |
---|
184 | String savDF=GetDataFolder(1) |
---|
185 | String DF |
---|
186 | ControlInfo /W=$(ba.win) DS_Popup |
---|
187 | DF = S_Value |
---|
188 | |
---|
189 | print DF |
---|
190 | //check for horrific null output from control |
---|
191 | if (cmpstr(DF,"") != 0) |
---|
192 | |
---|
193 | SetDataFolder DF |
---|
194 | KillVariables/A |
---|
195 | SetDataFolder savDF |
---|
196 | |
---|
197 | KillDataFolder/Z $DF |
---|
198 | ControlUpdate /W=$(ba.win) DS_Popup |
---|
199 | |
---|
200 | ControlInfo/W=DataManagementPanel DS_popup |
---|
201 | if (cmpstr(S_Value,"No data loaded") == 0) |
---|
202 | SetVariable NewName_setvar,value=_STR:"dataset_copy" |
---|
203 | else |
---|
204 | //fake call to popup |
---|
205 | STRUCT WMPopupAction pa |
---|
206 | pa.win = "DataManagementPanel" |
---|
207 | pa.ctrlName = "DS_popup" |
---|
208 | pa.eventCode = 2 |
---|
209 | DM_PopupProc(pa) |
---|
210 | endif |
---|
211 | endif |
---|
212 | break |
---|
213 | endswitch |
---|
214 | |
---|
215 | return 0 |
---|
216 | end |
---|
217 | |
---|
218 | |
---|
219 | Function DM_PopupProc(pa) : PopupMenuControl |
---|
220 | STRUCT WMPopupAction &pa |
---|
221 | |
---|
222 | String resultName |
---|
223 | |
---|
224 | switch( pa.eventCode) |
---|
225 | case 2: |
---|
226 | //print "Called by "+pa.ctrlname+" with value "+pa.popStr |
---|
227 | ControlInfo/W=$(pa.win) $(pa.ctrlName) |
---|
228 | String popStr = S_Value |
---|
229 | if (stringmatch(pa.ctrlname,"*DS*") == 1) |
---|
230 | resultName = stringfromlist(0,popStr,"_")+"_copy" |
---|
231 | |
---|
232 | SetVariable NewName_setvar win=$(pa.win), value=_STR:resultName |
---|
233 | endif |
---|
234 | break |
---|
235 | endswitch |
---|
236 | |
---|
237 | |
---|
238 | End |
---|
239 | |
---|
240 | |
---|
241 | //Must follow naming scheme to match buttons to popups |
---|
242 | //"Name_button" goes with "Name_popup" |
---|
243 | Function DM_LoadDataSetProc(ba) : ButtonControl |
---|
244 | STRUCT WMButtonAction &ba |
---|
245 | |
---|
246 | |
---|
247 | switch( ba.eventCode ) |
---|
248 | case 2: // mouse up |
---|
249 | // click code here |
---|
250 | String cmd = "A_LoadOneDDataWithName(\"\","+num2str(0)+")" |
---|
251 | Execute cmd |
---|
252 | |
---|
253 | SVAR gLastFileName = root:packages:NIST:gLastFileName |
---|
254 | |
---|
255 | String windowName = ba.win |
---|
256 | String popupName = StringFromList(0,ba.ctrlName,"_")+"_popup" |
---|
257 | |
---|
258 | ControlUpdate/W=$(windowName) $(popupName) |
---|
259 | //instead of a simple controlUpdate, better to pop the menu to make sure that the other menus follow |
---|
260 | // convoluted method to find the right item and pop the menu. |
---|
261 | |
---|
262 | String list,folderStr |
---|
263 | Variable num |
---|
264 | folderStr = CleanupName(gLastFileName,0) |
---|
265 | list = DM_DataSetPopupList() |
---|
266 | num=WhichListItem(folderStr,list,";",0,0) |
---|
267 | if(num != -1) |
---|
268 | PopupMenu $(popupName),mode=num+1,win=$(windowName) |
---|
269 | ControlUpdate/W=$(windowName) $(popupName) |
---|
270 | |
---|
271 | if (cmpstr(popupName,"DS_popup") == 0) |
---|
272 | //send fake mouse action to popup to update old name if |
---|
273 | Struct WMPopupAction pa |
---|
274 | pa.eventCode = 2 //fake mouse up |
---|
275 | pa.win = windowName |
---|
276 | pa.ctrlName = "DS_popup" |
---|
277 | DM_PopupProc(pa) |
---|
278 | endif |
---|
279 | endif |
---|
280 | break |
---|
281 | endswitch |
---|
282 | |
---|
283 | return 0 |
---|
284 | End |
---|
285 | |
---|
286 | |
---|
287 | Function/S DMGetDSName(dsNum) |
---|
288 | Variable dsNum |
---|
289 | |
---|
290 | String ctrlName |
---|
291 | if (dsNum == 1) |
---|
292 | ctrlName = "DS1_popup" |
---|
293 | elseif (dsNum == 2) |
---|
294 | ctrlName = "DS2_popup" |
---|
295 | endif |
---|
296 | |
---|
297 | ControlInfo/W=DataManagementPanel $(ctrlName) |
---|
298 | |
---|
299 | Return S_Value |
---|
300 | |
---|
301 | End |
---|
302 | |
---|
303 | |
---|
304 | Function DMDoneButtonProc(ba) : ButtonControl |
---|
305 | STRUCT WMButtonAction &ba |
---|
306 | |
---|
307 | String win = ba.win |
---|
308 | |
---|
309 | switch (ba.eventCode) |
---|
310 | case 2: |
---|
311 | DoWindow/K DataManagementPanel |
---|
312 | break |
---|
313 | endswitch |
---|
314 | |
---|
315 | return 0 |
---|
316 | End |
---|
317 | |
---|
318 | Function DMHelpButtonProc(ba) : ButtonControl |
---|
319 | STRUCT WMButtonAction &ba |
---|
320 | |
---|
321 | String win = ba.win |
---|
322 | |
---|
323 | switch (ba.eventCode) |
---|
324 | case 2: |
---|
325 | // click code here |
---|
326 | DisplayHelpTopic/Z/K=1 "Data Set Management" |
---|
327 | if(V_flag !=0) |
---|
328 | DoAlert 0,"The Data Set Management Help file could not be found" |
---|
329 | endif |
---|
330 | break |
---|
331 | endswitch |
---|
332 | |
---|
333 | return 0 |
---|
334 | End |
---|
335 | |
---|
336 | /////////////////////// Batch Data Conversion Panel //////////////////////////////////// |
---|
337 | // |
---|
338 | // |
---|
339 | |
---|
340 | Proc MakeNCNRBatchConvertPanel() |
---|
341 | NCNRInitBatchConvert() |
---|
342 | DoWindow/F NCNRBatchConvertPanel |
---|
343 | if(V_flag==0) |
---|
344 | fMakeNCNRBatchConvertPanel() |
---|
345 | endif |
---|
346 | End |
---|
347 | |
---|
348 | |
---|
349 | Function NCNRInitBatchConvert() |
---|
350 | NewDataFolder/O/S root:Packages:NIST:BatchConvert |
---|
351 | Make/O/T/N=1 filewave="" |
---|
352 | Make/O/N=1 selWave=0 |
---|
353 | Variable/G ind=0 |
---|
354 | SetDataFolder root: |
---|
355 | End |
---|
356 | |
---|
357 | Proc fMakeNCNRBatchConvertPanel() |
---|
358 | PauseUpdate; Silent 1 // building window... |
---|
359 | NewPanel /W=(658,347,1018,737)/N=NCNRBatchConvertPanel/K=2 as "Batch Convert 1D Data" |
---|
360 | ModifyPanel cbRGB=(40000,50000,32896) |
---|
361 | ModifyPanel fixedSize=1 |
---|
362 | |
---|
363 | ListBox fileList,pos={13,11},size={206,179} |
---|
364 | ListBox fileList,listWave=root:Packages:NIST:BatchConvert:fileWave |
---|
365 | ListBox fileList,selWave=root:Packages:NIST:BatchConvert:selWave,mode= 4 |
---|
366 | |
---|
367 | Button button7,pos={238,20},size={100,20},proc=NCNRBatchConvertNewFolder,title="New Folder" |
---|
368 | Button button7,help={"Select a new data folder"} |
---|
369 | TitleBox msg0,pos={238,140},size={100,30},title="\JCShift-click to\rselect multiple files" |
---|
370 | TitleBox msg0,frame=0,fixedSize=1 |
---|
371 | |
---|
372 | GroupBox filterGroup,pos={13,200},size={206,60},title="Filter list by input file type" |
---|
373 | |
---|
374 | Button button8,pos={238,76},size={100,20},proc=NCNRBatchConvertHelpProc,title="Help" |
---|
375 | Button button9,pos={238,48},size={100,20},proc=NCNRBatchConvertRefresh,title="Refresh List" |
---|
376 | Button button0,pos={238,106},size={100,20},proc=NCNRBatchConvertDone,title="Done" |
---|
377 | |
---|
378 | GroupBox outputGroup,pos={13,270},size={206,60},title="Output File Type" |
---|
379 | |
---|
380 | |
---|
381 | Button button6,pos={13,350},size={206,20},proc=NCNRBatchConvertFiles,title="Convert File(s)" |
---|
382 | Button button6,help={"Converts the files to the format selected"} |
---|
383 | |
---|
384 | |
---|
385 | |
---|
386 | End |
---|
387 | |
---|
388 | |
---|
389 | Function NCNRBatchConvertFiles(ba) : ButtonControl |
---|
390 | STRUCT WMButtonAction &ba |
---|
391 | |
---|
392 | switch (ba.eventCode) |
---|
393 | case 2: |
---|
394 | Wave/T fileWave=$"root:Packages:NIST:BatchConvert:fileWave" |
---|
395 | Wave sel=$"root:BatchConvert:NIST:BatchConvert:selWave" |
---|
396 | |
---|
397 | break |
---|
398 | endswitch |
---|
399 | |
---|
400 | return 0 |
---|
401 | End |
---|
402 | |
---|
403 | |
---|
404 | Function NCNRBatchConvertNewFolder(ba) : ButtonControl |
---|
405 | STRUCT WMButtonAction &ba |
---|
406 | |
---|
407 | switch (ba.eventcode) |
---|
408 | case 2: |
---|
409 | A_PickPath() |
---|
410 | NCNRBatchConvertGetList() |
---|
411 | break |
---|
412 | endswitch |
---|
413 | |
---|
414 | End |
---|
415 | |
---|
416 | Function NCNRBatchConvertGetList() |
---|
417 | |
---|
418 | //make sure that path exists |
---|
419 | PathInfo catPathName |
---|
420 | if (V_flag == 0) |
---|
421 | Abort "Folder path does not exist - use \"New Folder\" button" |
---|
422 | Endif |
---|
423 | |
---|
424 | String newList = A_ReducedDataFileList("") |
---|
425 | Variable num |
---|
426 | |
---|
427 | num=ItemsInList(newlist,";") |
---|
428 | WAVE/T fileWave=$"root:Packages:NIST:BatchConvert:fileWave" |
---|
429 | WAVE selWave=$"root:Packages:NIST:BatchConvert:selWave" |
---|
430 | Redimension/N=(num) fileWave |
---|
431 | Redimension/N=(num) selWave |
---|
432 | fileWave = StringFromList(p,newlist,";") |
---|
433 | Sort filewave,filewave |
---|
434 | End |
---|
435 | |
---|
436 | Function NCNRBatchConvertRefresh(ba) : ButtonControl |
---|
437 | STRUCT WMButtonAction &ba |
---|
438 | |
---|
439 | switch (ba.eventCode) |
---|
440 | case 2: |
---|
441 | NCNRBatchConvertGetList() |
---|
442 | break |
---|
443 | endswitch |
---|
444 | |
---|
445 | return 0 |
---|
446 | End |
---|
447 | |
---|
448 | |
---|
449 | Function NCNRBatchConvertDone(ba) : ButtonControl |
---|
450 | STRUCT WMButtonAction &ba |
---|
451 | |
---|
452 | switch (ba.eventCode) |
---|
453 | case 2: |
---|
454 | DoWindow/K NCNRBatchConvertPanel |
---|
455 | break |
---|
456 | endswitch |
---|
457 | |
---|
458 | return 0 |
---|
459 | End |
---|
460 | |
---|
461 | Function NCNRBatchConvertHelpProc(ba) : ButtonControl |
---|
462 | STRUCT WMButtonAction &ba |
---|
463 | |
---|
464 | String win = ba.win |
---|
465 | |
---|
466 | switch (ba.eventCode) |
---|
467 | case 2: |
---|
468 | // click code here |
---|
469 | DisplayHelpTopic/Z/K=1 "Batch Data Conversion" |
---|
470 | if(V_flag !=0) |
---|
471 | DoAlert 0,"The Batch Data Conversion Help file could not be found" |
---|
472 | endif |
---|
473 | break |
---|
474 | endswitch |
---|
475 | |
---|
476 | return 0 |
---|
477 | End |
---|
478 | |
---|
479 | /////////////////////// Data Arithmetic Panel ///////////////////////////////////////// |
---|
480 | |
---|
481 | // |
---|
482 | Function MakeDAPanel() |
---|
483 | DoWindow/F DataArithmeticPanel |
---|
484 | if(V_flag==0) |
---|
485 | fMakeDAPanel() |
---|
486 | else |
---|
487 | DoWindow/F DAPlotPanel |
---|
488 | endif |
---|
489 | |
---|
490 | return(0) |
---|
491 | End |
---|
492 | |
---|
493 | Function fMakeDAPanel() |
---|
494 | PauseUpdate; Silent 1 // building window... |
---|
495 | DoWindow/K DataArithmeticPanel |
---|
496 | NewPanel /W=(459,44,959,404)/N=DataArithmeticPanel/K=2 as "Data Set Arithmetic" |
---|
497 | ModifyPanel fixedSize=1 |
---|
498 | |
---|
499 | //Main bit of panel |
---|
500 | GroupBox grpBox_0,pos={20,10},size={460,105} |
---|
501 | |
---|
502 | Button DS1_button,pos={300,20},size={150,20},proc=DA_LoadDataSetProc,title="Load 1D Data Set 1" |
---|
503 | Button DS1_button,valueColor=(65535,0,0),userdata="DS1" |
---|
504 | PopupMenu DS1_popup,pos={30,21},size={318,20},title="Data Set 1" |
---|
505 | PopupMenu DS1_popup,mode=1,value= #"DM_DataSetPopupList()" |
---|
506 | PopupMenu DS1_popup,proc=DA_PopupProc |
---|
507 | PopupMenu DS1_popup,fsize=12,fcolor=(65535,0,0),valueColor=(65535,0,0) |
---|
508 | |
---|
509 | Button DS2_button,pos={300,50},size={150,20},proc=DA_LoadDataSetProc,title="Load 1D Data Set 2" |
---|
510 | Button DS2_button,valueColor=(0,0,65535),userdata="DS2" |
---|
511 | PopupMenu DS2_popup,pos={30,51},size={318,20},title="Data Set 2" |
---|
512 | PopupMenu DS2_popup,mode=1,value= #"DM_DataSetPopupList()" |
---|
513 | PopupMenu DS2_popup,proc=DA_PopupProc |
---|
514 | PopupMenu DS2_popup,fsize=12,fcolor=(0,0,65535),valueColor=(0,0,65535) |
---|
515 | |
---|
516 | Button DAPlot_button,title="Plot",pos={100,85},size={150,20} |
---|
517 | Button DAPlot_button,proc=DAPlotButtonProc |
---|
518 | Button DADone_button,title="Done",pos={360,85},size={60,20} |
---|
519 | Button DADone_button,proc=DADoneButtonProc |
---|
520 | Button DAHelp_button,title="?",pos={440,85},size={30,20} |
---|
521 | Button DAHelp_button,proc=DAHelpButtonProc |
---|
522 | |
---|
523 | |
---|
524 | //Tabs |
---|
525 | TabControl DATabs,pos={20,120},size={460,220},tabLabel(0)="Subtract", proc=DATabsProc |
---|
526 | TabControl DATabs,tablabel(1)="Add",tablabel(2)="Multiply",tablabel(3)="Divide" |
---|
527 | TabControl DATabs,value=0 |
---|
528 | |
---|
529 | Button DACalculate_button,title="Calculate",pos={50,310},size={150,20} |
---|
530 | Button DACalculate_button,proc=DACalculateProc |
---|
531 | Button DASave_button,title="Save Result",pos={300,310},size={150,20} |
---|
532 | Button DASave_button,proc=DASaveProc,disable=2 |
---|
533 | Button DACursors_button,title="Get Matching Range",pos={175,250},size={150,20} |
---|
534 | Button DACursors_button,proc=DACursorButtonProc |
---|
535 | |
---|
536 | SetVariable DAResultName_sv,title="Result Name (max 25 characters)",pos={50,280},size={400,20} |
---|
537 | SetVariable DAResultName_Sv,fsize=12,proc=DANameSetvarproc,live=1 |
---|
538 | //Update the result name |
---|
539 | ControlInfo/W=DataArithmeticPanel DS1_popup |
---|
540 | if (cmpstr(S_Value,"No data loaded") == 0) |
---|
541 | SetVariable DAResultName_sv,value=_STR:"SubtractionResult" |
---|
542 | else |
---|
543 | //fake call to popup |
---|
544 | STRUCT WMPopupAction pa |
---|
545 | pa.win = "DataArithmeticPanel" |
---|
546 | pa.ctrlName = "DS1_popup" |
---|
547 | pa.eventCode = 2 |
---|
548 | DA_PopupProc(pa) |
---|
549 | endif |
---|
550 | |
---|
551 | CheckBox DANoDS2_cb,title="Data Set 2 = 1?",pos={300,180} |
---|
552 | CheckBox DANoDS2_cb,proc=DANoDS2Proc |
---|
553 | |
---|
554 | ValDisplay DARangeStar_vd,title="Start",pos={40,220},size={100,20},fsize=12,value=_NUM:0 |
---|
555 | ValDisplay DARangeEnd_vd,title="End ",pos={160,220},size={100,20},fsize=12,value=_NUM:0 |
---|
556 | |
---|
557 | SetVariable DAScale_sv,title="Scale Factor (f)",pos={280,220},size={180,20},fsize=12,value=_NUM:1 |
---|
558 | |
---|
559 | GroupBox grpBox_1,pos={30,210},size={440,70} |
---|
560 | |
---|
561 | NewPanel/HOST=DataArithmeticPanel/N=arithDisplay/W=(50,150,170,190) |
---|
562 | |
---|
563 | //Update the result name |
---|
564 | ControlInfo/W=DataArithmeticPanel DS1_popup |
---|
565 | |
---|
566 | |
---|
567 | |
---|
568 | arithDisplayProc(0) |
---|
569 | |
---|
570 | End |
---|
571 | |
---|
572 | |
---|
573 | Function MakeDAPlotPanel() |
---|
574 | PauseUpdate; Silent 1 // building window... |
---|
575 | DoWindow/K DAPlotPanel |
---|
576 | NewPanel /W=(14,44,454,484)/N=DAPlotPanel/K=1 as "Data Set Arithmetic" |
---|
577 | ModifyPanel fixedSize=1 |
---|
578 | |
---|
579 | Display/HOST=DAPlotPanel/N=DAPlot/W=(0,0,440,400) |
---|
580 | Legend |
---|
581 | ShowInfo |
---|
582 | SetActiveSubWindow DAPlotPanel |
---|
583 | Checkbox DAPlot_log_cb, title="Log I(q)", pos={20,410},value=0 |
---|
584 | Checkbox DAPlot_log_cb, proc=DALogLinIProc |
---|
585 | |
---|
586 | End |
---|
587 | |
---|
588 | Function AddDAPlot(dataset) |
---|
589 | Variable dataset |
---|
590 | |
---|
591 | String win = "DataArithmeticPanel" |
---|
592 | String DS1name,DS2name,ResultName |
---|
593 | |
---|
594 | switch(dataset) |
---|
595 | case 1: |
---|
596 | ControlInfo/W=$(win) DS1_popup |
---|
597 | DS1name = S_Value |
---|
598 | Wave qWave = $("root:"+DS1name+":"+DS1name+"_q") |
---|
599 | Wave iWave = $("root:"+DS1name+":"+DS1name+"_i") |
---|
600 | Wave errWave = $("root:"+DS1name+":"+DS1name+"_s") |
---|
601 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
602 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(DS1name+"_i"), Y wave=(errWave,errWave) |
---|
603 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(DS1name+"_i"))=(65535,0,0) |
---|
604 | ControlInfo/W=$(win) DANoDS2_cb |
---|
605 | // if (V_Value == 1) |
---|
606 | // Cursor/W=DAPlotPanel#DAPlot A, $(DS1name+"_i"), leftx(iWave) |
---|
607 | // Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS1name+"_i"), rightx(iWave) |
---|
608 | // endif |
---|
609 | break |
---|
610 | case 2: |
---|
611 | ControlInfo/W=$(win) DANoDS2_cb |
---|
612 | if (V_Value == 0) |
---|
613 | ControlInfo/W=$(win) DS2_popup |
---|
614 | DS2name = S_Value |
---|
615 | if(cmpstr(DS2name,"No data loaded")==0) |
---|
616 | break //in case someone loads set 1, but not set two, then plots |
---|
617 | endif |
---|
618 | Wave qWave = $("root:"+DS2name+":"+DS2name+"_q") |
---|
619 | Wave iWave = $("root:"+DS2name+":"+DS2name+"_i") |
---|
620 | Wave errWave = $("root:"+DS2name+":"+DS2name+"_s") |
---|
621 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
622 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(DS2name+"_i"), Y wave=(errWave,errWave) |
---|
623 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(DS2name+"_i"))=(0,0,65535) |
---|
624 | Cursor/W=DAPlotPanel#DAPlot A, $(DS2name+"_i"), leftx(iWave) |
---|
625 | Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS2name+"_i"), rightx(iWave) |
---|
626 | else |
---|
627 | ControlInfo/W=$(win) DS1_popup |
---|
628 | DS1name = S_Value |
---|
629 | DuplicateDataSet("root:"+DS1name,"NullSolvent",1) |
---|
630 | Wave qWave =root:NullSolvent:NullSolvent_q |
---|
631 | Wave iWave = root:NullSolvent:NullSolvent_i |
---|
632 | Wave errWave = root:NullSolvent:NullSolvent_s |
---|
633 | Wave iWaveDS1 = $("root:"+DS1name+":"+DS1name+"_i") |
---|
634 | iWave = 1 |
---|
635 | errWave = 0 |
---|
636 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
637 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 NullSolvent_i, Y wave=(errWave,errWave) |
---|
638 | ModifyGraph/W=DAPlotPanel#DAPlot rgb(NullSolvent_i)=(0,0,65535) |
---|
639 | //Cursor/W=DAPlotPanel#DAPlot A, NullSolvent_i, leftx(iWave) |
---|
640 | //Cursor/W=DAPlotPanel#DAPlot/A=0 B, NullSolvent_i, rightx(iWave) |
---|
641 | if(strlen(CsrInfo(A,"DAPlotPanel#DAPlot")) == 0) //cursors not already on the graph |
---|
642 | Cursor/W=DAPlotPanel#DAPlot A, $(DS1Name+"_i"), leftx(iWaveDS1) |
---|
643 | Cursor/W=DAPlotPanel#DAPlot/A=0 B, $(DS1Name+"_i"), rightx(iWaveDS1) |
---|
644 | endif |
---|
645 | endif |
---|
646 | break |
---|
647 | case 3: |
---|
648 | ControlInfo/W=$(win) DAResultName_sv |
---|
649 | ResultName = S_Value |
---|
650 | Wave qWave = $("root:"+ResultName+":"+ResultName+"_q") |
---|
651 | Wave iWave = $("root:"+ResultName+":"+ResultName+"_i") |
---|
652 | Wave errWave = $("root:"+ResultName+":"+ResultName+"_s") |
---|
653 | AppendToGraph/W=DAPlotPanel#DAPlot iWave vs Qwave |
---|
654 | ErrorBars/W=DAPlotPanel#DAPlot /T=0 $(ResultName+"_i"), Y wave=(errWave,errWave) |
---|
655 | ModifyGraph/W=DAPlotPanel#DAPlot rgb($(ResultName+"_i"))=(0,65535,0) |
---|
656 | break |
---|
657 | endswitch |
---|
658 | |
---|
659 | ControlInfo/W=DAPlotPanel DAPlot_log_cb |
---|
660 | ModifyGraph/W=DAPlotPanel#DAPlot mode=3, msize=2, marker=19, mirror=1, tick=2, log(bottom)=1,log(left)=V_Value,tickUnit=1 |
---|
661 | End |
---|
662 | |
---|
663 | Function arithDisplayProc(s) |
---|
664 | Variable s |
---|
665 | |
---|
666 | SetActiveSubWindow DataArithmeticPanel#arithDisplay |
---|
667 | |
---|
668 | switch (s) |
---|
669 | case 0: |
---|
670 | //Subtract |
---|
671 | DrawAction/L=progFront delete |
---|
672 | DrawRect 0,0,120,40 |
---|
673 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
674 | DrawText 10,32,"I" |
---|
675 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
676 | DrawText 20,30,"=" |
---|
677 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
678 | DrawText 35,32,"I" |
---|
679 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
680 | DrawText 95,32,"I" |
---|
681 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
682 | DrawText 52,32,"-" |
---|
683 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
684 | DrawText 75,30,"f" |
---|
685 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
686 | DrawText 85,32,"*" |
---|
687 | break |
---|
688 | case 1: |
---|
689 | //Add |
---|
690 | DrawAction/L=progFront delete |
---|
691 | DrawRect 0,0,120,40 |
---|
692 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
693 | DrawText 10,32,"I" |
---|
694 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
695 | DrawText 20,30,"=" |
---|
696 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
697 | DrawText 35,32,"I" |
---|
698 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
699 | DrawText 95,32,"I" |
---|
700 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
701 | DrawText 52,32,"+" |
---|
702 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
703 | DrawText 75,30,"f" |
---|
704 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
705 | DrawText 85,32,"*" |
---|
706 | break |
---|
707 | case 2: |
---|
708 | //Multiply |
---|
709 | DrawAction/L=progFront delete |
---|
710 | DrawRect 0,0,120,40 |
---|
711 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
712 | DrawText 10,32,"I" |
---|
713 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
714 | DrawText 20,30,"=" |
---|
715 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
716 | DrawText 35,32,"I" |
---|
717 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
718 | DrawText 95,32,"I" |
---|
719 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
720 | DrawText 52,32,"*" |
---|
721 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
722 | DrawText 66,30,"(" |
---|
723 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
724 | DrawText 75,30,"f" |
---|
725 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
726 | DrawText 85,32,"*" |
---|
727 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
728 | DrawText 105,30,")" |
---|
729 | break |
---|
730 | case 3: |
---|
731 | //Divide |
---|
732 | DrawAction/L=progFront delete |
---|
733 | DrawRect 0,0,120,40 |
---|
734 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,65535,0) |
---|
735 | DrawText 10,32,"I" |
---|
736 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
737 | DrawText 20,30,"=" |
---|
738 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (65535,0,0) |
---|
739 | DrawText 35,32,"I" |
---|
740 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,65535) |
---|
741 | DrawText 95,32,"I" |
---|
742 | SetDrawEnv fname="Symbol", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
743 | DrawText 52,32,"/" |
---|
744 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
745 | DrawText 66,30,"(" |
---|
746 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
747 | DrawText 75,30,"f" |
---|
748 | SetDrawEnv fname="Times", fsize=22, fstyle= 1,textrgb= (0,0,0) |
---|
749 | DrawText 85,32,"*" |
---|
750 | SetDrawEnv fname="Times", fsize=22, fstyle= 2,textrgb= (0,0,0) |
---|
751 | DrawText 105,30,")" |
---|
752 | break |
---|
753 | endswitch |
---|
754 | |
---|
755 | SetActiveSubWindow DataArithmeticPanel |
---|
756 | |
---|
757 | return 0 |
---|
758 | End |
---|
759 | |
---|
760 | //Must follow naming scheme to match buttons to popups |
---|
761 | //"Name_button" goes with "Name_popup" |
---|
762 | Function DA_LoadDataSetProc(ba) : ButtonControl |
---|
763 | STRUCT WMButtonAction &ba |
---|
764 | |
---|
765 | switch( ba.eventCode ) |
---|
766 | case 2: // mouse up |
---|
767 | // click code here |
---|
768 | String cmd = "A_LoadOneDDataWithName(\"\","+num2str(0)+")" |
---|
769 | Execute cmd |
---|
770 | |
---|
771 | SVAR gLastFileName = root:packages:NIST:gLastFileName |
---|
772 | |
---|
773 | String windowName = ba.win |
---|
774 | String popupName = StringFromList(0,ba.ctrlName,"_")+"_popup" |
---|
775 | |
---|
776 | ControlUpdate/W=$(windowName) $(popupName) |
---|
777 | //instead of a simple controlUpdate, better to pop the menu to make sure that the other menus follow |
---|
778 | // convoluted method to find the right item and pop the menu. |
---|
779 | |
---|
780 | String list,folderStr |
---|
781 | Variable num |
---|
782 | folderStr = CleanupName(gLastFileName,0) |
---|
783 | list = DM_DataSetPopupList() |
---|
784 | num=WhichListItem(folderStr,list,";",0,0) |
---|
785 | if(num != -1) |
---|
786 | PopupMenu $(popupName),mode=num+1,win=$(windowName) |
---|
787 | ControlUpdate/W=$(windowName) $(popupName) |
---|
788 | |
---|
789 | endif |
---|
790 | //fake call to popup |
---|
791 | STRUCT WMPopupAction pa |
---|
792 | pa.win = ba.win |
---|
793 | pa.ctrlName = "DS1_popup" |
---|
794 | pa.eventCode = 2 |
---|
795 | DA_PopupProc(pa) |
---|
796 | break |
---|
797 | endswitch |
---|
798 | |
---|
799 | return 0 |
---|
800 | End |
---|
801 | |
---|
802 | Function DA_PopupProc(pa) : PopupMenuControl |
---|
803 | STRUCT WMPopupAction &pa |
---|
804 | |
---|
805 | String resultName |
---|
806 | |
---|
807 | switch( pa.eventCode) |
---|
808 | case 2: |
---|
809 | //print "Called by "+pa.ctrlname+" with value "+pa.popStr |
---|
810 | ControlInfo/W=$(pa.win) $(pa.ctrlName) |
---|
811 | String popStr = S_Value |
---|
812 | if (stringmatch(pa.ctrlname,"*DS1*") == 1) |
---|
813 | resultName = stringfromlist(0,popStr,"_")+"_mod" |
---|
814 | |
---|
815 | SetVariable DAResultName_sv win=$(pa.win), value=_STR:resultName |
---|
816 | endif |
---|
817 | break |
---|
818 | endswitch |
---|
819 | |
---|
820 | |
---|
821 | End |
---|
822 | |
---|
823 | // function to control the drawing of buttons in the TabControl on the main panel |
---|
824 | // Naming scheme for the buttons MUST be strictly adhered to... else buttons will |
---|
825 | // appear in odd places... |
---|
826 | // all buttons are named MainButton_NA where N is the tab number and A is the letter denoting |
---|
827 | // the button's position on that particular tab. |
---|
828 | // in this way, buttons will always be drawn correctly.. |
---|
829 | // |
---|
830 | Function DATabsProc(tca) : TabControl |
---|
831 | STRUCT WMTabControlAction &tca |
---|
832 | |
---|
833 | switch (tca.eventCode) |
---|
834 | case 2: |
---|
835 | // Print "name,number",name,tab |
---|
836 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
837 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
838 | for(ii=0;ii<num;ii+=1) |
---|
839 | //items all start w/"DSTabItem_" |
---|
840 | item=StringFromList(ii, ctrlList ,";") |
---|
841 | nameStr=item[0,9] |
---|
842 | if(cmpstr(nameStr,"DATabItem_")==0) |
---|
843 | onTab = str2num(item[10]) |
---|
844 | ControlInfo $item |
---|
845 | switch (V_flag) |
---|
846 | case 1: |
---|
847 | Button $item,disable=(tca.tab!=onTab) |
---|
848 | break |
---|
849 | case 2: |
---|
850 | CheckBox $item,disable=(tca.tab!=onTab) |
---|
851 | break |
---|
852 | case 3: |
---|
853 | PopUpMenu $item,disable=(tca.tab!=onTab) |
---|
854 | break |
---|
855 | case 5: |
---|
856 | SetVariable $item,disable=(tca.tab!=onTab) |
---|
857 | break |
---|
858 | endswitch |
---|
859 | endif |
---|
860 | endfor |
---|
861 | |
---|
862 | arithDisplayProc(tca.tab) |
---|
863 | break |
---|
864 | endswitch |
---|
865 | End |
---|
866 | |
---|
867 | |
---|
868 | Function DACalculateProc(ba) : ButtonControl |
---|
869 | STRUCT WMButtonAction &ba |
---|
870 | |
---|
871 | String DS1,DS2,Resultname |
---|
872 | |
---|
873 | switch(ba.eventCode) |
---|
874 | case 2: |
---|
875 | //Which tab? |
---|
876 | ControlInfo/W=$(ba.win) DATabs |
---|
877 | Variable tabNum = V_value |
---|
878 | //Print "Tab number "+num2str(tabNum) |
---|
879 | |
---|
880 | ControlInfo/W=$(ba.win) DS1_popup |
---|
881 | DS1 = S_Value |
---|
882 | ControlInfo/W=$(ba.win) DANoDS2_cb |
---|
883 | if (V_Value == 0) |
---|
884 | ControlInfo/W=$(ba.win) DS2_popup |
---|
885 | DS2 = S_Value |
---|
886 | else |
---|
887 | DS2 = "NullSolvent" |
---|
888 | endif |
---|
889 | ControlInfo/W=$(ba.win) DAResultName_sv |
---|
890 | Resultname = CleanupName(S_Value, 0 ) //clean up any bad characters, and put the cleaned string back |
---|
891 | SetVariable DAResultName_sv,value=_STR:ResultName |
---|
892 | |
---|
893 | ControlInfo/W=$(ba.win) DAScale_sv |
---|
894 | Variable Scalefactor = V_Value |
---|
895 | |
---|
896 | switch(tabNum) |
---|
897 | case 0: |
---|
898 | //do subtraction |
---|
899 | //print "Subtraction of "+DS2+" from "+DS1+" with sf "+num2str(scalefactor)+ " into "+Resultname |
---|
900 | SubtractDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
901 | break |
---|
902 | case 1: |
---|
903 | //do addition |
---|
904 | AddDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
905 | break |
---|
906 | case 2: |
---|
907 | //do multiplication |
---|
908 | MultiplyDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
909 | break |
---|
910 | case 3: |
---|
911 | //do division |
---|
912 | DivideDataSets(DS1,DS2,Scalefactor,Resultname) |
---|
913 | break |
---|
914 | endswitch |
---|
915 | |
---|
916 | //Sort out plot |
---|
917 | //Fake button press to DAPlotButtonProc |
---|
918 | STRUCT WMButtonAction ba2 |
---|
919 | ba2.win = ba.win |
---|
920 | ba2.ctrlName = "DAPlot_button" |
---|
921 | ba2.eventCode = 2 |
---|
922 | |
---|
923 | // I've commented this out - the cursors get reset to the ends since this removes all sets from the graph, and |
---|
924 | // then replots them. What is the real purpose of this call? To clear the old result off before adding the |
---|
925 | // new one? |
---|
926 | // DAPlotButtonProc(ba2) |
---|
927 | ba2.userData = ResultName |
---|
928 | DAPlotRemoveResult(ba2) |
---|
929 | |
---|
930 | |
---|
931 | AddDAPlot(3) |
---|
932 | DoWindow/F DataArithmeticPanel |
---|
933 | |
---|
934 | //Enable save button now that we have a result to save |
---|
935 | Button DASave_Button win=$(ba.win),disable=0 |
---|
936 | |
---|
937 | // SetActiveSubWindow DAPlotPanel |
---|
938 | endswitch |
---|
939 | |
---|
940 | End |
---|
941 | |
---|
942 | // remove what is not the |
---|
943 | // |
---|
944 | Function DAPlotRemoveResult(ba) : ButtonControl |
---|
945 | STRUCT WMButtonAction &ba |
---|
946 | |
---|
947 | String win = ba.win |
---|
948 | String ResultName = ba.userData |
---|
949 | String item="",traceList="" |
---|
950 | Variable ii=0,num |
---|
951 | |
---|
952 | switch (ba.eventCode) |
---|
953 | case 2: //mouse up |
---|
954 | //data set 1 |
---|
955 | ControlInfo/W=$(win) DS1_popup |
---|
956 | String DS1 = S_Value |
---|
957 | |
---|
958 | //Get folder for DS2 |
---|
959 | ControlInfo/W=$(win) DS2_popup |
---|
960 | String DS2 = S_Value |
---|
961 | |
---|
962 | // state of the checkbox |
---|
963 | ControlInfo/W=$(win) DANoDS2_cb |
---|
964 | if(V_Value) |
---|
965 | DS2 = "NullSolvent" |
---|
966 | endif |
---|
967 | |
---|
968 | DoWindow DAPlotPanel |
---|
969 | if (V_Flag == 0) |
---|
970 | MakeDAPlotPanel() |
---|
971 | else |
---|
972 | DoWindow/HIDE=0/F DAPlotPanel |
---|
973 | traceList = TraceNameList("DAPlotPanel#DAPlot",";",1) |
---|
974 | num=ItemsInList(traceList) |
---|
975 | ii=0 |
---|
976 | do |
---|
977 | item = StringFromList(ii,traceList,";") |
---|
978 | if (stringmatch(item,ResultName+"*")==1) //it it's the specific trace I've asked to remove |
---|
979 | RemoveFromGraph/W=DAPlotPanel#DAPlot $item |
---|
980 | elseif (stringmatch(item,DS1+"*")==0 && stringmatch(item,DS2+"*")==0) //if it's not set1 & not set2 |
---|
981 | RemoveFromGraph/W=DAPlotPanel#DAPlot $item |
---|
982 | endif |
---|
983 | |
---|
984 | ii+=1 |
---|
985 | while(ii<num) |
---|
986 | endif |
---|
987 | |
---|
988 | break |
---|
989 | endswitch |
---|
990 | |
---|
991 | return 0 |
---|
992 | End |
---|
993 | |
---|
994 | |
---|
995 | Function DAPlotButtonProc(ba) : ButtonControl |
---|
996 | STRUCT WMButtonAction &ba |
---|
997 | |
---|
998 | String win = ba.win |
---|
999 | |
---|
1000 | switch (ba.eventCode) |
---|
1001 | case 2: |
---|
1002 | //mouse up |
---|
1003 | //Get folder for DS1 |
---|
1004 | DoWindow DAPlotPanel |
---|
1005 | if (V_Flag == 0) |
---|
1006 | MakeDAPlotPanel() |
---|
1007 | else |
---|
1008 | DoWindow/HIDE=0/F DAPlotPanel |
---|
1009 | do |
---|
1010 | String tracename = StringFromList(0,TraceNameList("DAPlotPanel#DAPlot",";",1),";") |
---|
1011 | if (cmpstr(tracename,"")==0) |
---|
1012 | break |
---|
1013 | else |
---|
1014 | RemoveFromGraph/W=DAPlotPanel#DAPlot $tracename |
---|
1015 | endif |
---|
1016 | while(1) |
---|
1017 | endif |
---|
1018 | |
---|
1019 | ControlInfo/W=$(win) DS1_popup |
---|
1020 | String DS1 = S_Value |
---|
1021 | if (cmpstr(DS1,"") != 0 ) |
---|
1022 | AddDAPlot(1) |
---|
1023 | endif |
---|
1024 | //Get folder for DS2 |
---|
1025 | ControlInfo/W=$(win) DS2_popup |
---|
1026 | String DS2 = S_Value |
---|
1027 | if (cmpstr(DS2,"") != 0) |
---|
1028 | AddDAPlot(2) |
---|
1029 | endif |
---|
1030 | break |
---|
1031 | endswitch |
---|
1032 | |
---|
1033 | return 0 |
---|
1034 | End |
---|
1035 | |
---|
1036 | Function DADoneButtonProc(ba) : ButtonControl |
---|
1037 | STRUCT WMButtonAction &ba |
---|
1038 | |
---|
1039 | String win = ba.win |
---|
1040 | |
---|
1041 | switch (ba.eventCode) |
---|
1042 | case 2: |
---|
1043 | DoWindow/K DAPlotPanel |
---|
1044 | DoWindow/K DataArithmeticPanel |
---|
1045 | break |
---|
1046 | endswitch |
---|
1047 | |
---|
1048 | return 0 |
---|
1049 | End |
---|
1050 | |
---|
1051 | Function DAHelpButtonProc(ba) : ButtonControl |
---|
1052 | STRUCT WMButtonAction &ba |
---|
1053 | |
---|
1054 | String win = ba.win |
---|
1055 | |
---|
1056 | switch (ba.eventCode) |
---|
1057 | case 2: |
---|
1058 | // click code here |
---|
1059 | DisplayHelpTopic/Z/K=1 "Data Set Arithmetic" |
---|
1060 | if(V_flag !=0) |
---|
1061 | DoAlert 0,"The Data Set Arithmetic Help file could not be found" |
---|
1062 | endif |
---|
1063 | break |
---|
1064 | endswitch |
---|
1065 | |
---|
1066 | return 0 |
---|
1067 | End |
---|
1068 | |
---|
1069 | Function DALogLinIProc(cba) : CheckBoxControl |
---|
1070 | STRUCT WMCheckBoxAction &cba |
---|
1071 | |
---|
1072 | switch(cba.eventcode) |
---|
1073 | case 2: |
---|
1074 | |
---|
1075 | ModifyGraph/W=DAPlotPanel#DAPlot log(left)=cba.checked |
---|
1076 | |
---|
1077 | endswitch |
---|
1078 | |
---|
1079 | |
---|
1080 | End |
---|
1081 | |
---|
1082 | Function DACursorButtonProc(ba) : ButtonControl |
---|
1083 | STRUCT WMButtonAction &ba |
---|
1084 | |
---|
1085 | String DS1,DS2 |
---|
1086 | |
---|
1087 | switch(ba.eventCode) |
---|
1088 | case 2: |
---|
1089 | |
---|
1090 | ControlInfo/W=$(ba.win) DS1_popup |
---|
1091 | DS1 = S_Value |
---|
1092 | ControlInfo/W=$(ba.win) DANoDS2_cb |
---|
1093 | Variable NoDS2 = V_Value |
---|
1094 | if (NoDS2 == 0) |
---|
1095 | ControlInfo/W=$(ba.win) DS2_popup |
---|
1096 | DS2 = S_Value |
---|
1097 | else |
---|
1098 | DS2 = "NullSolvent" |
---|
1099 | endif |
---|
1100 | |
---|
1101 | //AJJ Nov 2009 - UGLY - Will have to revisit this when we deal with hierarchical folders |
---|
1102 | Wave set1_i = $("root:"+DS1+":"+DS1+"_i") |
---|
1103 | Wave set1_q = $("root:"+DS1+":"+DS1+"_q") |
---|
1104 | Wave set2_i = $("root:"+DS2+":"+DS2+"_i") |
---|
1105 | Wave set2_q = $("root:"+DS2+":"+DS2+"_q") |
---|
1106 | Duplicate/O set1_i tmp_i |
---|
1107 | Duplicate/O set1_q tmp_q |
---|
1108 | tmp_i = set1_i / interp(set1_q[p],set2_q,set2_i) |
---|
1109 | |
---|
1110 | //Get cursors |
---|
1111 | Variable q1,q2 |
---|
1112 | |
---|
1113 | DoWindow/F DAPlotPanel |
---|
1114 | SetActiveSubWindow DAPlotPanel#DAPlot |
---|
1115 | |
---|
1116 | q1 = CsrXWaveRef(A)[pcsr(A)] |
---|
1117 | q2 = CsrXWaveRef(B)[pcsr(B)] |
---|
1118 | |
---|
1119 | //Update value display |
---|
1120 | ValDisplay DARangeStar_vd,value=_NUM:q1, win=$(ba.win) |
---|
1121 | ValDisplay DARangeEnd_vd,value=_NUM:q2, win=$(ba.win) |
---|
1122 | |
---|
1123 | //Calculate scalefactor |
---|
1124 | |
---|
1125 | if (NoDS2 == 1) |
---|
1126 | Wave avgWave = set1_i |
---|
1127 | else |
---|
1128 | Wave avgWave = tmp_i |
---|
1129 | endif |
---|
1130 | |
---|
1131 | Variable p1 = BinarySearch(tmp_q,q1) |
---|
1132 | Variable p2 = BinarySearch(tmp_q,q2) |
---|
1133 | |
---|
1134 | //print avgWave |
---|
1135 | |
---|
1136 | WaveStats/Q/R=[p1,p2] avgWave |
---|
1137 | //print V_avg |
---|
1138 | //Update sv control |
---|
1139 | SetVariable DAScale_sv, value=_NUM:V_avg, win=$(ba.win) |
---|
1140 | |
---|
1141 | KillWaves/Z tmp_i,tmp_q |
---|
1142 | DoWindow/F DataArithmeticPanel |
---|
1143 | endswitch |
---|
1144 | |
---|
1145 | End |
---|
1146 | |
---|
1147 | |
---|
1148 | Function DANoDS2Proc(cba) : CheckBoxControl |
---|
1149 | STRUCT WMCheckBoxAction &cba |
---|
1150 | |
---|
1151 | |
---|
1152 | switch(cba.eventCode) |
---|
1153 | case 2: |
---|
1154 | if (cba.checked == 1) |
---|
1155 | //Disable DS2 popup etc |
---|
1156 | PopupMenu DS2_popup win=$(cba.win), disable=2 |
---|
1157 | Button DS2_button win=$(cba.win), disable=2 |
---|
1158 | else |
---|
1159 | //Enable DS2 popup etc |
---|
1160 | PopupMenu DS2_popup win=$(cba.win), disable=0 |
---|
1161 | Button DS2_button win=$(cba.win), disable=0 |
---|
1162 | endif |
---|
1163 | //Sort out plot |
---|
1164 | //Fake button press to DAPlotButtonProc |
---|
1165 | STRUCT WMButtonAction ba2 |
---|
1166 | ba2.win = cba.win |
---|
1167 | ba2.ctrlName = "DAPlot_button" |
---|
1168 | ba2.eventCode = 2 |
---|
1169 | DAPlotButtonProc(ba2) |
---|
1170 | SetActiveSubWindow DAPlotPanel |
---|
1171 | DoWindow/F DataArithmeticPanel |
---|
1172 | endswitch |
---|
1173 | |
---|
1174 | End |
---|
1175 | |
---|
1176 | Function DASaveProc(ba) : ButtonControl |
---|
1177 | STRUCT WMButtonAction &ba |
---|
1178 | |
---|
1179 | switch(ba.eventCode) |
---|
1180 | case 2: |
---|
1181 | ControlInfo/W=$(ba.win) DAResultName_sv |
---|
1182 | SaveDataSetToFile(S_Value) |
---|
1183 | break |
---|
1184 | endswitch |
---|
1185 | |
---|
1186 | |
---|
1187 | End |
---|
1188 | |
---|
1189 | /////////////////////// Common Panel Functions /////////////////////////////////////// |
---|
1190 | |
---|
1191 | |
---|
1192 | // is there a simpler way to do this? I don't think so. |
---|
1193 | Function/S DM_DataSetPopupList() |
---|
1194 | |
---|
1195 | String str=GetAList(4) |
---|
1196 | |
---|
1197 | if(strlen(str)==0) |
---|
1198 | str = "No data loaded" |
---|
1199 | endif |
---|
1200 | str = SortList(str) |
---|
1201 | |
---|
1202 | return(str) |
---|
1203 | End |
---|
1204 | |
---|
1205 | |
---|
1206 | Function DANameSetvarproc(sva) : SetVariableControl |
---|
1207 | STRUCT WMSetVariableAction &sva |
---|
1208 | |
---|
1209 | switch( sva.eventCode ) |
---|
1210 | case 1: // mouse up |
---|
1211 | case 2: // Enter key |
---|
1212 | case 3: // Live update |
---|
1213 | String sv = sva.sval |
---|
1214 | if( strlen(sv) > 25 ) |
---|
1215 | sv= sv[0,24] |
---|
1216 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
1217 | ControlUpdate /W=$(sva.win) $(sva.ctrlName) |
---|
1218 | Beep |
---|
1219 | endif |
---|
1220 | Button DASave_Button win=$(sva.win), disable=2 |
---|
1221 | break |
---|
1222 | endswitch |
---|
1223 | return 0 |
---|
1224 | End |
---|
1225 | |
---|
1226 | |
---|
1227 | ////////////////////// Functions to do manipulations /////////////////////////////////// |
---|
1228 | |
---|
1229 | Function RenameDataSet(dataSetFolder, newName) |
---|
1230 | String dataSetFolder |
---|
1231 | String newName |
---|
1232 | |
---|
1233 | String dataSetFolderParent,basestr,objName |
---|
1234 | Variable index = 0 |
---|
1235 | |
---|
1236 | //Abuse ParseFilePath to get path without folder name |
---|
1237 | dataSetFolderParent = ParseFilePath(1,dataSetFolder,":",1,0) |
---|
1238 | //Abuse ParseFilePath to get basestr |
---|
1239 | basestr = ParseFilePath(0,dataSetFolder,":",1,0) |
---|
1240 | |
---|
1241 | // try |
---|
1242 | RenameDataFolder $(dataSetFolder) $(newName)//; AbortOnRTE |
---|
1243 | |
---|
1244 | |
---|
1245 | SetDataFolder $(dataSetFolderParent+newName)//; AbortOnRTE |
---|
1246 | do |
---|
1247 | objName = GetIndexedObjName("",1,index) |
---|
1248 | if (strlen(objName) == 0) |
---|
1249 | break |
---|
1250 | endif |
---|
1251 | Rename $(objName) $(ReplaceString(basestr,objName,newName)) |
---|
1252 | index+=1 |
---|
1253 | while(1) |
---|
1254 | SetDataFolder root: |
---|
1255 | // catch |
---|
1256 | // Print "Aborted: " + num2str(V_AbortCode) |
---|
1257 | // SetDataFolder root: |
---|
1258 | // endtry |
---|
1259 | End |
---|
1260 | |
---|
1261 | |
---|
1262 | Function DuplicateDataSet(dataSetFolder, newName, forceoverwrite) |
---|
1263 | String dataSetFolder |
---|
1264 | String newName |
---|
1265 | Variable forceoverwrite |
---|
1266 | |
---|
1267 | String dataSetFolderParent,basestr,objName |
---|
1268 | Variable index = 0 |
---|
1269 | |
---|
1270 | //Abuse ParseFilePath to get path without folder name |
---|
1271 | dataSetFolderParent = ParseFilePath(1,dataSetFolder,":",1,0) |
---|
1272 | //Abuse ParseFilePath to get basestr |
---|
1273 | basestr = ParseFilePath(0,dataSetFolder,":",1,0) |
---|
1274 | |
---|
1275 | print "Duplicating "+dataSetFolder+" as "+newName |
---|
1276 | |
---|
1277 | SetDataFolder $(dataSetFolderParent) |
---|
1278 | |
---|
1279 | if (!DataFolderExists(newName)) |
---|
1280 | NewDataFolder $(newName) |
---|
1281 | else |
---|
1282 | if (!forceoverwrite) |
---|
1283 | DoAlert 1, "A dataset with the name "+newName+" already exists. Overwrite?" |
---|
1284 | if (V_flag == 2) |
---|
1285 | return 1 |
---|
1286 | endif |
---|
1287 | endif |
---|
1288 | endif |
---|
1289 | |
---|
1290 | //If we are here, the folder (now) exists and the user has agreed to overwrite |
---|
1291 | //either in the function call or from the alert. |
---|
1292 | do |
---|
1293 | objName = GetIndexedObjName(basestr,1,index) |
---|
1294 | if (strlen(objName) == 0) |
---|
1295 | break |
---|
1296 | endif |
---|
1297 | objname = ":"+basestr+":"+objname |
---|
1298 | Duplicate/O $(objName) $(ReplaceString(basestr,objName,newName)) |
---|
1299 | index+=1 |
---|
1300 | while(1) |
---|
1301 | |
---|
1302 | SetDataFolder root: |
---|
1303 | return 0 |
---|
1304 | End |
---|
1305 | |
---|
1306 | |
---|
1307 | // Subtract Set2 From Set1 |
---|
1308 | // Use Result_I = Set1_I - f*Set2_I |
---|
1309 | Function SubtractDataSets(set1Name,set2Name,set2Scale,resultName) |
---|
1310 | String set1Name |
---|
1311 | String set2Name |
---|
1312 | Variable set2Scale |
---|
1313 | String resultName |
---|
1314 | |
---|
1315 | String set1Path = "root:"+set1Name+":" |
---|
1316 | String set2Path = "root:"+set2Name+":" |
---|
1317 | String resultPath = "root:"+resultName+":" |
---|
1318 | |
---|
1319 | SetDataFolder root: |
---|
1320 | //Create folder for result |
---|
1321 | //UnloadDataSet(resultName) |
---|
1322 | //Make the folder |
---|
1323 | if (DuplicateDataSet(set1Path,resultName,0)) |
---|
1324 | return 1 |
---|
1325 | else |
---|
1326 | //Do subtraction of I waves - including interpolation if necessary. |
---|
1327 | Wave result_i = $(resultPath+resultName+"_i") |
---|
1328 | Wave result_s = $(resultPath+resultName+"_s") |
---|
1329 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
1330 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
1331 | Wave set1_s = $(set1Path+set1Name+"_s") |
---|
1332 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
1333 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
1334 | Wave set2_s = $(set2Path+set2Name+"_s") |
---|
1335 | |
---|
1336 | result_i = set1_i - (set2Scale*interp(set1_q[p],set2_q,set2_i)) |
---|
1337 | result_s = sqrt(set1_s^2 + (set2Scale*interp(set1_q[p],set2_q,set2_s))^2 ) |
---|
1338 | //Calculate result error wave - can we produce corrected Q error? |
---|
1339 | |
---|
1340 | //Generate history string to record what was done? |
---|
1341 | return 0 |
---|
1342 | endif |
---|
1343 | End |
---|
1344 | |
---|
1345 | // Add Set2 to Set1 |
---|
1346 | // Use Result_I = Set1_I + f*Set2_I |
---|
1347 | Function AddDataSets(set1Name,set2Name,set2Scale,resultName) |
---|
1348 | String set1Name |
---|
1349 | String set2Name |
---|
1350 | Variable set2Scale |
---|
1351 | String resultName |
---|
1352 | |
---|
1353 | String set1Path = "root:"+set1Name+":" |
---|
1354 | String set2Path = "root:"+set2Name+":" |
---|
1355 | String resultPath = "root:"+resultName+":" |
---|
1356 | |
---|
1357 | SetDataFolder root: |
---|
1358 | //Create folder for result |
---|
1359 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
1360 | //User said no overwrite |
---|
1361 | return 1 |
---|
1362 | else |
---|
1363 | //Do addition of I waves - including interpolation if necessary. |
---|
1364 | Wave result_i = $(resultPath+resultName+"_i") |
---|
1365 | Wave result_s = $(resultPath+resultName+"_s") |
---|
1366 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
1367 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
1368 | Wave set1_s = $(set1Path+set1Name+"_s") |
---|
1369 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
1370 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
1371 | Wave set2_s = $(set2Path+set2Name+"_s") |
---|
1372 | |
---|
1373 | result_i = set1_i + set2Scale*interp(set1_q[p],set2_q,set2_i) |
---|
1374 | //Calculate result error wave (note that this is identical to subtraction) |
---|
1375 | result_s = sqrt(set1_s^2 + (set2Scale*interp(set1_q[p],set2_q,set2_s))^2 ) |
---|
1376 | |
---|
1377 | // - can we produce corrected Q error? |
---|
1378 | //Generate history string to record what was done? |
---|
1379 | return 0 |
---|
1380 | endif |
---|
1381 | End |
---|
1382 | |
---|
1383 | // Multiply Set1 by Set2 |
---|
1384 | // Use Result_I = Set1_I * (f*Set2_I) |
---|
1385 | Function MultiplyDataSets(set1Name, set2Name, set2Scale, resultName) |
---|
1386 | String set1Name |
---|
1387 | String set2Name |
---|
1388 | Variable set2Scale |
---|
1389 | String resultName |
---|
1390 | |
---|
1391 | String set1Path = "root:"+set1Name+":" |
---|
1392 | String set2Path = "root:"+set2Name+":" |
---|
1393 | String resultPath = "root:"+resultName+":" |
---|
1394 | |
---|
1395 | SetDataFolder root: |
---|
1396 | //Create folder for result |
---|
1397 | //Make the folder |
---|
1398 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
1399 | //User said no overwrite |
---|
1400 | return 1 |
---|
1401 | else |
---|
1402 | //Do multiplcation of I waves - including interpolation if necessary. |
---|
1403 | Wave result_i = $(resultPath+resultName+"_i") |
---|
1404 | Wave result_s = $(resultPath+resultName+"_s") |
---|
1405 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
1406 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
1407 | Wave set1_s = $(set1Path+set1Name+"_s") |
---|
1408 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
1409 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
1410 | Wave set2_s = $(set2Path+set2Name+"_s") |
---|
1411 | |
---|
1412 | result_i = set1_i*set2Scale*interp(set1_q[p],set2_q,set2_i) |
---|
1413 | //Calculate result error wave |
---|
1414 | // sum each of the relative errors, interpolating set 2 intensity and error as needed |
---|
1415 | // then sqrt |
---|
1416 | result_s = (set2Scale*interp(set1_q[p],set2_q,set2_i)*set1_s)^2 |
---|
1417 | result_s += (set2Scale*set1_i*interp(set1_q[p],set2_q,set2_s))^2 |
---|
1418 | result_s = sqrt(result_s) |
---|
1419 | |
---|
1420 | // - can we produce corrected Q error? |
---|
1421 | |
---|
1422 | //Generate history string to record what was done? |
---|
1423 | return 0 |
---|
1424 | endif |
---|
1425 | End |
---|
1426 | |
---|
1427 | // Divide Set1 by Set2 |
---|
1428 | // Use Result_I = Set1_I / (f*Set2_I) |
---|
1429 | Function DivideDataSets(set1Name, set2Name, set2Scale, resultName) |
---|
1430 | String set1Name |
---|
1431 | String set2Name |
---|
1432 | Variable set2Scale |
---|
1433 | String resultName |
---|
1434 | |
---|
1435 | String set1Path = "root:"+set1Name+":" |
---|
1436 | String set2Path = "root:"+set2Name+":" |
---|
1437 | String resultPath = "root:"+resultName+":" |
---|
1438 | |
---|
1439 | SetDataFolder root: |
---|
1440 | //Create folder for result |
---|
1441 | //Make the folder |
---|
1442 | if(DuplicateDataSet(set1Path,resultName,0)) |
---|
1443 | //User said no overwrite |
---|
1444 | return 1 |
---|
1445 | else |
---|
1446 | //Do division of I waves - including interpolation if necessary. |
---|
1447 | Wave result_i = $(resultPath+resultName+"_i") |
---|
1448 | Wave result_s = $(resultPath+resultName+"_s") |
---|
1449 | Wave set1_i = $(set1Path+set1Name+"_i") |
---|
1450 | Wave set1_q = $(set1Path+set1Name+"_q") |
---|
1451 | Wave set1_s = $(set1Path+set1Name+"_s") |
---|
1452 | Wave set2_i = $(set2Path+set2Name+"_i") |
---|
1453 | Wave set2_q = $(set2Path+set2Name+"_q") |
---|
1454 | Wave set2_s = $(set2Path+set2Name+"_s") |
---|
1455 | |
---|
1456 | result_i = set1_i/(set2Scale*interp(set1_q[p],set2_q,set2_i) ) |
---|
1457 | //Calculate result error wave |
---|
1458 | // sum each of the relative errors, interpolating set 2 intensity and error as needed |
---|
1459 | // then sqrt |
---|
1460 | result_s = (set1_s/set2Scale/interp(set1_q[p],set2_q,set2_i))^2 |
---|
1461 | result_s += (interp(set1_q[p],set2_q,set2_s)*set1_i/set2Scale/interp(set1_q[p],set2_q,set2_i)^2)^2 |
---|
1462 | result_s = sqrt(result_s) |
---|
1463 | |
---|
1464 | // - can we produce corrected Q error? |
---|
1465 | |
---|
1466 | //Generate history string to record what was done? |
---|
1467 | return 0 |
---|
1468 | endif |
---|
1469 | End |
---|
1470 | |
---|
1471 | |
---|
1472 | ///////////////////////////Other Utility functions //////////////////////////// |
---|
1473 | |
---|
1474 | Function SaveDataSetToFile(folderName) |
---|
1475 | String folderName |
---|
1476 | |
---|
1477 | String protoStr = "" |
---|
1478 | //Check for history string in folder |
---|
1479 | //If it doesn't exist then |
---|
1480 | |
---|
1481 | //Do saving of data file. |
---|
1482 | |
---|
1483 | NVAR gXML_Write = root:Packages:NIST:gXML_Write |
---|
1484 | |
---|
1485 | if (gXML_Write == 1) |
---|
1486 | ReWrite1DXMLData(folderName) |
---|
1487 | else |
---|
1488 | fReWrite1DData(folderName,"tab","CRLF") |
---|
1489 | endif |
---|
1490 | |
---|
1491 | // NISTSave1DData(folderName,protoStr) |
---|
1492 | |
---|
1493 | //Include history string to record what was done? |
---|
1494 | |
---|
1495 | End |
---|
1496 | |
---|
1497 | |
---|
1498 | |
---|
1499 | //////////////////// Write data functions //////////////////////////////////// |
---|
1500 | // AJJ Nov 2009 - should move towards unified writer |
---|
1501 | // |
---|
1502 | ////////////////////////////////////////////////////////////////////////// |
---|
1503 | |
---|
1504 | //Function NISTSave1DData(folderPath,protoStr) |
---|
1505 | // String folderPath, protoStr |
---|
1506 | // |
---|
1507 | // //protoStr is string that will be written to either |
---|
1508 | // |
---|
1509 | // |
---|
1510 | //End |
---|