1 | #pragma TextEncoding = "MacRoman" |
---|
2 | #pragma rtGlobals=1 // Use modern global access method. |
---|
3 | #pragma version=5.0 |
---|
4 | #pragma IgorVersion=7 |
---|
5 | |
---|
6 | //************************ |
---|
7 | |
---|
8 | // |
---|
9 | //************************* |
---|
10 | ////////////////////////////////// |
---|
11 | // |
---|
12 | // KEYWORD=<value> lists used in protocol definitions |
---|
13 | // |
---|
14 | // KEYWORDS are ALWAYS capitalized, and yes, it does matter |
---|
15 | // |
---|
16 | // for ABSOLUTE parameters |
---|
17 | // (4) possible keywords, all with numerical values |
---|
18 | // TSTAND=value transmission of the standard |
---|
19 | // DSTAND=value thickness of the standard, in centimeters |
---|
20 | // IZERO=value I(q=0) value for the standard, in normalized neutron counts |
---|
21 | // XSECT=value calibrated cross-section of the standard sample |
---|
22 | // |
---|
23 | // For calibration with a transmission file, set TSTAND, DSTAND, and XSECT to 1.0 |
---|
24 | // and set IZERO to KAPPA (defined in Tania's handout, or in documentation of MRED_KAP on VAX) |
---|
25 | // |
---|
26 | // |
---|
27 | // For AVERAGE and for DRAWING |
---|
28 | // DRAWING routines only use a subset of the total list, since saving, naming, etc. don't apply |
---|
29 | // (10) possible keywords, some numerical, some string values |
---|
30 | // AVTYPE=string string from set {Circular,Annular,Rectangular,Sector,2D_ASCII,QxQy_ASCII,PNG_Graphic;Sector_PlusMinus;} |
---|
31 | // PHI=value azimuthal angle (-90,90) |
---|
32 | // DPHI=value +/- angular range around phi for average |
---|
33 | // WIDTH=value total width of rectangular section, in pixels |
---|
34 | // SIDE=string string from set {left,right,both} **note NOT capitalized |
---|
35 | |
---|
36 | // QCENTER=value q-value (1/A) of center of annulus for annular average |
---|
37 | // QDELTA=value (+/-) width of annulus centered at QCENTER, in units of q |
---|
38 | // DETGROUP=value string with "F" or "M" to name the detector group where the annulus lies. |
---|
39 | |
---|
40 | // PLOT=string string from set {Yes,No} = truth of generating plot of averaged data |
---|
41 | // SAVE=string string from set {Yes,No} = truth of saving averaged data to disk, now with "Concatenate" or "Individual" |
---|
42 | // NAME=string string from set {Auto,Manual} = Automatic name generation or Manual(dialog) |
---|
43 | // |
---|
44 | // |
---|
45 | // BINTYPE=string (VSANS binning type) "One;Two;Four;Slit Mode;", as defined by ksBinTypeStr |
---|
46 | // |
---|
47 | // |
---|
48 | // For work.DRK usage: |
---|
49 | // **the list is COMMA delimited, separator is = |
---|
50 | // DRK=none,DRKMODE=0, |
---|
51 | // DRK=name is the name of the file, must be a full name, expected to be raw data |
---|
52 | // DRKMODE=value is a numeric value (0 or 10 to add to the Correct(mode) switch (unused?) |
---|
53 | // |
---|
54 | ////////////////////////////////// |
---|
55 | |
---|
56 | |
---|
57 | //main entry procedure for initialzing and displaying the protocol panel |
---|
58 | // initilaizes folders and globals as needed |
---|
59 | // |
---|
60 | Proc V_ReductionProtocolPanel() |
---|
61 | DoWindow/F V_ProtocolPanel |
---|
62 | if(V_flag==0) |
---|
63 | V_InitProtocolPanel() |
---|
64 | V_ProtocolPanel() |
---|
65 | Endif |
---|
66 | End |
---|
67 | |
---|
68 | //initialization procedure for the protocol panel |
---|
69 | //note that :gAbsStr is also shared (common global) to that used in |
---|
70 | //the questionnare form of the protcol (see protocol.ipf) |
---|
71 | // |
---|
72 | Proc V_InitProtocolPanel() |
---|
73 | |
---|
74 | if(exists(" root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames") == 0) |
---|
75 | Abort "You must generate a file catalog before building protocols" |
---|
76 | endif |
---|
77 | |
---|
78 | //set up the global variables needed for the protocol panel |
---|
79 | //global strings to put in a temporary protocol textwave |
---|
80 | Variable ii=0 |
---|
81 | String waveStr="tempProtocol" |
---|
82 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
83 | Make/O/T/N=(kNumProtocolSteps) $"root:Packages:NIST:VSANS:Globals:Protocols:tempProtocol" = "" |
---|
84 | |
---|
85 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gSAM="ask" |
---|
86 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gBGD="ask" |
---|
87 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gEMP="ask" |
---|
88 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDIV="ask" |
---|
89 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK="ask" |
---|
90 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="ask" |
---|
91 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE="AVTYPE=Circular;SAVE=Yes - Concatenate;NAME=Auto;PLOT=No;BINTYPE=One;" |
---|
92 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK="DRK=none,DRKMODE=0," |
---|
93 | |
---|
94 | // global strings for trimming data are initialized in the main VSANS initilization |
---|
95 | // in case the trimming is done before the protocol panel is opened |
---|
96 | |
---|
97 | SetDataFolder root: |
---|
98 | |
---|
99 | End |
---|
100 | |
---|
101 | |
---|
102 | //button procedure to reset the panel seletctions/checks...etc... |
---|
103 | //to reflect the choices in a previously saved protocol |
---|
104 | // - parses through the protocol and resets the appropriate global strings and |
---|
105 | //updates the panel display |
---|
106 | // |
---|
107 | Function V_RecallProtocolButton(ctrlName) : ButtonControl |
---|
108 | String ctrlName |
---|
109 | |
---|
110 | //will reset panel values based on a previously saved protocol |
---|
111 | //pick a protocol wave from the Protocols folder |
---|
112 | //MUST move to Protocols folder to get wavelist |
---|
113 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
114 | Execute "V_PickAProtocol()" |
---|
115 | |
---|
116 | //get the selected protocol wave choice through a global string variable |
---|
117 | SVAR protocolName = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr |
---|
118 | |
---|
119 | //If "CreateNew" was selected, ask user to try again |
---|
120 | if(cmpstr("CreateNew",protocolName) == 0) |
---|
121 | Abort "CreateNew is for making a new Protocol. Select a previously saved Protocol" |
---|
122 | Endif |
---|
123 | |
---|
124 | //reset the panel based on the protocol textwave (currently a string) |
---|
125 | V_ResetToSavedProtocol(protocolName) |
---|
126 | |
---|
127 | SetDataFolder root: |
---|
128 | return(0) |
---|
129 | End |
---|
130 | |
---|
131 | //deletes the selected protocol from the list and from memory |
---|
132 | // |
---|
133 | Function V_DeleteProtocolButton(ctrlName) : ButtonControl |
---|
134 | String ctrlName |
---|
135 | |
---|
136 | //put up a list of protocols and pick one |
---|
137 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
138 | // Execute "DeleteAProtocol()" |
---|
139 | String Protocol="" |
---|
140 | Prompt Protocol "Delete A Protocol",popup, V_DeletableProtocols() |
---|
141 | DoPrompt "Select protocol to delete",protocol |
---|
142 | If(V_flag==1) |
---|
143 | return(0) |
---|
144 | endif |
---|
145 | |
---|
146 | //If "CreateNew, Base, DoAll, or tempProtocol" was selected, do nothing |
---|
147 | strswitch(protocol) |
---|
148 | case "CreateNew": |
---|
149 | break |
---|
150 | case "DoAll": |
---|
151 | break |
---|
152 | case "Base": |
---|
153 | break |
---|
154 | case "tempProtocol": |
---|
155 | break |
---|
156 | default: |
---|
157 | //delete the protocol |
---|
158 | KillWaves/Z $protocol |
---|
159 | endswitch |
---|
160 | |
---|
161 | SetDataFolder root: |
---|
162 | return(0) |
---|
163 | End |
---|
164 | |
---|
165 | // |
---|
166 | //function that actually parses the protocol specified by nameStr |
---|
167 | //which is just the name of the wave, without a datafolder path |
---|
168 | // |
---|
169 | // TODO |
---|
170 | // -- update this for 12 steps |
---|
171 | // |
---|
172 | Function V_ResetToSavedProtocol(nameStr) |
---|
173 | String nameStr |
---|
174 | |
---|
175 | //allow special cases of Base and DoAll Protocols to be recalled to panel - since they "ask" |
---|
176 | //and don't need paths |
---|
177 | |
---|
178 | String catPathStr |
---|
179 | PathInfo catPathName |
---|
180 | catPathStr=S_path |
---|
181 | |
---|
182 | //SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols //on windows, data folder seems to get reset (erratically) to root: |
---|
183 | Wave/T w=$("root:Packages:NIST:VSANS:Globals:Protocols:" + nameStr) |
---|
184 | |
---|
185 | String fullPath="",comma=",",list="",nameList="",PathStr="",item="" |
---|
186 | Variable ii=0,numItems,checked,specialProtocol |
---|
187 | |
---|
188 | if((cmpstr(nameStr,"Base")==0) || (cmpstr(nameStr,"DoAll")==0)) |
---|
189 | specialProtocol = 1 |
---|
190 | else |
---|
191 | specialProtocol = 0 |
---|
192 | Endif |
---|
193 | |
---|
194 | //background |
---|
195 | checked = 1 |
---|
196 | nameList = w[0] |
---|
197 | If(cmpstr(nameList,"none") ==0) |
---|
198 | checked = 0 |
---|
199 | Endif |
---|
200 | |
---|
201 | //set the global string to display and checkbox |
---|
202 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gBGD = nameList |
---|
203 | CheckBox prot_check win=V_ProtocolPanel,value=checked |
---|
204 | |
---|
205 | //empty |
---|
206 | checked = 1 |
---|
207 | nameList = w[1] |
---|
208 | If(cmpstr(nameList,"none") ==0) |
---|
209 | checked = 0 |
---|
210 | Endif |
---|
211 | |
---|
212 | //set the global string to display and checkbox |
---|
213 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gEMP = nameList |
---|
214 | CheckBox prot_check_1 win=V_ProtocolPanel,value=checked |
---|
215 | |
---|
216 | //DIV file |
---|
217 | checked = 1 |
---|
218 | nameList = w[2] |
---|
219 | If(cmpstr(nameList,"none") ==0) |
---|
220 | checked = 0 |
---|
221 | Endif |
---|
222 | |
---|
223 | //set the global string to display and checkbox |
---|
224 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDIV = nameList |
---|
225 | CheckBox prot_check_2 win=V_ProtocolPanel,value=checked |
---|
226 | |
---|
227 | //Mask file |
---|
228 | checked = 1 |
---|
229 | nameList = w[3] |
---|
230 | If(cmpstr(nameList,"none") ==0) |
---|
231 | checked = 0 |
---|
232 | Endif |
---|
233 | |
---|
234 | //set the global string to display and checkbox |
---|
235 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK = nameList |
---|
236 | CheckBox prot_check_3 win=V_ProtocolPanel,value=checked |
---|
237 | |
---|
238 | //4 = abs parameters |
---|
239 | list = w[4] |
---|
240 | numItems = ItemsInList(list,";") |
---|
241 | checked = 1 |
---|
242 | if(numitems == 4 || numitems == 5) //allow for protocols with no SDEV list item |
---|
243 | //correct number of parameters, assume ok |
---|
244 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = list |
---|
245 | CheckBox prot_check_9 win=V_ProtocolPanel,value=checked |
---|
246 | else |
---|
247 | item = StringFromList(0,list,";") |
---|
248 | if(cmpstr(item,"none")==0) |
---|
249 | checked = 0 |
---|
250 | list = "none" |
---|
251 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = list |
---|
252 | CheckBox prot_check_9 win=V_ProtocolPanel,value=checked |
---|
253 | else |
---|
254 | //force to "ask" |
---|
255 | checked = 1 |
---|
256 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "ask" |
---|
257 | CheckBox prot_check_9 win=V_ProtocolPanel,value=checked |
---|
258 | Endif |
---|
259 | Endif |
---|
260 | |
---|
261 | //5 = averaging choices |
---|
262 | list = w[5] |
---|
263 | item = StringByKey("AVTYPE",list,"=",";") |
---|
264 | if(cmpstr(item,"none") == 0) |
---|
265 | checked = 0 |
---|
266 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = "none" |
---|
267 | CheckBox prot_check_5 win=V_ProtocolPanel,value=checked |
---|
268 | else |
---|
269 | checked = 1 |
---|
270 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = list |
---|
271 | CheckBox prot_check_5 win=V_ProtocolPanel,value=checked |
---|
272 | Endif |
---|
273 | |
---|
274 | // //6 = DRK choice |
---|
275 | // list = w[6] |
---|
276 | // item = StringByKey("DRK",list,"=",",") |
---|
277 | // //print list,item |
---|
278 | // if(cmpstr(item,"none") == 0) |
---|
279 | // checked = 0 |
---|
280 | // String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK = list |
---|
281 | // CheckBox prot_check_6 win=V_ProtocolPanel,value=checked |
---|
282 | // else |
---|
283 | // checked = 1 |
---|
284 | // String/G root:Packages:NIST:VSANS:Globals:Protocols:gDRK = list |
---|
285 | // CheckBox prot_check_6 win=V_ProtocolPanel,value=checked |
---|
286 | // Endif |
---|
287 | |
---|
288 | //7 = beginning trim points |
---|
289 | SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
290 | gBegPtsStr = w[7] |
---|
291 | //8 = end trim points |
---|
292 | SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
293 | gEndPtsStr = w[8] |
---|
294 | |
---|
295 | //9 = unused |
---|
296 | //10 = unused |
---|
297 | //11 = unused |
---|
298 | |
---|
299 | |
---|
300 | //all has been reset, get out |
---|
301 | Return (0) |
---|
302 | End |
---|
303 | |
---|
304 | //button action procedure that simply closes the panel |
---|
305 | // |
---|
306 | Function V_DoneProtocolButton(ctrlName) : ButtonControl |
---|
307 | String ctrlName |
---|
308 | |
---|
309 | //will gracefully close and exit the protocol panel |
---|
310 | |
---|
311 | DoWindow/K V_ProtocolPanel |
---|
312 | End |
---|
313 | |
---|
314 | //button action procedure that saves the current choices on the panel |
---|
315 | //as a named protocol, for later recall |
---|
316 | //asks for a valid name, then creates a protocol from the panel choices |
---|
317 | //creates a wave, and sets the current protocol name to this new protocol |
---|
318 | // |
---|
319 | //now allows the user the choice to overwrite a protocol |
---|
320 | // |
---|
321 | Function V_SaveProtocolButton(ctrlName) : ButtonControl |
---|
322 | String ctrlName |
---|
323 | |
---|
324 | Variable notDone=1, newProto=1 |
---|
325 | //will prompt for protocol name, and save the protocol as a text wave |
---|
326 | //prompt for name of new protocol wave to save |
---|
327 | do |
---|
328 | Execute "V_AskForName()" |
---|
329 | SVAR newProtocol = root:Packages:NIST:VSANS:Globals:Protocols:gNewStr |
---|
330 | |
---|
331 | //make sure it's a valid IGOR name |
---|
332 | newProtocol = CleanupName(newProtocol,0) //strict naming convention |
---|
333 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gNewStr=newProtocol //reassign, if changed |
---|
334 | Print "newProtocol = ",newProtocol |
---|
335 | |
---|
336 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
337 | if(WaveExists( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) ) == 1) |
---|
338 | //wave already exists |
---|
339 | DoAlert 1,"That name is already in use. Do you wish to overwrite the existing protocol?" |
---|
340 | if(V_Flag==1) |
---|
341 | notDone = 0 |
---|
342 | newProto = 0 |
---|
343 | else |
---|
344 | notDone = 1 |
---|
345 | endif |
---|
346 | else |
---|
347 | //name is good |
---|
348 | notDone = 0 |
---|
349 | Endif |
---|
350 | while(notDone) |
---|
351 | |
---|
352 | //current data folder is root:Packages:NIST:VSANS:Globals:Protocols |
---|
353 | if(newProto) |
---|
354 | Make/O/T/N=(kNumProtocolSteps) $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) |
---|
355 | Endif |
---|
356 | |
---|
357 | V_MakeProtocolFromPanel( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) ) |
---|
358 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtocol |
---|
359 | |
---|
360 | //the data folder WAS changed above, this must be reset to root: |
---|
361 | SetDatafolder root: |
---|
362 | End |
---|
363 | |
---|
364 | //function that does the guts of reading the panel controls and globals |
---|
365 | //to create the necessary text fields for a protocol |
---|
366 | //Wave/T w (input) is an empty text wave of 8 elements for the protocol |
---|
367 | //on output, w[] is filled with the protocol strings as needed from the panel |
---|
368 | // |
---|
369 | // TODO |
---|
370 | // -- update for 12 points |
---|
371 | // |
---|
372 | Function V_MakeProtocolFromPanel(w) |
---|
373 | Wave/T w |
---|
374 | |
---|
375 | //construct the protocol text wave form the panel |
---|
376 | //it is to be parsed by ExecuteProtocol() for the actual data reduction |
---|
377 | PathInfo catPathName //this is where the files came from |
---|
378 | String pathstr=S_path,tempStr,curList |
---|
379 | Variable checked,ii,numItems |
---|
380 | |
---|
381 | //look for checkbox, then take each item in list and prepend the path |
---|
382 | //w[0] = background |
---|
383 | ControlInfo/W=V_ProtocolPanel prot_check |
---|
384 | checked = V_value |
---|
385 | if(checked) |
---|
386 | //build the list |
---|
387 | //just read the global |
---|
388 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gBGD |
---|
389 | if(cmpstr(str,"ask")==0) |
---|
390 | w[0] = str //just ask |
---|
391 | else |
---|
392 | tempstr = V_ParseRunNumberList(str) |
---|
393 | if(strlen(tempStr)==0) |
---|
394 | return(1) //error parsing list |
---|
395 | else |
---|
396 | w[0] = tempstr |
---|
397 | str = tempstr //set the protocol and the global |
---|
398 | endif |
---|
399 | endif |
---|
400 | else |
---|
401 | //none used - set textwave (and global?) |
---|
402 | w[0] = "none" |
---|
403 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gBGD = "none" |
---|
404 | endif |
---|
405 | |
---|
406 | //w[1] = empty |
---|
407 | ControlInfo/W=V_ProtocolPanel prot_check_1 |
---|
408 | checked = V_value |
---|
409 | if(checked) |
---|
410 | //build the list |
---|
411 | //just read the global |
---|
412 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gEMP |
---|
413 | if(cmpstr(str,"ask")==0) |
---|
414 | w[1] = str |
---|
415 | else |
---|
416 | tempstr = V_ParseRunNumberList(str) |
---|
417 | if(strlen(tempStr)==0) |
---|
418 | return(1) |
---|
419 | else |
---|
420 | w[1] = tempstr |
---|
421 | str=tempStr |
---|
422 | endif |
---|
423 | endif |
---|
424 | else |
---|
425 | //none used - set textwave (and global?) |
---|
426 | w[1] = "none" |
---|
427 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gEMP = "none" |
---|
428 | endif |
---|
429 | |
---|
430 | //w[2] = div file |
---|
431 | ControlInfo/W=V_ProtocolPanel prot_check_2 |
---|
432 | checked = V_value |
---|
433 | if(checked) |
---|
434 | //build the list |
---|
435 | //just read the global |
---|
436 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gDIV |
---|
437 | if(cmpstr(str,"ask")==0) |
---|
438 | w[2] = str |
---|
439 | else |
---|
440 | tempStr = V_ParseRunNumberList(str) |
---|
441 | if(strlen(tempStr)==0) |
---|
442 | return(1) |
---|
443 | else |
---|
444 | w[2] = tempstr |
---|
445 | str=tempstr |
---|
446 | endif |
---|
447 | endif |
---|
448 | else |
---|
449 | //none used - set textwave (and global?) |
---|
450 | w[2] = "none" |
---|
451 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gDIV = "none" |
---|
452 | endif |
---|
453 | |
---|
454 | //w[3] = mask file |
---|
455 | ControlInfo/W=V_ProtocolPanel prot_check_3 |
---|
456 | checked = V_value |
---|
457 | if(checked) |
---|
458 | //build the list |
---|
459 | //just read the global |
---|
460 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gMASK |
---|
461 | if(cmpstr(str,"ask")==0) |
---|
462 | w[3] = str |
---|
463 | else |
---|
464 | tempstr = V_ParseRunNumberList(str) |
---|
465 | if(strlen(tempstr)==0) |
---|
466 | return(1) |
---|
467 | else |
---|
468 | w[3] = tempstr |
---|
469 | str = tempstr |
---|
470 | endif |
---|
471 | endif |
---|
472 | else |
---|
473 | //none used - set textwave (and global?) |
---|
474 | w[3] = "none" |
---|
475 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gMASK = "none" |
---|
476 | endif |
---|
477 | |
---|
478 | //w[4] = abs parameters |
---|
479 | ControlInfo/W=V_ProtocolPanel prot_check_9 |
---|
480 | checked = V_value |
---|
481 | if(checked) |
---|
482 | //build the list |
---|
483 | //just read the global |
---|
484 | SVAR str=root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
485 | w[4] = str |
---|
486 | else |
---|
487 | //none used - set textwave (and global?) |
---|
488 | w[4] = "none" |
---|
489 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "none" |
---|
490 | endif |
---|
491 | |
---|
492 | //w[5] = averaging choices |
---|
493 | ControlInfo/W=V_ProtocolPanel prot_check_5 //do the average? |
---|
494 | checked = V_value |
---|
495 | if(checked) |
---|
496 | //just read the global |
---|
497 | SVAR avestr=root:Packages:NIST:VSANS:Globals:Protocols:gAVE |
---|
498 | w[5] = avestr |
---|
499 | else |
---|
500 | //none used - set textwave |
---|
501 | w[5] = "AVTYPE=none;" |
---|
502 | endif |
---|
503 | |
---|
504 | //w[6] |
---|
505 | //work.DRK information |
---|
506 | SVAR drkStr=root:Packages:NIST:VSANS:Globals:Protocols:gDRK |
---|
507 | w[6] = drkStr |
---|
508 | |
---|
509 | //w[7] |
---|
510 | // beginning trim points |
---|
511 | SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
512 | w[7] = gBegPtsStr |
---|
513 | |
---|
514 | //w[8] |
---|
515 | // End trim points |
---|
516 | SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
517 | w[8] = gEndPtsStr |
---|
518 | |
---|
519 | //w[9] |
---|
520 | //currently unused |
---|
521 | w[9] = "" |
---|
522 | //w[10] |
---|
523 | //currently unused |
---|
524 | w[10] = "" |
---|
525 | //w[11] |
---|
526 | //currently unused |
---|
527 | w[11] = "" |
---|
528 | |
---|
529 | return(0) |
---|
530 | End |
---|
531 | |
---|
532 | |
---|
533 | // |
---|
534 | Function V_PickSAMButton(ctrlName) : ButtonControl |
---|
535 | String ctrlName |
---|
536 | |
---|
537 | |
---|
538 | End |
---|
539 | |
---|
540 | |
---|
541 | |
---|
542 | |
---|
543 | // |
---|
544 | // TODO |
---|
545 | // -- identifying "intent" using V_get can be very slow, since it reads in each and every data file. |
---|
546 | // grep is a lot faster, but there can be a lot of false "hits" unless I do it correctly. |
---|
547 | // |
---|
548 | // |
---|
549 | // //grep through what text I can find in the VAX binary |
---|
550 | // // Grep Note: the \\b sequences limit matches to a word boundary before and after |
---|
551 | // // "boondoggle", so "boondoggles" and "aboondoggle" won't match. |
---|
552 | // if(gRadioVal == 2) |
---|
553 | // for(ii=0;ii<num;ii+=1) |
---|
554 | // item=StringFromList(ii, newList , ";") |
---|
555 | //// Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
556 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
557 | // if( V_value ) // at least one instance was found |
---|
558 | //// Print "found ", item,ii |
---|
559 | // list += item + ";" |
---|
560 | // endif |
---|
561 | // endfor |
---|
562 | // |
---|
563 | // newList = list |
---|
564 | // endif |
---|
565 | |
---|
566 | // match is the string to look for in the search |
---|
567 | // 0 is a flag to tell it to look in the file catalog (the fastest method) |
---|
568 | // Other options are to grep, or to read the intent field in every file |
---|
569 | Function/S V_GetSAMList() |
---|
570 | |
---|
571 | // String match="SAMPLE" |
---|
572 | // String list = V_getFileIntentList(match,0) |
---|
573 | |
---|
574 | String intent = "SAMPLE" |
---|
575 | String purpose = "SCATTERING" |
---|
576 | String list = V_getFileIntentPurposeList(intent,purpose,0) |
---|
577 | |
---|
578 | // Printf "SAM files = %s\r",list |
---|
579 | return(list) |
---|
580 | end |
---|
581 | |
---|
582 | |
---|
583 | Function/S V_GetBGDList() |
---|
584 | |
---|
585 | String intent="BLOCKED BEAM" |
---|
586 | String purpose="SCATTERING" |
---|
587 | // String list = V_getFileIntentList(match,0) |
---|
588 | String list = V_getFileIntentPurposeList(intent,purpose,0) |
---|
589 | |
---|
590 | // Printf "BGD files = %s\r",list |
---|
591 | return(list) |
---|
592 | end |
---|
593 | |
---|
594 | // |
---|
595 | // V_getFileIntentPurposeList(intent,purpose,method) |
---|
596 | Function/S V_GetEMPList() |
---|
597 | |
---|
598 | String intent="EMPTY CELL" |
---|
599 | String purpose="SCATTERING" |
---|
600 | // String list = V_getFileIntentList(match,0) |
---|
601 | String list = V_getFileIntentPurposeList(intent,purpose,0) |
---|
602 | |
---|
603 | |
---|
604 | // Printf "EMP files = %s\r",list |
---|
605 | return(list) |
---|
606 | end |
---|
607 | |
---|
608 | |
---|
609 | // |
---|
610 | // TODO |
---|
611 | // -- decide on the way to locate the blocked beam files. Is the enumerated text of the intent |
---|
612 | // sufficiently unique to locate the file? |
---|
613 | // -- can I use the Data Catalog waves to locate the files - faster? |
---|
614 | // (fails if the catalog has not been read in recently enough) |
---|
615 | // |
---|
616 | // |
---|
617 | Function/S V_PickBGDButton(ctrlName) : ButtonControl |
---|
618 | String ctrlName |
---|
619 | |
---|
620 | String list="",item="",fname,newList,intent |
---|
621 | Variable ii,num |
---|
622 | |
---|
623 | PathInfo catPathName |
---|
624 | String path = S_path |
---|
625 | |
---|
626 | String match="BLOCKED BEAM" |
---|
627 | |
---|
628 | //v_tic() |
---|
629 | // get the list from the file catalog (=0.0007s) |
---|
630 | // |
---|
631 | WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
632 | WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
633 | |
---|
634 | Variable np = numpnts(intentW) |
---|
635 | for(ii=0;ii<np;ii+=1) |
---|
636 | if(cmpstr(intentW[ii],match)==0) |
---|
637 | list += fileNameW[ii] + ";" |
---|
638 | endif |
---|
639 | endfor |
---|
640 | |
---|
641 | List = SortList(List,";",0) |
---|
642 | Printf "BGD files = %s\r",list |
---|
643 | //v_toc() |
---|
644 | |
---|
645 | |
---|
646 | ////v_tic() // from grep = 3.3s |
---|
647 | // newList = V_GetRawDataFileList() |
---|
648 | // num=ItemsInList(newList) |
---|
649 | // |
---|
650 | //// for(ii=0;ii<num;ii+=1) |
---|
651 | //// item=StringFromList(ii, newList , ";") |
---|
652 | //// fname = path + item |
---|
653 | //// intent = V_getReduction_intent(fname) |
---|
654 | //// if(cmpstr(intent,"BLOCKED BEAM") == 0) |
---|
655 | //// list += item + ";" |
---|
656 | //// endif |
---|
657 | //// |
---|
658 | //// endfor |
---|
659 | // list = "" |
---|
660 | // for(ii=0;ii<num;ii+=1) |
---|
661 | // item=StringFromList(ii, newList , ";") |
---|
662 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
663 | // if( V_value ) // at least one instance was found |
---|
664 | //// Print "found ", item,ii |
---|
665 | // list += item + ";" |
---|
666 | // endif |
---|
667 | // endfor |
---|
668 | // |
---|
669 | // |
---|
670 | // List = SortList(List,";",0) |
---|
671 | // Printf "BGD files = %s\r",list |
---|
672 | ////v_toc() |
---|
673 | |
---|
674 | return(list) |
---|
675 | End |
---|
676 | |
---|
677 | |
---|
678 | // |
---|
679 | Function/S V_PickEMPButton(ctrlName) : ButtonControl |
---|
680 | String ctrlName |
---|
681 | String list="",item="",fname,newList,intent |
---|
682 | Variable ii,num |
---|
683 | |
---|
684 | PathInfo catPathName |
---|
685 | String path = S_path |
---|
686 | |
---|
687 | String match="EMPTY CELL" |
---|
688 | |
---|
689 | // get the list from the file catalog (=0.0007s) |
---|
690 | // |
---|
691 | WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
692 | WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
693 | |
---|
694 | Variable np = numpnts(intentW) |
---|
695 | for(ii=0;ii<np;ii+=1) |
---|
696 | if(cmpstr(intentW[ii],match)==0) |
---|
697 | list += fileNameW[ii] + ";" |
---|
698 | endif |
---|
699 | endfor |
---|
700 | |
---|
701 | List = SortList(List,";",0) |
---|
702 | Printf "EMP files = %s\r",list |
---|
703 | |
---|
704 | |
---|
705 | // |
---|
706 | // newList = V_GetRawDataFileList() |
---|
707 | // num=ItemsInList(newList) |
---|
708 | // |
---|
709 | //// for(ii=0;ii<num;ii+=1) |
---|
710 | //// item=StringFromList(ii, newList , ";") |
---|
711 | //// fname = path + item |
---|
712 | //// intent = V_getReduction_intent(fname) |
---|
713 | //// if(cmpstr(intent,"EMPTY CELL") == 0) |
---|
714 | //// list += item + ";" |
---|
715 | //// endif |
---|
716 | //// |
---|
717 | //// endfor |
---|
718 | // |
---|
719 | // for(ii=0;ii<num;ii+=1) |
---|
720 | // item=StringFromList(ii, newList , ";") |
---|
721 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
722 | // if( V_value ) // at least one instance was found |
---|
723 | //// Print "found ", item,ii |
---|
724 | // list += item + ";" |
---|
725 | // endif |
---|
726 | // |
---|
727 | // endfor |
---|
728 | // |
---|
729 | // List = SortList(List,";",0) |
---|
730 | // Printf "EMP files = %s\r",list |
---|
731 | |
---|
732 | return(list) |
---|
733 | End |
---|
734 | |
---|
735 | |
---|
736 | // |
---|
737 | Function/S V_PickEMPBeamButton(ctrlName) : ButtonControl |
---|
738 | String ctrlName |
---|
739 | String list="",item="",fname,newList,intent |
---|
740 | Variable ii,num |
---|
741 | |
---|
742 | PathInfo catPathName |
---|
743 | String path = S_path |
---|
744 | |
---|
745 | String match="OPEN BEAM" |
---|
746 | |
---|
747 | // get the list from the file catalog (=0.0007s) |
---|
748 | // |
---|
749 | WAVE/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
750 | WAVE/T intentW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
751 | |
---|
752 | Variable np = numpnts(intentW) |
---|
753 | for(ii=0;ii<np;ii+=1) |
---|
754 | if(cmpstr(intentW[ii],match)==0) |
---|
755 | list += fileNameW[ii] + ";" |
---|
756 | endif |
---|
757 | endfor |
---|
758 | |
---|
759 | List = SortList(List,";",0) |
---|
760 | Printf "EMP Beam files = %s\r",list |
---|
761 | |
---|
762 | |
---|
763 | |
---|
764 | return(list) |
---|
765 | End |
---|
766 | |
---|
767 | |
---|
768 | // TODO |
---|
769 | // -- find proper way to search for these files |
---|
770 | // -- they *may* be written to the file header(reduction block) |
---|
771 | // -- or grep for VSANS_DIV (in the title) |
---|
772 | Function/S V_GetDIVList() |
---|
773 | |
---|
774 | String list="",item="",fname,newList,intent |
---|
775 | Variable ii,num |
---|
776 | |
---|
777 | PathInfo catPathName |
---|
778 | String path = S_path |
---|
779 | |
---|
780 | newList = V_Get_NotRawDataFileList() |
---|
781 | newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files |
---|
782 | newList = V_RemoveEXTFromList(newlist,"ave") // remove the ave files |
---|
783 | newList = V_RemoveEXTFromList(newlist,"abs") // remove the abs files |
---|
784 | newList = V_RemoveEXTFromList(newlist,"pxp") // remove the pxp files |
---|
785 | newList = V_RemoveEXTFromList(newlist,"DS_Store") // remove the DS_Store file (OSX only) |
---|
786 | |
---|
787 | num=ItemsInList(newList) |
---|
788 | |
---|
789 | // for(ii=0;ii<num;ii+=1) |
---|
790 | // item=StringFromList(ii, newList , ";") |
---|
791 | // fname = path + item |
---|
792 | // intent = V_getReduction_intent(fname) |
---|
793 | // if(cmpstr(intent,"SENSITIVITY") == 0) |
---|
794 | // list += item + ";" |
---|
795 | // endif |
---|
796 | // |
---|
797 | // endfor |
---|
798 | |
---|
799 | String match="DIV" |
---|
800 | for(ii=0;ii<num;ii+=1) |
---|
801 | item=StringFromList(ii, newList , ";") |
---|
802 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
803 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
804 | if( V_value ) // at least one instance was found |
---|
805 | // Print "found ", item,ii |
---|
806 | // if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) |
---|
807 | list += item + ";" |
---|
808 | // endif |
---|
809 | endif |
---|
810 | endfor |
---|
811 | |
---|
812 | List = SortList(List,";",0) |
---|
813 | |
---|
814 | return(list) |
---|
815 | end |
---|
816 | |
---|
817 | |
---|
818 | Function/S V_GetMSKList() |
---|
819 | |
---|
820 | String list="",item="",fname,newList,intent |
---|
821 | Variable ii,num |
---|
822 | |
---|
823 | PathInfo catPathName |
---|
824 | String path = S_path |
---|
825 | |
---|
826 | newList = V_Get_NotRawDataFileList() |
---|
827 | newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files |
---|
828 | newList = V_RemoveEXTFromList(newlist,"ave") // remove the ave files |
---|
829 | newList = V_RemoveEXTFromList(newlist,"abs") // remove the abs files |
---|
830 | newList = V_RemoveEXTFromList(newlist,"pxp") // remove the pxp files |
---|
831 | newList = V_RemoveEXTFromList(newlist,"DS_Store") // remove the DS_Store file (OSX only) |
---|
832 | |
---|
833 | num=ItemsInList(newList) |
---|
834 | |
---|
835 | // for(ii=0;ii<num;ii+=1) |
---|
836 | // item=StringFromList(ii, newList , ";") |
---|
837 | // fname = path + item |
---|
838 | // intent = V_getReduction_intent(fname) |
---|
839 | // if(cmpstr(intent,"SENSITIVITY") == 0) |
---|
840 | // list += item + ";" |
---|
841 | // endif |
---|
842 | // |
---|
843 | // endfor |
---|
844 | |
---|
845 | // String match="MASK" // this is part of the title of a VSANS MASK file |
---|
846 | String match="VSANS_MASK" // this is part of the title of a VSANS MASK file |
---|
847 | for(ii=0;ii<num;ii+=1) |
---|
848 | item=StringFromList(ii, newList , ";") |
---|
849 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
850 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
851 | if( V_value ) // at least one instance was found |
---|
852 | // Print "found ", item,ii |
---|
853 | // if(strsearch(item,"pxp",0,2) == -1) //does NOT contain .pxp (the current experiment will be a match) |
---|
854 | list += item + ";" |
---|
855 | // endif |
---|
856 | endif |
---|
857 | |
---|
858 | endfor |
---|
859 | |
---|
860 | List = SortList(List,";",0) |
---|
861 | |
---|
862 | return(list) |
---|
863 | end |
---|
864 | |
---|
865 | |
---|
866 | // |
---|
867 | // TODO |
---|
868 | // -- find proper way to search for these files |
---|
869 | // -- they *may* be written to the file header(reduction block) |
---|
870 | // -- or grep for VSANS_MASK (in the title) |
---|
871 | Function/S V_PickMASKButton(ctrlName) : ButtonControl |
---|
872 | String ctrlName |
---|
873 | String list="",item="",fname,newList,intent |
---|
874 | Variable ii,num |
---|
875 | |
---|
876 | PathInfo catPathName |
---|
877 | String path = S_path |
---|
878 | |
---|
879 | newList = V_Get_NotRawDataFileList() |
---|
880 | newList = V_RemoveEXTFromList(newlist,"hst") // remove the event files |
---|
881 | num=ItemsInList(newList) |
---|
882 | |
---|
883 | // for(ii=0;ii<num;ii+=1) |
---|
884 | // item=StringFromList(ii, newList , ";") |
---|
885 | // fname = path + item |
---|
886 | // intent = V_getReduction_intent(fname) |
---|
887 | // if(cmpstr(intent,"MASK") == 0) |
---|
888 | // list += item + ";" |
---|
889 | // endif |
---|
890 | // |
---|
891 | // endfor |
---|
892 | |
---|
893 | String match="MASK" |
---|
894 | for(ii=0;ii<num;ii+=1) |
---|
895 | item=StringFromList(ii, newList , ";") |
---|
896 | Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
897 | // Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
898 | if( V_value ) // at least one instance was found |
---|
899 | // Print "found ", item,ii |
---|
900 | list += item + ";" |
---|
901 | endif |
---|
902 | |
---|
903 | endfor |
---|
904 | |
---|
905 | List = SortList(List,";",0) |
---|
906 | Printf "MASK files = %s\r",list |
---|
907 | |
---|
908 | return(list) |
---|
909 | |
---|
910 | |
---|
911 | End |
---|
912 | |
---|
913 | //button action function to reduce one file with the information specified on |
---|
914 | //the panel |
---|
915 | //a temporary protocol is created, even if the fields correspond to a named protocol |
---|
916 | //(only the protocol wave values are written to the data header, but the name is written to the |
---|
917 | //schematic - this could cause some unwanted confusion) |
---|
918 | // |
---|
919 | //if a sample file(s) is selected, only that file(s) will be reduced |
---|
920 | //if no file is selected, the user will be prompted with a standard open |
---|
921 | //dialog to select sample data file(s) |
---|
922 | // |
---|
923 | Function V_ReduceOneButton(ctrlName) : ButtonControl |
---|
924 | String ctrlName |
---|
925 | |
---|
926 | //parse the information on the panel and assign to tempProtocol wave (in protocol folder) |
---|
927 | //and execute |
---|
928 | String temp="root:Packages:NIST:VSANS:Globals:Protocols:tempProtocol" |
---|
929 | Wave/T w=$temp |
---|
930 | Variable ii=0,num=12 |
---|
931 | do |
---|
932 | w[ii] = "" |
---|
933 | ii+=1 |
---|
934 | while(ii<num) |
---|
935 | |
---|
936 | V_MakeProtocolFromPanel(w) |
---|
937 | |
---|
938 | //the "current" protocol is the "tempProtocol" that was parsed from the panel input |
---|
939 | //set the global, so that the data writing routine can find the protocol wave (fatal otherwise) |
---|
940 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr="tempProtocol" |
---|
941 | |
---|
942 | PathInfo catPathName //this is where the files came from |
---|
943 | String pathstr=S_path,samStr |
---|
944 | |
---|
945 | //take the string from the panel |
---|
946 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gSAM |
---|
947 | |
---|
948 | if( (strlen(tempStr) == 0) || (cmpstr(tempStr,"ask")==0) ) |
---|
949 | //let user select the files |
---|
950 | tempStr="ask" |
---|
951 | V_ExecuteProtocol(temp,tempStr) |
---|
952 | return(0) |
---|
953 | Else |
---|
954 | //parse the list of numbers |
---|
955 | //send only the filenames, without paths |
---|
956 | samStr = V_ParseRunNumberList(tempStr) |
---|
957 | If(strlen(samStr)==0) |
---|
958 | DoAlert 0,"The SAM file number cound not be interpreted. Please enter a valid run number or filename" |
---|
959 | return(1) |
---|
960 | endif |
---|
961 | tempStr=samStr //reset the global |
---|
962 | V_ExecuteProtocol(temp,samStr) |
---|
963 | return(0) |
---|
964 | endif |
---|
965 | End |
---|
966 | |
---|
967 | |
---|
968 | //button action function will prompt user for absolute scaling parameters |
---|
969 | //either from an empty beam file or by manually entering the 4 required values |
---|
970 | //uses the same function and shared global string as the questionnare form of reduction |
---|
971 | //in "protocol.ipf" - the string is root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
972 | // |
---|
973 | Function V_SetABSParamsButton(ctrlName) : ButtonControl |
---|
974 | String ctrlName |
---|
975 | |
---|
976 | //will prompt for a list of ABS parameters (4) through a global string variable |
---|
977 | |
---|
978 | Execute "V_AskForAbsoluteParams_Quest()" |
---|
979 | |
---|
980 | End |
---|
981 | |
---|
982 | |
---|
983 | |
---|
984 | //the panel recreation macro |
---|
985 | // |
---|
986 | Window V_ProtocolPanel() |
---|
987 | PauseUpdate; Silent 1 // building window... |
---|
988 | NewPanel /W=(1280,332,1630,932) /K=1 as "VSANS Reduction Protocol" |
---|
989 | ModifyPanel cbRGB=(56589,50441,50159), fixedSize=1 |
---|
990 | SetDrawLayer UserBack |
---|
991 | DrawLine 3,65,301,65 |
---|
992 | DrawLine 3,157,301,157 |
---|
993 | DrawLine 3,208,301,208 |
---|
994 | DrawLine 3,257,301,257 |
---|
995 | DrawLine 3,305,301,305 |
---|
996 | DrawLine 3,350,301,350 |
---|
997 | DrawLine 3,445,301,445 |
---|
998 | DrawLine 3,513,301,513 |
---|
999 | DrawLine 3,396,301,396 |
---|
1000 | |
---|
1001 | // |
---|
1002 | Button button_help,pos={300,2},size={25,20},proc=V_ShowProtoHelp,title="?" |
---|
1003 | Button button_help,help={"Show the help file for setting up a reduction protocol"} |
---|
1004 | Button button_quest,pos={20,2},size={150,20},proc=V_ProtocolQuestionnaire,title="Questions" |
---|
1005 | Button button_quest,help={"Run through the questionnaire for setting up a reduction protocol"} |
---|
1006 | Button button_quest,disable=2 |
---|
1007 | |
---|
1008 | |
---|
1009 | PopupMenu popup_sam,pos={85,68},size={51,23},proc=SAMFilePopMenuProc |
---|
1010 | PopupMenu popup_sam,mode=1,value= #"V_getSAMList()" |
---|
1011 | PopupMenu popup_bkg,pos={85,164},size={51,23},proc=BKGFilePopMenuProc |
---|
1012 | PopupMenu popup_bkg,mode=1,value= #"V_getBGDList()" |
---|
1013 | PopupMenu popup_emp,pos={85,213},size={51,23},proc=EMPFilePopMenuProc |
---|
1014 | PopupMenu popup_emp,mode=1,value= #"V_getEMPList()" |
---|
1015 | PopupMenu popup_div,pos={85,263},size={51,23},proc=DIVFilePopMenuProc |
---|
1016 | PopupMenu popup_div,mode=1,value= #"V_getDIVList()" |
---|
1017 | PopupMenu popup_msk,pos={85,356},size={51,23},proc=MSKFilePopMenuProc |
---|
1018 | PopupMenu popup_msk,mode=1,value= #"V_getMSKList()" |
---|
1019 | |
---|
1020 | |
---|
1021 | CheckBox prot_check,pos={6,163},size={74,14},title="Background" |
---|
1022 | CheckBox prot_check,help={"If checked, the specified background file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
1023 | CheckBox prot_check,value= 1 |
---|
1024 | CheckBox prot_check_1,pos={6,215},size={71,14},title="Empty Cell" |
---|
1025 | CheckBox prot_check_1,help={"If checked, the specified empty cell file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
1026 | CheckBox prot_check_1,value= 1 |
---|
1027 | CheckBox prot_check_2,pos={6,263},size={72,14},title="Sensitivity" |
---|
1028 | CheckBox prot_check_2,help={"If checked, the specified detector sensitivity file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
1029 | CheckBox prot_check_2,value= 1 |
---|
1030 | CheckBox prot_check_3,pos={6,356},size={43,14},title="Mask" |
---|
1031 | CheckBox prot_check_3,help={"If checked, the specified mask file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
1032 | CheckBox prot_check_3,value= 1 |
---|
1033 | CheckBox prot_check_4,pos={6,70},size={53,14},title="Sample" |
---|
1034 | CheckBox prot_check_4,help={"If checked, the specified sample file will be included in the data reduction. If the file name is \"ask\", then the user will be prompted for the file"} |
---|
1035 | CheckBox prot_check_4,value= 1 |
---|
1036 | CheckBox prot_check_5,pos={6,399},size={56,14},title="Average" |
---|
1037 | CheckBox prot_check_5,help={"If checked, the specified averaging will be performed at the end of the data reduction."} |
---|
1038 | CheckBox prot_check_5,value= 1 |
---|
1039 | CheckBox prot_check_9,pos={6,310},size={59,14},title="Absolute" |
---|
1040 | CheckBox prot_check_9,help={"If checked, absolute calibration will be included in the data reduction. If the parameter list is \"ask\", then the user will be prompted for absolue parameters"} |
---|
1041 | CheckBox prot_check_9,value= 1 |
---|
1042 | |
---|
1043 | |
---|
1044 | // Button pick_sam,pos={214,28},size={70,20},proc=V_PickSAMButton,title="set SAM" |
---|
1045 | // Button pick_sam,help={"This button will set the file selected in the File Catalog table to be the sample file"} |
---|
1046 | // Button pick_bgd,pos={214,75},size={70,20},proc=V_PickBGDButton,title="set BGD" |
---|
1047 | // Button pick_bgd,help={"This button will set the file selected in the File Catalog table to be the background file."} |
---|
1048 | // Button pick_emp,pos={214,125},size={70,20},proc=V_PickEMPButton,title="set EMP" |
---|
1049 | // Button pick_emp,help={"This button will set the file selected in the File Catalog table to be the empty cell file."} |
---|
1050 | // Button pick_DIV,pos={214,173},size={70,20},proc=V_PickDIVButton,title="set DIV" |
---|
1051 | // Button pick_DIV,help={"This button will set the file selected in the File Catalog table to be the sensitivity file."} |
---|
1052 | Button pick_ABS,pos={264,308},size={70,20},proc=V_SetABSParamsButton,title="set ABS" |
---|
1053 | Button pick_ABS,help={"This button will prompt the user for absolute scaling parameters"} |
---|
1054 | // Button pick_MASK,pos={214,266},size={70,20},proc=V_PickMASKButton,title="set MASK" |
---|
1055 | // Button pick_MASK,help={"This button will set the file selected in the File Catalog table to be the mask file."} |
---|
1056 | |
---|
1057 | |
---|
1058 | Button pick_AVE,pos={188,401},size={150,20},proc=V_SetAverageParamsButtonProc,title="set AVERAGE params" |
---|
1059 | Button pick_AVE,help={"Prompts the user for the type of 1-D averaging to perform, as well as saving options"} |
---|
1060 | |
---|
1061 | |
---|
1062 | Button pick_trim,pos={264,454},size={70,20},proc=V_TrimDataProtoButton,title="Trim" |
---|
1063 | Button pick_trim,help={"This button will prompt the user for trimming parameters"} |
---|
1064 | |
---|
1065 | |
---|
1066 | SetVariable samStr,pos={6,90},size={250,15},title="file:" |
---|
1067 | SetVariable samStr,help={"Filename of the sample file(s) to be used in the data reduction"} |
---|
1068 | SetVariable samStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gSAM |
---|
1069 | SetVariable bgdStr,pos={7,186},size={250,15},title="file:" |
---|
1070 | SetVariable bgdStr,help={"Filename of the background file(s) to be used in the data reduction"} |
---|
1071 | SetVariable bgdStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gBGD |
---|
1072 | SetVariable empStr,pos={8,236},size={250,15},title="file:" |
---|
1073 | SetVariable empStr,help={"Filename of the empty cell file(s) to be used in the data reduction"} |
---|
1074 | SetVariable empStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gEMP |
---|
1075 | SetVariable divStr,pos={9,285},size={250,15},title="file:" |
---|
1076 | SetVariable divStr,help={"Filename of the detector sensitivity file to be used in the data reduction"} |
---|
1077 | SetVariable divStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gDIV |
---|
1078 | SetVariable maskStr,pos={9,377},size={250,15},title="file:" |
---|
1079 | SetVariable maskStr,help={"Filename of the mask file to be used in the data reduction"} |
---|
1080 | SetVariable maskStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gMASK |
---|
1081 | SetVariable absStr,pos={7,331},size={250,15},title="parameters:" |
---|
1082 | SetVariable absStr,help={"Keyword-string of values necessary for absolute scaling of data. Remaining parameters are taken from the sample file."} |
---|
1083 | SetVariable absStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
1084 | SetVariable aveStr,pos={9,424},size={250,15},title="parameters:" |
---|
1085 | SetVariable aveStr,help={"Keyword-string of choices used for averaging and saving the 1-D data files"} |
---|
1086 | SetVariable aveStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gAVE |
---|
1087 | |
---|
1088 | SetVariable begStr,pos={9,464},size={250,15},title="Beg Trim:" |
---|
1089 | SetVariable begStr,help={"Keyword-string of choices used for averaging and saving the 1-D data files"} |
---|
1090 | SetVariable begStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
1091 | SetVariable endStr,pos={9,484},size={250,15},title="End Trim:" |
---|
1092 | SetVariable endStr,help={"Keyword-string of choices used for averaging and saving the 1-D data files"} |
---|
1093 | SetVariable endStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
1094 | |
---|
1095 | |
---|
1096 | |
---|
1097 | //only show DRK if user wants to see it |
---|
1098 | //if global = 1,then show => set disable = 0 |
---|
1099 | // CheckBox prot_check_6,pos={6,363},size={113,14},proc=DrkCheckProc,title="Use DRK correction" |
---|
1100 | // CheckBox prot_check_6,help={"If checked, the selected file will be used for DRK correction. Typically this is NOT checked"} |
---|
1101 | // CheckBox prot_check_6,value= 0,disable = (!root:Packages:NIST:gAllowDRK) |
---|
1102 | // SetVariable drkStr,pos={120,363},size={150,15},title="." |
---|
1103 | // SetVariable drkStr,help={"DRK detector count file"},disable = (!root:Packages:NIST:gAllowDRK) |
---|
1104 | // SetVariable drkStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Protocols:gDRK |
---|
1105 | |
---|
1106 | |
---|
1107 | Button export_button, size={120,20},pos={125,540},title="Export to Data",proc=V_ExportFileProtocol |
---|
1108 | Button export_button, help={"Exports the protocol to data file on disk for Importing into another experiment"} |
---|
1109 | Button import_button, size={120,20},pos={125,562},title="Import from Data",proc=V_ImportFileProtocol |
---|
1110 | Button import_button,help={"Imports a protocol from a data file on disk for use in this experiment"} |
---|
1111 | Button recallProt,pos={7,540},size={107,20},proc=V_RecallProtocolButton,title="Recall Protocol" |
---|
1112 | Button recallProt,help={"Resets the panel to the file choices in a previously saved protocol"} |
---|
1113 | Button del_protocol,pos={7,562},size={110,20},proc=V_DeleteProtocolButton,title="Delete Protocol" |
---|
1114 | Button del_protocol,help={"Use this to delete a previously saved protocol."} |
---|
1115 | Button done_protocol,pos={285,562},size={45,20},proc=V_DoneProtocolButton,title="Done" |
---|
1116 | Button done_protocol,help={"This button will close the panel. The panel can be recalled at any time from the SANS menu."} |
---|
1117 | Button saveProtocol,pos={7,518},size={100,20},proc=V_SaveProtocolButton,title="Save Protocol" |
---|
1118 | Button saveProtocol,help={"Saves the cerrent selections in the panel to a protocol which can be later recalled"} |
---|
1119 | Button ReduceOne,pos={240,518},size={100,20},proc=V_ReduceOneButton,title="Reduce A File" |
---|
1120 | Button ReduceOne,help={"Using the panel selections, the specified sample file will be reduced. If none is specified, the user will be prompted for a sample file"} |
---|
1121 | |
---|
1122 | EndMacro |
---|
1123 | |
---|
1124 | |
---|
1125 | |
---|
1126 | |
---|
1127 | |
---|
1128 | Function SAMFilePopMenuProc(pa) : PopupMenuControl |
---|
1129 | STRUCT WMPopupAction &pa |
---|
1130 | |
---|
1131 | switch( pa.eventCode ) |
---|
1132 | case 2: // mouse up |
---|
1133 | Variable popNum = pa.popNum |
---|
1134 | String popStr = pa.popStr |
---|
1135 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gSAM |
---|
1136 | tempStr = popStr |
---|
1137 | break |
---|
1138 | case -1: // control being killed |
---|
1139 | break |
---|
1140 | endswitch |
---|
1141 | |
---|
1142 | return 0 |
---|
1143 | End |
---|
1144 | |
---|
1145 | |
---|
1146 | Function BKGFilePopMenuProc(pa) : PopupMenuControl |
---|
1147 | STRUCT WMPopupAction &pa |
---|
1148 | |
---|
1149 | switch( pa.eventCode ) |
---|
1150 | case 2: // mouse up |
---|
1151 | Variable popNum = pa.popNum |
---|
1152 | String popStr = pa.popStr |
---|
1153 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gBGD |
---|
1154 | tempStr = popStr |
---|
1155 | break |
---|
1156 | case -1: // control being killed |
---|
1157 | break |
---|
1158 | endswitch |
---|
1159 | |
---|
1160 | return 0 |
---|
1161 | End |
---|
1162 | |
---|
1163 | Function EMPFilePopMenuProc(pa) : PopupMenuControl |
---|
1164 | STRUCT WMPopupAction &pa |
---|
1165 | |
---|
1166 | switch( pa.eventCode ) |
---|
1167 | case 2: // mouse up |
---|
1168 | Variable popNum = pa.popNum |
---|
1169 | String popStr = pa.popStr |
---|
1170 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gEMP |
---|
1171 | tempStr = popStr |
---|
1172 | break |
---|
1173 | case -1: // control being killed |
---|
1174 | break |
---|
1175 | endswitch |
---|
1176 | |
---|
1177 | return 0 |
---|
1178 | End |
---|
1179 | |
---|
1180 | Function DIVFilePopMenuProc(pa) : PopupMenuControl |
---|
1181 | STRUCT WMPopupAction &pa |
---|
1182 | |
---|
1183 | switch( pa.eventCode ) |
---|
1184 | case 2: // mouse up |
---|
1185 | Variable popNum = pa.popNum |
---|
1186 | String popStr = pa.popStr |
---|
1187 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gDIV |
---|
1188 | tempStr = popStr |
---|
1189 | break |
---|
1190 | case -1: // control being killed |
---|
1191 | break |
---|
1192 | endswitch |
---|
1193 | |
---|
1194 | return 0 |
---|
1195 | End |
---|
1196 | |
---|
1197 | Function MSKFilePopMenuProc(pa) : PopupMenuControl |
---|
1198 | STRUCT WMPopupAction &pa |
---|
1199 | |
---|
1200 | switch( pa.eventCode ) |
---|
1201 | case 2: // mouse up |
---|
1202 | Variable popNum = pa.popNum |
---|
1203 | String popStr = pa.popStr |
---|
1204 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gMASK |
---|
1205 | tempStr = popStr |
---|
1206 | break |
---|
1207 | case -1: // control being killed |
---|
1208 | break |
---|
1209 | endswitch |
---|
1210 | |
---|
1211 | return 0 |
---|
1212 | End |
---|
1213 | |
---|
1214 | ////activated when user checks/unchecks the box |
---|
1215 | ////either prompts for a file using a standard dialog, or removes the current file |
---|
1216 | //Function V_DrkCheckProc(ctrlName,checked) : CheckBoxControl |
---|
1217 | // String ctrlName |
---|
1218 | // Variable checked //Desired state, not previous state |
---|
1219 | // |
---|
1220 | // SVAR drkStr=root:Packages:NIST:VSANS:Globals:Protocols:gDRK |
---|
1221 | // if(checked==1) |
---|
1222 | // //print "Unchecked on call" |
---|
1223 | // //this just asks for the filename, doesn't open the file |
---|
1224 | // String msgStr="Select the DRK file",fullPath="",fileStr="" |
---|
1225 | // Variable refnum |
---|
1226 | // |
---|
1227 | // Open/D/R/T="????"/M=(msgStr)/P=catPathName refNum |
---|
1228 | // fullPath = S_FileName //fname is the full path |
---|
1229 | // if(cmpstr(fullpath,"")==0) |
---|
1230 | // //user cancelled |
---|
1231 | // CheckBox prot_check_6,value=0 //keep box unchecked |
---|
1232 | // return(0) |
---|
1233 | // Endif |
---|
1234 | // fileStr=V_GetFileNameFromPathNoSemi(fullPath) |
---|
1235 | // //Print fileStr |
---|
1236 | // //update the global string |
---|
1237 | // drkStr = ReplaceStringByKey("DRK",drkStr,fileStr,"=",",") |
---|
1238 | // drkStr = ReplaceNumberByKey("DRKMODE", drkStr, 10 ,"=",",") |
---|
1239 | // else |
---|
1240 | // //print "checked on call" |
---|
1241 | // drkStr="DRK=none,DRKMODE=0," //change the global |
---|
1242 | // endif |
---|
1243 | // |
---|
1244 | //End |
---|
1245 | |
---|
1246 | |
---|
1247 | Function V_ShowProtoHelp(ctrlName) : ButtonControl |
---|
1248 | String ctrlName |
---|
1249 | DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[VSANS Reduction Protocol]" |
---|
1250 | if(V_flag !=0) |
---|
1251 | DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found" |
---|
1252 | endif |
---|
1253 | End |
---|
1254 | |
---|
1255 | //button action procedure to get the type of average requested by the user |
---|
1256 | //presented as a missing parameter dialog, which is really user-UN-friendly |
---|
1257 | //and will need to be re-thought. Defaults of dialog are set for normal |
---|
1258 | //circular average, so typically click "continue" and proceed |
---|
1259 | // |
---|
1260 | Function V_SetAverageParamsButtonProc(ctrlName) : ButtonControl |
---|
1261 | String ctrlName |
---|
1262 | |
---|
1263 | // Execute "V_GetAvgInfo_Full()" |
---|
1264 | Execute "V_GetAvgInfo()" |
---|
1265 | |
---|
1266 | //set the global string |
---|
1267 | SVAR tempStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr |
---|
1268 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAVE = tempStr |
---|
1269 | |
---|
1270 | End |
---|
1271 | |
---|
1272 | // TODO |
---|
1273 | // -- this is a trimmed down version of the "full" set of averaging options |
---|
1274 | // add to this as needed as I figure out what functionality is appropriate |
---|
1275 | // |
---|
1276 | //procedure called by protocol panel to ask user for average type choices |
---|
1277 | // somewhat confusing and complex, but may be as good as it gets. |
---|
1278 | // |
---|
1279 | //Proc V_GetAvgInfo(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) |
---|
1280 | Proc V_GetAvgInfo(av_typ,autoSave,autoName,binType,qCtr,qDelta,detGroup) |
---|
1281 | String av_typ,autoSave,AutoName,binType |
---|
1282 | // Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 |
---|
1283 | Variable Qctr=0.1,qDelta=0.01 |
---|
1284 | String detGroup="F" |
---|
1285 | |
---|
1286 | // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" |
---|
1287 | Prompt av_typ, "Type of Average",popup,"Circular;Annular;" |
---|
1288 | |
---|
1289 | // comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) |
---|
1290 | // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" |
---|
1291 | Prompt autoSave,"Save files to disk?",popup,"Yes - Concatenate;Yes - Individual;No" |
---|
1292 | Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" |
---|
1293 | // Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" |
---|
1294 | // Prompt side,"Include detector halves?",popup,"both;right;left" |
---|
1295 | // Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" |
---|
1296 | // Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" |
---|
1297 | // Prompt width, "Width of Rectangular average (1,128)" |
---|
1298 | Prompt binType,"Binning Type?",popup,ksBinTypeStr |
---|
1299 | |
---|
1300 | Prompt Qctr, "q-value of center of annulus" |
---|
1301 | Prompt Qdelta,"(+/-) q-width of annulus" |
---|
1302 | Prompt detGroup,"Group for annulus" |
---|
1303 | |
---|
1304 | //assign results of dialog to key=value string, semicolon separated |
---|
1305 | //do only what is necessary, based on av_typ |
---|
1306 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" |
---|
1307 | |
---|
1308 | // TODO: |
---|
1309 | // hard wired value |
---|
1310 | String autoPlot = "No" |
---|
1311 | |
---|
1312 | |
---|
1313 | // all averages need these values |
---|
1314 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" |
---|
1315 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" |
---|
1316 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" |
---|
1317 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" |
---|
1318 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "BINTYPE=" + binType + ";" |
---|
1319 | |
---|
1320 | // if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) |
---|
1321 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
1322 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
1323 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" |
---|
1324 | // Endif |
---|
1325 | // |
---|
1326 | // if(cmpstr(av_typ,"Rectangular")==0) |
---|
1327 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
1328 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
1329 | // root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" |
---|
1330 | // Endif |
---|
1331 | // |
---|
1332 | if(cmpstr(av_typ,"Annular")==0) |
---|
1333 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" |
---|
1334 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" |
---|
1335 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DETGROUP=" + detGroup + ";" |
---|
1336 | Endif |
---|
1337 | End |
---|
1338 | |
---|
1339 | |
---|
1340 | // TODO |
---|
1341 | // -- this is the original(SANS) version, and needs to be updated for VSANS as the averaging options are |
---|
1342 | // worked out |
---|
1343 | // -- there have been changes made to V_GetAvgInfo() above -- so work from that version, NOT this one. |
---|
1344 | // |
---|
1345 | // |
---|
1346 | //procedure called by protocol panel to ask user for average type choices |
---|
1347 | // somewhat confusing and complex, but may be as good as it gets. |
---|
1348 | // |
---|
1349 | Proc V_GetAvgInfo_Full(av_typ,autoSave,autoName,autoPlot,side,phi,dphi,width,QCtr,QDelta) |
---|
1350 | String av_typ,autoSave,AutoName,autoPlot,side |
---|
1351 | Variable phi=0,dphi=10,width=10,Qctr = 0.01,qDelta=10 |
---|
1352 | Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII;PNG_Graphic;Sector_PlusMinus;" |
---|
1353 | // comment out above line in DEMO_MODIFIED version, and uncomment the line below (to disable PNG save) |
---|
1354 | // Prompt av_typ, "Type of Average",popup,"Circular;Sector;Rectangular;Annular;2D_ASCII;QxQy_ASCII" |
---|
1355 | Prompt autoSave,"Save files to disk?",popup,"Yes;No" |
---|
1356 | Prompt autoName,"Auto-Name files?",popup,"Auto;Manual" |
---|
1357 | Prompt autoPlot,"Plot the averaged Data?",popup,"Yes;No" |
---|
1358 | Prompt side,"Include detector halves?",popup,"both;right;left" |
---|
1359 | Prompt phi,"Orientation Angle (-90,90) degrees (Rectangular or Sector)" |
---|
1360 | Prompt dphi, "Azimuthal range (0,45) degrees (Sector only)" |
---|
1361 | Prompt width, "Width of Rectangular average (1,128)" |
---|
1362 | Prompt Qctr, "q-value of center of annulus" |
---|
1363 | Prompt Qdelta,"Pixel width of annulus" |
---|
1364 | |
---|
1365 | //assign results of dialog to key=value string, semicolon separated |
---|
1366 | //do only what is necessary, based on av_typ |
---|
1367 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr="" |
---|
1368 | |
---|
1369 | // all averages need these four values |
---|
1370 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "AVTYPE=" + av_typ + ";" |
---|
1371 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SAVE=" + autoSave + ";" |
---|
1372 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "NAME=" + autoName + ";" |
---|
1373 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PLOT=" + autoPlot + ";" |
---|
1374 | |
---|
1375 | if(cmpstr(av_typ,"Sector")==0 || cmpstr(av_typ,"Sector_PlusMinus")==0) |
---|
1376 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
1377 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
1378 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "DPHI=" + num2str(dphi) + ";" |
---|
1379 | Endif |
---|
1380 | |
---|
1381 | if(cmpstr(av_typ,"Rectangular")==0) |
---|
1382 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "SIDE=" + side + ";" |
---|
1383 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "PHI=" + num2str(phi) + ";" |
---|
1384 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "WIDTH=" + num2str(width) + ";" |
---|
1385 | Endif |
---|
1386 | |
---|
1387 | if(cmpstr(av_typ,"Annular")==0) |
---|
1388 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QCENTER=" + num2str(QCtr) + ";" |
---|
1389 | root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr += "QDELTA=" + num2str(QDelta) + ";" |
---|
1390 | Endif |
---|
1391 | End |
---|
1392 | |
---|
1393 | |
---|
1394 | //prompts the user to pick a previously created protocol from a popup list |
---|
1395 | //of given the option to create a new protocol |
---|
1396 | //the chosen protocol is passed back to the calling procedure by a global string |
---|
1397 | //the popup is presented as a missing parameter dialog (called with empty parameter list) |
---|
1398 | // |
---|
1399 | // MAXROWS is present to exclude the PanelNameW from appearing as a protocol |
---|
1400 | Proc V_PickAProtocol(protocol) |
---|
1401 | String Protocol |
---|
1402 | Prompt Protocol "Pick A Protocol",popup, V_RecallableProtocols() |
---|
1403 | |
---|
1404 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = protocol |
---|
1405 | End |
---|
1406 | |
---|
1407 | Proc V_DeleteAProtocol(protocol) |
---|
1408 | String Protocol |
---|
1409 | // Prompt Protocol "Delete A Protocol",popup, WaveList("*",";","TEXT:1") |
---|
1410 | Prompt Protocol "Delete A Protocol",popup, V_DeletableProtocols() |
---|
1411 | |
---|
1412 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = protocol |
---|
1413 | End |
---|
1414 | |
---|
1415 | Function/S V_DeletableProtocols() |
---|
1416 | String list=WaveList("*",";","TEXT:1,MAXROWS:13") |
---|
1417 | |
---|
1418 | list= RemoveFromList("Base", list , ";") |
---|
1419 | list= RemoveFromList("DoAll", list , ";") |
---|
1420 | list= RemoveFromList("CreateNew", list , ";") |
---|
1421 | list= RemoveFromList("tempProtocol", list , ";") |
---|
1422 | list= RemoveFromList("wTTmpWrite", list , ";") |
---|
1423 | if(cmpstr(list,"")==0) |
---|
1424 | list = "_no_protocols_;" |
---|
1425 | endif |
---|
1426 | |
---|
1427 | return(list) |
---|
1428 | End |
---|
1429 | |
---|
1430 | Function/S V_RecallableProtocols() |
---|
1431 | String list=WaveList("*",";","TEXT:1,MAXROWS:13") |
---|
1432 | |
---|
1433 | // list= RemoveFromList("Base", list , ";") |
---|
1434 | // list= RemoveFromList("DoAll", list , ";") |
---|
1435 | list= RemoveFromList("CreateNew", list , ";") |
---|
1436 | list= RemoveFromList("tempProtocol", list , ";") |
---|
1437 | list= RemoveFromList("wTTmpWrite", list , ";") |
---|
1438 | if(cmpstr(list,"")==0) |
---|
1439 | list = "_no_protocols_;" |
---|
1440 | endif |
---|
1441 | |
---|
1442 | return(list) |
---|
1443 | End |
---|
1444 | |
---|
1445 | |
---|
1446 | //missing parameter dialog to solicit user for a waveStr for the protocol |
---|
1447 | //about to be created |
---|
1448 | //name is passed back as a global string and calling procedure is responsible for |
---|
1449 | //checking for wave conflicts and valid names |
---|
1450 | // |
---|
1451 | Proc V_AskForName(protocol) |
---|
1452 | String Protocol |
---|
1453 | Prompt Protocol "Enter a new name for your protocol (no extension)" |
---|
1454 | |
---|
1455 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gNewStr = protocol |
---|
1456 | End |
---|
1457 | |
---|
1458 | //this is a lengthy procedure for sequentially polling the user about what data |
---|
1459 | //reduction steps they want to be performed during the protocol |
---|
1460 | //ensures that a valid protocol name was chosen, then fills out each "item" |
---|
1461 | //(6 total) needed for reduction |
---|
1462 | //it the user cancels at any point, the partial protocol will be deleted |
---|
1463 | // |
---|
1464 | Function V_ProtocolQuestionnaire(ctrlName) |
---|
1465 | String ctrlName |
---|
1466 | |
---|
1467 | String filename,cmd |
---|
1468 | Variable notDone,refnum |
---|
1469 | |
---|
1470 | //prompt for name of new protocol wave to save |
---|
1471 | do |
---|
1472 | Execute "V_AskForName()" |
---|
1473 | SVAR newProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gNewStr |
---|
1474 | |
---|
1475 | //make sure it's a valid IGOR name |
---|
1476 | newProtoStr = CleanupName(newProtoStr,0) //strict naming convention |
---|
1477 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gNewStr=newProtoStr //reassign, if changed |
---|
1478 | //Print "newProtoStr = ",newProtoStr |
---|
1479 | |
---|
1480 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
1481 | if(WaveExists( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtoStr) ) == 1) |
---|
1482 | //wave already exists |
---|
1483 | DoAlert 0,"that name is already in use. Please pick a new name" |
---|
1484 | notDone = 1 |
---|
1485 | else |
---|
1486 | //name is good |
---|
1487 | notDone = 0 |
---|
1488 | Endif |
---|
1489 | while(notDone) |
---|
1490 | |
---|
1491 | //Print "protocol questionnaire is "+newProtocol |
---|
1492 | |
---|
1493 | //make a new text wave (12 points) and fill it in, in response to questions |
---|
1494 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols //(redundant - full wave specs are used) |
---|
1495 | Make/O/T/N=(kNumProtocolSteps) $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtoStr) |
---|
1496 | Wave/T newProtocol = $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtoStr) |
---|
1497 | newProtocol = "" |
---|
1498 | |
---|
1499 | //ask the questions |
---|
1500 | ///// |
---|
1501 | //*****Multiple files in these lists are full paths/filenames which may or may not |
---|
1502 | //have semicolon version numbers in the filename. Therefore, construct the list with |
---|
1503 | //COMMAS as separators - to avoid messy parsing |
---|
1504 | /////// |
---|
1505 | |
---|
1506 | String fileFilters = "VSANS Data Files (*.ngv,*.h5):.ngv,.h5;" |
---|
1507 | // fileFilters += "HTML Files (*.htm,*.html):.htm,.html;" |
---|
1508 | fileFilters += "All Files:.*;" |
---|
1509 | ////////////////////////// |
---|
1510 | String drkStr="",fileStr="" |
---|
1511 | |
---|
1512 | |
---|
1513 | ////////////////////////// |
---|
1514 | // DoAlert 1,"Do you want to correct your data for DRK (beam off) counts?" |
---|
1515 | // if(V_flag == 1) //1=yes |
---|
1516 | // //prompt for DRK file, but don't actually open it (/D flag) |
---|
1517 | // Open/D/R/F=fileFilters/M="Select the DRK file"/P=catPathName refnum |
---|
1518 | // //check for cancel |
---|
1519 | // if(strlen(S_filename)==0) |
---|
1520 | // //user cancelled, abort |
---|
1521 | // KillWaves/Z newProtocol |
---|
1522 | // SetDataFolder root: |
---|
1523 | // Abort "Incomplete protocol has been deleted" |
---|
1524 | // Endif |
---|
1525 | // //assign filename (just the name) to [6] |
---|
1526 | // fileStr = V_GetFileNameFromPathNoSemi(S_filename) |
---|
1527 | // drkStr = "DRK=none,DRKMODE=0," |
---|
1528 | // drkStr = ReplaceStringByKey("DRK",drkStr,fileStr,"=",",") |
---|
1529 | // drkStr = ReplaceNumberByKey("DRKMODE", drkStr, 10 ,"=",",") |
---|
1530 | // newProtocol[6] = drkStr |
---|
1531 | // else |
---|
1532 | // //no Work.DRK desired |
---|
1533 | // newProtocol[6] = "DRK=none,DRKMODE=0," |
---|
1534 | // Endif |
---|
1535 | // |
---|
1536 | //////////// |
---|
1537 | |
---|
1538 | |
---|
1539 | // TODO: |
---|
1540 | // -- there is a lag in the V_pick() routine as it greps through all of the files. Several seconds even when there |
---|
1541 | // are 20-ish files. Pre-search for the strings? When to refresh them for new data? |
---|
1542 | ///////////////// |
---|
1543 | DoAlert 1,"Do you want to subtract background from your data?" |
---|
1544 | if(V_flag == 1) //1=yes |
---|
1545 | |
---|
1546 | Prompt filename,"BKG File",popup,V_PickBGDButton("") |
---|
1547 | DoPrompt "Select File",filename |
---|
1548 | if (V_Flag) |
---|
1549 | return 0 // user canceled |
---|
1550 | endif |
---|
1551 | // //assign filename to [0] |
---|
1552 | newProtocol[0] = V_GetFileNameFromPathNoSemi(fileName) |
---|
1553 | |
---|
1554 | |
---|
1555 | // OLD way, using an open file dialog |
---|
1556 | // and allowing for multiple files to be added together |
---|
1557 | // |
---|
1558 | // //prompt for background file, but don't actually open it (/D flag) |
---|
1559 | // Open/D/R/F=fileFilters/M="Select the Background data file"/P=catPathName refnum |
---|
1560 | // //check for cancel |
---|
1561 | // if(strlen(S_filename)==0) |
---|
1562 | // //user cancelled, abort |
---|
1563 | // KillWaves/Z newProtocol |
---|
1564 | // SetDataFolder root: |
---|
1565 | // Abort "Incomplete protocol has been deleted" |
---|
1566 | // Endif |
---|
1567 | // //assign filename (full path) to [0] |
---|
1568 | // newProtocol[0] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
1569 | |
---|
1570 | // notDone=1 |
---|
1571 | // do |
---|
1572 | // //prompt for additional background files |
---|
1573 | // DoAlert 1,"Do you want to add another background file?" |
---|
1574 | // if(V_flag == 1) //yes |
---|
1575 | // Open/D/R/F=fileFilters/M="Select another Background data file"/P=catPathName refnum |
---|
1576 | // //check for cancel |
---|
1577 | // if(strlen(S_filename)==0) |
---|
1578 | // //user cancelled, abort ********maybe just break out of the loop here |
---|
1579 | // KillWaves/Z newProtocol |
---|
1580 | // SetDataFolder root: |
---|
1581 | // Abort "Incomplete protocol has been deleted" |
---|
1582 | // Endif |
---|
1583 | // //assign filename (full path) to [0] |
---|
1584 | // newProtocol[0] += "," + V_GetFileNameFromPathNoSemi(S_filename) //***COMMA separated list |
---|
1585 | // notDone = 1 //keep going |
---|
1586 | // else |
---|
1587 | // notDone = 0 //no more to add |
---|
1588 | // Endif |
---|
1589 | // While(notDone) |
---|
1590 | ////// |
---|
1591 | |
---|
1592 | else //no background desired |
---|
1593 | newProtocol[0] = "none" |
---|
1594 | Endif |
---|
1595 | |
---|
1596 | |
---|
1597 | ////////////////////// |
---|
1598 | DoAlert 1,"Do you want to subtract empty cell scattering from your data?" |
---|
1599 | if(V_flag == 1) //1=yes |
---|
1600 | |
---|
1601 | Prompt filename,"EMP File",popup,V_PickEMPButton("") |
---|
1602 | DoPrompt "Select File",filename |
---|
1603 | if (V_Flag) |
---|
1604 | return 0 // user canceled |
---|
1605 | endif |
---|
1606 | // //assign filename to [1] |
---|
1607 | newProtocol[1] = V_GetFileNameFromPathNoSemi(fileName) |
---|
1608 | |
---|
1609 | |
---|
1610 | |
---|
1611 | // //prompt for Empty cell file, but don't actually open it (/D flag) |
---|
1612 | // Open/D/R/F=fileFilters/M="Select the Empty Cell data file"/P=catPathName refnum |
---|
1613 | // //check for cancel |
---|
1614 | // if(strlen(S_filename)==0) |
---|
1615 | // //user cancelled, abort |
---|
1616 | // KillWaves/Z newProtocol |
---|
1617 | // SetDataFolder root: |
---|
1618 | // Abort "Incomplete protocol has been deleted" |
---|
1619 | // Endif |
---|
1620 | // //assign filename (full path) to [1] |
---|
1621 | // newProtocol[1] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
1622 | // |
---|
1623 | // notDone=1 |
---|
1624 | // do |
---|
1625 | // //prompt for additional Empty Cell files |
---|
1626 | // DoAlert 1,"Do you want to add another Empty Cell file?" |
---|
1627 | // if(V_flag == 1) //yes |
---|
1628 | // Open/D/R/F=fileFilters/M="Select another Empty Cell data file"/P=catPathName refnum |
---|
1629 | // //check for cancel |
---|
1630 | // if(strlen(S_filename)==0) |
---|
1631 | // //user cancelled, abort ********maybe just break out of the loop here |
---|
1632 | // KillWaves/Z newProtocol |
---|
1633 | // SetDataFolder root: |
---|
1634 | // Abort "Incomplete protocol has been deleted" |
---|
1635 | // Endif |
---|
1636 | // //assign filename (full path) to [1] |
---|
1637 | // newProtocol[1] += "," + V_GetFileNameFromPathNoSemi(S_filename) //***COMMA separated list |
---|
1638 | // notDone = 1 //keep going |
---|
1639 | // else |
---|
1640 | // notDone = 0 //no more to add |
---|
1641 | // Endif |
---|
1642 | // While(notDone) |
---|
1643 | |
---|
1644 | |
---|
1645 | else //no background desired |
---|
1646 | newProtocol[1] = "none" |
---|
1647 | Endif |
---|
1648 | |
---|
1649 | |
---|
1650 | ////////////////////////// |
---|
1651 | DoAlert 1,"Do you want to correct your data for detector sensitivity?" |
---|
1652 | |
---|
1653 | if(V_flag == 1) //1=yes |
---|
1654 | |
---|
1655 | Prompt filename,"DIV File",popup,V_GetDIVList() |
---|
1656 | DoPrompt "Select File",filename |
---|
1657 | if (V_Flag) |
---|
1658 | return 0 // user canceled |
---|
1659 | endif |
---|
1660 | // //assign filename to [2] |
---|
1661 | newProtocol[2] = V_GetFileNameFromPathNoSemi(fileName) |
---|
1662 | |
---|
1663 | // //prompt for DIV file, but don't actually open it (/D flag) |
---|
1664 | // Open/D/R/F=fileFilters/M="Select the detector sensitivity file"/P=catPathName refnum |
---|
1665 | // //check for cancel |
---|
1666 | // if(strlen(S_filename)==0) |
---|
1667 | // //user cancelled, abort |
---|
1668 | // KillWaves/Z newProtocol |
---|
1669 | // SetDataFolder root: |
---|
1670 | // Abort "Incomplete protocol has been deleted" |
---|
1671 | // Endif |
---|
1672 | // //assign filename (full path) to [2] |
---|
1673 | // newProtocol[2] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
1674 | |
---|
1675 | |
---|
1676 | else |
---|
1677 | //no Work.DIV desired |
---|
1678 | newProtocol[2] = "none" |
---|
1679 | Endif |
---|
1680 | ////////////////////////// |
---|
1681 | DoAlert 1,"Do you want to mask your files before averaging?" |
---|
1682 | |
---|
1683 | if(V_flag == 1) //1=yes |
---|
1684 | |
---|
1685 | Prompt filename,"MASK File",popup,V_PickMASKButton("") |
---|
1686 | DoPrompt "Select File",filename |
---|
1687 | if (V_Flag) |
---|
1688 | return 0 // user canceled |
---|
1689 | endif |
---|
1690 | // //assign filename to [3] |
---|
1691 | newProtocol[3] = V_GetFileNameFromPathNoSemi(fileName) |
---|
1692 | |
---|
1693 | // //prompt for mask file, but don't actually open it (/D flag) |
---|
1694 | // Open/D/R/F=fileFilters/M="Select the mask file"/P=catPathName refnum |
---|
1695 | // //check for cancel |
---|
1696 | // if(strlen(S_filename)==0) |
---|
1697 | // //user cancelled, abort |
---|
1698 | // KillWaves/Z newProtocol |
---|
1699 | // SetDataFolder root: |
---|
1700 | // Abort "Incomplete protocol has been deleted" |
---|
1701 | // Endif |
---|
1702 | // //assign filename (full path) to [3] |
---|
1703 | // newProtocol[3] = V_GetFileNameFromPathNoSemi(S_filename) |
---|
1704 | |
---|
1705 | |
---|
1706 | else |
---|
1707 | //no MASK desired |
---|
1708 | newProtocol[3] = "none" |
---|
1709 | Endif |
---|
1710 | |
---|
1711 | //absolute scaling |
---|
1712 | |
---|
1713 | ////////////////////////// |
---|
1714 | //ABS parameters stored as keyword=value string |
---|
1715 | DoAlert 1,"Do you want absolute scaling?" |
---|
1716 | if(V_flag == 1) //1=yes |
---|
1717 | //missing param - prompt for values, put in semicolon-separated list |
---|
1718 | Execute "V_AskForAbsoluteParams_Quest()" |
---|
1719 | SVAR absStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
1720 | newProtocol[4] = absStr |
---|
1721 | else |
---|
1722 | //no absolute scaling desired |
---|
1723 | newProtocol[4] = "none" |
---|
1724 | Endif |
---|
1725 | |
---|
1726 | //type of average, plot?, auto/manual naming/saving... put in semicolon separated string |
---|
1727 | //of KEY=<value> format for easy parsing |
---|
1728 | //Kewords are: AVTYPE,PHI,DPHI,PLOT,SAVE,NAME,SIDE,WIDTH |
---|
1729 | //note that AVTYPE,NAME,SIDE have string values, others have numerical values |
---|
1730 | /////////////////////// |
---|
1731 | DoAlert 1,"Do you want to average your data to I vs. q?" |
---|
1732 | if(V_flag == 1) //1=yes |
---|
1733 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr = "" |
---|
1734 | Execute "V_GetAvgInfo()" //will put up missing paramter dialog and do all the work |
---|
1735 | //:gAvgInfo is reset by the Proc(), copy this string tot he protocol |
---|
1736 | SVAR tempStr=root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr |
---|
1737 | |
---|
1738 | //get a file path for saving files, if desired |
---|
1739 | /////no - save files to the same data folder as the one with the raw data |
---|
1740 | //then only one path to manage. |
---|
1741 | //String yesNo = StringByKey("SAVE", tempStr,"=", ";") |
---|
1742 | //if(cmpstr("Yes",yesNo) == 0) //0=yes |
---|
1743 | //NewPath/C/M="Select Folder"/O Save_path //Save_path is the symbolic path |
---|
1744 | //Endif |
---|
1745 | |
---|
1746 | newProtocol[5] = tempStr |
---|
1747 | KillStrings/Z tempStr |
---|
1748 | else |
---|
1749 | //no averaging desired |
---|
1750 | newProtocol[5] = "AVTYPE=none" |
---|
1751 | Endif |
---|
1752 | |
---|
1753 | //returns the name of the newly created (= currently in use) protocol wave through a global |
---|
1754 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtoStr |
---|
1755 | |
---|
1756 | //reset the panel based on the protocol textwave (currently a string) |
---|
1757 | V_ResetToSavedProtocol(newProtoStr) |
---|
1758 | |
---|
1759 | SetDataFolder root: |
---|
1760 | |
---|
1761 | return(0) |
---|
1762 | End |
---|
1763 | |
---|
1764 | |
---|
1765 | // TODO |
---|
1766 | // -- this function may not work properly for VSANS, but I haven't tested it yet |
---|
1767 | // -- I'd rather have some sort of display to show the current content of the WORK folders |
---|
1768 | // |
---|
1769 | // -- the global string fileList does not exist, so this will always fail and return zero |
---|
1770 | // |
---|
1771 | // |
---|
1772 | //function to check the work files (to see what's already there) |
---|
1773 | //and compare that with the files that are supposed to be there, according to the |
---|
1774 | //current protocol (to save unnecessary time re-loading files) |
---|
1775 | // |
---|
1776 | //the "type" folder is checked for all files in the list req(ested)Files |
---|
1777 | //note that the list of files is a full path:name;ver, while the |
---|
1778 | //fileList in the folder is just the name (or a list of names) |
---|
1779 | // |
---|
1780 | //returns 0 false, if files are NOT present |
---|
1781 | //or 1 = true, yes, the files are there as requested |
---|
1782 | // |
---|
1783 | Function V_AreFilesThere(type,reqFiles) |
---|
1784 | String type,reqFiles |
---|
1785 | |
---|
1786 | //in general, reqFiles is a list of full paths to files - which MAY include semicolon version numbers |
---|
1787 | //reqFiles MUST be constructed with COMMAS as list separators, to avoid disaster |
---|
1788 | //when the version numbers are interpreted as filenames |
---|
1789 | |
---|
1790 | //get the number of files requested |
---|
1791 | Variable nReq,nCur,match,ii |
---|
1792 | nReq = ItemsInList(reqFiles,",") |
---|
1793 | |
---|
1794 | //get the name of the file currently in BGD - in the global fileList |
---|
1795 | //fileList has NAMES ONLY - since it was derived from the file header |
---|
1796 | String testStr |
---|
1797 | testStr = "root:Packages:NIST:"+type+":fileList" |
---|
1798 | if(Exists(testStr) == 2) //2 if string variable exists |
---|
1799 | SVAR curFiles = $testStr |
---|
1800 | else |
---|
1801 | //no files currently in type folder, return zero |
---|
1802 | Return (0) |
---|
1803 | Endif |
---|
1804 | //get the number of files already in folder |
---|
1805 | nCur = ItemsInList(curFiles,";") |
---|
1806 | If(nCur != nReq) |
---|
1807 | Return (0) //quit now, the wrong number of files present |
---|
1808 | Endif |
---|
1809 | //right number of files... are the names right... |
---|
1810 | //check for a match (case-sensitive!!) of each requested file in the curFile string |
---|
1811 | //need to extract filenames from reqFiles, since they're the full path and name |
---|
1812 | |
---|
1813 | ii=0 |
---|
1814 | do |
---|
1815 | testStr = StringFromList(ii,reqFiles,",") //testStr is the Nth full path and filename |
---|
1816 | //testStr = GetFileNameFromPathNoSemi(testStr) //testStr will now be just the filename |
---|
1817 | match = stringmatch(curFiles,testStr) |
---|
1818 | If(!match) |
---|
1819 | Return (0) //req file was not found in curFile list - get out now |
---|
1820 | Endif |
---|
1821 | ii+=1 |
---|
1822 | while(ii<nreq) |
---|
1823 | |
---|
1824 | Return (1) //indicate that files are OK, no changes needed |
---|
1825 | End |
---|
1826 | |
---|
1827 | |
---|
1828 | // |
---|
1829 | //will add the files specified in the protocol to the "type" folder |
---|
1830 | //will add multiple files together if more than one file is requested |
---|
1831 | //(list is a comma delimited list of filenames, with NO path information) |
---|
1832 | // |
---|
1833 | // This routine NOW DOES check for the possibility that the filenames may have ";vers" from the |
---|
1834 | // VAX - data should be picked up from Charlotte, where it won't have version numbers. |
---|
1835 | // |
---|
1836 | Function V_AddFilesInList(type,list) |
---|
1837 | String type,list |
---|
1838 | |
---|
1839 | //type is the work folder to put the data into, and list is a COMMA delimited list of paths/names |
---|
1840 | Variable num,ii,err=0,refNum |
---|
1841 | String filename,pathStr="" |
---|
1842 | PathInfo catPathName //this is where the files are |
---|
1843 | pathstr=S_path |
---|
1844 | |
---|
1845 | num = ItemsInList(list,",") // comma delimited list |
---|
1846 | |
---|
1847 | ii=0 |
---|
1848 | do |
---|
1849 | //FindValidFilename only needed in case of vax version numbers |
---|
1850 | filename = pathStr + V_FindValidFilename(StringFromList(ii,list,",")) |
---|
1851 | Open/Z/R refnum as filename |
---|
1852 | if(V_flag != 0) //file not found |
---|
1853 | //Print "file not found AddFilesInList()" |
---|
1854 | //Print filename |
---|
1855 | err = 1 |
---|
1856 | return(err) |
---|
1857 | Endif |
---|
1858 | Close refnum //file was found and opened, so close it |
---|
1859 | |
---|
1860 | // Abort "Find equivalent to ReadHeaderAndData(filename)" |
---|
1861 | // ReadHeaderAndData(filename) |
---|
1862 | err = V_LoadHDF5Data(filename,"RAW") |
---|
1863 | |
---|
1864 | if(ii == 0) |
---|
1865 | //first pass, wipe out the old contents of the work file |
---|
1866 | err = V_Raw_to_work(type) |
---|
1867 | else |
---|
1868 | err = V_Add_raw_to_work(type) |
---|
1869 | Endif |
---|
1870 | ii+=1 |
---|
1871 | while(ii<num) |
---|
1872 | return(err) |
---|
1873 | End |
---|
1874 | |
---|
1875 | //function will reduce a sample file (or ask for file(s)) |
---|
1876 | //using the protocol named as "protoStr" in the Protocols subfolder |
---|
1877 | //samStr is the file(s) or "ask" to force prompt |
---|
1878 | //sequentially proceeds through flowchart, doing reduction steps as needed |
---|
1879 | //show Schematic to debug what steps/values were used |
---|
1880 | // |
---|
1881 | //function is long, but straightforward logic |
---|
1882 | // |
---|
1883 | Function V_ExecuteProtocol(protStr,samStr) |
---|
1884 | String protStr,samStr |
---|
1885 | //protStr is the full path to the selected protocol wave |
---|
1886 | //samStr is either "ask" or the name ONLY ofthe desired sample data file(s) (NO PATH) |
---|
1887 | WAVE/T prot = $protStr |
---|
1888 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
1889 | |
---|
1890 | Variable filesOK,err,notDone |
---|
1891 | String activeType, msgStr, junkStr, pathStr="" |
---|
1892 | PathInfo catPathName //this is where the files are |
---|
1893 | pathStr=S_path |
---|
1894 | |
---|
1895 | // NVAR useXMLOutput = root:Packages:NIST:gXML_Write |
---|
1896 | |
---|
1897 | //Parse the instructions in the prot wave |
---|
1898 | //0 - bkg |
---|
1899 | //1 - emp |
---|
1900 | //2 - div |
---|
1901 | //3 - mask |
---|
1902 | //4 - abs params c2-c5 |
---|
1903 | //5 - average params |
---|
1904 | //6 = DRK file (**out of sequence) |
---|
1905 | //7 = beginning trim points |
---|
1906 | //8 = end trim points |
---|
1907 | //9 = unused |
---|
1908 | //10 = unused |
---|
1909 | //11 = unused |
---|
1910 | |
---|
1911 | // for VSANS, DIV is used on each data file as it is converted to WORK, so it needs to be |
---|
1912 | // the first thing in place, before any data or backgrounds are loaded |
---|
1913 | |
---|
1914 | |
---|
1915 | // |
---|
1916 | // DONE: |
---|
1917 | // x- this is no longer done after the COR step, and CAL is not produced as output of DIV |
---|
1918 | // x- needs to be aware of the file name passed in |
---|
1919 | // x- PromptForPath does not exist in VSANS. Need a better (automated) way to find the file. |
---|
1920 | |
---|
1921 | //check for work.div file (prot[2]) |
---|
1922 | //load in if needed |
---|
1923 | // no math is done here, DIV is applied as files are converted to WORK (the first operation in VSANS) |
---|
1924 | // |
---|
1925 | String divFileName = "" |
---|
1926 | |
---|
1927 | If(cmpstr("none",prot[2])!=0) // if !0, then there's a file requested |
---|
1928 | If(cmpstr("ask",prot[2]) == 0) |
---|
1929 | //ask user for file |
---|
1930 | // junkStr = PromptForPath("Select the detector sensitivity file") |
---|
1931 | Prompt divFileName,"DIV File",popup,V_GetDIVList() |
---|
1932 | DoPrompt "Select File",divFileName |
---|
1933 | |
---|
1934 | If(strlen(divFileName)==0) |
---|
1935 | SetDataFolder root: |
---|
1936 | Abort "No file selected, data reduction aborted" |
---|
1937 | Endif |
---|
1938 | V_LoadHDF5Data(divFileName,"DIV") |
---|
1939 | else |
---|
1940 | //assume it's a path, and that the first (and only) item is the path:file |
---|
1941 | //list processing is necessary to remove any final comma |
---|
1942 | junkStr = pathStr + StringFromList(0, prot[2],"," ) |
---|
1943 | V_LoadHDF5Data(junkStr,"DIV") |
---|
1944 | Endif |
---|
1945 | |
---|
1946 | else |
---|
1947 | // DIV step is being skipped |
---|
1948 | NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor |
---|
1949 | Variable saved_gDoDIVCor = gDoDIVCor |
---|
1950 | gDoDIVCor = 0 // protocol says to turn it off for now (reset later) |
---|
1951 | Endif |
---|
1952 | |
---|
1953 | |
---|
1954 | // TODO: |
---|
1955 | // -- currently does not allow adding RAW data files together, so no parsing is done |
---|
1956 | // -- NOTE detector corrections (including DIV) are done at the V_Raw_to_Work() step |
---|
1957 | // So if the DIV is not part of the protocol, be sure to set/reset the global preference |
---|
1958 | // |
---|
1959 | //prompt for sam data => read raw data, add to sam folder |
---|
1960 | //or parse file(s) from the input paramter string |
---|
1961 | activeType = "SAM" |
---|
1962 | msgStr = "Select sample data" |
---|
1963 | //Ask for SAM file or parse |
---|
1964 | do |
---|
1965 | if((cmpstr(samStr,"ask") == 0) || (cmpstr(samStr,"")==0) ) //zero if strings are equal |
---|
1966 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
1967 | if(err) |
---|
1968 | PathInfo/S catPathName |
---|
1969 | Abort "reduction sequence aborted" |
---|
1970 | endif |
---|
1971 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
1972 | err = V_Raw_to_work(activeType) //this is the first file (default) |
---|
1973 | //Ask for another SAM file |
---|
1974 | do |
---|
1975 | DoAlert 1,"Do you want to add another Sample file?" |
---|
1976 | if(V_flag == 1) //yes |
---|
1977 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
1978 | if(err) |
---|
1979 | PathInfo/S catPathName |
---|
1980 | Abort "reduction sequence aborted" |
---|
1981 | endif |
---|
1982 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
1983 | err = V_Add_raw_to_work(activeType) |
---|
1984 | notDone = 1 |
---|
1985 | else |
---|
1986 | notDone = 0 |
---|
1987 | endif |
---|
1988 | while(notDone) |
---|
1989 | break |
---|
1990 | Endif |
---|
1991 | //"none" is not an option - you always need a sample file - "none" will never return zero |
---|
1992 | //if not "ask" AND not "none" then try to parse the filenames |
---|
1993 | If((cmpstr(samStr,"none") != 0) && (cmpstr(samStr,"ask") != 0)) |
---|
1994 | //filesOK = AreFilesThere(activeType,samStr) //return 1 if correct files are already there |
---|
1995 | filesOK = 0 // Feb 2008, always force a reload of files. Maybe slow, but always correct |
---|
1996 | if(!filesOK) |
---|
1997 | //add the correct file(s) to SAM |
---|
1998 | |
---|
1999 | // TODO: only one file is allowed currently |
---|
2000 | err = V_AddFilesInList(activeType,samStr) |
---|
2001 | |
---|
2002 | if(err) |
---|
2003 | //Print "samstr = ",samStr |
---|
2004 | Abort "SAM file not found, reset SAM file" |
---|
2005 | Endif |
---|
2006 | Endif |
---|
2007 | Endif |
---|
2008 | While(0) |
---|
2009 | // TODO |
---|
2010 | // -- this may not be the most reliable way to pass the file name (for naming of the saved file later) |
---|
2011 | SVAR file_name = root:file_Name |
---|
2012 | String samFileLoaded = file_name //keep a copy of the sample file loaded |
---|
2013 | |
---|
2014 | //always update |
---|
2015 | V_UpdateDisplayInformation(ActiveType) |
---|
2016 | |
---|
2017 | //check for bkg file -- "ask" might not fail - "ask?" will - ? not allowed in VAX filenames |
---|
2018 | // add if needed |
---|
2019 | //use a "case" statement |
---|
2020 | msgStr = "Select background file" |
---|
2021 | activeType = "BGD" |
---|
2022 | do |
---|
2023 | if(cmpstr(prot[0],"ask") == 0) //zero if strings are equal |
---|
2024 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
2025 | if(err) |
---|
2026 | PathInfo/S catPathName |
---|
2027 | Abort "reduction sequence aborted" |
---|
2028 | endif |
---|
2029 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
2030 | err = V_Raw_to_work(activeType) //this is the first file (default) |
---|
2031 | //Ask for another BGD file |
---|
2032 | do |
---|
2033 | DoAlert 1,"Do you want to add another Background file?" |
---|
2034 | if(V_flag == 1) //yes |
---|
2035 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
2036 | if(err) |
---|
2037 | PathInfo/S catPathName |
---|
2038 | Abort "reduction sequence aborted" |
---|
2039 | endif |
---|
2040 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
2041 | err = V_Add_raw_to_work(activeType) |
---|
2042 | notDone = 1 |
---|
2043 | else |
---|
2044 | notDone = 0 |
---|
2045 | endif |
---|
2046 | while(notDone) |
---|
2047 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
2048 | break |
---|
2049 | Endif |
---|
2050 | If(cmpstr(prot[0],"none") == 0) |
---|
2051 | //clean out the BKG folder? |
---|
2052 | //KillDataFolder root:BKG |
---|
2053 | //NewDataFolder/O root:BKG |
---|
2054 | break |
---|
2055 | Endif |
---|
2056 | //if not "ask" AND not "none" then try to parse the filenames |
---|
2057 | If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[0],"ask") != 0)) |
---|
2058 | //filesOK = AreFilesThere(activeType,prot[0]) |
---|
2059 | filesOK = 0 // Feb 2008, always force a reload of files. Maybe slow, but always correct |
---|
2060 | if(!filesOK) |
---|
2061 | //add the correct file(s) to BGD |
---|
2062 | string bgdStr = prot[0] |
---|
2063 | err = V_AddFilesInList(activeType,bgdStr) |
---|
2064 | If(err) |
---|
2065 | Abort "BGD file not found. Reset BGD file list" |
---|
2066 | Endif |
---|
2067 | Endif |
---|
2068 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
2069 | Endif |
---|
2070 | While(0) |
---|
2071 | |
---|
2072 | |
---|
2073 | //check for emp file (prot[1]) |
---|
2074 | // add if needed |
---|
2075 | msgStr = "Select empty cell data" |
---|
2076 | activeType = "EMP" |
---|
2077 | do |
---|
2078 | if(cmpstr(prot[1],"ask") == 0) |
---|
2079 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
2080 | if(err) |
---|
2081 | PathInfo/S catPathName |
---|
2082 | Abort "reduction sequence aborted" |
---|
2083 | endif |
---|
2084 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
2085 | err = V_Raw_to_work(activeType) //this is the first file (default) |
---|
2086 | //Ask for another EMP file |
---|
2087 | do |
---|
2088 | DoAlert 1,"Do you want to add another Empty Cell file?" |
---|
2089 | if(V_flag == 1) //yes |
---|
2090 | err = V_LoadHDF5Data("","RAW") //will prompt for file |
---|
2091 | if(err) |
---|
2092 | PathInfo/S catPathName |
---|
2093 | Abort "reduction sequence aborted" |
---|
2094 | endif |
---|
2095 | V_UpdateDisplayInformation("RAW") //display the new type of data that was loaded |
---|
2096 | err = V_Add_raw_to_work(activeType) |
---|
2097 | notDone = 1 |
---|
2098 | else |
---|
2099 | notDone = 0 |
---|
2100 | endif |
---|
2101 | while(notDone) |
---|
2102 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
2103 | break |
---|
2104 | Endif |
---|
2105 | If(cmpstr(prot[1],"none") == 0) |
---|
2106 | //clean out the EMP folder? |
---|
2107 | //KillDataFolder root:Packages:NIST:EMP |
---|
2108 | //NewDataFolder/O root:Packages:NIST:EMP |
---|
2109 | break |
---|
2110 | Endif |
---|
2111 | //if not "ask" AND not "none" then try to parse the filenames |
---|
2112 | If((cmpstr(prot[1],"none") != 0) && (cmpstr(prot[1],"ask") != 0)) |
---|
2113 | //filesOK = AreFilesThere(activeType,prot[1]) |
---|
2114 | filesOK = 0 // Feb 2008, always force a reload of files. Maybe slow, but always correct |
---|
2115 | if(!filesOK) |
---|
2116 | //add the correct file(s) to BGD |
---|
2117 | err = V_AddFilesInList(activeType,prot[1]) |
---|
2118 | If(err) |
---|
2119 | Abort "EMP file not found. Reset EMP file list" |
---|
2120 | Endif |
---|
2121 | Endif |
---|
2122 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
2123 | Endif |
---|
2124 | While(0) |
---|
2125 | |
---|
2126 | //do the CORRECT step based on the answers to emp and bkg subtraction |
---|
2127 | //by setting the proper"mode" |
---|
2128 | //1 = both emp and bgd subtraction |
---|
2129 | //2 = only bgd subtraction |
---|
2130 | //3 = only emp subtraction |
---|
2131 | //4 = no subtraction |
---|
2132 | //additional modes 091301 |
---|
2133 | //11 = emp, bgd, drk |
---|
2134 | //12 = bgd and drk |
---|
2135 | //13 = emp and drk |
---|
2136 | //14 = no subtractions |
---|
2137 | //work.drk is from proto[6] |
---|
2138 | // |
---|
2139 | //subtracting just the DRK data is NOT an option - it doesnt' really make any physical sense |
---|
2140 | // - in this case, DRK is skipped (equivalent to mode==4) |
---|
2141 | // automatically accounts for attenuators given the lookup tables and the |
---|
2142 | //desired subtractions |
---|
2143 | //Attenuator lookup tables are alredy implemented (NG1 = NG7) |
---|
2144 | // |
---|
2145 | |
---|
2146 | |
---|
2147 | /////// DRK is SKIPPED |
---|
2148 | |
---|
2149 | // //read in the DRK data if necessary |
---|
2150 | // //only one file, assumed to be RAW data |
---|
2151 | // // |
---|
2152 | // String fname="",drkStr="" |
---|
2153 | // drkStr=StringByKey("DRK",prot[6],"=",",") |
---|
2154 | // if(cmpstr(drkStr,"none") != 0) |
---|
2155 | // err = ReadHeaderAndData( (pathStr+drkStr) ) |
---|
2156 | // if(err) |
---|
2157 | // PathInfo/S catPathName |
---|
2158 | // Abort "reduction sequence aborted" |
---|
2159 | // endif |
---|
2160 | // err = V_Raw_to_Work_NoNorm("DRK") |
---|
2161 | // endif |
---|
2162 | |
---|
2163 | |
---|
2164 | |
---|
2165 | //dispatch to the proper "mode" of Correct() |
---|
2166 | Variable mode=4,val |
---|
2167 | do |
---|
2168 | if( (cmpstr("none",prot[0]) == 0) && (cmpstr("none",prot[1]) == 0) ) |
---|
2169 | //no subtraction (mode = 4), |
---|
2170 | mode = 4 |
---|
2171 | Endif |
---|
2172 | If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[1],"none") == 0)) |
---|
2173 | //subtract BGD only |
---|
2174 | mode=2 |
---|
2175 | Endif |
---|
2176 | If((cmpstr(prot[0],"none") == 0) && (cmpstr(prot[1],"none") != 0)) |
---|
2177 | //subtract EMP only |
---|
2178 | mode=3 |
---|
2179 | Endif |
---|
2180 | If((cmpstr(prot[0],"none") != 0) && (cmpstr(prot[1],"none") != 0)) |
---|
2181 | // bkg and emp subtraction are to be done (BOTH not "none") |
---|
2182 | mode=1 |
---|
2183 | Endif |
---|
2184 | activeType = "COR" |
---|
2185 | //add in DRK mode (0= no used, 10 = used) |
---|
2186 | val = NumberByKey("DRKMODE",prot[6],"=","," ) |
---|
2187 | mode += val |
---|
2188 | // print "mode = ",mode |
---|
2189 | err = V_Correct(mode) |
---|
2190 | if(err) |
---|
2191 | SetDataFolder root: |
---|
2192 | Abort "error in Correct, called from executeprotocol, normal cor" |
---|
2193 | endif |
---|
2194 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
2195 | While(0) |
---|
2196 | |
---|
2197 | |
---|
2198 | //////////////////////////////////////////////////////// |
---|
2199 | // Absolute scale |
---|
2200 | |
---|
2201 | // x- calculation works, needs proper inputs (solid angle aware) |
---|
2202 | // x- Open beam method needs to be verified in V_AskForAbsoluteParams_Quest() |
---|
2203 | Variable c2,c3,c4,c5,kappa_err |
---|
2204 | //do absolute scaling if desired |
---|
2205 | // DoAlert 0,"Abs step incomplete" |
---|
2206 | |
---|
2207 | if(cmpstr("none",prot[4])!=0) |
---|
2208 | if(cmpstr("ask",prot[4])==0) |
---|
2209 | //get the params from the user |
---|
2210 | Execute "V_AskForAbsoluteParams_Quest()" |
---|
2211 | //then from the list |
---|
2212 | SVAR junkAbsStr = root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr |
---|
2213 | c2 = NumberByKey("TSTAND", junkAbsStr, "=", ";") //parse the list of values |
---|
2214 | c3 = NumberByKey("DSTAND", junkAbsStr, "=", ";") |
---|
2215 | c4 = NumberByKey("IZERO", junkAbsStr, "=", ";") |
---|
2216 | c5 = NumberByKey("XSECT", junkAbsStr, "=", ";") |
---|
2217 | kappa_err = NumberByKey("SDEV", junkAbsStr, "=", ";") |
---|
2218 | else |
---|
2219 | //get the parames from the list |
---|
2220 | c2 = NumberByKey("TSTAND", prot[4], "=", ";") //parse the list of values |
---|
2221 | c3 = NumberByKey("DSTAND", prot[4], "=", ";") |
---|
2222 | c4 = NumberByKey("IZERO", prot[4], "=", ";") |
---|
2223 | c5 = NumberByKey("XSECT", prot[4], "=", ";") |
---|
2224 | kappa_err = NumberByKey("SDEV", prot[4], "=", ";") |
---|
2225 | Endif |
---|
2226 | //get the sample trans and thickness from the activeType folder |
---|
2227 | Variable c0 = V_getSampleTransmission(activeType) //sample transmission |
---|
2228 | Variable c1 = V_getSampleThickness(activeType) //sample thickness |
---|
2229 | |
---|
2230 | err = V_Absolute_Scale(activeType,c0,c1,c2,c3,c4,c5,kappa_err) |
---|
2231 | if(err) |
---|
2232 | SetDataFolder root: |
---|
2233 | Abort "Error in V_Absolute_Scale(), called from V_ExecuteProtocol" |
---|
2234 | endif |
---|
2235 | activeType = "ABS" |
---|
2236 | V_UpdateDisplayInformation(ActiveType) //update before breaking from loop |
---|
2237 | Endif |
---|
2238 | |
---|
2239 | // |
---|
2240 | // DONE |
---|
2241 | // x- fill in the "ask" step |
---|
2242 | // x- none is OK, except if the kill fails for any reason |
---|
2243 | // x- the regular case of the file name specified by the protocol works correctly |
---|
2244 | // x- don't create a null mask if not used, it will handle the error and print out that the mask is missing |
---|
2245 | |
---|
2246 | //mask data if desired (this is done automatically when the data is binned to I(q)) and is |
---|
2247 | //not done explicitly here |
---|
2248 | |
---|
2249 | //check for mask |
---|
2250 | //doesn't change the activeType |
---|
2251 | String mskFileName="" |
---|
2252 | |
---|
2253 | if(cmpstr("none",prot[3])!=0) |
---|
2254 | If(cmpstr("ask",prot[3])==0) |
---|
2255 | //get file from user |
---|
2256 | // x- fill in the get file prompt, and handle the result |
---|
2257 | Prompt mskFileName,"MASK File",popup,V_PickMASKButton("") |
---|
2258 | DoPrompt "Select File",mskFileName |
---|
2259 | // if (V_Flag) |
---|
2260 | // return 0 // user cancelled |
---|
2261 | // endif |
---|
2262 | |
---|
2263 | If(strlen(mskFileName)==0) //use cancelled |
---|
2264 | //if none desired, make sure that the old mask is deleted |
---|
2265 | KillDataFolder/Z root:Packages:NIST:VSANS:MSK: |
---|
2266 | NewDataFolder/O root:Packages:NIST:VSANS:MSK |
---|
2267 | |
---|
2268 | DoAlert 0,"No Mask file selected, data not masked" |
---|
2269 | else |
---|
2270 | //read in the file from the selection |
---|
2271 | V_LoadHDF5Data(mskFileName,"MSK") |
---|
2272 | Endif |
---|
2273 | else |
---|
2274 | //just read it in from the protocol |
---|
2275 | //list processing is necessary to remove any final comma |
---|
2276 | mskFileName = pathStr + StringFromList(0, prot[3],"," ) |
---|
2277 | V_LoadHDF5Data(mskFileName,"MSK") |
---|
2278 | Endif |
---|
2279 | |
---|
2280 | else |
---|
2281 | //if none desired, make sure that the old mask is deleted |
---|
2282 | // TODO |
---|
2283 | // x- clean out the data folder |
---|
2284 | // x- note that V_KillNamedDataFolder() points to RawVSANS, and won't work |
---|
2285 | // -- what happens if the kill fails? need error handling |
---|
2286 | // |
---|
2287 | KillDataFolder/Z root:Packages:NIST:VSANS:MSK: |
---|
2288 | NewDataFolder/O root:Packages:NIST:VSANS:MSK |
---|
2289 | |
---|
2290 | Endif |
---|
2291 | |
---|
2292 | |
---|
2293 | // average/save data as specified |
---|
2294 | //Parse the keyword=<Value> string as needed, based on AVTYPE |
---|
2295 | |
---|
2296 | //average/plot first |
---|
2297 | String av_type = StringByKey("AVTYPE",prot[5],"=",";") |
---|
2298 | If(cmpstr(av_type,"none") != 0) |
---|
2299 | If (cmpstr(av_type,"")==0) //if the key could not be found... (if "ask" the string) |
---|
2300 | //get the averaging parameters from the user, as if the set button was hit in the panel |
---|
2301 | V_SetAverageParamsButtonProc("dummy") //from "ProtocolAsPanel" |
---|
2302 | SVAR tempAveStr = root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr |
---|
2303 | av_type = StringByKey("AVTYPE",tempAveStr,"=",";") |
---|
2304 | else |
---|
2305 | //there is info in the string, use the protocol |
---|
2306 | //set the global keyword-string to prot[5] |
---|
2307 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAvgInfoStr = prot[5] |
---|
2308 | Endif |
---|
2309 | Endif |
---|
2310 | |
---|
2311 | //convert the folder to linear scale before averaging, then revert by calling the window hook |
---|
2312 | // (not needed for VSANS, data is always linear scale) |
---|
2313 | |
---|
2314 | // bin and plot the data |
---|
2315 | |
---|
2316 | // |
---|
2317 | // x- need to convert BINTYPE keyword into a numerical value to pass |
---|
2318 | // |
---|
2319 | |
---|
2320 | // |
---|
2321 | // (DONE) |
---|
2322 | // -x this generates a "Bin Type Not Found" error if reducing only to a 2D level (like for DIV) |
---|
2323 | // because binTypeStr is null |
---|
2324 | String binTypeStr = StringByKey("BINTYPE",prot[5],"=",";") |
---|
2325 | // plotting is not really necessary, and the graph may not be open - so skip for now? |
---|
2326 | Variable binType |
---|
2327 | // only get the binning type if user asks for averaging |
---|
2328 | If(cmpstr(av_type,"none") != 0) |
---|
2329 | binType = V_BinTypeStr2Num(binTypeStr) |
---|
2330 | if(binType == 0) |
---|
2331 | Abort "Binning mode not found in V_QBinAllPanels() "// when no case matches |
---|
2332 | endif |
---|
2333 | endif |
---|
2334 | |
---|
2335 | // |
---|
2336 | // TODO: |
---|
2337 | // -- do I calculate the proper resolution here? I've already decoded the binning type |
---|
2338 | // and the averaging type has been specified by the protocol. |
---|
2339 | // |
---|
2340 | // currently, the resolution is calculated every time that the data is averaged (in VC_fDoBinning_QxQy2D) |
---|
2341 | // |
---|
2342 | // -- if I calculate the resolution here, then the Trimming routines must be updated |
---|
2343 | // to trim the resolution waves also. This will work for the columns present in |
---|
2344 | // pinhole resolution, but anything using the matrix method - it won't work - and I'll need |
---|
2345 | // a different solution |
---|
2346 | // |
---|
2347 | strswitch(av_type) //dispatch to the proper routine to average to 1D data |
---|
2348 | case "none": |
---|
2349 | //still do nothing |
---|
2350 | break |
---|
2351 | case "2D_ASCII": |
---|
2352 | //do nothing |
---|
2353 | break |
---|
2354 | case "QxQy_ASCII": |
---|
2355 | //do nothing |
---|
2356 | break |
---|
2357 | case "PNG_Graphic": |
---|
2358 | //do nothing |
---|
2359 | break |
---|
2360 | case "Rectangular": |
---|
2361 | // RectangularAverageTo1D(activeType) |
---|
2362 | break |
---|
2363 | case "Annular": |
---|
2364 | // AnnularAverageTo1D(activeType) |
---|
2365 | String detGroup = StringByKey("DETGROUP",prot[5],"=",";") |
---|
2366 | Variable qCtr_Ann = NumberByKey("QCENTER",prot[5],"=",";") |
---|
2367 | Variable qWidth = NumberByKey("QDELTA",prot[5],"=",";") |
---|
2368 | V_QBinAllPanels_Annular(activeType,detGroup,qCtr_Ann,qWidth) |
---|
2369 | break |
---|
2370 | case "Circular": |
---|
2371 | |
---|
2372 | V_QBinAllPanels_Circular(activeType,binType) // this does a default circular average |
---|
2373 | break |
---|
2374 | case "Sector": |
---|
2375 | // CircularAverageTo1D(activeType) |
---|
2376 | break |
---|
2377 | case "Sector_PlusMinus": |
---|
2378 | // Sector_PlusMinus1D(activeType) |
---|
2379 | break |
---|
2380 | default: |
---|
2381 | //do nothing |
---|
2382 | endswitch |
---|
2383 | |
---|
2384 | // DONE |
---|
2385 | // x- this call will bin the active type, then the next call bins the active type |
---|
2386 | // x- then later, I dispatch to bin the active type... |
---|
2387 | // x- !!!need to split out the panel draw and the binning calls from V_PlotData_Panel |
---|
2388 | // |
---|
2389 | // TODO: |
---|
2390 | // -- BAD logic here, skipping the normal graph if annular is chosen. Go back and see how I do this |
---|
2391 | // in SANS for a better and more foolproof way to do this |
---|
2392 | // x- don't draw the graph if "none" is the average type! |
---|
2393 | // |
---|
2394 | if(cmpstr(av_type,"Annular") != 0 && (cmpstr(av_type,"none") != 0) ) |
---|
2395 | V_PlotData_Panel() //this brings the plot window to the front, or draws it (ONLY) |
---|
2396 | V_Update1D_Graph(activeType,binType) //update the graph, data was already binned |
---|
2397 | endif |
---|
2398 | ///// end of averaging dispatch |
---|
2399 | |
---|
2400 | |
---|
2401 | // |
---|
2402 | // x- how do I get the sample file name? |
---|
2403 | // local variable samFileLoaded is the file name loaded (contains the extension) |
---|
2404 | // |
---|
2405 | //save data if desired - dispatch as needed |
---|
2406 | String fullpath = "", newfileName="" |
---|
2407 | String saveType = StringByKey("SAVE",prot[5],"=",";") //does user want to save data? |
---|
2408 | |
---|
2409 | If( (cmpstr(saveType[0,2],"Yes")==0) && (cmpstr(av_type,"none") != 0) ) |
---|
2410 | //then save |
---|
2411 | newFileName = RemoveEnding(samFileLoaded,".nxs.ngv") |
---|
2412 | |
---|
2413 | //pick ABS or AVE extension |
---|
2414 | String exten = activeType |
---|
2415 | if(cmpstr(exten,"ABS") != 0) |
---|
2416 | exten = "AVE" |
---|
2417 | endif |
---|
2418 | if(cmpstr(av_type,"2D_ASCII") == 0) |
---|
2419 | exten = "ASC" |
---|
2420 | endif |
---|
2421 | if(cmpstr(av_type,"QxQy_ASCII") == 0) |
---|
2422 | exten = "DAT" |
---|
2423 | endif |
---|
2424 | |
---|
2425 | // // add an "x" to the file extension if the output is XML |
---|
2426 | // // currently (2010), only for ABS and AVE (1D) output |
---|
2427 | // if( cmpstr(exten,"ABS") == 0 || cmpstr(exten,"AVE") == 0 ) |
---|
2428 | // if(useXMLOutput == 1) |
---|
2429 | // exten += "x" |
---|
2430 | // endif |
---|
2431 | // endif |
---|
2432 | |
---|
2433 | //Path is catPathName, symbolic path |
---|
2434 | //if this doesn't exist, a dialog will be presented by setting dialog = 1 |
---|
2435 | // |
---|
2436 | Variable dialog = 0 |
---|
2437 | |
---|
2438 | PathInfo/S catPathName |
---|
2439 | String item = StringByKey("NAME",prot[5],"=",";") //Auto or Manual naming |
---|
2440 | String autoname = StringByKey("AUTONAME",prot[5],"=",";") //autoname - will get empty string if not present |
---|
2441 | If((cmpstr(item,"Manual")==0) || (cmpstr(newFileName,"") == 0)) |
---|
2442 | //manual name if requested or if no name can be derived from header |
---|
2443 | fullPath = newfileName + "."+ exten //puts possible new name or null string in dialog |
---|
2444 | dialog = 1 //force dialog for user to enter name |
---|
2445 | else |
---|
2446 | //auto-generate name and prepend path - won't put up any dialogs since it has all it needs |
---|
2447 | //use autoname if present |
---|
2448 | if (cmpstr(autoname,"") != 0) |
---|
2449 | fullPath = S_Path + autoname + "." +exten |
---|
2450 | else |
---|
2451 | fullPath = S_Path + newFileName+"." + exten |
---|
2452 | endif |
---|
2453 | Endif |
---|
2454 | // |
---|
2455 | strswitch(av_type) |
---|
2456 | case "Annular": |
---|
2457 | // WritePhiave_W_Protocol(activeType,fullPath,dialog) |
---|
2458 | V_fWrite1DAnnular("root:Packages:NIST:VSANS:",activeType,detGroup,newFileName+".phi") |
---|
2459 | Print "data written to: "+ newFileName+".phi" |
---|
2460 | |
---|
2461 | break |
---|
2462 | case "2D_ASCII": |
---|
2463 | // Fast2DExport(activeType,fullPath,dialog) |
---|
2464 | break |
---|
2465 | case "QxQy_ASCII": |
---|
2466 | // QxQy_Export(activeType,fullPath,dialog) |
---|
2467 | break |
---|
2468 | case "PNG_Graphic": |
---|
2469 | // SaveAsPNG(activeType,fullpath,dialog) |
---|
2470 | break |
---|
2471 | case "Circular": //in SANS, this was the default, but is dangerous, so make it explicit here |
---|
2472 | // if (useXMLOutput == 1) |
---|
2473 | // WriteXMLWaves_W_Protocol(activeType,fullPath,dialog) |
---|
2474 | // else |
---|
2475 | // WriteWaves_W_Protocol(activeType,fullpath,dialog) |
---|
2476 | // endif |
---|
2477 | // |
---|
2478 | // x- get the trim strings from somewhere-- from the file or from the protocol?? |
---|
2479 | // then replace the null strings being passed |
---|
2480 | |
---|
2481 | if(cmpstr(saveType,"Yes - Concatenate")==0) |
---|
2482 | V_Trim1DDataStr(activeType,binType,prot[7],prot[8]) // x- passing null strings uses global or default trim values |
---|
2483 | |
---|
2484 | V_ConcatenateForSave("root:Packages:NIST:VSANS:",activeType,"",binType) // this removes q=0 point, concatenates, sorts |
---|
2485 | V_Write1DData("root:Packages:NIST:VSANS:",activeType,newFileName+"."+exten) //don't pass the full path, just the name |
---|
2486 | else |
---|
2487 | // remove the q=0 point from the back detector, if it's there |
---|
2488 | // does not trim any of the data |
---|
2489 | V_RemoveQ0_B(activeType) |
---|
2490 | V_Write1DData_ITX("root:Packages:NIST:VSANS:",activeType,newFileName,binType) |
---|
2491 | endif |
---|
2492 | Print "data written to: "+ newFileName+"."+exten |
---|
2493 | |
---|
2494 | break |
---|
2495 | default: |
---|
2496 | DoAlert 0, "av_type not found in dispatch to write file" |
---|
2497 | |
---|
2498 | endswitch |
---|
2499 | |
---|
2500 | Endif |
---|
2501 | |
---|
2502 | //done with everything in protocol list |
---|
2503 | |
---|
2504 | |
---|
2505 | // reset any global preferences that I had changed |
---|
2506 | gDoDIVCor = saved_gDoDIVCor |
---|
2507 | |
---|
2508 | |
---|
2509 | Return(0) |
---|
2510 | End |
---|
2511 | |
---|
2512 | |
---|
2513 | |
---|
2514 | |
---|
2515 | |
---|
2516 | //missing parameter dialog to solicit the 4 absolute intensity parameters |
---|
2517 | //from the user |
---|
2518 | //values are passed back as a global string variable (keyword=value) |
---|
2519 | // |
---|
2520 | Proc V_AskForAbsoluteParams(c2,c3,c4,c5,I_err) |
---|
2521 | Variable c2=1,c3=1,c4=1e8,c5=1,I_err=1 |
---|
2522 | Prompt c2, "Standard Transmission" |
---|
2523 | Prompt c3, "Standard Thickness (cm)" |
---|
2524 | Prompt c4, "I(0) from standard fit (normalized to 1E8 monitor cts)" |
---|
2525 | Prompt c5, "Standard Cross-Section (cm-1)" |
---|
2526 | Prompt I_err, "error in I(q=0) (one std dev)" |
---|
2527 | |
---|
2528 | String/G root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr="" |
---|
2529 | |
---|
2530 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr = "TSTAND="+num2str(c2) |
---|
2531 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "DSTAND="+num2str(c3) |
---|
2532 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "IZERO="+num2str(c4) |
---|
2533 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "XSECT="+num2str(c5) |
---|
2534 | root:Packages:NIST:VSANS:Globals:Protocols:gAbsStr += ";" + "SDEV="+num2str(I_err) |
---|
2535 | |
---|
2536 | End |
---|
2537 | |
---|
2538 | |
---|
2539 | // |
---|
2540 | // DONE |
---|
2541 | // x- fill in all of the functionality for calculation from direct beam |
---|
2542 | // and verify that the calculations are numerically correct |
---|
2543 | // |
---|
2544 | //asks the user for absolute scaling information. the user can either |
---|
2545 | //enter the necessary values in manually (missing parameter dialog) |
---|
2546 | //or the user can select an empty beam file from a standard open dialog |
---|
2547 | //if an empty beam file is selected, the "kappa" value is automatically calculated |
---|
2548 | //in either case, the global keyword=value string is set. |
---|
2549 | // |
---|
2550 | Function V_AskForAbsoluteParams_Quest() |
---|
2551 | |
---|
2552 | Variable err,loc,refnum |
---|
2553 | |
---|
2554 | Variable ii |
---|
2555 | |
---|
2556 | Variable kappa=1 |
---|
2557 | Variable kappa_err |
---|
2558 | |
---|
2559 | //get the necessary variables for the calculation of kappa |
---|
2560 | Variable countTime,monCnt,sdd,pixel_x,pixel_y |
---|
2561 | String detStr,junkStr,errStr |
---|
2562 | |
---|
2563 | Variable empAttenFactor, emp_atten_err |
---|
2564 | |
---|
2565 | //get the XY box and files |
---|
2566 | Variable x1,x2,y1,y2,emptyCts,empty_ct_err |
---|
2567 | String emptyFileName,tempStr,divFileName,detPanel_toSum |
---|
2568 | |
---|
2569 | //ask user if he wants to use a transmision file for absolute scaling |
---|
2570 | //or if he wants to enter his own information |
---|
2571 | err = V_UseStdOrEmpForABS() |
---|
2572 | //DoAlert 1,"<Yes> to enter your own values, <No> to select an empty beam flux file" |
---|
2573 | If ( err==1 ) |
---|
2574 | //secondary standard selected, prompt for values |
---|
2575 | Execute "V_AskForAbsoluteParams()" //missing parameters |
---|
2576 | else |
---|
2577 | //empty beam flux file selected, prompt for file, and use this to calculate KAPPA |
---|
2578 | |
---|
2579 | // DONE |
---|
2580 | // x- need an empty beam file name |
---|
2581 | // |
---|
2582 | Prompt emptyFileName,"Empty Beam File",popup,V_PickEMPBeamButton("") |
---|
2583 | DoPrompt "Select File",emptyFileName |
---|
2584 | if (V_Flag) |
---|
2585 | return 0 // user canceled |
---|
2586 | endif |
---|
2587 | |
---|
2588 | // DONE |
---|
2589 | // x- need panel |
---|
2590 | // x- now, look for the value in the file, if not there, ask |
---|
2591 | |
---|
2592 | detPanel_toSum = V_getReduction_BoxPanel(emptyFileName) |
---|
2593 | if(strlen(detPanel_toSum) > 2) |
---|
2594 | // it's the error message |
---|
2595 | Prompt detPanel_toSum,"Panel with Direct Beam",popup,ksDetectorListAll |
---|
2596 | DoPrompt "Select Panel",detPanel_toSum |
---|
2597 | if (V_Flag) |
---|
2598 | return 0 // user canceled |
---|
2599 | endif |
---|
2600 | endif |
---|
2601 | |
---|
2602 | //need the detector sensitivity file - make a guess, allow to override |
---|
2603 | Prompt divFileName,"DIV File",popup,V_GetDIVList() |
---|
2604 | DoPrompt "Select File",divFileName |
---|
2605 | if (V_Flag) |
---|
2606 | return 0 // user canceled |
---|
2607 | endif |
---|
2608 | V_LoadHDF5Data(divFileName,"DIV") |
---|
2609 | |
---|
2610 | |
---|
2611 | WAVE xyBoxW = V_getBoxCoordinates(emptyFileName) |
---|
2612 | |
---|
2613 | |
---|
2614 | // load in the data, and use all of the corrections, especially DIV |
---|
2615 | // (be sure the corrections are actually set to "on", don't assume that they are) |
---|
2616 | // save preferences for file loading |
---|
2617 | Variable savDivPref,savSAPref |
---|
2618 | NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor |
---|
2619 | savDivPref = gDoDIVCor |
---|
2620 | NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor |
---|
2621 | savSAPref = gDoSolidAngleCor |
---|
2622 | |
---|
2623 | // set local preferences |
---|
2624 | gDoDIVCor = 1 |
---|
2625 | gDoSolidAngleCor = 1 |
---|
2626 | |
---|
2627 | V_LoadAndPlotRAW_wName(emptyFileName) |
---|
2628 | // convert raw->SAM |
---|
2629 | // V_Raw_to_work("SAM") |
---|
2630 | // V_UpdateDisplayInformation("SAM") |
---|
2631 | V_UpdateDisplayInformation("RAW") |
---|
2632 | |
---|
2633 | // do the DIV correction |
---|
2634 | if (gDoDIVCor == 1) |
---|
2635 | // need extra check here for file existence |
---|
2636 | // if not in DIV folder, load. |
---|
2637 | // if unable to load, skip correction and report error (Alert?) (Ask to Load?) |
---|
2638 | Print "Doing DIV correction"// for "+ detStr |
---|
2639 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
2640 | detStr = StringFromList(ii, ksDetectorListAll, ";") |
---|
2641 | Wave w = V_getDetectorDataW("RAW",detStr) |
---|
2642 | Wave w_err = V_getDetectorDataErrW("RAW",detStr) |
---|
2643 | |
---|
2644 | V_DIVCorrection(w,w_err,detStr,"RAW") // do the correction in-place |
---|
2645 | endfor |
---|
2646 | else |
---|
2647 | Print "DIV correction NOT DONE" // not an error since correction was unchecked |
---|
2648 | endif |
---|
2649 | |
---|
2650 | // and determine box sum and error |
---|
2651 | // store these locally |
---|
2652 | |
---|
2653 | |
---|
2654 | // x- need to get the panel string for the sum. |
---|
2655 | // x- the detector string is currently hard-wired |
---|
2656 | // detStr = "MR" |
---|
2657 | |
---|
2658 | emptyCts = V_SumCountsInBox(xyBoxW[0],xyBoxW[1],xyBoxW[2],xyBoxW[3],empty_ct_err,"RAW",detPanel_toSum) |
---|
2659 | |
---|
2660 | Print "empty counts = ",emptyCts |
---|
2661 | Print "empty err/counts = ",empty_ct_err/emptyCts |
---|
2662 | |
---|
2663 | // |
---|
2664 | // x- get all of the proper values for the calculation |
---|
2665 | // -x currently the attenuation is incorrect |
---|
2666 | // such that kappa_err = 1*kappa |
---|
2667 | // x- verify the calculation (no solid angle needed??) |
---|
2668 | |
---|
2669 | // get the attenuation factor for the empty beam |
---|
2670 | // -- the attenuation is not written by NICE to the file |
---|
2671 | // so I need to calculate it myself from the tables |
---|
2672 | // |
---|
2673 | // empAttenFactor = V_getAttenuator_transmission(emptyFileName) |
---|
2674 | // emp_atten_err = V_getAttenuator_trans_err(emptyFileName) |
---|
2675 | empAttenFactor = V_CalculateAttenuationFactor(emptyFileName) |
---|
2676 | emp_atten_err = V_CalculateAttenuationError(emptyFileName) |
---|
2677 | |
---|
2678 | countTime = V_getCount_time(emptyFileName) |
---|
2679 | |
---|
2680 | // TODO |
---|
2681 | // -- not sure if this is the correct monitor count to use |
---|
2682 | monCnt = V_getBeamMonNormData("RAW") |
---|
2683 | |
---|
2684 | pixel_x = V_getDet_x_pixel_size("RAW",detPanel_toSum) |
---|
2685 | pixel_x /= 10 //convert mm to cm, since sdd in cm |
---|
2686 | pixel_y = V_getDet_y_pixel_size("RAW",detPanel_toSum) |
---|
2687 | pixel_y /= 10 //convert mm to cm, since sdd in cm |
---|
2688 | sdd = V_getDet_ActualDistance("RAW",detPanel_toSum) |
---|
2689 | |
---|
2690 | // kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime)*(pixel_x*pixel_y/sdd^2) |
---|
2691 | kappa = emptyCts/countTime/empAttenFactor*1.0e8/(monCnt/countTime) |
---|
2692 | |
---|
2693 | |
---|
2694 | kappa_err = (empty_ct_err/emptyCts)^2 + (emp_atten_err/empAttenFactor)^2 |
---|
2695 | kappa_err = sqrt(kappa_err) * kappa |
---|
2696 | |
---|
2697 | // x- set the parameters in the global string |
---|
2698 | junkStr = num2str(kappa) |
---|
2699 | errStr = num2Str(kappa_err) |
---|
2700 | Execute "V_AskForAbsoluteParams(1,1,"+junkStr+",1,"+errStr+")" //no missing parameters, no dialog |
---|
2701 | |
---|
2702 | |
---|
2703 | Printf "Kappa was successfully calculated as = %g +/- %g (%g %)\r",kappa,kappa_err,(kappa_err/kappa)*100 |
---|
2704 | |
---|
2705 | // restore preferences on exit |
---|
2706 | gDoDIVCor = savDivPref |
---|
2707 | gDoSolidAngleCor = savSAPref |
---|
2708 | |
---|
2709 | Endif |
---|
2710 | |
---|
2711 | End |
---|
2712 | |
---|
2713 | Function V_UserSelectBox_Continue(ctrlName) :buttonControl |
---|
2714 | String ctrlName |
---|
2715 | |
---|
2716 | DoWindow/K junkWindow //kill panel |
---|
2717 | end |
---|
2718 | |
---|
2719 | Function V_SelectABS_XYBox(x1,x2,y1,y2) |
---|
2720 | Variable &x1,&x2,&y1,&y2 |
---|
2721 | |
---|
2722 | Variable err=0 |
---|
2723 | |
---|
2724 | Variable/G root:V_marquee=1 //sets the sneaky bit to automatically update marquee coords |
---|
2725 | Variable/G root:V_left,root:V_right,root:V_bottom,root:V_top //must be global for auto-update |
---|
2726 | DoWindow/F SANS_Data |
---|
2727 | NewPanel/K=2 /W=(139,341,382,432) as "Select the primary beam" |
---|
2728 | DoWindow/C junkWindow |
---|
2729 | AutoPositionWindow/E/M=1/R=SANS_Data |
---|
2730 | |
---|
2731 | Drawtext 21,20 ,"Select the primary beam with the" |
---|
2732 | DrawText 21,40, "marquee and press continue" |
---|
2733 | Button button0,pos={80,58},size={92,20},title="Continue" |
---|
2734 | Button button0,proc=V_UserSelectBox_Continue |
---|
2735 | |
---|
2736 | PauseForUser junkWindow,SANS_Data |
---|
2737 | |
---|
2738 | DoWindow/F SANS_Data |
---|
2739 | |
---|
2740 | //GetMarquee left,bottom //not needed |
---|
2741 | NVAR V_left=V_left |
---|
2742 | NVAR V_right=V_right |
---|
2743 | NVAR V_bottom=V_bottom |
---|
2744 | NVAR V_top=V_top |
---|
2745 | |
---|
2746 | x1 = V_left |
---|
2747 | x2 = V_right |
---|
2748 | y1 = V_bottom |
---|
2749 | y2 = V_top |
---|
2750 | // Print "new values,before rounding = ",x1,x2,y1,y2 |
---|
2751 | |
---|
2752 | // TODO -- replace this call |
---|
2753 | // KeepSelectionInBounds(x1,x2,y1,y2) |
---|
2754 | //Print "new values = ",x1,x2,y1,y2 |
---|
2755 | |
---|
2756 | KillVariables/Z root:V_Marquee,root:V_left,root:V_right,root:V_bottom,root:V_top |
---|
2757 | if((x1-x2)==0 || (y1-y2)==0) |
---|
2758 | err=1 |
---|
2759 | endif |
---|
2760 | return(err) |
---|
2761 | End |
---|
2762 | |
---|
2763 | Function V_UseStdOrEmpForABS() |
---|
2764 | |
---|
2765 | NewPanel/K=2 /W=(139,341,402,448) as "Absolute Scaling" |
---|
2766 | DoWindow/C junkABSWindow |
---|
2767 | ModifyPanel cbRGB=(57346,65535,49151) |
---|
2768 | SetDrawLayer UserBack |
---|
2769 | SetDrawEnv fstyle= 1 |
---|
2770 | DrawText 21,20,"Method of absolute calibration" |
---|
2771 | Button button0,pos={52,33},size={150,20},proc=V_UserSelectABS_Continue,title="Empty Beam Flux" |
---|
2772 | Button button1,pos={52,65},size={150,20},proc=V_UserSelectABS_Continue,title="Secondary Standard" |
---|
2773 | |
---|
2774 | PauseForUser junkABSWindow |
---|
2775 | NVAR val = root:Packages:NIST:VSANS:Globals:tmpAbsVal |
---|
2776 | return(val) |
---|
2777 | End |
---|
2778 | |
---|
2779 | //returns 0 if button0 (empty beam flux) |
---|
2780 | // or 1 if secondary standard |
---|
2781 | Function V_UserSelectABS_Continue(ctrlName) :buttonControl |
---|
2782 | String ctrlName |
---|
2783 | |
---|
2784 | variable val=0 |
---|
2785 | If(cmpstr(ctrlName,"button0")==0) |
---|
2786 | val=0 |
---|
2787 | else |
---|
2788 | val=1 |
---|
2789 | endif |
---|
2790 | // print "val = ",ctrlName,val |
---|
2791 | Variable/G root:Packages:NIST:VSANS:Globals:tmpAbsVal = val |
---|
2792 | DoWindow/K junkABSWindow //kill panel |
---|
2793 | return(0) |
---|
2794 | end |
---|
2795 | |
---|
2796 | |
---|
2797 | Function V_TrimDataProtoButton(ctrlName) :buttonControl |
---|
2798 | String ctrlName |
---|
2799 | |
---|
2800 | Execute "V_CombineDataGraph()" |
---|
2801 | return(0) |
---|
2802 | end |
---|
2803 | |
---|
2804 | // |
---|
2805 | // export protocol to a data file |
---|
2806 | // |
---|
2807 | // |
---|
2808 | Function V_ExportFileProtocol(ctrlName) : ButtonControl |
---|
2809 | String ctrlName |
---|
2810 | // get a list of protocols |
---|
2811 | String Protocol="" |
---|
2812 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
2813 | Prompt Protocol "Pick A Protocol",popup, V_DeletableProtocols() |
---|
2814 | DoPrompt "Pick A Protocol to Export",Protocol |
---|
2815 | if(V_flag==1) |
---|
2816 | //Print "user cancel" |
---|
2817 | SetDatafolder root: |
---|
2818 | return(1) |
---|
2819 | endif |
---|
2820 | |
---|
2821 | String fileName = V_DoSaveFileDialog("pick the file to write to") |
---|
2822 | print fileName |
---|
2823 | // |
---|
2824 | if(strlen(fileName) == 0) |
---|
2825 | return(0) |
---|
2826 | endif |
---|
2827 | |
---|
2828 | V_writeReductionProtocolWave(fileName,$("root:Packages:NIST:VSANS:Globals:Protocols:"+Protocol) ) |
---|
2829 | |
---|
2830 | setDataFolder root: |
---|
2831 | return(0) |
---|
2832 | |
---|
2833 | End |
---|
2834 | |
---|
2835 | // |
---|
2836 | // imports a protocol from a file on disk into the protocols folder |
---|
2837 | // |
---|
2838 | // |
---|
2839 | Function V_ImportFileProtocol(ctrlName) : ButtonControl |
---|
2840 | String ctrlName |
---|
2841 | |
---|
2842 | // SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
2843 | |
---|
2844 | String fullPath,fileName |
---|
2845 | fullPath = DoOpenFileDialog("Import Protocol from file") |
---|
2846 | print fullPath |
---|
2847 | // |
---|
2848 | if(strlen(fullPath) == 0) |
---|
2849 | return(0) |
---|
2850 | endif |
---|
2851 | |
---|
2852 | fileName = ParseFilePath(0, fullPath, ":", 1, 0) //just the file name at the end of the full path |
---|
2853 | |
---|
2854 | Wave/T tmpW = V_getReductionProtocolWave(fileName) |
---|
2855 | if(numpnts(tmpW) == 0) |
---|
2856 | DoAlert 0,"No protocol wave has been saved to this data file" |
---|
2857 | return(0) |
---|
2858 | endif |
---|
2859 | |
---|
2860 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
2861 | String newName |
---|
2862 | newName = CleanupName(fileName,0) + "_proto" |
---|
2863 | duplicate/o tmpw $newName |
---|
2864 | |
---|
2865 | |
---|
2866 | SetDataFolder root: |
---|
2867 | return(0) |
---|
2868 | end |
---|
2869 | |
---|
2870 | |
---|
2871 | // currently not used - and not updated to 12 point protocols (5/2017) |
---|
2872 | // |
---|
2873 | //save the protocol as an IGOR text wave (.itx) |
---|
2874 | // |
---|
2875 | // |
---|
2876 | Function V_ExportProtocol(ctrlName) : ButtonControl |
---|
2877 | String ctrlName |
---|
2878 | // get a list of protocols |
---|
2879 | String Protocol="" |
---|
2880 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
2881 | Prompt Protocol "Pick A Protocol",popup, WaveList("*",";","") |
---|
2882 | DoPrompt "Pick A Protocol to Export",Protocol |
---|
2883 | if(V_flag==1) |
---|
2884 | //Print "user cancel" |
---|
2885 | SetDatafolder root: |
---|
2886 | return(1) |
---|
2887 | endif |
---|
2888 | //get the selection, or exit |
---|
2889 | Wave/T pW= $protocol |
---|
2890 | Make/O/T/N=13 tw |
---|
2891 | // save in the proper format (must write manually, for demo version) |
---|
2892 | tw[0] = "IGOR" |
---|
2893 | tw[1] = "WAVES/T \t"+protocol |
---|
2894 | tw[2] = "BEGIN" |
---|
2895 | tw[3,10] = "\t\""+pW[p-3]+"\"" |
---|
2896 | tw[11] = "END" |
---|
2897 | tw[12] = "X SetScale/P x 0,1,\"\","+protocol+"; SetScale y 0,0,\"\","+protocol |
---|
2898 | |
---|
2899 | Variable refnum |
---|
2900 | String fullPath |
---|
2901 | |
---|
2902 | PathInfo/S catPathName |
---|
2903 | fullPath = DoSaveFileDialog("Export Protocol as",fname=Protocol,suffix="") |
---|
2904 | If(cmpstr(fullPath,"")==0) |
---|
2905 | //user cancel, don't write out a file |
---|
2906 | Close/A |
---|
2907 | Abort "no Protocol file was written" |
---|
2908 | Endif |
---|
2909 | |
---|
2910 | //actually open the file |
---|
2911 | Open refNum as fullpath+".itx" |
---|
2912 | |
---|
2913 | wfprintf refnum, "%s\r", tw |
---|
2914 | Close refnum |
---|
2915 | //Print "all is well ",protocol |
---|
2916 | KillWaves/Z tw |
---|
2917 | setDataFolder root: |
---|
2918 | return(0) |
---|
2919 | |
---|
2920 | End |
---|
2921 | |
---|
2922 | |
---|
2923 | // currently not used - and not updated to 12 point protocols (5/2017) |
---|
2924 | //imports a protocol from disk into the protocols folder |
---|
2925 | // |
---|
2926 | // will overwrite existing protocols if necessary |
---|
2927 | // |
---|
2928 | // |
---|
2929 | Function V_ImportProtocol(ctrlName) : ButtonControl |
---|
2930 | String ctrlName |
---|
2931 | |
---|
2932 | SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols |
---|
2933 | |
---|
2934 | String fullPath |
---|
2935 | |
---|
2936 | PathInfo/S catPathName |
---|
2937 | fullPath = DoOpenFileDialog("Import Protocol") |
---|
2938 | If(cmpstr(fullPath,"")==0) |
---|
2939 | //user cancel, don't write out a file |
---|
2940 | Close/A |
---|
2941 | Abort "no protocol was loaded" |
---|
2942 | Endif |
---|
2943 | |
---|
2944 | LoadWave/O/T fullPath |
---|
2945 | |
---|
2946 | SetDataFolder root: |
---|
2947 | return(0) |
---|
2948 | end |
---|