1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=4.00 |
---|
3 | #pragma IgorVersion=6.1 |
---|
4 | |
---|
5 | // This is to be used with the Analysis packages ONLY |
---|
6 | // there are a number of utility procedures here for loading |
---|
7 | // data and generating valid lists of data files that are |
---|
8 | // directly copied from the Reduction package |
---|
9 | // -- There WILL be name conflicts if you mix the two... |
---|
10 | // |
---|
11 | // 16 DEC 05 SRK |
---|
12 | // prepended function names with A_ to tag them for the |
---|
13 | // "A"nalysis parckage, though nearly all are duplicate procedures |
---|
14 | // so there will be no overlap with the reduction package |
---|
15 | // |
---|
16 | // |
---|
17 | // these extra procedures are used by: |
---|
18 | // Linearized fits (duplicated in Reduction - will need to handle gently) |
---|
19 | // Invariant (no overlap with reduction) |
---|
20 | // |
---|
21 | // SRK MAR 2005 |
---|
22 | |
---|
23 | // create a KW=string; of model=coef correspondence as the models are plotted, rather than |
---|
24 | // some other hard-wired solution |
---|
25 | Function AddModelToStrings(funcStr,coefStr,paramStr,suffix) |
---|
26 | String funcStr,coefStr,paramStr,suffix |
---|
27 | |
---|
28 | if(exists("root:Packages:NIST:paramKWStr")==0) |
---|
29 | String/G root:Packages:NIST:coefKWStr="" |
---|
30 | String/G root:Packages:NIST:paramKWStr="" |
---|
31 | String/G root:Packages:NIST:suffixKWStr="" |
---|
32 | endif |
---|
33 | SVAR coefKWStr = root:Packages:NIST:coefKWStr |
---|
34 | SVAR paramKWStr = root:Packages:NIST:paramKWStr |
---|
35 | SVAR suffixKWStr = root:Packages:NIST:suffixKWStr |
---|
36 | coefKWStr += funcStr+"="+coefStr+";" |
---|
37 | paramKWStr += funcStr+"="+paramStr+";" |
---|
38 | suffixKWStr += funcStr+"="+suffix+";" |
---|
39 | end |
---|
40 | |
---|
41 | // always pass this the function string |
---|
42 | // |
---|
43 | // this is new in the 2009 release, so make sure that it generates itself as needed. |
---|
44 | // Two options: (1) search and construct as needed, ask for intervention if I need it. |
---|
45 | // (2) since I'm passed the function, try to replot it to re-run the function |
---|
46 | // to fill in the strings. (Being sure to save the coefficients) |
---|
47 | // |
---|
48 | // using method (1) to fill in what I need with no intervention |
---|
49 | // |
---|
50 | Function/S getFunctionParams(funcStr) |
---|
51 | String funcStr |
---|
52 | |
---|
53 | String paramStr="" |
---|
54 | SVAR/Z listStr=root:Packages:NIST:paramKWStr |
---|
55 | |
---|
56 | if(SVAR_Exists(listStr)) |
---|
57 | paramStr = StringByKey(funcStr, listStr ,"=",";",0) |
---|
58 | if(strlen(paramStr)!=0) //will drop out of loop if string can't be found |
---|
59 | return(paramStr) |
---|
60 | endif |
---|
61 | else //global string does not exist, create it and fill it in |
---|
62 | Variable/G root:Pacakges:NIST:gReconstructStrings = 1 //coefficients old style and must be rebuilt too |
---|
63 | String/G root:Packages:NIST:paramKWStr="" |
---|
64 | SVAR/Z listStr=root:Packages:NIST:paramKWStr |
---|
65 | endif |
---|
66 | |
---|
67 | // find everything to rebuild only if the model has been plotted (if so, coefficients will exist) |
---|
68 | String coef = getFunctionCoef(funcStr) |
---|
69 | if(strlen(coef)==0) |
---|
70 | //model not plotted, don't reconstruct, return null string |
---|
71 | return(paramStr) |
---|
72 | endif |
---|
73 | |
---|
74 | ///// NEED TO BE IN PROPER DATA FOLDER FOR SMEARED FUNCTIONS |
---|
75 | // FUNCTION POP MENU WILL LOOK IN ROOT OTHERWISE |
---|
76 | ControlInfo/W=WrapperPanel popup_0 |
---|
77 | String folderStr=S_Value |
---|
78 | // this if/else/endif should not ever return an error alert |
---|
79 | // it should simply set the data folder properly |
---|
80 | if(Stringmatch(funcStr,"Smear*")) //simple test for smeared function |
---|
81 | if(DataFolderExists("root:"+folderStr)) |
---|
82 | SetDataFolder $("root:"+folderStr) |
---|
83 | else |
---|
84 | SetDataFolder root: |
---|
85 | endif |
---|
86 | else |
---|
87 | SetDataFolder root: |
---|
88 | endif |
---|
89 | |
---|
90 | // model was plotted, find the suffix to fill in the parameter wave |
---|
91 | SVAR suffListStr=root:Packages:NIST:suffixKWStr |
---|
92 | String suffix = StringByKey(coef, suffListStr ,"=",";",0) |
---|
93 | |
---|
94 | String paramWave = WaveList("*par*"+suffix,"","TEXT:1") //should be one wave name, no trailing semicolon |
---|
95 | listStr += funcStr+"="+paramWave+";" |
---|
96 | |
---|
97 | //now look it up again |
---|
98 | paramStr = StringByKey(funcStr, listStr ,"=",";",0) |
---|
99 | |
---|
100 | return(paramStr) |
---|
101 | End |
---|
102 | |
---|
103 | // always pass this the function string |
---|
104 | // |
---|
105 | Function/S getFunctionCoef(funcStr) |
---|
106 | String funcStr |
---|
107 | |
---|
108 | SVAR listStr=root:Packages:NIST:coefKWStr |
---|
109 | String coefStr = StringByKey(funcStr, listStr ,"=",";",0) |
---|
110 | |
---|
111 | return(coefStr) |
---|
112 | End |
---|
113 | |
---|
114 | // always pass this the Function string |
---|
115 | // |
---|
116 | // does NOT return the leading "_" as part of the suffix |
---|
117 | // may need to set the string correctly - so lost of messing around for back-compatibility |
---|
118 | Function/S getModelSuffix(funcStr) |
---|
119 | String funcStr |
---|
120 | |
---|
121 | SVAR listStr=root:Packages:NIST:suffixKWStr |
---|
122 | String suffixStr = StringByKey(funcStr, listStr ,"=",";",0) |
---|
123 | |
---|
124 | if(strlen(suffixStr) !=0) //found it, get out |
---|
125 | return(suffixStr) |
---|
126 | endif |
---|
127 | |
---|
128 | // was the model plotted? |
---|
129 | String coef = getFunctionCoef(funcStr) |
---|
130 | if(strlen(coef)==0) |
---|
131 | //nothing plotted |
---|
132 | return("") |
---|
133 | else |
---|
134 | //plotted, find the coeff |
---|
135 | String suffix = StringByKey(coef, ListStr ,"=",";",0) |
---|
136 | |
---|
137 | // add to the suffix list in the new style, if it was found |
---|
138 | if(strlen(suffix) !=0) |
---|
139 | listStr += funcStr+"="+suffix+";" |
---|
140 | endif |
---|
141 | return(suffix) |
---|
142 | endif |
---|
143 | |
---|
144 | return("") |
---|
145 | End |
---|
146 | |
---|
147 | |
---|
148 | ///////////////////////////// |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | // loads a 1-d (ascii) datafile and plots the data |
---|
154 | // will overwrite existing data if user is OK with this |
---|
155 | // - multiple datasets can be automatically plotted on the same graph |
---|
156 | // |
---|
157 | //substantially easier to write this as a Proc rather than a function... |
---|
158 | |
---|
159 | // |
---|
160 | Proc A_LoadOneDData() |
---|
161 | A_LoadOneDDataWithName("",1) //will prompt for file and plot data |
---|
162 | End |
---|
163 | |
---|
164 | // load the data specified by fileStr (a full path:name) |
---|
165 | // and plots if doPlot==1 |
---|
166 | // if fileStr is null, a dialog is presented to select the file |
---|
167 | // |
---|
168 | // 3 cases (if) |
---|
169 | // - 3 columns = QIS, no resolution |
---|
170 | // - 6 columns = QSIG, SANS w/resolution |
---|
171 | // - 5 columns = old-style desmeared USANS data (from VAX) |
---|
172 | // |
---|
173 | // This loader replaces the A_LoadOneDData() which was almost completely duplicated code |
---|
174 | // |
---|
175 | //new version, 19JUN07 that loads each data set into a separate data folder |
---|
176 | // the data folder is given the "base name" of the data file as it's loaded |
---|
177 | // |
---|
178 | |
---|
179 | Proc A_LoadOneDDataWithName(fileStr,doPlot) |
---|
180 | String fileStr |
---|
181 | Variable doPlot |
---|
182 | |
---|
183 | A_LoadOneDDataToName(fileStr,"",doPlot,0) |
---|
184 | |
---|
185 | End |
---|
186 | |
---|
187 | |
---|
188 | ///Function that takes output name as well as input |
---|
189 | Proc A_LoadOneDDataToName(fileStr,outStr,doPlot,forceOverwrite) |
---|
190 | String fileStr, outstr |
---|
191 | Variable doPlot,forceOverwrite |
---|
192 | |
---|
193 | Variable rr,gg,bb,refnum,dQv |
---|
194 | String w0,w1,w2,n0,n1,n2 |
---|
195 | String w3,w4,w5,n3,n4,n5 //3 extra waves to load |
---|
196 | SetDataFolder root: //build sub-folders for each data set under root |
---|
197 | |
---|
198 | // I can't see that we need to find dQv here. |
---|
199 | // if (exists("root:Packages:NIST:USANS:Globals:MainPanel:gDQv")) |
---|
200 | // //Running from USANS reduction |
---|
201 | // Variable dQv = root:Packages:NIST:USANS:Globals:MainPanel:gDQv |
---|
202 | // endif |
---|
203 | // if(exists("root:Packages:NIST:USANS_dQv")) |
---|
204 | // //Running from SANS Analysis |
---|
205 | // Variable dQv = root:Packages:NIST:USANS_dQv |
---|
206 | // else |
---|
207 | // //running from somewhere else, probably SANS Reduction, which uses common loaders |
---|
208 | // Variable/G root:Packages:NIST:USANS_dQv = 0.117 |
---|
209 | // endif |
---|
210 | String angst = StrVarOrDefault("root:Packages:NIST:gAngstStr", "A" ) |
---|
211 | |
---|
212 | // if no fileStr passed in, display dialog now |
---|
213 | if (cmpStr(fileStr,"") == 0) |
---|
214 | fileStr = DoOpenFileDialog("Select a data file to load") |
---|
215 | if (cmpstr(fileStr,"") == 0) |
---|
216 | String/G root:Packages:NIST:gLastFileName = "" |
---|
217 | return //get out if no file selected |
---|
218 | endif |
---|
219 | endif |
---|
220 | |
---|
221 | if (isXML(fileStr) == 1) |
---|
222 | LoadNISTXMLData(fileStr,outstr,doPlot,forceOverwrite) |
---|
223 | else |
---|
224 | //Load the waves, using default waveX names |
---|
225 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
226 | LoadWave/G/D/A/Q fileStr |
---|
227 | String fileNamePath = S_Path+S_fileName |
---|
228 | // String basestr = ParseFilePath(3,ParseFilePath(5,fileNamePath,":",0,0),":",0,0) |
---|
229 | |
---|
230 | String basestr |
---|
231 | if (!cmpstr(outstr, "")) //Outstr = "", cmpstr returns 0 |
---|
232 | // enforce a short enough name here to keep Igor objects < 31 chars |
---|
233 | baseStr = ShortFileNameString(CleanupName(S_fileName,0)) |
---|
234 | baseStr = CleanupName(baseStr,0) //in case the user added odd characters |
---|
235 | //baseStr = CleanupName(S_fileName,0) |
---|
236 | else |
---|
237 | baseStr = outstr //for output, hopefully correct length as passed in |
---|
238 | endif |
---|
239 | |
---|
240 | // print "basestr :"+basestr |
---|
241 | String fileName = ParseFilePath(0,ParseFilePath(5,filestr,":",0,0),":",1,0) |
---|
242 | // print "filename :"+filename |
---|
243 | Variable numCols = V_flag |
---|
244 | |
---|
245 | //changes JIL to allow 2-column data to be read in, "faking" a 3rd column of errors |
---|
246 | if(numCols==2) //no errors |
---|
247 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
248 | Duplicate/O $("root:"+n1), errorTmp |
---|
249 | errorTmp = 0.01*(errorTmp)+ 0.03*sqrt(errorTmp) |
---|
250 | S_waveNames+="errorTmp;" |
---|
251 | numCols=3 |
---|
252 | endif |
---|
253 | |
---|
254 | if(numCols==3) //simple 3-column data with no resolution information |
---|
255 | |
---|
256 | // put the names of the three loaded waves into local names |
---|
257 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
258 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
259 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
260 | |
---|
261 | //remove the semicolon AND period from files from the VAX |
---|
262 | w0 = CleanupName((basestr + "_q"),0) |
---|
263 | w1 = CleanupName((basestr + "_i"),0) |
---|
264 | w2 = CleanupName((basestr + "_s"),0) |
---|
265 | |
---|
266 | //String baseStr=w1[0,strlen(w1)-3] |
---|
267 | if(DataFolderExists("root:"+baseStr)) |
---|
268 | if (!forceOverwrite) |
---|
269 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
270 | if(V_flag==2) //user selected No, don't load the data |
---|
271 | SetDataFolder root: |
---|
272 | KillWaves $n0,$n1,$n2 // kill the default waveX that were loaded |
---|
273 | if(DataFolderExists("root:Packages:NIST")) |
---|
274 | String/G root:Packages:NIST:gLastFileName = filename |
---|
275 | endif |
---|
276 | return //quits the macro |
---|
277 | endif |
---|
278 | endif |
---|
279 | SetDataFolder $("root:"+baseStr) |
---|
280 | else |
---|
281 | NewDataFolder/S $("root:"+baseStr) |
---|
282 | endif |
---|
283 | |
---|
284 | |
---|
285 | ////overwrite the existing data, if it exists |
---|
286 | Duplicate/O $("root:"+n0), $w0 |
---|
287 | Duplicate/O $("root:"+n1), $w1 |
---|
288 | Duplicate/O $("root:"+n2), $w2 |
---|
289 | |
---|
290 | // no resolution matrix to make |
---|
291 | |
---|
292 | SetScale d,0,0,"1/A",$w0 |
---|
293 | SetScale d,0,0,"1/cm",$w1 |
---|
294 | |
---|
295 | endif //3-col data |
---|
296 | |
---|
297 | if(numCols == 6) //6-column SANS or USANS data that has resolution information |
---|
298 | |
---|
299 | // put the names of the (default named) loaded waves into local names |
---|
300 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
301 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
302 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
303 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
304 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
305 | n5 = StringFromList(5, S_waveNames ,";" ) |
---|
306 | |
---|
307 | //remove the semicolon AND period from files from the VAX |
---|
308 | w0 = CleanupName((basestr + "_q"),0) |
---|
309 | w1 = CleanupName((basestr + "_i"),0) |
---|
310 | w2 = CleanupName((basestr + "_s"),0) |
---|
311 | w3 = CleanupName((basestr + "sq"),0) |
---|
312 | w4 = CleanupName((basestr + "qb"),0) |
---|
313 | w5 = CleanupName((basestr + "fs"),0) |
---|
314 | |
---|
315 | //String baseStr=w1[0,strlen(w1)-3] |
---|
316 | if(DataFolderExists("root:"+baseStr)) |
---|
317 | if(!forceOverwrite) |
---|
318 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
319 | if(V_flag==2) //user selected No, don't load the data |
---|
320 | SetDataFolder root: |
---|
321 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 // kill the default waveX that were loaded |
---|
322 | if(DataFolderExists("root:Packages:NIST")) |
---|
323 | String/G root:Packages:NIST:gLastFileName = filename |
---|
324 | endif |
---|
325 | return //quits the macro |
---|
326 | endif |
---|
327 | endif |
---|
328 | SetDataFolder $("root:"+baseStr) |
---|
329 | else |
---|
330 | NewDataFolder/S $("root:"+baseStr) |
---|
331 | endif |
---|
332 | |
---|
333 | |
---|
334 | |
---|
335 | |
---|
336 | ////overwrite the existing data, if it exists |
---|
337 | Duplicate/O $("root:"+n0), $w0 |
---|
338 | Duplicate/O $("root:"+n1), $w1 |
---|
339 | Duplicate/O $("root:"+n2), $w2 |
---|
340 | Duplicate/O $("root:"+n3), $w3 |
---|
341 | Duplicate/O $("root:"+n4), $w4 |
---|
342 | Duplicate/O $("root:"+n5), $w5 |
---|
343 | |
---|
344 | // need to switch based on SANS/USANS |
---|
345 | if (isSANSResolution($w3[0])) //checks to see if the first point of the wave is <0] |
---|
346 | // make a resolution matrix for SANS data |
---|
347 | Variable np=numpnts($w0) |
---|
348 | Make/D/O/N=(np,4) $(baseStr+"_res") |
---|
349 | |
---|
350 | $(baseStr+"_res")[][0] = $w3[p] //sigQ |
---|
351 | $(baseStr+"_res")[][1] = $w4[p] //qBar |
---|
352 | $(baseStr+"_res")[][2] = $w5[p] //fShad |
---|
353 | $(baseStr+"_res")[][3] = $w0[p] //Qvalues |
---|
354 | else |
---|
355 | //the data is USANS data |
---|
356 | // marix calculation here, but for now, just copy the waves |
---|
357 | //$(baseStr+"_res")[][0] = $w3[p] //sigQ |
---|
358 | //$(baseStr+"_res")[][1] = $w4[p] //qBar |
---|
359 | //$(baseStr+"_res")[][2] = $w5[p] //fShad |
---|
360 | //$(baseStr+"_res")[][3] = $w0[p] //Qvalues |
---|
361 | dQv = -$w3[0] |
---|
362 | |
---|
363 | USANS_CalcWeights(baseStr,dQv) |
---|
364 | |
---|
365 | endif |
---|
366 | Killwaves/Z $w3,$w4,$w5 //get rid of the resolution waves that are in the matrix |
---|
367 | |
---|
368 | SetScale d,0,0,"1/A",$w0 |
---|
369 | SetScale d,0,0,"1/cm",$w1 |
---|
370 | |
---|
371 | endif //6-col data |
---|
372 | |
---|
373 | // Load ORNL data from Heller program |
---|
374 | if(numCols == 4) //4-column SANS or USANS data that has resolution information |
---|
375 | |
---|
376 | // put the names of the (default named) loaded waves into local names |
---|
377 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
378 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
379 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
380 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
381 | |
---|
382 | //remove the semicolon AND period from files from the VAX |
---|
383 | w0 = CleanupName((basestr + "_q"),0) |
---|
384 | w1 = CleanupName((basestr + "_i"),0) |
---|
385 | w2 = CleanupName((basestr + "_s"),0) |
---|
386 | w3 = CleanupName((basestr + "sq"),0) |
---|
387 | w4 = CleanupName((basestr + "qb"),0) |
---|
388 | w5 = CleanupName((basestr + "fs"),0) |
---|
389 | |
---|
390 | |
---|
391 | //String baseStr=w1[0,strlen(w1)-3] |
---|
392 | if(DataFolderExists("root:"+baseStr)) |
---|
393 | if(!forceOverwrite) |
---|
394 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
395 | if(V_flag==2) //user selected No, don't load the data |
---|
396 | SetDataFolder root: |
---|
397 | KillWaves $n0,$n1,$n2,$n3 // kill the default waveX that were loaded |
---|
398 | if(DataFolderExists("root:Packages:NIST")) |
---|
399 | String/G root:Packages:NIST:gLastFileName = filename |
---|
400 | endif |
---|
401 | return //quits the macro |
---|
402 | endif |
---|
403 | endif |
---|
404 | SetDataFolder $("root:"+baseStr) |
---|
405 | else |
---|
406 | NewDataFolder/S $("root:"+baseStr) |
---|
407 | endif |
---|
408 | |
---|
409 | |
---|
410 | |
---|
411 | |
---|
412 | ////overwrite the existing data, if it exists |
---|
413 | Duplicate/O $("root:"+n0), $w0 |
---|
414 | Duplicate/O $("root:"+n1), $w1 |
---|
415 | Duplicate/O $("root:"+n2), $w2 |
---|
416 | Duplicate/O $("root:"+n3), $w3 |
---|
417 | Duplicate/O $("root:"+n0), $w4 // Set qb wave to nominal measured Q values |
---|
418 | Duplicate/O $("root:"+n0), $w5 // Make wave of appropriate length |
---|
419 | $w4 = $w0 |
---|
420 | $w5 = 1 // Set all shadowfactor to 1 |
---|
421 | |
---|
422 | // need to switch based on SANS/USANS |
---|
423 | if (isSANSResolution($w3[0])) //checks to see if the first point of the wave is <0] |
---|
424 | // make a resolution matrix for SANS data |
---|
425 | Variable np=numpnts($w0) |
---|
426 | Make/D/O/N=(np,4) $(baseStr+"_res") |
---|
427 | |
---|
428 | $(baseStr+"_res")[][0] = $w3[p] //sigQ |
---|
429 | $(baseStr+"_res")[][1] = $w4[p] //qBar |
---|
430 | $(baseStr+"_res")[][2] = $w5[p] //fShad |
---|
431 | $(baseStr+"_res")[][3] = $w0[p] //Qvalues |
---|
432 | else |
---|
433 | //the data is USANS data |
---|
434 | // marix calculation here, but for now, just copy the waves |
---|
435 | //$(baseStr+"_res")[][0] = $w3[p] //sigQ |
---|
436 | //$(baseStr+"_res")[][1] = $w4[p] //qBar |
---|
437 | //$(baseStr+"_res")[][2] = $w5[p] //fShad |
---|
438 | //$(baseStr+"_res")[][3] = $w0[p] //Qvalues |
---|
439 | dQv = -$w3[0] |
---|
440 | |
---|
441 | USANS_CalcWeights(baseStr,dQv) |
---|
442 | |
---|
443 | endif |
---|
444 | Killwaves/Z $w3,$w4,$w5 //get rid of the resolution waves that are in the matrix |
---|
445 | |
---|
446 | SetScale d,0,0,"1/A",$w0 |
---|
447 | SetScale d,0,0,"1/cm",$w1 |
---|
448 | |
---|
449 | endif //4-col data |
---|
450 | |
---|
451 | |
---|
452 | if(numCols==5) //this is the "old-style" VAX desmeared data format |
---|
453 | |
---|
454 | // put the names of the three loaded waves into local names |
---|
455 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
456 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
457 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
458 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
459 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
460 | |
---|
461 | |
---|
462 | //remove the semicolon AND period from files from the VAX |
---|
463 | w0 = CleanupName((basestr+"_q"),0) |
---|
464 | w1 = CleanupName((basestr+"_i"),0) |
---|
465 | w2 = CleanupName((basestr+"_s"),0) |
---|
466 | w3 = CleanupName((basestr+"_ism"),0) |
---|
467 | w4 = CleanupName((basestr+"_fit_ism"),0) |
---|
468 | |
---|
469 | //String baseStr=w1[0,strlen(w1)-3] |
---|
470 | if(DataFolderExists("root:"+baseStr)) |
---|
471 | if(!forceOverwrite) |
---|
472 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
473 | if(V_flag==2) //user selected No, don't load the data |
---|
474 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 // kill the default waveX that were loaded |
---|
475 | if(DataFolderExists("root:Packages:NIST")) |
---|
476 | String/G root:Packages:NIST:gLastFileName = filename |
---|
477 | endif //set the last file loaded to the one NOT loaded |
---|
478 | return //quits the macro |
---|
479 | endif |
---|
480 | endif |
---|
481 | SetDataFolder $("root:"+baseStr) |
---|
482 | else |
---|
483 | NewDataFolder/S $("root:"+baseStr) |
---|
484 | endif |
---|
485 | |
---|
486 | ////overwrite the existing data, if it exists |
---|
487 | Duplicate/O $("root:"+n0), $w0 |
---|
488 | Duplicate/O $("root:"+n1), $w1 |
---|
489 | Duplicate/O $("root:"+n2), $w2 |
---|
490 | Duplicate/O $("root:"+n3), $w3 |
---|
491 | Duplicate/O $("root:"+n4), $w4 |
---|
492 | |
---|
493 | // no resolution matrix |
---|
494 | endif //5-col data |
---|
495 | |
---|
496 | ////// |
---|
497 | if(DataFolderExists("root:Packages:NIST")) |
---|
498 | String/G root:Packages:NIST:gLastFileName = filename |
---|
499 | endif |
---|
500 | |
---|
501 | |
---|
502 | //plot if desired |
---|
503 | if(doPlot) |
---|
504 | Print GetDataFolder(1) |
---|
505 | |
---|
506 | // assign colors randomly |
---|
507 | rr = abs(trunc(enoise(65535))) |
---|
508 | gg = abs(trunc(enoise(65535))) |
---|
509 | bb = abs(trunc(enoise(65535))) |
---|
510 | |
---|
511 | // if target window is a graph, and user wants to append, do so |
---|
512 | DoWindow/B Plot_Manager |
---|
513 | if(WinType("") == 1) |
---|
514 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
515 | |
---|
516 | |
---|
517 | if(V_Flag == 1) |
---|
518 | AppendToGraph $w1 vs $w0 |
---|
519 | ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb),tickUnit=1 |
---|
520 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
521 | ModifyGraph tickUnit(left)=1 |
---|
522 | else |
---|
523 | //new graph |
---|
524 | SetDataFolder $("root:"+baseStr) //sometimes I end up back in root: here, and I can't figure out why! |
---|
525 | Display $w1 vs $w0 |
---|
526 | ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 |
---|
527 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
528 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
529 | ModifyGraph tickUnit(left)=1 |
---|
530 | Label left "I(q)" |
---|
531 | Label bottom "q ("+angst+"\\S-1\\M)" |
---|
532 | Legend |
---|
533 | endif |
---|
534 | else |
---|
535 | // graph window was not target, make new one |
---|
536 | Display $w1 vs $w0 |
---|
537 | ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 |
---|
538 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
539 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
540 | ModifyGraph tickUnit(left)=1 |
---|
541 | Label left "I(q)" |
---|
542 | Label bottom "q ("+angst+"\\S-1\\M)" |
---|
543 | Legend |
---|
544 | endif |
---|
545 | endif |
---|
546 | |
---|
547 | //go back to the root folder and clean up before leaving |
---|
548 | SetDataFolder root: |
---|
549 | KillWaves/Z $n0,$n1,$n2,$n3,$n4,$n5 |
---|
550 | |
---|
551 | endif |
---|
552 | End |
---|
553 | |
---|
554 | |
---|
555 | //procedure for loading NSE data in the format (4-columns) |
---|
556 | // qvals - time - I(q,t) - dI(q,t) |
---|
557 | // |
---|
558 | // |
---|
559 | // this does NOT load the data into separate folders... |
---|
560 | // |
---|
561 | Proc A_LoadNSEData() |
---|
562 | A_LoadNSEDataWithName("",1) |
---|
563 | End |
---|
564 | |
---|
565 | Proc A_LoadNSEDataWithName(fileStr,doPlot) |
---|
566 | |
---|
567 | //Load the waves, using default waveX names |
---|
568 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
569 | LoadWave/G/D/A fileStr |
---|
570 | String filename = S_fileName |
---|
571 | |
---|
572 | String w0,w1,w2,n0,n1,n2,wt,w3,n3 |
---|
573 | Variable rr,gg,bb |
---|
574 | |
---|
575 | // put the names of the three loaded waves into local names |
---|
576 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
577 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
578 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
579 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
580 | |
---|
581 | |
---|
582 | //remove the semicolon AND period from files from the VAX |
---|
583 | w0 = CleanupName(("qvals_"+S_fileName),0) |
---|
584 | w1 = CleanupName(("time_"+S_fileName),0) |
---|
585 | w2 = CleanupName(("iqt_"+S_fileName),0) |
---|
586 | w3 = CleanupName(("iqterr_"+S_fileName),0) |
---|
587 | |
---|
588 | if(exists(w0) !=0) |
---|
589 | DoAlert 0,"This file has already been loaded. Use Append to Graph..." |
---|
590 | KillWaves $n0,$n1,$n2 // kill the default waveX that were loaded |
---|
591 | return |
---|
592 | endif |
---|
593 | |
---|
594 | // Rename to give nice names |
---|
595 | Rename $n0, $w0 |
---|
596 | Rename $n1, $w1 |
---|
597 | Rename $n2, $w2 |
---|
598 | Rename $n3, $w3 |
---|
599 | |
---|
600 | if(doPlot) |
---|
601 | // assign colors randomly |
---|
602 | rr = abs(trunc(enoise(65535))) |
---|
603 | gg = abs(trunc(enoise(65535))) |
---|
604 | bb = abs(trunc(enoise(65535))) |
---|
605 | |
---|
606 | // if target window is a graph, and user wants to append, do so |
---|
607 | if(WinType("") == 1) |
---|
608 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
609 | if(V_Flag == 1) |
---|
610 | AppendToGraph $w2 vs $w1 |
---|
611 | ModifyGraph mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2) =(rr,gg,bb),grid=1,mirror=2,tickUnit=1 |
---|
612 | ErrorBars/T=0 $w2 Y,wave=($w3,$w3) |
---|
613 | else |
---|
614 | //new graph |
---|
615 | Display $w2 vs $w1 |
---|
616 | ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 |
---|
617 | ErrorBars/T=0 $w2 Y,wave=($w3,$w3) |
---|
618 | Legend |
---|
619 | endif |
---|
620 | else |
---|
621 | // graph window was not target, make new one |
---|
622 | Display $w2 vs $w1 |
---|
623 | ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 |
---|
624 | ErrorBars/T=0 $w2 Y,wave=($w3,$w3) |
---|
625 | Legend |
---|
626 | endif |
---|
627 | endif //doPlot |
---|
628 | |
---|
629 | End |
---|
630 | |
---|
631 | //procedure for loading desmeared USANS data in the format (5-columns) |
---|
632 | // qvals - I(q) - sig I - Ism(q) - fitted Ism(q) |
---|
633 | //no weighting wave is created (not needed in IGOR 4) |
---|
634 | // |
---|
635 | // not really ever used... |
---|
636 | // |
---|
637 | Proc A_LoadUSANSData() |
---|
638 | |
---|
639 | //Load the waves, using default waveX names |
---|
640 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
641 | LoadWave/G/D/A |
---|
642 | String filename = S_fileName |
---|
643 | |
---|
644 | String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 |
---|
645 | Variable rr,gg,bb |
---|
646 | |
---|
647 | // put the names of the three loaded waves into local names |
---|
648 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
649 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
650 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
651 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
652 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
653 | |
---|
654 | |
---|
655 | //remove the semicolon AND period from files from the VAX |
---|
656 | w0 = CleanupName((S_fileName+"_q"),0) |
---|
657 | w1 = CleanupName((S_fileName+"_i"),0) |
---|
658 | w2 = CleanupName((S_fileName+"_s"),0) |
---|
659 | w3 = CleanupName((S_fileName+"_ism"),0) |
---|
660 | w4 = CleanupName((S_fileName+"_fit_ism"),0) |
---|
661 | |
---|
662 | if(exists(w0) !=0) //the wave already exists |
---|
663 | DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
664 | if(V_flag==2) //user selected No |
---|
665 | KillWaves $n0,$n1,$n2,$n3,$n4 // kill the default waveX that were loaded |
---|
666 | if(DataFolderExists("root:Packages:NIST")) |
---|
667 | String/G root:Packages:NIST:gLastFileName = filename |
---|
668 | endif //set the last file loaded to the one NOT loaded |
---|
669 | return //quits the macro |
---|
670 | endif |
---|
671 | endif |
---|
672 | |
---|
673 | ////overwrite the existing data, if it exists |
---|
674 | Duplicate/O $n0, $w0 |
---|
675 | Duplicate/O $n1, $w1 |
---|
676 | Duplicate/O $n2, $w2 |
---|
677 | Duplicate/O $n3, $w3 |
---|
678 | Duplicate/O $n4, $w4 |
---|
679 | KillWaves $n0,$n1,$n2,$n3,$n4 |
---|
680 | |
---|
681 | if(DataFolderExists("root:Packages:NIST")) |
---|
682 | String/G root:Packages:NIST:gLastFileName = filename |
---|
683 | endif |
---|
684 | |
---|
685 | // assign colors randomly |
---|
686 | rr = abs(trunc(enoise(65535))) |
---|
687 | gg = abs(trunc(enoise(65535))) |
---|
688 | bb = abs(trunc(enoise(65535))) |
---|
689 | |
---|
690 | // if target window is a graph, and user wants to append, do so |
---|
691 | if(WinType("") == 1) |
---|
692 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
693 | if(V_Flag == 1) |
---|
694 | AppendToGraph $w1 vs $w0 |
---|
695 | ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
696 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
697 | else |
---|
698 | //new graph |
---|
699 | Display $w1 vs $w0 |
---|
700 | ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
701 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
702 | Legend |
---|
703 | endif |
---|
704 | else |
---|
705 | // graph window was not target, make new one |
---|
706 | Display $w1 vs $w0 |
---|
707 | ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
708 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
709 | Legend |
---|
710 | endif |
---|
711 | |
---|
712 | End |
---|
713 | |
---|
714 | |
---|
715 | //// Extra "Utility Procedures" |
---|
716 | // to pick path, get a list of data files, and make sure that a valid filename |
---|
717 | // is passed to LoadOneDDataWithName() |
---|
718 | // |
---|
719 | |
---|
720 | //prompts user to choose the local folder that contains the SANS Data |
---|
721 | //only one folder can be used, and its path is catPathName (and is a NAME, not a string) |
---|
722 | //this will overwrite the path selection |
---|
723 | //returns 1 if no path selected as error condition |
---|
724 | Function A_PickPath() |
---|
725 | |
---|
726 | //set the global string to the selected pathname |
---|
727 | NewPath/O/M="pick the SANS data folder" catPathName |
---|
728 | PathInfo/S catPathName |
---|
729 | String dum = S_path |
---|
730 | String alertStr = "" |
---|
731 | alertStr = "You must set the path to Charlotte through a Mapped Network Drive, not through the Network Neighborhood" |
---|
732 | //alertStr += " Please see the manual for details." |
---|
733 | if (V_flag == 0) |
---|
734 | //path does not exist - no folder selected |
---|
735 | String/G root:Packages:NIST:gCatPathStr = "no folder selected" |
---|
736 | return(1) |
---|
737 | else |
---|
738 | //set the global to the path (as a string) |
---|
739 | // need 4 \ since it is the escape character |
---|
740 | if(cmpstr("\\\\",dum[0,1])==0) //Windoze user going through network neighborhood |
---|
741 | DoAlert 0,alertStr |
---|
742 | KillPath catPathName |
---|
743 | return(1) |
---|
744 | endif |
---|
745 | String/G root:Packages:NIST:gCatPathStr = dum |
---|
746 | return(0) //no error |
---|
747 | endif |
---|
748 | End |
---|
749 | |
---|
750 | //Function attempts to find valid filename from partial name that has been stripped of |
---|
751 | //the VAX version number. The partial name is tried first |
---|
752 | //*** the PATH is hard-wired to catPathName (which is assumed to exist) |
---|
753 | //version numers up to ;10 are tried |
---|
754 | //only the "name;vers" is returned. the path is not prepended, hence the return string |
---|
755 | //is not a complete specification of the file |
---|
756 | // |
---|
757 | // added 11/99 - uppercase and lowercase versions of the file are tried, if necessary |
---|
758 | // since from marquee, the filename field (textread[0]) must be used, and can be a mix of |
---|
759 | // upper/lowercase letters, while the filename on the server (should) be all caps |
---|
760 | // now makes repeated calls to ValidFileString() |
---|
761 | // |
---|
762 | Function/S A_FindValidFilename(partialName) |
---|
763 | String PartialName |
---|
764 | |
---|
765 | String retStr="" |
---|
766 | |
---|
767 | //try name with no changes - to allow for ABS files that have spaces in the names 12APR04 |
---|
768 | retStr = A_ValidFileString(partialName) |
---|
769 | if(cmpstr(retStr,"") !=0) |
---|
770 | //non-null return |
---|
771 | return(retStr) |
---|
772 | Endif |
---|
773 | |
---|
774 | //if the partial name is derived from the file header, there can be spaces at the beginning |
---|
775 | //or in the middle of the filename - depending on the prefix and initials used |
---|
776 | // |
---|
777 | //remove any leading spaces from the name before starting |
---|
778 | partialName = A_RemoveAllSpaces(partialName) |
---|
779 | |
---|
780 | //try name with no spaces |
---|
781 | retStr = A_ValidFileString(partialName) |
---|
782 | if(cmpstr(retStr,"") !=0) |
---|
783 | //non-null return |
---|
784 | return(retStr) |
---|
785 | Endif |
---|
786 | |
---|
787 | //try all UPPERCASE |
---|
788 | partialName = UpperStr(partialName) |
---|
789 | retStr = A_ValidFileString(partialName) |
---|
790 | if(cmpstr(retStr,"") !=0) |
---|
791 | //non-null return |
---|
792 | return(retStr) |
---|
793 | Endif |
---|
794 | |
---|
795 | //try all lowercase (ret null if failure) |
---|
796 | partialName = LowerStr(partialName) |
---|
797 | retStr = A_ValidFileString(partialName) |
---|
798 | if(cmpstr(retStr,"") !=0) |
---|
799 | //non-null return |
---|
800 | return(retStr) |
---|
801 | else |
---|
802 | return(retStr) |
---|
803 | Endif |
---|
804 | End |
---|
805 | |
---|
806 | //function to test a binary file to see if it is a RAW binary SANS file |
---|
807 | //first checks the total bytes in the file (which for raw data is 33316 bytes) |
---|
808 | //**note that the "DIV" file will also show up as a raw file by the run field |
---|
809 | //should be listed in CAT/SHORT and in patch windows |
---|
810 | // |
---|
811 | //Function then checks the file fname (full path:file) for "RAW" run.type field |
---|
812 | //if not found, the data is not raw data and zero is returned |
---|
813 | Function A_CheckIfRawData(fname) |
---|
814 | String fname |
---|
815 | |
---|
816 | Variable refnum,totalBytes |
---|
817 | String testStr="" |
---|
818 | |
---|
819 | Open/R/T="????TEXT" refNum as fname |
---|
820 | //get the total number of bytes in the file, to avoid moving past EOF |
---|
821 | FStatus refNum |
---|
822 | totalBytes = V_logEOF |
---|
823 | //Print totalBytes |
---|
824 | if(totalBytes!=33316) |
---|
825 | //can't possibly be a raw data file |
---|
826 | Close refnum |
---|
827 | return(0) //not a raw SANS file |
---|
828 | Endif |
---|
829 | FSetPos refNum,75 |
---|
830 | FReadLine/N=3 refNum,testStr |
---|
831 | Close refNum |
---|
832 | |
---|
833 | if(cmpstr(testStr,"RAW")==0) |
---|
834 | //true, is raw data file |
---|
835 | Return(1) |
---|
836 | else |
---|
837 | //some other file |
---|
838 | Return(0) |
---|
839 | Endif |
---|
840 | End |
---|
841 | |
---|
842 | //list (input) is a list, typically returned from IndexedFile() |
---|
843 | //which is semicolon-delimited, and may contain filesnames from the VAX |
---|
844 | //that contain version numbers, where the version number appears as a separate list item |
---|
845 | //(and also as a non-existent file) |
---|
846 | //these numbers must be purged from the list, especially for display in a popup |
---|
847 | //or list processing of filenames |
---|
848 | //the function returns the list, cleaned of version numbers (up to 11) |
---|
849 | //raw data files will typically never have a version number other than 1. |
---|
850 | Function/S A_RemoveVersNumsFromList(list) |
---|
851 | String list |
---|
852 | |
---|
853 | //get rid of version numbers first (up to 11) |
---|
854 | Variable ii,num |
---|
855 | String item |
---|
856 | num = ItemsInList(list,";") |
---|
857 | ii=1 |
---|
858 | do |
---|
859 | item = num2str(ii) |
---|
860 | list = RemoveFromList(item, list ,";" ) |
---|
861 | ii+=1 |
---|
862 | while(ii<12) |
---|
863 | |
---|
864 | return (list) |
---|
865 | End |
---|
866 | |
---|
867 | //Function attempts to find valid filename from partial name that has been stripped of |
---|
868 | //the VAX version number. The partial name is tried first |
---|
869 | //*** the PATH is hard-wired to catPathName (which is assumed to exist) |
---|
870 | //version numers up to ;10 are tried |
---|
871 | //only the "name;vers" is returned. the path is not prepended, hence the return string |
---|
872 | //is not a complete specification of the file |
---|
873 | // |
---|
874 | Function/S A_ValidFileString(partialName) |
---|
875 | String partialName |
---|
876 | |
---|
877 | String tempName = "",msg="" |
---|
878 | Variable ii,refnum |
---|
879 | |
---|
880 | ii=0 |
---|
881 | do |
---|
882 | if(ii==0) |
---|
883 | //first pass, try the partialName |
---|
884 | tempName = partialName |
---|
885 | Open/Z/R/T="????TEXT"/P=catPathName refnum tempName //Does open file (/Z flag) |
---|
886 | if(V_flag == 0) |
---|
887 | //file exists |
---|
888 | Close refnum //YES needed, |
---|
889 | break |
---|
890 | endif |
---|
891 | else |
---|
892 | tempName = partialName + ";" + num2str(ii) |
---|
893 | Open/Z/R/T="????TEXT"/P=catPathName refnum tempName |
---|
894 | if(V_flag == 0) |
---|
895 | //file exists |
---|
896 | Close refnum |
---|
897 | break |
---|
898 | endif |
---|
899 | Endif |
---|
900 | ii+=1 |
---|
901 | //print "ii=",ii |
---|
902 | while(ii<11) |
---|
903 | //go get the selected bits of information, using tempName, which exists |
---|
904 | if(ii>=11) |
---|
905 | //msg = partialName + " not found. is version number > 11?" |
---|
906 | //DoAlert 0, msg |
---|
907 | //PathInfo catPathName |
---|
908 | //Print S_Path |
---|
909 | Return ("") //use null string as error condition |
---|
910 | Endif |
---|
911 | |
---|
912 | Return (tempName) |
---|
913 | End |
---|
914 | |
---|
915 | //function to remove all spaces from names when searching for filenames |
---|
916 | //the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn) |
---|
917 | //but the text field in the header WILL, if less than 3 characters were used for the |
---|
918 | //user's initials, and can have leading spaces if prefix was less than 5 characters |
---|
919 | // |
---|
920 | //returns a string identical to the original string, except with the interior spaces removed |
---|
921 | // |
---|
922 | Function/S A_RemoveAllSpaces(str) |
---|
923 | String str |
---|
924 | |
---|
925 | String tempstr = str |
---|
926 | Variable ii,spc,len //should never be more than 2 or 3 trailing spaces in a filename |
---|
927 | ii=0 |
---|
928 | do |
---|
929 | len = strlen(tempStr) |
---|
930 | spc = strsearch(tempStr," ",0) //is the last character a space? |
---|
931 | if (spc == -1) |
---|
932 | break //no more spaces found, get out |
---|
933 | endif |
---|
934 | str = tempstr |
---|
935 | tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string |
---|
936 | While(1) //should never be more than 2 or 3 |
---|
937 | |
---|
938 | If(strlen(tempStr) < 1) |
---|
939 | tempStr = "" //be sure to return a null string if problem found |
---|
940 | Endif |
---|
941 | |
---|
942 | //Print strlen(tempstr) |
---|
943 | |
---|
944 | Return(tempStr) |
---|
945 | |
---|
946 | End |
---|
947 | |
---|
948 | //AJJ Oct 2008 |
---|
949 | //Moved from GaussUtils - makes more sense to have it here |
---|
950 | |
---|
951 | // utility used in the "PlotSmeared...() macros to get a list of data folders |
---|
952 | // |
---|
953 | //1: Waves. |
---|
954 | //2: Numeric variables. |
---|
955 | //3: String variables. |
---|
956 | //4: Data folders. |
---|
957 | Function/S GetAList(type) |
---|
958 | Variable type |
---|
959 | |
---|
960 | SetDataFolder root: |
---|
961 | |
---|
962 | String objName,str="" |
---|
963 | Variable index = 0 |
---|
964 | do |
---|
965 | objName = GetIndexedObjName(":", type, index) |
---|
966 | if (strlen(objName) == 0) |
---|
967 | break |
---|
968 | endif |
---|
969 | //Print objName |
---|
970 | str += objName + ";" |
---|
971 | index += 1 |
---|
972 | while(1) |
---|
973 | |
---|
974 | // remove myGlobals, Packages, etc. from the folder list |
---|
975 | if(type==4) |
---|
976 | str = RemoveFromList("myGlobals", str , ";" ) |
---|
977 | str = RemoveFromList("Packages", str, ";") |
---|
978 | str = RemoveFromList("AutoFit", str, ";") |
---|
979 | str = RemoveFromList("TISANE", str, ";") |
---|
980 | str = RemoveFromList("HayPenMSA", str, ";") |
---|
981 | str = RemoveFromList("SAS", str, ";") //from Irena |
---|
982 | str = RemoveFromList("USAXS", str, ";") |
---|
983 | str = RemoveFromList("RAW;SAM;EMP;BGD;DIV;MSK;ABS;CAL;COR;STO;SUB;DRK;SAS;", str ,";") //root level folders present in old reduction experiments |
---|
984 | endif |
---|
985 | |
---|
986 | return(str) |
---|
987 | End |
---|
988 | |
---|
989 | |
---|
990 | //returns the path to the file, or null if cancel |
---|
991 | // |
---|
992 | // either the T="????" or the /F flags work to set the filter to "all files" |
---|
993 | // but the T is essentially obsolete, /F is new for Igor 6.1 and recommended |
---|
994 | Function/S DoOpenFileDialog(msg) |
---|
995 | String msg |
---|
996 | |
---|
997 | Variable refNum |
---|
998 | // String message = "Select a file" |
---|
999 | String outputPath |
---|
1000 | |
---|
1001 | String fileFilters = "All Files:.*;" |
---|
1002 | |
---|
1003 | // Open/D/R/T="????"/M=msg refNum |
---|
1004 | Open/D/R/F=fileFilters/M=msg refNum |
---|
1005 | outputPath = S_fileName |
---|
1006 | |
---|
1007 | return outputPath |
---|
1008 | End |
---|
1009 | |
---|
1010 | // returns the path to the file, or null if the user cancelled |
---|
1011 | // fancy use of optional parameters |
---|
1012 | // |
---|
1013 | // enforce short file names (25 characters) |
---|
1014 | Function/S DoSaveFileDialog(msg,[fname,suffix]) |
---|
1015 | String msg,fname,suffix |
---|
1016 | Variable refNum |
---|
1017 | // String message = "Save the file as" |
---|
1018 | |
---|
1019 | if(ParamIsDefault(fname)) |
---|
1020 | // Print "fname not supplied" |
---|
1021 | fname = "" |
---|
1022 | endif |
---|
1023 | if(ParamIsDefault(suffix)) |
---|
1024 | // Print "suffix not supplied" |
---|
1025 | suffix = "" |
---|
1026 | endif |
---|
1027 | |
---|
1028 | String outputPath,tmpName,testStr |
---|
1029 | Variable badLength=0,maxLength=25,l1,l2 |
---|
1030 | |
---|
1031 | |
---|
1032 | tmpName = fname + suffix |
---|
1033 | |
---|
1034 | do |
---|
1035 | badLength=0 |
---|
1036 | Open/D/M=msg/T="????" refNum as tmpName //OS will allow 255 characters, but then I can't read it back in! |
---|
1037 | outputPath = S_fileName |
---|
1038 | |
---|
1039 | testStr = ParseFilePath(0, outputPath, ":", 1, 0) //just the filename |
---|
1040 | if(strlen(testStr)==0) |
---|
1041 | break //cancel, allow exit |
---|
1042 | endif |
---|
1043 | if(strlen(testStr) > maxLength) |
---|
1044 | badlength = 1 |
---|
1045 | DoAlert 2,"File name is too long. Is\r"+testStr[0,maxLength-1]+"\rOK?" |
---|
1046 | if(V_flag==3) |
---|
1047 | outputPath = "" |
---|
1048 | break |
---|
1049 | endif |
---|
1050 | if(V_flag==1) //my suggested name is OK, so trim the output |
---|
1051 | badlength=0 |
---|
1052 | l1 = strlen(testStr) //too long length |
---|
1053 | l1 = l1-maxLength //number to trim |
---|
1054 | //Print outputPath |
---|
1055 | l2=strlen(outputPath) |
---|
1056 | outputPath = outputPath[0,l2-1-l1] |
---|
1057 | //Print "modified ",outputPath |
---|
1058 | endif |
---|
1059 | //if(V_flag==2) do nothing, let it go around again |
---|
1060 | endif |
---|
1061 | |
---|
1062 | while(badLength) |
---|
1063 | |
---|
1064 | return outputPath |
---|
1065 | End |
---|
1066 | |
---|
1067 | // returns a shortened file name (26 characters max) so that the loader |
---|
1068 | // won't try to create Igor objects that have names that are longer than 31 |
---|
1069 | // |
---|
1070 | Function/S ShortFileNameString(inStr) |
---|
1071 | String inStr |
---|
1072 | |
---|
1073 | String outStr="" |
---|
1074 | Variable maxLength=25 |
---|
1075 | Variable nameTooLong=0 |
---|
1076 | String/G root:Packages:NIST:gShortNameStr = inStr[0,maxLength-1] |
---|
1077 | SVAR newStr = root:Packages:NIST:gShortNameStr |
---|
1078 | |
---|
1079 | if(strlen(inStr) <= maxLength) |
---|
1080 | return (inStr) //length OK |
---|
1081 | else |
---|
1082 | do |
---|
1083 | nameTooLong = 0 |
---|
1084 | |
---|
1085 | DoAlert 1,"File name is too long. Is\r"+inStr[0,maxLength-1]+"\rOK?" |
---|
1086 | if(V_flag==1) //my suggested name is OK, so trim the output |
---|
1087 | outStr = inStr[0,maxLength-1] |
---|
1088 | //Print "modified ",outStr |
---|
1089 | newStr=outStr |
---|
1090 | return(outStr) |
---|
1091 | endif |
---|
1092 | |
---|
1093 | |
---|
1094 | if(V_flag == 2) //not OK, do something about it |
---|
1095 | |
---|
1096 | DoWindow/F ShorterNameInput //it really shouldn't exist... |
---|
1097 | if(V_flag==0) |
---|
1098 | |
---|
1099 | NewPanel /W=(166,90,666,230) as "Enter a Shorter Name" |
---|
1100 | DoWindow/C ShorterNameInput |
---|
1101 | SetDrawLayer UserBack |
---|
1102 | TitleBox title0,pos={35,8},size={261,20},title=" Enter a shorter file name. It must be 25 characters or less " |
---|
1103 | TitleBox title0,fSize=12,fStyle=1 |
---|
1104 | SetVariable setvar0,pos={21,52},size={300,15},title="New name",value= _STR:newStr |
---|
1105 | SetVariable setvar0,proc=ShorterNameSetVarProc,fsize=12 |
---|
1106 | SetVariable setvar0 valueBackColor=(65535,49151,49151) |
---|
1107 | Button button0,pos={259,87},size={60,20},title="Done" |
---|
1108 | Button button0,proc=ShorterNameDoneButtonProc |
---|
1109 | |
---|
1110 | endif |
---|
1111 | |
---|
1112 | PauseForUser ShorterNameInput |
---|
1113 | |
---|
1114 | // this really should force a good name, but there could be errors that I'm not catching |
---|
1115 | // Print newStr, strlen(newStr) |
---|
1116 | nameTooLong = 0 |
---|
1117 | endif |
---|
1118 | |
---|
1119 | while (nameTooLong) |
---|
1120 | |
---|
1121 | return(newStr) |
---|
1122 | |
---|
1123 | endif |
---|
1124 | |
---|
1125 | End |
---|
1126 | |
---|
1127 | |
---|
1128 | // for the ShortFileNameString() - PauseForUser to get a shorter file name |
---|
1129 | Function ShorterNameSetVarProc(sva) : SetVariableControl |
---|
1130 | STRUCT WMSetVariableAction &sva |
---|
1131 | |
---|
1132 | switch( sva.eventCode ) |
---|
1133 | case 1: // mouse up |
---|
1134 | case 2: // Enter key |
---|
1135 | case 3: // Live update |
---|
1136 | String sv = sva.sval |
---|
1137 | if( strlen(sv) > 25 ) |
---|
1138 | sv= sv[0,24] |
---|
1139 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
1140 | SetVariable setvar0 valueBackColor=(65535,49151,49151) |
---|
1141 | Beep |
---|
1142 | else |
---|
1143 | SetVariable setvar0 valueBackColor=(65535,65535,65535) |
---|
1144 | endif |
---|
1145 | break |
---|
1146 | endswitch |
---|
1147 | return 0 |
---|
1148 | End |
---|
1149 | |
---|
1150 | // for the ShortFileNameString() - PauseForUser to get a shorter file name |
---|
1151 | Function ShorterNameDoneButtonProc(ba) : ButtonControl |
---|
1152 | STRUCT WMButtonAction &ba |
---|
1153 | |
---|
1154 | String win = ba.win |
---|
1155 | |
---|
1156 | switch (ba.eventCode) |
---|
1157 | case 2: |
---|
1158 | SVAR newStr = root:Packages:NIST:gShortNameStr |
---|
1159 | ControlInfo setvar0 |
---|
1160 | newStr = S_value |
---|
1161 | DoWindow/K ShorterNameInput |
---|
1162 | |
---|
1163 | break |
---|
1164 | endswitch |
---|
1165 | |
---|
1166 | return 0 |
---|
1167 | End |
---|
1168 | |
---|
1169 | |
---|
1170 | // a function common to many panels, so put the basic version here that simply |
---|
1171 | // returns null string if no functions are present. Calling procedures can |
---|
1172 | // add to the list to customize as needed. |
---|
1173 | // show the available models |
---|
1174 | // not the f*(cw,xw) point calculations |
---|
1175 | // not the *X(cw,xw) XOPS |
---|
1176 | // |
---|
1177 | // KIND:10 should show only user-defined curve fitting functions |
---|
1178 | // - not XOPs |
---|
1179 | // - not other user-defined functions |
---|
1180 | Function/S User_FunctionPopupList() |
---|
1181 | String list,tmp |
---|
1182 | list = FunctionList("*",";","KIND:10") //get every user defined curve fit function |
---|
1183 | |
---|
1184 | //now start to remove everything the user doesn't need to see... |
---|
1185 | |
---|
1186 | tmp = FunctionList("*_proto",";","KIND:10") //prototypes |
---|
1187 | list = RemoveFromList(tmp, list ,";") |
---|
1188 | |
---|
1189 | //prototypes that show up if GF is loaded |
---|
1190 | list = RemoveFromList("GFFitFuncTemplate", list) |
---|
1191 | list = RemoveFromList("GFFitAllAtOnceTemplate", list) |
---|
1192 | list = RemoveFromList("NewGlblFitFunc", list) |
---|
1193 | list = RemoveFromList("NewGlblFitFuncAllAtOnce", list) |
---|
1194 | list = RemoveFromList("GlobalFitFunc", list) |
---|
1195 | list = RemoveFromList("GlobalFitAllAtOnce", list) |
---|
1196 | list = RemoveFromList("GFFitAAOStructTemplate", list) |
---|
1197 | list = RemoveFromList("NewGF_SetXWaveInList", list) |
---|
1198 | list = RemoveFromList("NewGlblFitFuncAAOStruct", list) |
---|
1199 | |
---|
1200 | // more to remove as a result of 2D/Gizmo |
---|
1201 | list = RemoveFromList("A_WMRunLessThanDelta", list) |
---|
1202 | list = RemoveFromList("WMFindNaNValue", list) |
---|
1203 | list = RemoveFromList("WM_Make3DBarChartParametricWave", list) |
---|
1204 | list = RemoveFromList("UpdateQxQy2Mat", list) |
---|
1205 | list = RemoveFromList("MakeBSMask", list) |
---|
1206 | |
---|
1207 | // MOTOFIT/GenFit bits |
---|
1208 | tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;GeneticFit_UnSmearedModel;GeneticFit_SmearedModel;" |
---|
1209 | list = RemoveFromList(tmp, list ,";") |
---|
1210 | |
---|
1211 | // SANS Reduction bits |
---|
1212 | tmp = "ASStandardFunction;Ann_1D_Graph;Avg_1D_Graph;BStandardFunction;CStandardFunction;Draw_Plot1D;MyMat2XYZ;" |
---|
1213 | list = RemoveFromList(tmp, list ,";") |
---|
1214 | tmp = "NewDirection;SANSModelAAO_MCproto;Monte_SANS_Threaded;Monte_SANS_NotThreaded;Monte_SANS_W1;Monte_SANS_W2;Monte_SANS_W3;Monte_SANS_W4;Monte_SANS;FractionReachingDetector;TwoLevel_EC;SmearedTwoLevel_EC;" |
---|
1215 | list = RemoveFromList(tmp, list ,";") |
---|
1216 | |
---|
1217 | |
---|
1218 | // USANS Reduction bits |
---|
1219 | tmp = "DSM_Guinier_Fit;RemoveMaskedPoints;" |
---|
1220 | list = RemoveFromList(tmp, list ,";") |
---|
1221 | |
---|
1222 | //more functions from analysis models (2008) |
---|
1223 | tmp = "Barbell_Inner;Barbell_Outer;Barbell_integrand;BCC_Integrand;Integrand_BCC_Inner;Integrand_BCC_Outer;" |
---|
1224 | list = RemoveFromList(tmp, list ,";") |
---|
1225 | tmp = "CapCyl;CapCyl_Inner;CapCyl_Outer;ConvLens;ConvLens_Inner;ConvLens_Outer;" |
---|
1226 | list = RemoveFromList(tmp, list ,";") |
---|
1227 | tmp = "Dumb;Dumb_Inner;Dumb_Outer;FCC_Integrand;Integrand_FCC_Inner;Integrand_FCC_Outer;" |
---|
1228 | list = RemoveFromList(tmp, list ,";") |
---|
1229 | tmp = "Integrand_SC_Inner;Integrand_SC_Outer;SC_Integrand;SphCyl;SphCyl_Inner;SphCyl_Outer;" |
---|
1230 | list = RemoveFromList(tmp, list ,";") |
---|
1231 | tmp = "CSPP_Outer;CSPP_Inner;PP_Outer;PP_Inner;" |
---|
1232 | list = RemoveFromList(tmp, list ,";") |
---|
1233 | tmp = "Guinier_Fit;" |
---|
1234 | list = RemoveFromList(tmp, list ,";") |
---|
1235 | |
---|
1236 | tmp = FunctionList("f*",";","NPARAMS:2") //point calculations |
---|
1237 | list = RemoveFromList(tmp, list ,";") |
---|
1238 | |
---|
1239 | tmp = FunctionList("fSmear*",";","NPARAMS:3") //smeared dependency calculations |
---|
1240 | list = RemoveFromList(tmp, list ,";") |
---|
1241 | |
---|
1242 | // anything that might be included in Irena |
---|
1243 | tmp = FunctionList("GEN_*",";","KIND:10") |
---|
1244 | list = RemoveFromList(tmp, list ,";") |
---|
1245 | tmp = FunctionList("IN2G_*",";","KIND:10") |
---|
1246 | list = RemoveFromList(tmp, list ,";") |
---|
1247 | tmp = FunctionList("IR1A_*",";","KIND:10") |
---|
1248 | list = RemoveFromList(tmp, list ,";") |
---|
1249 | tmp = FunctionList("IR1B_*",";","KIND:10") |
---|
1250 | list = RemoveFromList(tmp, list ,";") |
---|
1251 | tmp = FunctionList("IR1U_*",";","KIND:10") |
---|
1252 | list = RemoveFromList(tmp, list ,";") |
---|
1253 | tmp = FunctionList("IR1V_*",";","KIND:10") |
---|
1254 | list = RemoveFromList(tmp, list ,";") |
---|
1255 | tmp = FunctionList("IR1_*",";","KIND:10") |
---|
1256 | list = RemoveFromList(tmp, list ,";") |
---|
1257 | tmp = FunctionList("IR2D_*",";","KIND:10") |
---|
1258 | list = RemoveFromList(tmp, list ,";") |
---|
1259 | |
---|
1260 | tmp = FunctionList("IR2D_*",";","KIND:10") |
---|
1261 | list = RemoveFromList(tmp, list ,";") |
---|
1262 | tmp = FunctionList("IR2H_*",";","KIND:10") |
---|
1263 | list = RemoveFromList(tmp, list ,";") |
---|
1264 | tmp = FunctionList("IR2L_*",";","KIND:10") |
---|
1265 | list = RemoveFromList(tmp, list ,";") |
---|
1266 | tmp = FunctionList("IR2Pr_*",";","KIND:10") |
---|
1267 | list = RemoveFromList(tmp, list ,";") |
---|
1268 | tmp = FunctionList("IR2R_*",";","KIND:10") |
---|
1269 | list = RemoveFromList(tmp, list ,";") |
---|
1270 | tmp = FunctionList("IR2S_*",";","KIND:10") |
---|
1271 | list = RemoveFromList(tmp, list ,";") |
---|
1272 | tmp = FunctionList("IR2_*",";","KIND:10") |
---|
1273 | list = RemoveFromList(tmp, list ,";") |
---|
1274 | tmp = FunctionList("*LogLog",";","KIND:10") |
---|
1275 | list = RemoveFromList(tmp, list ,";") |
---|
1276 | |
---|
1277 | //functions included in Nika |
---|
1278 | tmp = FunctionList("NI1*",";","KIND:10") |
---|
1279 | list = RemoveFromList(tmp, list ,";") |
---|
1280 | tmp = FunctionList("TransAx_*",";","KIND:10") |
---|
1281 | list = RemoveFromList(tmp, list ,";") |
---|
1282 | tmp = FunctionList("TransformAxis*",";","KIND:10") |
---|
1283 | list = RemoveFromList(tmp, list ,";") |
---|
1284 | tmp = FunctionList("erfForNormal*",";","KIND:10") |
---|
1285 | list = RemoveFromList(tmp, list ,";") |
---|
1286 | |
---|
1287 | // functions in Indra (USAXS) |
---|
1288 | tmp = FunctionList("IN2Q_*",";","KIND:10") |
---|
1289 | list = RemoveFromList(tmp, list ,";") |
---|
1290 | tmp = FunctionList("IN3_*",";","KIND:10") |
---|
1291 | list = RemoveFromList(tmp, list ,";") |
---|
1292 | |
---|
1293 | // tmp = FunctionList("*X",";","KIND:4") //XOPs, but these shouldn't show up if KIND:10 is used initially |
---|
1294 | // Print "X* = ",tmp |
---|
1295 | // print " " |
---|
1296 | // list = RemoveFromList(tmp, list ,";") |
---|
1297 | |
---|
1298 | //non-fit functions that I can't seem to filter out |
---|
1299 | list = RemoveFromList("BinaryHS_PSF11;BinaryHS_PSF12;BinaryHS_PSF22;EllipCyl_Integrand;PP_Inner;PP_Outer;Phi_EC;TaE_Inner;TaE_Outer;",list,";") |
---|
1300 | |
---|
1301 | // from 2010 model functions |
---|
1302 | list = RemoveFromList("fTwoYukawa;DoBoxGraph;Gauss2D_theta;",list,";") |
---|
1303 | |
---|
1304 | // from Debye Sphere method |
---|
1305 | list = RemoveFromList("CalcIQRfromMat;ConnectPoints2D;ConnectPoints3D;ConnectPoints3D_old;ConnectedRodFill;ConvertXYZto3N;CylindersAtPoints;",list,";") |
---|
1306 | list = RemoveFromList("FillSphere;FillSphere3;FillSphereRadius;FillSphereRadiusNoOverlap;FillXCylinder;FillXYCircle;FillXZCircle;FillYCylinder;",list,";") |
---|
1307 | list = RemoveFromList("FillYZCircle;FillZCylinder;PadMatrix;RandomFill3DMat;RandomPoints2D;SobolFill3DMat;SphereAtEachPoint;UnConnectedRodFill;XYZV_toByteVoxels;",list,";") |
---|
1308 | list = RemoveFromList("MakeTriplet;SobolPoints2D;X_CylindersAtPoints;X_CylindersHexagonalGrid;X_CylindersSquareGrid;maxDistance_Threaded;KR_MultiCylinder;",list,";") |
---|
1309 | list = RemoveFromList("X_CoreShellCylinderHexGrid;FillPlaneHexagonal;FillPlaneSquareGrid;",list,";") |
---|
1310 | |
---|
1311 | // from Polarization |
---|
1312 | list = RemoveFromList("ParseDecayRow;ParseFlipperRow;",list,";") |
---|
1313 | |
---|
1314 | // from 2012 models |
---|
1315 | list = RemoveFromList("cng_integ;",list,";") |
---|
1316 | |
---|
1317 | // from 2012 Event Mode Processing |
---|
1318 | list = RemoveFromList("CleanupTimes;IndexForHistogram;JointHistogram;MakeFibonacciWave;Osc_ProcessEvents;SetFibonacciBins;SetLinearBins;SetLogBins;Stream_ProcessEvents;",list,";") |
---|
1319 | |
---|
1320 | // from 2013 Simulation |
---|
1321 | // list = RemoveFromList("EC_Empirical;SmearedEC_Empirical;",list,";") |
---|
1322 | |
---|
1323 | list = SortList(list) |
---|
1324 | return(list) |
---|
1325 | End |
---|
1326 | |
---|
1327 | |
---|
1328 | /////////////////////////////////////////////////// |
---|
1329 | // old SANSPreferences have been moved here to a common place and renamed to "NCNR Preferences" so that they |
---|
1330 | // are common to all of the packages (and will appear on all of the menus) |
---|
1331 | // |
---|
1332 | // globals moved to root:Packages:NIST: since this is generated by all packages. |
---|
1333 | // |
---|
1334 | /////////////////////////// |
---|
1335 | // user preferences |
---|
1336 | // |
---|
1337 | // globals are created in initialize.ipf |
---|
1338 | // |
---|
1339 | // this panel allows for user modification |
---|
1340 | /////////////////////////// |
---|
1341 | Proc Show_Preferences_Panel() |
---|
1342 | |
---|
1343 | DoWindow/F Pref_Panel |
---|
1344 | if(V_flag==0) |
---|
1345 | // only re-initialize if the variables don't exist, so you don't overwrite what users have changed |
---|
1346 | if( exists("root:Packages:NIST:gXML_Write") != 2 ) //if the global variable does not exist, initialize |
---|
1347 | Initialize_Preferences() |
---|
1348 | endif |
---|
1349 | Pref_Panel() |
---|
1350 | Endif |
---|
1351 | // Print "Preferences Panel stub" |
---|
1352 | End |
---|
1353 | |
---|
1354 | Proc Initialize_Preferences() |
---|
1355 | // create the globals here if they are not already present |
---|
1356 | |
---|
1357 | // each package initialization should call this to repeat the initialization |
---|
1358 | // without overwriting what was already set |
---|
1359 | |
---|
1360 | Variable val |
---|
1361 | |
---|
1362 | ///// items for SANS reduction |
---|
1363 | val = NumVarOrDefault("root:Packages:NIST:gLogScalingAsDefault", 1 ) |
---|
1364 | Variable/G root:Packages:NIST:gLogScalingAsDefault=val |
---|
1365 | |
---|
1366 | val = NumVarOrDefault("root:Packages:NIST:gAllowDRK", 0 ) |
---|
1367 | Variable/G root:Packages:NIST:gAllowDRK=val //don't show DRK as default |
---|
1368 | |
---|
1369 | val = NumVarOrDefault("root:Packages:NIST:gDoTransCheck", 1 ) |
---|
1370 | Variable/G root:Packages:NIST:gDoTransCheck=val |
---|
1371 | |
---|
1372 | val = NumVarOrDefault("root:Packages:NIST:gBinWidth", 1 ) |
---|
1373 | Variable/G root:Packages:NIST:gBinWidth=val |
---|
1374 | |
---|
1375 | val = NumVarOrDefault("root:Packages:NIST:gNPhiSteps", 72 ) |
---|
1376 | Variable/G root:Packages:NIST:gNPhiSteps=val |
---|
1377 | |
---|
1378 | // flags to turn detector corrections on/off for testing (you should leave these ON) |
---|
1379 | val = NumVarOrDefault("root:Packages:NIST:gDoDetectorEffCorr", 1 ) |
---|
1380 | Variable/G root:Packages:NIST:gDoDetectorEffCorr = 1 |
---|
1381 | |
---|
1382 | val = NumVarOrDefault("root:Packages:NIST:gDoTransmissionCorr", 1 ) |
---|
1383 | Variable/G root:Packages:NIST:gDoTransmissionCorr = 1 |
---|
1384 | |
---|
1385 | |
---|
1386 | /// items for SANS Analysis |
---|
1387 | |
---|
1388 | |
---|
1389 | /// items for USANS Reduction |
---|
1390 | |
---|
1391 | |
---|
1392 | /// items for everyone |
---|
1393 | val = NumVarOrDefault("root:Packages:NIST:gXML_Write", 0 ) |
---|
1394 | Variable/G root:Packages:NIST:gXML_Write = val |
---|
1395 | |
---|
1396 | |
---|
1397 | end |
---|
1398 | |
---|
1399 | Function LogScalePrefCheck(ctrlName,checked) : CheckBoxControl |
---|
1400 | String ctrlName |
---|
1401 | Variable checked |
---|
1402 | |
---|
1403 | NVAR gLog = root:Packages:NIST:gLogScalingAsDefault |
---|
1404 | glog=checked |
---|
1405 | //print "log pref checked = ",checked |
---|
1406 | End |
---|
1407 | |
---|
1408 | Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl |
---|
1409 | String ctrlName |
---|
1410 | Variable checked |
---|
1411 | |
---|
1412 | NVAR gDRK = root:Packages:NIST:gAllowDRK |
---|
1413 | gDRK = checked |
---|
1414 | //Print "DRK preference = ",checked |
---|
1415 | End |
---|
1416 | |
---|
1417 | Function UnityTransPref(ctrlName,checked) : CheckBoxControl |
---|
1418 | String ctrlName |
---|
1419 | Variable checked |
---|
1420 | |
---|
1421 | NVAR gVal = root:Packages:NIST:gDoTransCheck |
---|
1422 | gVal = checked |
---|
1423 | End |
---|
1424 | |
---|
1425 | Function XMLWritePref(ctrlName,checked) : CheckBoxControl |
---|
1426 | String ctrlName |
---|
1427 | Variable checked |
---|
1428 | |
---|
1429 | NVAR gVal = root:Packages:NIST:gXML_Write |
---|
1430 | gVal = checked |
---|
1431 | End |
---|
1432 | |
---|
1433 | Function DoTransCorrPref(ctrlName,checked) : CheckBoxControl |
---|
1434 | String ctrlName |
---|
1435 | Variable checked |
---|
1436 | |
---|
1437 | NVAR gVal = root:Packages:NIST:gDoTransmissionCorr |
---|
1438 | gVal = checked |
---|
1439 | End |
---|
1440 | |
---|
1441 | Function DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl |
---|
1442 | String ctrlName |
---|
1443 | Variable checked |
---|
1444 | |
---|
1445 | NVAR gVal = root:Packages:NIST:gDoDetectorEffCorr |
---|
1446 | gVal = checked |
---|
1447 | End |
---|
1448 | |
---|
1449 | Function PrefDoneButtonProc(ctrlName) : ButtonControl |
---|
1450 | String ctrlName |
---|
1451 | |
---|
1452 | DoWindow/K pref_panel |
---|
1453 | End |
---|
1454 | |
---|
1455 | Proc Pref_Panel() |
---|
1456 | PauseUpdate; Silent 1 // building window... |
---|
1457 | NewPanel /W=(646,208,1070,468)/K=2 as "NCNR Preference Panel" |
---|
1458 | DoWindow/C pref_panel |
---|
1459 | ModifyPanel cbRGB=(49694,61514,27679) |
---|
1460 | SetDrawLayer UserBack |
---|
1461 | ModifyPanel fixedSize=1 |
---|
1462 | ////// |
---|
1463 | //on main portion of panel, always visible |
---|
1464 | Button PrefPanelButtonA,pos={354,12},size={50,20},proc=PrefDoneButtonProc,title="Done" |
---|
1465 | |
---|
1466 | TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=PrefTabProc |
---|
1467 | TabControl PrefTab,tabLabel(1)="SANS",tabLabel(2)="USANS",tabLabel(3)="Analysis" |
---|
1468 | TabControl PrefTab,value=0 |
---|
1469 | TabControl PrefTab labelBack=(49694,61514,27679) |
---|
1470 | |
---|
1471 | //on tab(0) - General - initially visible |
---|
1472 | CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=XMLWritePref,title="Use canSAS XML Output" |
---|
1473 | CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"} |
---|
1474 | CheckBox PrefCtrl_0a,value= root:Packages:NIST:gXML_Write |
---|
1475 | |
---|
1476 | //on tab(1) - SANS |
---|
1477 | CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=LogScalePrefCheck,title="Use Log scaling for 2D data display" |
---|
1478 | CheckBox PrefCtrl_1a,help={"Checking this will display 2D SANS data with a logarithmic color scale of neutron counts. If not checked, the color mapping will be linear."} |
---|
1479 | CheckBox PrefCtrl_1a,value= root:Packages:NIST:gLogScalingAsDefault |
---|
1480 | CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=DRKProtocolPref,title="Allow DRK correction in protocols" |
---|
1481 | CheckBox PrefCtrl_1b,help={"Checking this will allow DRK correction to be used in reduction protocols. You will need to re-draw the protocol panel for this change to be visible."} |
---|
1482 | CheckBox PrefCtrl_1b,value= root:Packages:NIST:gAllowDRK |
---|
1483 | CheckBox PrefCtrl_1c,pos={21,140},size={137,14},proc=UnityTransPref,title="Check for Transmission = 1" |
---|
1484 | CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"} |
---|
1485 | CheckBox PrefCtrl_1c,value= root:Packages:NIST:gDoTransCheck |
---|
1486 | SetVariable PrefCtrl_1d,pos={21,170},size={200,15},title="Averaging Bin Width (pixels)" |
---|
1487 | SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:gBinWidth |
---|
1488 | SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)" |
---|
1489 | SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:gNPhiSteps |
---|
1490 | CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:gDoTransmissionCorr,proc=DoTransCorrPref |
---|
1491 | CheckBox PrefCtrl_1f pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} |
---|
1492 | CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=DoEfficiencyCorrPref |
---|
1493 | CheckBox PrefCtrl_1g value=root:Packages:NIST:gDoDetectorEffCorr,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."} |
---|
1494 | |
---|
1495 | |
---|
1496 | CheckBox PrefCtrl_1a,disable=1 |
---|
1497 | CheckBox PrefCtrl_1b,disable=1 |
---|
1498 | CheckBox PrefCtrl_1c,disable=1 |
---|
1499 | SetVariable PrefCtrl_1d,disable=1 |
---|
1500 | SetVariable PrefCtrl_1e,disable=1 |
---|
1501 | CheckBox PrefCtrl_1f,disable=1 |
---|
1502 | CheckBox PrefCtrl_1g,disable=1 |
---|
1503 | |
---|
1504 | //on tab(2) - USANS |
---|
1505 | GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
1506 | |
---|
1507 | GroupBox PrefCtrl_2a,disable=1 |
---|
1508 | |
---|
1509 | |
---|
1510 | //on tab(3) - Analysis |
---|
1511 | GroupBox PrefCtrl_3a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
1512 | |
---|
1513 | GroupBox PrefCtrl_3a,disable=1 |
---|
1514 | |
---|
1515 | EndMacro |
---|
1516 | |
---|
1517 | // function to control the drawing of controls in the TabControl on the main panel |
---|
1518 | // Naming scheme for the controls MUST be strictly adhered to... else controls will |
---|
1519 | // appear in odd places... |
---|
1520 | // all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting |
---|
1521 | // the controls position on that particular tab. |
---|
1522 | // in this way, they will always be drawn correctly.. |
---|
1523 | // |
---|
1524 | Function PrefTabProc(name,tab) |
---|
1525 | String name |
---|
1526 | Variable tab |
---|
1527 | |
---|
1528 | // Print "name,number",name,tab |
---|
1529 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
1530 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
1531 | for(ii=0;ii<num;ii+=1) |
---|
1532 | //items all start w/"PrefCtrl_", 9 characters |
---|
1533 | item=StringFromList(ii, ctrlList ,";") |
---|
1534 | nameStr=item[0,8] |
---|
1535 | if(cmpstr(nameStr,"PrefCtrl_")==0) |
---|
1536 | onTab = str2num(item[9]) //[9] is a number |
---|
1537 | ControlInfo $item |
---|
1538 | switch(abs(V_flag)) |
---|
1539 | case 1: |
---|
1540 | Button $item,disable=(tab!=onTab) |
---|
1541 | break |
---|
1542 | case 2: |
---|
1543 | CheckBox $item,disable=(tab!=onTab) |
---|
1544 | break |
---|
1545 | case 5: |
---|
1546 | SetVariable $item,disable=(tab!=onTab) |
---|
1547 | break |
---|
1548 | case 10: |
---|
1549 | TitleBox $item,disable=(tab!=onTab) |
---|
1550 | break |
---|
1551 | case 4: |
---|
1552 | ValDisplay $item,disable=(tab!=onTab) |
---|
1553 | break |
---|
1554 | case 9: |
---|
1555 | GroupBox $item,disable=(tab!=onTab) |
---|
1556 | break |
---|
1557 | // add more items to the switch if different control types are used |
---|
1558 | endswitch |
---|
1559 | endif |
---|
1560 | endfor |
---|
1561 | return(0) |
---|
1562 | End |
---|
1563 | |
---|