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 | //DONE: this works correctly and can be included in either |
---|
364 | // a VSANS reduction experiment, or a standalone analysis package |
---|
365 | // -- since this is a Proc, not a function, #conditional compile does not work, |
---|
366 | // but, since it's a Proc, it is not compiled, so missing functions aren't flagged as a compile error |
---|
367 | // if (exists("NCNR_VSANS")==6) //defined in the main VSANS #includes file. |
---|
368 | // DoAlert 0,"**Treating data as VSANS data**" |
---|
369 | Duplicate/O $w3,$(baseStr+"_dQv") //save a copy for VSANS |
---|
370 | $(baseStr+"_dQv") = -$(baseStr+"_dQv") |
---|
371 | USANS_CalcWeights(baseStr,dQv) |
---|
372 | // else |
---|
373 | // DoAlert 0,"Treating data as USANS (normal slit-smeared data)" |
---|
374 | // USANS_CalcWeights(baseStr,dQv) |
---|
375 | // endif |
---|
376 | |
---|
377 | |
---|
378 | |
---|
379 | endif |
---|
380 | Killwaves/Z $w3,$w4,$w5 //get rid of the resolution waves that are in the matrix |
---|
381 | |
---|
382 | SetScale d,0,0,"1/A",$w0 |
---|
383 | SetScale d,0,0,"1/cm",$w1 |
---|
384 | |
---|
385 | endif //6-col data |
---|
386 | |
---|
387 | // Load ORNL data from Heller program |
---|
388 | if(numCols == 4) //4-column SANS or USANS data that has resolution information |
---|
389 | |
---|
390 | // put the names of the (default named) loaded waves into local names |
---|
391 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
392 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
393 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
394 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
395 | |
---|
396 | //remove the semicolon AND period from files from the VAX |
---|
397 | w0 = CleanupName((basestr + "_q"),0) |
---|
398 | w1 = CleanupName((basestr + "_i"),0) |
---|
399 | w2 = CleanupName((basestr + "_s"),0) |
---|
400 | w3 = CleanupName((basestr + "sq"),0) |
---|
401 | w4 = CleanupName((basestr + "qb"),0) |
---|
402 | w5 = CleanupName((basestr + "fs"),0) |
---|
403 | |
---|
404 | |
---|
405 | //String baseStr=w1[0,strlen(w1)-3] |
---|
406 | if(DataFolderExists("root:"+baseStr)) |
---|
407 | if(!forceOverwrite) |
---|
408 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
409 | if(V_flag==2) //user selected No, don't load the data |
---|
410 | SetDataFolder root: |
---|
411 | KillWaves $n0,$n1,$n2,$n3 // kill the default waveX that were loaded |
---|
412 | if(DataFolderExists("root:Packages:NIST")) |
---|
413 | String/G root:Packages:NIST:gLastFileName = filename |
---|
414 | endif |
---|
415 | return //quits the macro |
---|
416 | endif |
---|
417 | endif |
---|
418 | SetDataFolder $("root:"+baseStr) |
---|
419 | else |
---|
420 | NewDataFolder/S $("root:"+baseStr) |
---|
421 | endif |
---|
422 | |
---|
423 | |
---|
424 | |
---|
425 | |
---|
426 | ////overwrite the existing data, if it exists |
---|
427 | Duplicate/O $("root:"+n0), $w0 |
---|
428 | Duplicate/O $("root:"+n1), $w1 |
---|
429 | Duplicate/O $("root:"+n2), $w2 |
---|
430 | Duplicate/O $("root:"+n3), $w3 |
---|
431 | Duplicate/O $("root:"+n0), $w4 // Set qb wave to nominal measured Q values |
---|
432 | Duplicate/O $("root:"+n0), $w5 // Make wave of appropriate length |
---|
433 | $w4 = $w0 |
---|
434 | $w5 = 1 // Set all shadowfactor to 1 |
---|
435 | |
---|
436 | // need to switch based on SANS/USANS |
---|
437 | if (isSANSResolution($w3[0])) //checks to see if the first point of the wave is <0] |
---|
438 | // make a resolution matrix for SANS data |
---|
439 | Variable np=numpnts($w0) |
---|
440 | Make/D/O/N=(np,4) $(baseStr+"_res") |
---|
441 | |
---|
442 | $(baseStr+"_res")[][0] = $w3[p] //sigQ |
---|
443 | $(baseStr+"_res")[][1] = $w4[p] //qBar |
---|
444 | $(baseStr+"_res")[][2] = $w5[p] //fShad |
---|
445 | $(baseStr+"_res")[][3] = $w0[p] //Qvalues |
---|
446 | else |
---|
447 | //the data is USANS data |
---|
448 | // marix calculation here, but for now, just copy the waves |
---|
449 | //$(baseStr+"_res")[][0] = $w3[p] //sigQ |
---|
450 | //$(baseStr+"_res")[][1] = $w4[p] //qBar |
---|
451 | //$(baseStr+"_res")[][2] = $w5[p] //fShad |
---|
452 | //$(baseStr+"_res")[][3] = $w0[p] //Qvalues |
---|
453 | dQv = -$w3[0] |
---|
454 | |
---|
455 | USANS_CalcWeights(baseStr,dQv) |
---|
456 | |
---|
457 | endif |
---|
458 | Killwaves/Z $w3,$w4,$w5 //get rid of the resolution waves that are in the matrix |
---|
459 | |
---|
460 | SetScale d,0,0,"1/A",$w0 |
---|
461 | SetScale d,0,0,"1/cm",$w1 |
---|
462 | |
---|
463 | endif //4-col data |
---|
464 | |
---|
465 | |
---|
466 | if(numCols==5) //this is the "old-style" VAX desmeared data format |
---|
467 | |
---|
468 | // put the names of the three loaded waves into local names |
---|
469 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
470 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
471 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
472 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
473 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
474 | |
---|
475 | |
---|
476 | //remove the semicolon AND period from files from the VAX |
---|
477 | w0 = CleanupName((basestr+"_q"),0) |
---|
478 | w1 = CleanupName((basestr+"_i"),0) |
---|
479 | w2 = CleanupName((basestr+"_s"),0) |
---|
480 | w3 = CleanupName((basestr+"_ism"),0) |
---|
481 | w4 = CleanupName((basestr+"_fit_ism"),0) |
---|
482 | |
---|
483 | //String baseStr=w1[0,strlen(w1)-3] |
---|
484 | if(DataFolderExists("root:"+baseStr)) |
---|
485 | if(!forceOverwrite) |
---|
486 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
487 | if(V_flag==2) //user selected No, don't load the data |
---|
488 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 // kill the default waveX that were loaded |
---|
489 | if(DataFolderExists("root:Packages:NIST")) |
---|
490 | String/G root:Packages:NIST:gLastFileName = filename |
---|
491 | endif //set the last file loaded to the one NOT loaded |
---|
492 | return //quits the macro |
---|
493 | endif |
---|
494 | endif |
---|
495 | SetDataFolder $("root:"+baseStr) |
---|
496 | else |
---|
497 | NewDataFolder/S $("root:"+baseStr) |
---|
498 | endif |
---|
499 | |
---|
500 | ////overwrite the existing data, if it exists |
---|
501 | Duplicate/O $("root:"+n0), $w0 |
---|
502 | Duplicate/O $("root:"+n1), $w1 |
---|
503 | Duplicate/O $("root:"+n2), $w2 |
---|
504 | Duplicate/O $("root:"+n3), $w3 |
---|
505 | Duplicate/O $("root:"+n4), $w4 |
---|
506 | |
---|
507 | // no resolution matrix |
---|
508 | endif //5-col data |
---|
509 | |
---|
510 | ////// |
---|
511 | if(DataFolderExists("root:Packages:NIST")) |
---|
512 | String/G root:Packages:NIST:gLastFileName = filename |
---|
513 | endif |
---|
514 | |
---|
515 | |
---|
516 | //plot if desired |
---|
517 | if(doPlot) |
---|
518 | Print GetDataFolder(1) |
---|
519 | |
---|
520 | // assign colors randomly |
---|
521 | rr = abs(trunc(enoise(65535))) |
---|
522 | gg = abs(trunc(enoise(65535))) |
---|
523 | bb = abs(trunc(enoise(65535))) |
---|
524 | |
---|
525 | // if target window is a graph, and user wants to append, do so |
---|
526 | DoWindow/B Plot_Manager |
---|
527 | if(WinType("") == 1) |
---|
528 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
529 | |
---|
530 | |
---|
531 | if(V_Flag == 1) |
---|
532 | AppendToGraph $w1 vs $w0 |
---|
533 | ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb),tickUnit=1 |
---|
534 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
535 | ModifyGraph tickUnit(left)=1 |
---|
536 | else |
---|
537 | //new graph |
---|
538 | SetDataFolder $("root:"+baseStr) //sometimes I end up back in root: here, and I can't figure out why! |
---|
539 | Display $w1 vs $w0 |
---|
540 | ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 |
---|
541 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
542 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
543 | ModifyGraph tickUnit(left)=1 |
---|
544 | Label left "I(q)" |
---|
545 | Label bottom "q ("+angst+"\\S-1\\M)" |
---|
546 | Legend |
---|
547 | endif |
---|
548 | else |
---|
549 | // graph window was not target, make new one |
---|
550 | Display $w1 vs $w0 |
---|
551 | ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb),tickUnit=1 |
---|
552 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
553 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
554 | ModifyGraph tickUnit(left)=1 |
---|
555 | Label left "I(q)" |
---|
556 | Label bottom "q ("+angst+"\\S-1\\M)" |
---|
557 | Legend |
---|
558 | endif |
---|
559 | endif |
---|
560 | |
---|
561 | //go back to the root folder and clean up before leaving |
---|
562 | SetDataFolder root: |
---|
563 | KillWaves/Z $n0,$n1,$n2,$n3,$n4,$n5 |
---|
564 | |
---|
565 | endif |
---|
566 | End |
---|
567 | |
---|
568 | |
---|
569 | //procedure for loading NSE data in the format (4-columns) |
---|
570 | // qvals - time - I(q,t) - dI(q,t) |
---|
571 | // |
---|
572 | // |
---|
573 | // this does NOT load the data into separate folders... |
---|
574 | // |
---|
575 | Proc A_LoadNSEData() |
---|
576 | A_LoadNSEDataWithName("",1) |
---|
577 | End |
---|
578 | |
---|
579 | Proc A_LoadNSEDataWithName(fileStr,doPlot) |
---|
580 | |
---|
581 | //Load the waves, using default waveX names |
---|
582 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
583 | LoadWave/G/D/A fileStr |
---|
584 | String filename = S_fileName |
---|
585 | |
---|
586 | String w0,w1,w2,n0,n1,n2,wt,w3,n3 |
---|
587 | Variable rr,gg,bb |
---|
588 | |
---|
589 | // put the names of the three loaded waves into local names |
---|
590 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
591 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
592 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
593 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
594 | |
---|
595 | |
---|
596 | //remove the semicolon AND period from files from the VAX |
---|
597 | w0 = CleanupName(("qvals_"+S_fileName),0) |
---|
598 | w1 = CleanupName(("time_"+S_fileName),0) |
---|
599 | w2 = CleanupName(("iqt_"+S_fileName),0) |
---|
600 | w3 = CleanupName(("iqterr_"+S_fileName),0) |
---|
601 | |
---|
602 | if(exists(w0) !=0) |
---|
603 | DoAlert 0,"This file has already been loaded. Use Append to Graph..." |
---|
604 | KillWaves $n0,$n1,$n2 // kill the default waveX that were loaded |
---|
605 | return |
---|
606 | endif |
---|
607 | |
---|
608 | // Rename to give nice names |
---|
609 | Rename $n0, $w0 |
---|
610 | Rename $n1, $w1 |
---|
611 | Rename $n2, $w2 |
---|
612 | Rename $n3, $w3 |
---|
613 | |
---|
614 | if(doPlot) |
---|
615 | // assign colors randomly |
---|
616 | rr = abs(trunc(enoise(65535))) |
---|
617 | gg = abs(trunc(enoise(65535))) |
---|
618 | bb = abs(trunc(enoise(65535))) |
---|
619 | |
---|
620 | // if target window is a graph, and user wants to append, do so |
---|
621 | if(WinType("") == 1) |
---|
622 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
623 | if(V_Flag == 1) |
---|
624 | AppendToGraph $w2 vs $w1 |
---|
625 | ModifyGraph mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2) =(rr,gg,bb),grid=1,mirror=2,tickUnit=1 |
---|
626 | ErrorBars/T=0 $w2 Y,wave=($w3,$w3) |
---|
627 | else |
---|
628 | //new graph |
---|
629 | Display $w2 vs $w1 |
---|
630 | ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 |
---|
631 | ErrorBars/T=0 $w2 Y,wave=($w3,$w3) |
---|
632 | Legend |
---|
633 | endif |
---|
634 | else |
---|
635 | // graph window was not target, make new one |
---|
636 | Display $w2 vs $w1 |
---|
637 | ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1 |
---|
638 | ErrorBars/T=0 $w2 Y,wave=($w3,$w3) |
---|
639 | Legend |
---|
640 | endif |
---|
641 | endif //doPlot |
---|
642 | |
---|
643 | End |
---|
644 | |
---|
645 | //procedure for loading desmeared USANS data in the format (5-columns) |
---|
646 | // qvals - I(q) - sig I - Ism(q) - fitted Ism(q) |
---|
647 | //no weighting wave is created (not needed in IGOR 4) |
---|
648 | // |
---|
649 | // not really ever used... |
---|
650 | // |
---|
651 | Proc A_LoadUSANSData() |
---|
652 | |
---|
653 | //Load the waves, using default waveX names |
---|
654 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
655 | LoadWave/G/D/A |
---|
656 | String filename = S_fileName |
---|
657 | |
---|
658 | String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 |
---|
659 | Variable rr,gg,bb |
---|
660 | |
---|
661 | // put the names of the three loaded waves into local names |
---|
662 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
663 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
664 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
665 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
666 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
667 | |
---|
668 | |
---|
669 | //remove the semicolon AND period from files from the VAX |
---|
670 | w0 = CleanupName((S_fileName+"_q"),0) |
---|
671 | w1 = CleanupName((S_fileName+"_i"),0) |
---|
672 | w2 = CleanupName((S_fileName+"_s"),0) |
---|
673 | w3 = CleanupName((S_fileName+"_ism"),0) |
---|
674 | w4 = CleanupName((S_fileName+"_fit_ism"),0) |
---|
675 | |
---|
676 | if(exists(w0) !=0) //the wave already exists |
---|
677 | DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
678 | if(V_flag==2) //user selected No |
---|
679 | KillWaves $n0,$n1,$n2,$n3,$n4 // kill the default waveX that were loaded |
---|
680 | if(DataFolderExists("root:Packages:NIST")) |
---|
681 | String/G root:Packages:NIST:gLastFileName = filename |
---|
682 | endif //set the last file loaded to the one NOT loaded |
---|
683 | return //quits the macro |
---|
684 | endif |
---|
685 | endif |
---|
686 | |
---|
687 | ////overwrite the existing data, if it exists |
---|
688 | Duplicate/O $n0, $w0 |
---|
689 | Duplicate/O $n1, $w1 |
---|
690 | Duplicate/O $n2, $w2 |
---|
691 | Duplicate/O $n3, $w3 |
---|
692 | Duplicate/O $n4, $w4 |
---|
693 | KillWaves $n0,$n1,$n2,$n3,$n4 |
---|
694 | |
---|
695 | if(DataFolderExists("root:Packages:NIST")) |
---|
696 | String/G root:Packages:NIST:gLastFileName = filename |
---|
697 | endif |
---|
698 | |
---|
699 | // assign colors randomly |
---|
700 | rr = abs(trunc(enoise(65535))) |
---|
701 | gg = abs(trunc(enoise(65535))) |
---|
702 | bb = abs(trunc(enoise(65535))) |
---|
703 | |
---|
704 | // if target window is a graph, and user wants to append, do so |
---|
705 | if(WinType("") == 1) |
---|
706 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
707 | if(V_Flag == 1) |
---|
708 | AppendToGraph $w1 vs $w0 |
---|
709 | ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
710 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
711 | else |
---|
712 | //new graph |
---|
713 | Display $w1 vs $w0 |
---|
714 | ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
715 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
716 | Legend |
---|
717 | endif |
---|
718 | else |
---|
719 | // graph window was not target, make new one |
---|
720 | Display $w1 vs $w0 |
---|
721 | ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
722 | ErrorBars/T=0 $w1 Y,wave=($w2,$w2) |
---|
723 | Legend |
---|
724 | endif |
---|
725 | |
---|
726 | End |
---|
727 | |
---|
728 | |
---|
729 | //// Extra "Utility Procedures" |
---|
730 | // to pick path, get a list of data files, and make sure that a valid filename |
---|
731 | // is passed to LoadOneDDataWithName() |
---|
732 | // |
---|
733 | |
---|
734 | //prompts user to choose the local folder that contains the SANS Data |
---|
735 | //only one folder can be used, and its path is catPathName (and is a NAME, not a string) |
---|
736 | //this will overwrite the path selection |
---|
737 | //returns 1 if no path selected as error condition |
---|
738 | Function A_PickPath() |
---|
739 | |
---|
740 | //set the global string to the selected pathname |
---|
741 | NewPath/O/M="pick the SANS data folder" catPathName |
---|
742 | PathInfo/S catPathName |
---|
743 | String dum = S_path |
---|
744 | String alertStr = "" |
---|
745 | alertStr = "You must set the path to Charlotte through a Mapped Network Drive, not through the Network Neighborhood" |
---|
746 | //alertStr += " Please see the manual for details." |
---|
747 | if (V_flag == 0) |
---|
748 | //path does not exist - no folder selected |
---|
749 | String/G root:Packages:NIST:gCatPathStr = "no folder selected" |
---|
750 | return(1) |
---|
751 | else |
---|
752 | //set the global to the path (as a string) |
---|
753 | // need 4 \ since it is the escape character |
---|
754 | |
---|
755 | // SRK 2016, for windows 10, try to eliminate this restriction |
---|
756 | // print igorinfo(3) |
---|
757 | // if(cmpstr("\\\\",dum[0,1])==0) //Windoze user going through network neighborhood |
---|
758 | // DoAlert 0,alertStr |
---|
759 | // KillPath catPathName |
---|
760 | // return(1) |
---|
761 | // endif |
---|
762 | |
---|
763 | String/G root:Packages:NIST:gCatPathStr = dum |
---|
764 | return(0) //no error |
---|
765 | endif |
---|
766 | End |
---|
767 | |
---|
768 | //Function attempts to find valid filename from partial name that has been stripped of |
---|
769 | //the VAX version number. The partial name is tried first |
---|
770 | //*** the PATH is hard-wired to catPathName (which is assumed to exist) |
---|
771 | //version numers up to ;10 are tried |
---|
772 | //only the "name;vers" is returned. the path is not prepended, hence the return string |
---|
773 | //is not a complete specification of the file |
---|
774 | // |
---|
775 | // added 11/99 - uppercase and lowercase versions of the file are tried, if necessary |
---|
776 | // since from marquee, the filename field (textread[0]) must be used, and can be a mix of // 02JUL13 |
---|
777 | // upper/lowercase letters, while the filename on the server (should) be all caps |
---|
778 | // now makes repeated calls to ValidFileString() |
---|
779 | // |
---|
780 | Function/S A_FindValidFilename(partialName) |
---|
781 | String PartialName |
---|
782 | |
---|
783 | String retStr="" |
---|
784 | |
---|
785 | //try name with no changes - to allow for ABS files that have spaces in the names 12APR04 |
---|
786 | retStr = A_ValidFileString(partialName) |
---|
787 | if(cmpstr(retStr,"") !=0) |
---|
788 | //non-null return |
---|
789 | return(retStr) |
---|
790 | Endif |
---|
791 | |
---|
792 | //if the partial name is derived from the file header, there can be spaces at the beginning |
---|
793 | //or in the middle of the filename - depending on the prefix and initials used |
---|
794 | // |
---|
795 | //remove any leading spaces from the name before starting |
---|
796 | partialName = A_RemoveAllSpaces(partialName) |
---|
797 | |
---|
798 | //try name with no spaces |
---|
799 | retStr = A_ValidFileString(partialName) |
---|
800 | if(cmpstr(retStr,"") !=0) |
---|
801 | //non-null return |
---|
802 | return(retStr) |
---|
803 | Endif |
---|
804 | |
---|
805 | //try all UPPERCASE |
---|
806 | partialName = UpperStr(partialName) |
---|
807 | retStr = A_ValidFileString(partialName) |
---|
808 | if(cmpstr(retStr,"") !=0) |
---|
809 | //non-null return |
---|
810 | return(retStr) |
---|
811 | Endif |
---|
812 | |
---|
813 | //try all lowercase (ret null if failure) |
---|
814 | partialName = LowerStr(partialName) |
---|
815 | retStr = A_ValidFileString(partialName) |
---|
816 | if(cmpstr(retStr,"") !=0) |
---|
817 | //non-null return |
---|
818 | return(retStr) |
---|
819 | else |
---|
820 | return(retStr) |
---|
821 | Endif |
---|
822 | End |
---|
823 | |
---|
824 | //function to test a binary file to see if it is a RAW binary SANS file |
---|
825 | //first checks the total bytes in the file (which for raw data is 33316 bytes) |
---|
826 | //**note that the "DIV" file will also show up as a raw file by the run field |
---|
827 | //should be listed in CAT/SHORT and in patch windows |
---|
828 | // |
---|
829 | //Function then checks the file fname (full path:file) for "RAW" run.type field |
---|
830 | //if not found, the data is not raw data and zero is returned |
---|
831 | Function A_CheckIfRawData(fname) |
---|
832 | String fname |
---|
833 | |
---|
834 | Variable refnum,totalBytes |
---|
835 | String testStr="" |
---|
836 | |
---|
837 | Open/R/T="????TEXT" refNum as fname |
---|
838 | //get the total number of bytes in the file, to avoid moving past EOF |
---|
839 | FStatus refNum |
---|
840 | totalBytes = V_logEOF |
---|
841 | //Print totalBytes |
---|
842 | if(totalBytes!=33316) |
---|
843 | //can't possibly be a raw data file |
---|
844 | Close refnum |
---|
845 | return(0) //not a raw SANS file |
---|
846 | Endif |
---|
847 | FSetPos refNum,75 |
---|
848 | FReadLine/N=3 refNum,testStr |
---|
849 | Close refNum |
---|
850 | |
---|
851 | if(cmpstr(testStr,"RAW")==0) |
---|
852 | //true, is raw data file |
---|
853 | Return(1) |
---|
854 | else |
---|
855 | //some other file |
---|
856 | Return(0) |
---|
857 | Endif |
---|
858 | End |
---|
859 | |
---|
860 | //list (input) is a list, typically returned from IndexedFile() |
---|
861 | //which is semicolon-delimited, and may contain filesnames from the VAX |
---|
862 | //that contain version numbers, where the version number appears as a separate list item |
---|
863 | //(and also as a non-existent file) |
---|
864 | //these numbers must be purged from the list, especially for display in a popup |
---|
865 | //or list processing of filenames |
---|
866 | //the function returns the list, cleaned of version numbers (up to 11) |
---|
867 | //raw data files will typically never have a version number other than 1. |
---|
868 | Function/S A_RemoveVersNumsFromList(list) |
---|
869 | String list |
---|
870 | |
---|
871 | //get rid of version numbers first (up to 11) |
---|
872 | Variable ii,num |
---|
873 | String item |
---|
874 | num = ItemsInList(list,";") |
---|
875 | ii=1 |
---|
876 | do |
---|
877 | item = num2str(ii) |
---|
878 | list = RemoveFromList(item, list ,";" ) |
---|
879 | ii+=1 |
---|
880 | while(ii<12) |
---|
881 | |
---|
882 | return (list) |
---|
883 | End |
---|
884 | |
---|
885 | //Function attempts to find valid filename from partial name that has been stripped of |
---|
886 | //the VAX version number. The partial name is tried first |
---|
887 | //*** the PATH is hard-wired to catPathName (which is assumed to exist) |
---|
888 | //version numers up to ;10 are tried |
---|
889 | //only the "name;vers" is returned. the path is not prepended, hence the return string |
---|
890 | //is not a complete specification of the file |
---|
891 | // |
---|
892 | Function/S A_ValidFileString(partialName) |
---|
893 | String partialName |
---|
894 | |
---|
895 | String tempName = "",msg="" |
---|
896 | Variable ii,refnum |
---|
897 | |
---|
898 | ii=0 |
---|
899 | do |
---|
900 | if(ii==0) |
---|
901 | //first pass, try the partialName |
---|
902 | tempName = partialName |
---|
903 | Open/Z/R/T="????TEXT"/P=catPathName refnum tempName //Does open file (/Z flag) |
---|
904 | if(V_flag == 0) |
---|
905 | //file exists |
---|
906 | Close refnum //YES needed, |
---|
907 | break |
---|
908 | endif |
---|
909 | else |
---|
910 | tempName = partialName + ";" + num2str(ii) |
---|
911 | Open/Z/R/T="????TEXT"/P=catPathName refnum tempName |
---|
912 | if(V_flag == 0) |
---|
913 | //file exists |
---|
914 | Close refnum |
---|
915 | break |
---|
916 | endif |
---|
917 | Endif |
---|
918 | ii+=1 |
---|
919 | //print "ii=",ii |
---|
920 | while(ii<11) |
---|
921 | //go get the selected bits of information, using tempName, which exists |
---|
922 | if(ii>=11) |
---|
923 | //msg = partialName + " not found. is version number > 11?" |
---|
924 | //DoAlert 0, msg |
---|
925 | //PathInfo catPathName |
---|
926 | //Print S_Path |
---|
927 | Return ("") //use null string as error condition |
---|
928 | Endif |
---|
929 | |
---|
930 | Return (tempName) |
---|
931 | End |
---|
932 | |
---|
933 | //function to remove all spaces from names when searching for filenames |
---|
934 | //the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn) |
---|
935 | //but the text field in the header WILL, if less than 3 characters were used for the |
---|
936 | //user's initials, and can have leading spaces if prefix was less than 5 characters |
---|
937 | // |
---|
938 | //returns a string identical to the original string, except with the interior spaces removed |
---|
939 | // |
---|
940 | Function/S A_RemoveAllSpaces(str) |
---|
941 | String str |
---|
942 | |
---|
943 | String tempstr = str |
---|
944 | Variable ii,spc,len //should never be more than 2 or 3 trailing spaces in a filename |
---|
945 | ii=0 |
---|
946 | do |
---|
947 | len = strlen(tempStr) |
---|
948 | spc = strsearch(tempStr," ",0) //is the last character a space? |
---|
949 | if (spc == -1) |
---|
950 | break //no more spaces found, get out |
---|
951 | endif |
---|
952 | str = tempstr |
---|
953 | tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string |
---|
954 | While(1) //should never be more than 2 or 3 |
---|
955 | |
---|
956 | If(strlen(tempStr) < 1) |
---|
957 | tempStr = "" //be sure to return a null string if problem found |
---|
958 | Endif |
---|
959 | |
---|
960 | //Print strlen(tempstr) |
---|
961 | |
---|
962 | Return(tempStr) |
---|
963 | |
---|
964 | End |
---|
965 | |
---|
966 | //AJJ Oct 2008 |
---|
967 | //Moved from GaussUtils - makes more sense to have it here |
---|
968 | |
---|
969 | // utility used in the "PlotSmeared...() macros to get a list of data folders |
---|
970 | // |
---|
971 | //1: Waves. |
---|
972 | //2: Numeric variables. |
---|
973 | //3: String variables. |
---|
974 | //4: Data folders. |
---|
975 | Function/S GetAList(type) |
---|
976 | Variable type |
---|
977 | |
---|
978 | SetDataFolder root: |
---|
979 | |
---|
980 | String objName,str="" |
---|
981 | Variable index = 0 |
---|
982 | do |
---|
983 | objName = GetIndexedObjName(":", type, index) |
---|
984 | if (strlen(objName) == 0) |
---|
985 | break |
---|
986 | endif |
---|
987 | //Print objName |
---|
988 | str += objName + ";" |
---|
989 | index += 1 |
---|
990 | while(1) |
---|
991 | |
---|
992 | // remove myGlobals, Packages, etc. from the folder list |
---|
993 | if(type==4) |
---|
994 | str = RemoveFromList("myGlobals", str , ";" ) |
---|
995 | str = RemoveFromList("Packages", str, ";") |
---|
996 | str = RemoveFromList("AutoFit", str, ";") |
---|
997 | str = RemoveFromList("TISANE", str, ";") |
---|
998 | str = RemoveFromList("HayPenMSA", str, ";") |
---|
999 | str = RemoveFromList("SAS", str, ";") //from Irena |
---|
1000 | str = RemoveFromList("USAXS", str, ";") |
---|
1001 | str = RemoveFromList("RAW;SAM;EMP;BGD;DIV;MSK;ABS;CAL;COR;STO;SUB;DRK;SAS;", str ,";") //root level folders present in old reduction experiments |
---|
1002 | str = RemoveFromList("ToTrim", str , ";" ) //from VSANS |
---|
1003 | endif |
---|
1004 | |
---|
1005 | return(str) |
---|
1006 | End |
---|
1007 | |
---|
1008 | |
---|
1009 | //returns the path to the file, or null if cancel |
---|
1010 | // |
---|
1011 | // either the T="????" or the /F flags work to set the filter to "all files" |
---|
1012 | // but the T is essentially obsolete, /F is new for Igor 6.1 and recommended |
---|
1013 | Function/S DoOpenFileDialog(msg) |
---|
1014 | String msg |
---|
1015 | |
---|
1016 | Variable refNum |
---|
1017 | // String message = "Select a file" |
---|
1018 | String outputPath |
---|
1019 | |
---|
1020 | String fileFilters = "All Files:.*;" |
---|
1021 | |
---|
1022 | // Open/D/R/T="????"/M=msg refNum |
---|
1023 | Open/D/R/F=fileFilters/M=msg refNum |
---|
1024 | outputPath = S_fileName |
---|
1025 | |
---|
1026 | return outputPath |
---|
1027 | End |
---|
1028 | |
---|
1029 | // returns the path to the file, or null if the user cancelled |
---|
1030 | // fancy use of optional parameters |
---|
1031 | // |
---|
1032 | // enforce short file names (25 characters) |
---|
1033 | Function/S DoSaveFileDialog(msg,[fname,suffix]) |
---|
1034 | String msg,fname,suffix |
---|
1035 | Variable refNum |
---|
1036 | // String message = "Save the file as" |
---|
1037 | |
---|
1038 | if(ParamIsDefault(fname)) |
---|
1039 | // Print "fname not supplied" |
---|
1040 | fname = "" |
---|
1041 | endif |
---|
1042 | if(ParamIsDefault(suffix)) |
---|
1043 | // Print "suffix not supplied" |
---|
1044 | suffix = "" |
---|
1045 | endif |
---|
1046 | |
---|
1047 | String outputPath,tmpName,testStr |
---|
1048 | Variable badLength=0,maxLength=25,l1,l2 |
---|
1049 | |
---|
1050 | |
---|
1051 | tmpName = fname + suffix |
---|
1052 | |
---|
1053 | do |
---|
1054 | badLength=0 |
---|
1055 | Open/D/M=msg/T="????" refNum as tmpName //OS will allow 255 characters, but then I can't read it back in! |
---|
1056 | outputPath = S_fileName |
---|
1057 | |
---|
1058 | testStr = ParseFilePath(0, outputPath, ":", 1, 0) //just the filename |
---|
1059 | if(strlen(testStr)==0) |
---|
1060 | break //cancel, allow exit |
---|
1061 | endif |
---|
1062 | if(strlen(testStr) > maxLength) |
---|
1063 | badlength = 1 |
---|
1064 | DoAlert 2,"File name is too long. Is\r"+testStr[0,maxLength-1]+"\rOK?" |
---|
1065 | if(V_flag==3) |
---|
1066 | outputPath = "" |
---|
1067 | break |
---|
1068 | endif |
---|
1069 | if(V_flag==1) //my suggested name is OK, so trim the output |
---|
1070 | badlength=0 |
---|
1071 | l1 = strlen(testStr) //too long length |
---|
1072 | l1 = l1-maxLength //number to trim |
---|
1073 | //Print outputPath |
---|
1074 | l2=strlen(outputPath) |
---|
1075 | outputPath = outputPath[0,l2-1-l1] |
---|
1076 | //Print "modified ",outputPath |
---|
1077 | endif |
---|
1078 | //if(V_flag==2) do nothing, let it go around again |
---|
1079 | endif |
---|
1080 | |
---|
1081 | while(badLength) |
---|
1082 | |
---|
1083 | return outputPath |
---|
1084 | End |
---|
1085 | |
---|
1086 | // returns a shortened file name (26 characters max) so that the loader |
---|
1087 | // won't try to create Igor objects that have names that are longer than 31 |
---|
1088 | // |
---|
1089 | // if Igor 8+, use longer names (within reason) |
---|
1090 | // |
---|
1091 | Function/S ShortFileNameString(inStr) |
---|
1092 | String inStr |
---|
1093 | |
---|
1094 | String outStr="" |
---|
1095 | Variable maxLength |
---|
1096 | |
---|
1097 | if(IgorVersion() < 8) |
---|
1098 | maxLength = 25 |
---|
1099 | else |
---|
1100 | maxLength = 40 |
---|
1101 | endif |
---|
1102 | |
---|
1103 | |
---|
1104 | Variable nameTooLong=0 |
---|
1105 | String/G root:Packages:NIST:gShortNameStr = inStr[0,maxLength-1] |
---|
1106 | SVAR newStr = root:Packages:NIST:gShortNameStr |
---|
1107 | |
---|
1108 | if(strlen(inStr) <= maxLength) |
---|
1109 | return (inStr) //length OK |
---|
1110 | else |
---|
1111 | do |
---|
1112 | nameTooLong = 0 |
---|
1113 | |
---|
1114 | DoAlert 1,"File name is too long. Is\r"+inStr[0,maxLength-1]+"\rOK?" |
---|
1115 | if(V_flag==1) //my suggested name is OK, so trim the output |
---|
1116 | outStr = inStr[0,maxLength-1] |
---|
1117 | //Print "modified ",outStr |
---|
1118 | newStr=outStr |
---|
1119 | return(outStr) |
---|
1120 | endif |
---|
1121 | |
---|
1122 | |
---|
1123 | if(V_flag == 2) //not OK, do something about it |
---|
1124 | |
---|
1125 | DoWindow/F ShorterNameInput //it really shouldn't exist... |
---|
1126 | if(V_flag==0) |
---|
1127 | |
---|
1128 | NewPanel /W=(166,90,666,230) as "Enter a Shorter Name" |
---|
1129 | DoWindow/C ShorterNameInput |
---|
1130 | SetDrawLayer UserBack |
---|
1131 | TitleBox title0,pos={35,8},size={261,20},title=" Enter a shorter file name. It must be 25 characters or less " |
---|
1132 | TitleBox title0,fSize=12,fStyle=1 |
---|
1133 | SetVariable setvar0,pos={21,52},size={300,15},title="New name",value= _STR:newStr |
---|
1134 | SetVariable setvar0,proc=ShorterNameSetVarProc,fsize=12 |
---|
1135 | SetVariable setvar0 valueBackColor=(65535,49151,49151) |
---|
1136 | Button button0,pos={259,87},size={60,20},title="Done" |
---|
1137 | Button button0,proc=ShorterNameDoneButtonProc |
---|
1138 | |
---|
1139 | endif |
---|
1140 | |
---|
1141 | PauseForUser ShorterNameInput |
---|
1142 | |
---|
1143 | // this really should force a good name, but there could be errors that I'm not catching |
---|
1144 | // Print newStr, strlen(newStr) |
---|
1145 | nameTooLong = 0 |
---|
1146 | endif |
---|
1147 | |
---|
1148 | while (nameTooLong) |
---|
1149 | |
---|
1150 | return(newStr) |
---|
1151 | |
---|
1152 | endif |
---|
1153 | |
---|
1154 | End |
---|
1155 | |
---|
1156 | |
---|
1157 | // for the ShortFileNameString() - PauseForUser to get a shorter file name |
---|
1158 | Function ShorterNameSetVarProc(sva) : SetVariableControl |
---|
1159 | STRUCT WMSetVariableAction &sva |
---|
1160 | |
---|
1161 | switch( sva.eventCode ) |
---|
1162 | case 1: // mouse up |
---|
1163 | case 2: // Enter key |
---|
1164 | case 3: // Live update |
---|
1165 | String sv = sva.sval |
---|
1166 | if( strlen(sv) > 25 ) |
---|
1167 | sv= sv[0,24] |
---|
1168 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
1169 | SetVariable setvar0 valueBackColor=(65535,49151,49151) |
---|
1170 | Beep |
---|
1171 | else |
---|
1172 | SetVariable setvar0 valueBackColor=(65535,65535,65535) |
---|
1173 | endif |
---|
1174 | break |
---|
1175 | endswitch |
---|
1176 | return 0 |
---|
1177 | End |
---|
1178 | |
---|
1179 | // for the ShortFileNameString() - PauseForUser to get a shorter file name |
---|
1180 | Function ShorterNameDoneButtonProc(ba) : ButtonControl |
---|
1181 | STRUCT WMButtonAction &ba |
---|
1182 | |
---|
1183 | String win = ba.win |
---|
1184 | |
---|
1185 | switch (ba.eventCode) |
---|
1186 | case 2: |
---|
1187 | SVAR newStr = root:Packages:NIST:gShortNameStr |
---|
1188 | ControlInfo setvar0 |
---|
1189 | newStr = S_value |
---|
1190 | DoWindow/K ShorterNameInput |
---|
1191 | |
---|
1192 | break |
---|
1193 | endswitch |
---|
1194 | |
---|
1195 | return 0 |
---|
1196 | End |
---|
1197 | |
---|
1198 | |
---|
1199 | // a function common to many panels, so put the basic version here that simply |
---|
1200 | // returns null string if no functions are present. Calling procedures can |
---|
1201 | // add to the list to customize as needed. |
---|
1202 | // show the available models |
---|
1203 | // not the f*(cw,xw) point calculations |
---|
1204 | // not the *X(cw,xw) XOPS |
---|
1205 | // |
---|
1206 | // KIND:10 should show only user-defined curve fitting functions |
---|
1207 | // - not XOPs |
---|
1208 | // - not other user-defined functions |
---|
1209 | Function/S User_FunctionPopupList() |
---|
1210 | String list,tmp |
---|
1211 | list = FunctionList("*",";","KIND:10") //get every user defined curve fit function |
---|
1212 | |
---|
1213 | //now start to remove everything the user doesn't need to see... |
---|
1214 | |
---|
1215 | tmp = FunctionList("*_proto",";","KIND:10") //prototypes |
---|
1216 | list = RemoveFromList(tmp, list ,";") |
---|
1217 | |
---|
1218 | |
---|
1219 | //prototypes that show up if GF is loaded |
---|
1220 | list = RemoveFromList("GFFitFuncTemplate", list) |
---|
1221 | list = RemoveFromList("GFFitAllAtOnceTemplate", list) |
---|
1222 | list = RemoveFromList("NewGlblFitFunc", list) |
---|
1223 | list = RemoveFromList("NewGlblFitFuncAllAtOnce", list) |
---|
1224 | list = RemoveFromList("GlobalFitFunc", list) |
---|
1225 | list = RemoveFromList("GlobalFitAllAtOnce", list) |
---|
1226 | list = RemoveFromList("GFFitAAOStructTemplate", list) |
---|
1227 | list = RemoveFromList("NewGF_SetXWaveInList", list) |
---|
1228 | list = RemoveFromList("NewGlblFitFuncAAOStruct", list) |
---|
1229 | |
---|
1230 | // more to remove as a result of 2D/Gizmo |
---|
1231 | list = RemoveFromList("A_WMRunLessThanDelta", list) |
---|
1232 | list = RemoveFromList("WMFindNaNValue", list) |
---|
1233 | list = RemoveFromList("WM_Make3DBarChartParametricWave", list) |
---|
1234 | list = RemoveFromList("UpdateQxQy2Mat", list) |
---|
1235 | list = RemoveFromList("MakeBSMask", list) |
---|
1236 | |
---|
1237 | // MOTOFIT/GenFit bits |
---|
1238 | tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;GeneticFit_UnSmearedModel;GeneticFit_SmearedModel;" |
---|
1239 | list = RemoveFromList(tmp, list ,";") |
---|
1240 | |
---|
1241 | // SANS Reduction bits |
---|
1242 | tmp = "ASStandardFunction;Ann_1D_Graph;Avg_1D_Graph;BStandardFunction;CStandardFunction;Draw_Plot1D;MyMat2XYZ;" |
---|
1243 | list = RemoveFromList(tmp, list ,";") |
---|
1244 | 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;" |
---|
1245 | list = RemoveFromList(tmp, list ,";") |
---|
1246 | |
---|
1247 | |
---|
1248 | // USANS Reduction bits |
---|
1249 | tmp = "DSM_Guinier_Fit;RemoveMaskedPoints;" |
---|
1250 | list = RemoveFromList(tmp, list ,";") |
---|
1251 | |
---|
1252 | //more functions from analysis models (2008) |
---|
1253 | tmp = "Barbell_Inner;Barbell_Outer;Barbell_integrand;BCC_Integrand;Integrand_BCC_Inner;Integrand_BCC_Outer;" |
---|
1254 | list = RemoveFromList(tmp, list ,";") |
---|
1255 | tmp = "CapCyl;CapCyl_Inner;CapCyl_Outer;ConvLens;ConvLens_Inner;ConvLens_Outer;" |
---|
1256 | list = RemoveFromList(tmp, list ,";") |
---|
1257 | tmp = "Dumb;Dumb_Inner;Dumb_Outer;FCC_Integrand;Integrand_FCC_Inner;Integrand_FCC_Outer;" |
---|
1258 | list = RemoveFromList(tmp, list ,";") |
---|
1259 | tmp = "Integrand_SC_Inner;Integrand_SC_Outer;SC_Integrand;SphCyl;SphCyl_Inner;SphCyl_Outer;" |
---|
1260 | list = RemoveFromList(tmp, list ,";") |
---|
1261 | tmp = "CSPP_Outer;CSPP_Inner;PP_Outer;PP_Inner;" |
---|
1262 | list = RemoveFromList(tmp, list ,";") |
---|
1263 | tmp = "Guinier_Fit;" |
---|
1264 | list = RemoveFromList(tmp, list ,";") |
---|
1265 | |
---|
1266 | tmp = FunctionList("f*",";","NPARAMS:2") //point calculations |
---|
1267 | list = RemoveFromList(tmp, list ,";") |
---|
1268 | |
---|
1269 | tmp = FunctionList("fSmear*",";","NPARAMS:3") //smeared dependency calculations |
---|
1270 | list = RemoveFromList(tmp, list ,";") |
---|
1271 | |
---|
1272 | // anything that might be included in Irena |
---|
1273 | tmp = FunctionList("GEN_*",";","KIND:10") |
---|
1274 | list = RemoveFromList(tmp, list ,";") |
---|
1275 | tmp = FunctionList("IN2G_*",";","KIND:10") |
---|
1276 | list = RemoveFromList(tmp, list ,";") |
---|
1277 | tmp = FunctionList("IR1A_*",";","KIND:10") |
---|
1278 | list = RemoveFromList(tmp, list ,";") |
---|
1279 | tmp = FunctionList("IR1B_*",";","KIND:10") |
---|
1280 | list = RemoveFromList(tmp, list ,";") |
---|
1281 | tmp = FunctionList("IR1U_*",";","KIND:10") |
---|
1282 | list = RemoveFromList(tmp, list ,";") |
---|
1283 | tmp = FunctionList("IR1V_*",";","KIND:10") |
---|
1284 | list = RemoveFromList(tmp, list ,";") |
---|
1285 | tmp = FunctionList("IR1_*",";","KIND:10") |
---|
1286 | list = RemoveFromList(tmp, list ,";") |
---|
1287 | tmp = FunctionList("IR2D_*",";","KIND:10") |
---|
1288 | list = RemoveFromList(tmp, list ,";") |
---|
1289 | |
---|
1290 | tmp = FunctionList("IR2D_*",";","KIND:10") |
---|
1291 | list = RemoveFromList(tmp, list ,";") |
---|
1292 | tmp = FunctionList("IR2H_*",";","KIND:10") |
---|
1293 | list = RemoveFromList(tmp, list ,";") |
---|
1294 | tmp = FunctionList("IR2L_*",";","KIND:10") |
---|
1295 | list = RemoveFromList(tmp, list ,";") |
---|
1296 | tmp = FunctionList("IR2Pr_*",";","KIND:10") |
---|
1297 | list = RemoveFromList(tmp, list ,";") |
---|
1298 | tmp = FunctionList("IR2R_*",";","KIND:10") |
---|
1299 | list = RemoveFromList(tmp, list ,";") |
---|
1300 | tmp = FunctionList("IR2S_*",";","KIND:10") |
---|
1301 | list = RemoveFromList(tmp, list ,";") |
---|
1302 | tmp = FunctionList("IR2_*",";","KIND:10") |
---|
1303 | list = RemoveFromList(tmp, list ,";") |
---|
1304 | tmp = FunctionList("*LogLog",";","KIND:10") |
---|
1305 | list = RemoveFromList(tmp, list ,";") |
---|
1306 | |
---|
1307 | //functions included in Nika |
---|
1308 | tmp = FunctionList("NI1*",";","KIND:10") |
---|
1309 | list = RemoveFromList(tmp, list ,";") |
---|
1310 | tmp = FunctionList("TransAx_*",";","KIND:10") |
---|
1311 | list = RemoveFromList(tmp, list ,";") |
---|
1312 | tmp = FunctionList("TransformAxis*",";","KIND:10") |
---|
1313 | list = RemoveFromList(tmp, list ,";") |
---|
1314 | tmp = FunctionList("erfForNormal*",";","KIND:10") |
---|
1315 | list = RemoveFromList(tmp, list ,";") |
---|
1316 | |
---|
1317 | // functions in Indra (USAXS) |
---|
1318 | tmp = FunctionList("IN2Q_*",";","KIND:10") |
---|
1319 | list = RemoveFromList(tmp, list ,";") |
---|
1320 | tmp = FunctionList("IN3_*",";","KIND:10") |
---|
1321 | list = RemoveFromList(tmp, list ,";") |
---|
1322 | |
---|
1323 | // tmp = FunctionList("*X",";","KIND:4") //XOPs, but these shouldn't show up if KIND:10 is used initially |
---|
1324 | // Print "X* = ",tmp |
---|
1325 | // print " " |
---|
1326 | // list = RemoveFromList(tmp, list ,";") |
---|
1327 | |
---|
1328 | //non-fit functions that I can't seem to filter out |
---|
1329 | list = RemoveFromList("BinaryHS_PSF11;BinaryHS_PSF12;BinaryHS_PSF22;EllipCyl_Integrand;PP_Inner;PP_Outer;Phi_EC;TaE_Inner;TaE_Outer;",list,";") |
---|
1330 | |
---|
1331 | // from 2010 model functions |
---|
1332 | list = RemoveFromList("fTwoYukawa;DoBoxGraph;Gauss2D_theta;",list,";") |
---|
1333 | |
---|
1334 | // from Debye Sphere method |
---|
1335 | list = RemoveFromList("CalcIQRfromMat;ConnectPoints2D;ConnectPoints3D;ConnectPoints3D_old;ConnectedRodFill;ConvertXYZto3N;CylindersAtPoints;",list,";") |
---|
1336 | list = RemoveFromList("FillSphere;FillSphere3;FillSphereRadius;FillSphereRadiusNoOverlap;FillXCylinder;FillXYCircle;FillXZCircle;FillYCylinder;",list,";") |
---|
1337 | list = RemoveFromList("FillYZCircle;FillZCylinder;PadMatrix;RandomFill3DMat;RandomPoints2D;SobolFill3DMat;SphereAtEachPoint;UnConnectedRodFill;XYZV_toByteVoxels;",list,";") |
---|
1338 | list = RemoveFromList("MakeTriplet;SobolPoints2D;X_CylindersAtPoints;X_CylindersHexagonalGrid;X_CylindersSquareGrid;maxDistance_Threaded;KR_MultiCylinder;KR_MultiCylinder_Units;",list,";") |
---|
1339 | list = RemoveFromList("X_CoreShellCylinderHexGrid;FillPlaneHexagonal;FillPlaneSquareGrid;FillSphereRadiusPeriodic;",list,";") |
---|
1340 | list = RemoveFromList("Setup_Ur;M_energy;DoRotation;Copy_xyz_to_xyz3d;MultiCyl_Loop;",list,";") |
---|
1341 | |
---|
1342 | // from Polarization |
---|
1343 | list = RemoveFromList("ParseDecayRow;ParseFlipperRow;",list,";") |
---|
1344 | |
---|
1345 | // from 2012 models |
---|
1346 | list = RemoveFromList("cng_integ;",list,";") |
---|
1347 | |
---|
1348 | // from 2012 Event Mode Processing |
---|
1349 | list = RemoveFromList("CleanupTimes;IndexForHistogram;JointHistogram;MakeFibonacciWave;Osc_ProcessEvents;SetFibonacciBins;SetLinearBins;SetLogBins;Stream_ProcessEvents;",list,";") |
---|
1350 | |
---|
1351 | // from 2013 Simulation |
---|
1352 | // list = RemoveFromList("EC_Empirical;SmearedEC_Empirical;",list,";") |
---|
1353 | list = RemoveFromList("SAS_XS_Sphere;Generate_UofR;Setup_Ur_HS;",list,";") |
---|
1354 | |
---|
1355 | |
---|
1356 | // from 2014 Automation of reduction |
---|
1357 | list = RemoveFromList("DoAnnulusGraph;DoArcGraph;",list,";") |
---|
1358 | |
---|
1359 | // from 2017-2018 VSANS reduction |
---|
1360 | tmp = FunctionList("V_*",";","KIND:10") |
---|
1361 | list = RemoveFromList(tmp, list ,";") |
---|
1362 | list = RemoveFromList("V_BroadPeak_Pix2D;V_BroadPeak_Pix2D_noThread;V_CleanupTimes;V_I_BroadPeak_Pix2D;V_IndexForHistogram;V_MakeFibonacciWave;V_UpdatePix2Mat;",list,";") |
---|
1363 | |
---|
1364 | tmp = FunctionList("*X_",";","KIND:10") // dummy functions with "X_" at the end, for vsans (2018) |
---|
1365 | list = RemoveFromList(tmp, list ,";") |
---|
1366 | |
---|
1367 | list = RemoveFromList("Integrate_BuiltIn;intgrnd;xJointHistogram;",list,";") |
---|
1368 | |
---|
1369 | |
---|
1370 | list = SortList(list) |
---|
1371 | return(list) |
---|
1372 | End |
---|
1373 | |
---|
1374 | |
---|
1375 | /////////////////////////////////////////////////// |
---|
1376 | // old SANSPreferences have been moved here to a common place and renamed to "NCNR Preferences" so that they |
---|
1377 | // are common to all of the packages (and will appear on all of the menus) |
---|
1378 | // |
---|
1379 | // globals moved to root:Packages:NIST: since this is generated by all packages. |
---|
1380 | // |
---|
1381 | /////////////////////////// |
---|
1382 | // user preferences |
---|
1383 | // |
---|
1384 | // globals are created in initialize.ipf |
---|
1385 | // |
---|
1386 | // this panel allows for user modification |
---|
1387 | /////////////////////////// |
---|
1388 | Proc Show_Preferences_Panel() |
---|
1389 | |
---|
1390 | DoWindow/F Pref_Panel |
---|
1391 | if(V_flag==0) |
---|
1392 | // only re-initialize if the variables don't exist, so you don't overwrite what users have changed |
---|
1393 | if( exists("root:Packages:NIST:gXML_Write") != 2 ) //if the global variable does not exist, initialize |
---|
1394 | Initialize_Preferences() |
---|
1395 | endif |
---|
1396 | Pref_Panel() |
---|
1397 | Endif |
---|
1398 | // Print "Preferences Panel stub" |
---|
1399 | End |
---|
1400 | |
---|
1401 | Proc Initialize_Preferences() |
---|
1402 | // create the globals here if they are not already present |
---|
1403 | |
---|
1404 | // each package initialization should call this to repeat the initialization |
---|
1405 | // without overwriting what was already set |
---|
1406 | |
---|
1407 | Variable val |
---|
1408 | |
---|
1409 | ///// items for SANS reduction |
---|
1410 | val = NumVarOrDefault("root:Packages:NIST:gLogScalingAsDefault", 1 ) |
---|
1411 | Variable/G root:Packages:NIST:gLogScalingAsDefault=val |
---|
1412 | |
---|
1413 | val = NumVarOrDefault("root:Packages:NIST:gAllowDRK", 0 ) |
---|
1414 | Variable/G root:Packages:NIST:gAllowDRK=val //don't show DRK as default |
---|
1415 | |
---|
1416 | val = NumVarOrDefault("root:Packages:NIST:gDoTransCheck", 1 ) |
---|
1417 | Variable/G root:Packages:NIST:gDoTransCheck=val |
---|
1418 | |
---|
1419 | val = NumVarOrDefault("root:Packages:NIST:gBinWidth", 1 ) |
---|
1420 | Variable/G root:Packages:NIST:gBinWidth=val |
---|
1421 | |
---|
1422 | val = NumVarOrDefault("root:Packages:NIST:gNPhiSteps", 72 ) |
---|
1423 | Variable/G root:Packages:NIST:gNPhiSteps=val |
---|
1424 | |
---|
1425 | // flags to turn detector corrections on/off for testing (you should leave these ON) |
---|
1426 | val = NumVarOrDefault("root:Packages:NIST:gDoDetectorEffCorr", 1 ) |
---|
1427 | Variable/G root:Packages:NIST:gDoDetectorEffCorr = 1 |
---|
1428 | |
---|
1429 | val = NumVarOrDefault("root:Packages:NIST:gDoTransmissionCorr", 1 ) |
---|
1430 | Variable/G root:Packages:NIST:gDoTransmissionCorr = 1 |
---|
1431 | |
---|
1432 | // flag to allow adding raw data files with different attenuation (normally not done) |
---|
1433 | val = NumVarOrDefault("root:Packages:NIST:gDoAdjustRAW_Atten",0) |
---|
1434 | Variable/G root:Packages:NIST:gDoAdjustRAW_Atten=val |
---|
1435 | |
---|
1436 | /// items for SANS Analysis |
---|
1437 | |
---|
1438 | |
---|
1439 | /// items for USANS Reduction |
---|
1440 | // is the data file from NICE and in terms of QValues rather than angle |
---|
1441 | val = NumVarOrDefault("root:Packages:NIST:gRawUSANSisQvalues", 1 ) |
---|
1442 | Variable/G root:Packages:NIST:gRawUSANSisQvalues=val |
---|
1443 | |
---|
1444 | /// items for everyone |
---|
1445 | val = NumVarOrDefault("root:Packages:NIST:gXML_Write", 0 ) |
---|
1446 | Variable/G root:Packages:NIST:gXML_Write = val |
---|
1447 | |
---|
1448 | |
---|
1449 | end |
---|
1450 | |
---|
1451 | Function LogScalePrefCheck(ctrlName,checked) : CheckBoxControl |
---|
1452 | String ctrlName |
---|
1453 | Variable checked |
---|
1454 | |
---|
1455 | NVAR gLog = root:Packages:NIST:gLogScalingAsDefault |
---|
1456 | glog=checked |
---|
1457 | //print "log pref checked = ",checked |
---|
1458 | End |
---|
1459 | |
---|
1460 | Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl |
---|
1461 | String ctrlName |
---|
1462 | Variable checked |
---|
1463 | |
---|
1464 | NVAR gDRK = root:Packages:NIST:gAllowDRK |
---|
1465 | gDRK = checked |
---|
1466 | //Print "DRK preference = ",checked |
---|
1467 | End |
---|
1468 | |
---|
1469 | Function UnityTransPref(ctrlName,checked) : CheckBoxControl |
---|
1470 | String ctrlName |
---|
1471 | Variable checked |
---|
1472 | |
---|
1473 | NVAR gVal = root:Packages:NIST:gDoTransCheck |
---|
1474 | gVal = checked |
---|
1475 | End |
---|
1476 | |
---|
1477 | Function XMLWritePref(ctrlName,checked) : CheckBoxControl |
---|
1478 | String ctrlName |
---|
1479 | Variable checked |
---|
1480 | |
---|
1481 | NVAR gVal = root:Packages:NIST:gXML_Write |
---|
1482 | gVal = checked |
---|
1483 | End |
---|
1484 | |
---|
1485 | Function DoTransCorrPref(ctrlName,checked) : CheckBoxControl |
---|
1486 | String ctrlName |
---|
1487 | Variable checked |
---|
1488 | |
---|
1489 | NVAR gVal = root:Packages:NIST:gDoTransmissionCorr |
---|
1490 | gVal = checked |
---|
1491 | End |
---|
1492 | |
---|
1493 | Function DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl |
---|
1494 | String ctrlName |
---|
1495 | Variable checked |
---|
1496 | |
---|
1497 | NVAR gVal = root:Packages:NIST:gDoDetectorEffCorr |
---|
1498 | gVal = checked |
---|
1499 | End |
---|
1500 | |
---|
1501 | Function DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl |
---|
1502 | String ctrlName |
---|
1503 | Variable checked |
---|
1504 | |
---|
1505 | NVAR gVal = root:Packages:NIST:gDoAdjustRAW_Atten |
---|
1506 | gVal = checked |
---|
1507 | End |
---|
1508 | |
---|
1509 | //set the angle->Q conversion factor |
---|
1510 | // or set the Q->Q "conversion" factor |
---|
1511 | // this is the same value that is set in Init_USANS_Facility() |
---|
1512 | // Mar 2019 |
---|
1513 | Function RawUSANSisQPref(ctrlName,checked) : CheckBoxControl |
---|
1514 | String ctrlName |
---|
1515 | Variable checked |
---|
1516 | |
---|
1517 | NVAR gVal = root:Packages:NIST:gRawUSANSisQvalues |
---|
1518 | gVal = checked |
---|
1519 | |
---|
1520 | if(checked == 1) |
---|
1521 | Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv = 1 //so that the q-values are unchanged |
---|
1522 | else |
---|
1523 | Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv=5.55e-5 //JGB -- 2/24/01 |
---|
1524 | endif |
---|
1525 | End |
---|
1526 | |
---|
1527 | |
---|
1528 | |
---|
1529 | Function PrefDoneButtonProc(ctrlName) : ButtonControl |
---|
1530 | String ctrlName |
---|
1531 | |
---|
1532 | DoWindow/K pref_panel |
---|
1533 | End |
---|
1534 | |
---|
1535 | Proc Pref_Panel() |
---|
1536 | PauseUpdate; Silent 1 // building window... |
---|
1537 | NewPanel /W=(646,208,1070,468)/K=2 as "NCNR Preference Panel" |
---|
1538 | DoWindow/C pref_panel |
---|
1539 | ModifyPanel cbRGB=(49694,61514,27679) |
---|
1540 | SetDrawLayer UserBack |
---|
1541 | ModifyPanel fixedSize=1 |
---|
1542 | ////// |
---|
1543 | //on main portion of panel, always visible |
---|
1544 | Button PrefPanelButtonA,pos={354,12},size={50,20},proc=PrefDoneButtonProc,title="Done" |
---|
1545 | |
---|
1546 | TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=PrefTabProc |
---|
1547 | TabControl PrefTab,tabLabel(1)="SANS",tabLabel(2)="USANS",tabLabel(3)="Analysis" |
---|
1548 | TabControl PrefTab,value=0 |
---|
1549 | TabControl PrefTab labelBack=(49694,61514,27679) |
---|
1550 | |
---|
1551 | //on tab(0) - General - initially visible |
---|
1552 | CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=XMLWritePref,title="Use canSAS XML Output" |
---|
1553 | CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"} |
---|
1554 | CheckBox PrefCtrl_0a,value= root:Packages:NIST:gXML_Write |
---|
1555 | |
---|
1556 | //on tab(1) - SANS |
---|
1557 | CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=LogScalePrefCheck,title="Use Log scaling for 2D data display" |
---|
1558 | 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."} |
---|
1559 | CheckBox PrefCtrl_1a,value= root:Packages:NIST:gLogScalingAsDefault |
---|
1560 | CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=DRKProtocolPref,title="Allow DRK correction in protocols" |
---|
1561 | 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."} |
---|
1562 | CheckBox PrefCtrl_1b,value= root:Packages:NIST:gAllowDRK |
---|
1563 | CheckBox PrefCtrl_1c,pos={21,140},size={137,14},proc=UnityTransPref,title="Check for Transmission = 1" |
---|
1564 | CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"} |
---|
1565 | CheckBox PrefCtrl_1c,value= root:Packages:NIST:gDoTransCheck |
---|
1566 | SetVariable PrefCtrl_1d,pos={21,170},size={200,15},title="Averaging Bin Width (pixels)" |
---|
1567 | SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:gBinWidth |
---|
1568 | SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)" |
---|
1569 | SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:gNPhiSteps |
---|
1570 | CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:gDoTransmissionCorr,proc=DoTransCorrPref |
---|
1571 | CheckBox PrefCtrl_1f pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} |
---|
1572 | CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=DoEfficiencyCorrPref |
---|
1573 | 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."} |
---|
1574 | CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=DoRawAttenAdjPref |
---|
1575 | CheckBox PrefCtrl_1h value=root:Packages:NIST:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"} |
---|
1576 | |
---|
1577 | CheckBox PrefCtrl_1a,disable=1 |
---|
1578 | CheckBox PrefCtrl_1b,disable=1 |
---|
1579 | CheckBox PrefCtrl_1c,disable=1 |
---|
1580 | SetVariable PrefCtrl_1d,disable=1 |
---|
1581 | SetVariable PrefCtrl_1e,disable=1 |
---|
1582 | CheckBox PrefCtrl_1f,disable=1 |
---|
1583 | CheckBox PrefCtrl_1g,disable=1 |
---|
1584 | CheckBox PrefCtrl_1h,disable=1 |
---|
1585 | |
---|
1586 | //on tab(2) - USANS |
---|
1587 | // GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
1588 | // GroupBox PrefCtrl_2a,disable=1 |
---|
1589 | CheckBox PrefCtrl_2a,pos={21,100},size={171,14},proc=RawUSANSisQPref,title="Raw USANS Data is Q-values" |
---|
1590 | CheckBox PrefCtrl_2a,help={"Check this if raw data was collected using NICE (q-values). If data was collected using ICP (angle), leave this unchecked."} |
---|
1591 | CheckBox PrefCtrl_2a,value= root:Packages:NIST:gRawUSANSisQvalues |
---|
1592 | |
---|
1593 | |
---|
1594 | CheckBox PrefCtrl_2a,disable=1 |
---|
1595 | |
---|
1596 | |
---|
1597 | |
---|
1598 | //on tab(3) - Analysis |
---|
1599 | GroupBox PrefCtrl_3a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
1600 | |
---|
1601 | GroupBox PrefCtrl_3a,disable=1 |
---|
1602 | |
---|
1603 | EndMacro |
---|
1604 | |
---|
1605 | // function to control the drawing of controls in the TabControl on the main panel |
---|
1606 | // Naming scheme for the controls MUST be strictly adhered to... else controls will |
---|
1607 | // appear in odd places... |
---|
1608 | // all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting |
---|
1609 | // the controls position on that particular tab. |
---|
1610 | // in this way, they will always be drawn correctly.. |
---|
1611 | // |
---|
1612 | Function PrefTabProc(name,tab) |
---|
1613 | String name |
---|
1614 | Variable tab |
---|
1615 | |
---|
1616 | // Print "name,number",name,tab |
---|
1617 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
1618 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
1619 | for(ii=0;ii<num;ii+=1) |
---|
1620 | //items all start w/"PrefCtrl_", 9 characters |
---|
1621 | item=StringFromList(ii, ctrlList ,";") |
---|
1622 | nameStr=item[0,8] |
---|
1623 | if(cmpstr(nameStr,"PrefCtrl_")==0) |
---|
1624 | onTab = str2num(item[9]) //[9] is a number |
---|
1625 | ControlInfo $item |
---|
1626 | switch(abs(V_flag)) |
---|
1627 | case 1: |
---|
1628 | Button $item,disable=(tab!=onTab) |
---|
1629 | break |
---|
1630 | case 2: |
---|
1631 | CheckBox $item,disable=(tab!=onTab) |
---|
1632 | break |
---|
1633 | case 5: |
---|
1634 | SetVariable $item,disable=(tab!=onTab) |
---|
1635 | break |
---|
1636 | case 10: |
---|
1637 | TitleBox $item,disable=(tab!=onTab) |
---|
1638 | break |
---|
1639 | case 4: |
---|
1640 | ValDisplay $item,disable=(tab!=onTab) |
---|
1641 | break |
---|
1642 | case 9: |
---|
1643 | GroupBox $item,disable=(tab!=onTab) |
---|
1644 | break |
---|
1645 | // add more items to the switch if different control types are used |
---|
1646 | endswitch |
---|
1647 | endif |
---|
1648 | endfor |
---|
1649 | return(0) |
---|
1650 | End |
---|
1651 | |
---|
1652 | |
---|
1653 | |
---|
1654 | |
---|
1655 | |
---|
1656 | |
---|
1657 | |
---|
1658 | //////////////////////////////////// |
---|
1659 | // Modification from Matt Wasbrough to allow rescaling of the |
---|
1660 | // axes while plotting and fitting. allows export of the rescaled |
---|
1661 | // data and of the rescaled model |
---|
1662 | // Nov 2012 |
---|
1663 | /// |
---|
1664 | |
---|
1665 | Function UseRescaleAxisCheckProc(cba) : CheckBoxControl |
---|
1666 | STRUCT WMCheckboxAction &cba |
---|
1667 | |
---|
1668 | switch( cba.eventCode ) |
---|
1669 | case 2: // mouse up |
---|
1670 | Variable checked = cba.checked |
---|
1671 | if(checked) |
---|
1672 | Execute "OpenAxisPanel()" |
---|
1673 | else |
---|
1674 | if(exists("RescaleAxisPanel") !=0) |
---|
1675 | DoWindow/K RescaleAxisPanel |
---|
1676 | endif |
---|
1677 | endif |
---|
1678 | break |
---|
1679 | endswitch |
---|
1680 | |
---|
1681 | return 0 |
---|
1682 | End |
---|
1683 | |
---|
1684 | Proc OpenAxisPanel() |
---|
1685 | If(WinType("RescaleAxisPanel") == 0) |
---|
1686 | //create the necessary data folder |
---|
1687 | NewDataFolder/O root:Packages |
---|
1688 | NewDataFolder/O root:Packages:NIST |
---|
1689 | NewDataFolder/O root:Packages:NIST:RescaleAxis |
---|
1690 | //initialize the values |
---|
1691 | Variable/G root:Packages:NIST:RescaleAxis:gRAExpA = 1 |
---|
1692 | Variable/G root:Packages:NIST:RescaleAxis:gRAExpB = 1 |
---|
1693 | Variable/G root:Packages:NIST:RescaleAxis:gRAExpC = 1 |
---|
1694 | RescaleAxisPanel() |
---|
1695 | else |
---|
1696 | //window already exists, just bring to front for update |
---|
1697 | DoWindow/F RescaleAxisPanel |
---|
1698 | endif |
---|
1699 | End |
---|
1700 | |
---|
1701 | Window RescaleAxisPanel() |
---|
1702 | PauseUpdate; Silent 1 // building window... |
---|
1703 | NewPanel /W=(461,46,735,195)/K=1 |
---|
1704 | ModifyPanel cbRGB=(49360,30954,64507), fixedSize=1 |
---|
1705 | SetDrawLayer UserBack |
---|
1706 | PopupMenu ymodel,pos={20,10},size={76,19},title="y-axis" |
---|
1707 | PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"} |
---|
1708 | PopupMenu ymodel,mode=1,value= #"\"I;log(I);ln(I);1/I;I^a;Iq^a;I^a q^b;1/sqrt(I);ln(Iq);ln(Iq^2)\"" |
---|
1709 | Button GoRescale,pos={50,80},size={70,20},proc=RescalePlot,title="Rescale" |
---|
1710 | Button GoRescale,help={"This button will rescale the axis using the selections in this panel"} |
---|
1711 | Button DoneButton,pos={170,80},size={70,20},proc=RADoneButton,title="Done" |
---|
1712 | Button DoneButton,help={"This button will close the panel"} |
---|
1713 | Button ExportData, pos={100,110}, size={90,20}, proc=ExportData, title="Export Data" |
---|
1714 | Button ExportData, help={"This button will export data from the top graph"} |
---|
1715 | SetVariable expa,pos={13,45},size={80,17},title="pow \"a\"" |
---|
1716 | SetVariable expa,help={"This sets the exponent \"a\" for some y-axis formats. The value is ignored if the model does not use an adjustable exponent"} |
---|
1717 | SetVariable expa,limits={-2,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpA |
---|
1718 | SetVariable expb,pos={98,45},size={80,17},title="pow \"b\"" |
---|
1719 | SetVariable expb,help={"This sets the exponent \"b\" for some x-axis formats. The value is ignored if the model does not use an adjustable exponent"} |
---|
1720 | SetVariable expb,limits={0,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpB |
---|
1721 | PopupMenu xmodel,pos={155,10},size={79,19},title="x-axis" |
---|
1722 | PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"} |
---|
1723 | PopupMenu xmodel,mode=1,value= #"\"q;log(q);q^2;q^c\"" |
---|
1724 | SetVariable expc,pos={182,45},size={80,17},title="pow \"c\"" |
---|
1725 | SetVariable expc,help={"This sets the exponent \"c\" for some x-axis formats. The value is ignored if the model does not use \"c\" as an adjustable exponent"} |
---|
1726 | SetVariable expc,limits={-10,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpC |
---|
1727 | Button RAHelp, pos={220,110}, size={20,20}, proc=RAHelpButtonProc, title="?" |
---|
1728 | EndMacro |
---|
1729 | |
---|
1730 | Proc RADoneButton(ctrlName): ButtonControl |
---|
1731 | String ctrlName |
---|
1732 | DoWindow/K RescaleAxisPanel |
---|
1733 | DoWindow/F WrapperPanel |
---|
1734 | CheckBox check_8 value=0 |
---|
1735 | end |
---|
1736 | |
---|
1737 | Function RAHelpButtonProc(ba) : ButtonControl |
---|
1738 | STRUCT WMButtonAction &ba |
---|
1739 | |
---|
1740 | switch( ba.eventCode ) |
---|
1741 | case 2: // mouse up |
---|
1742 | // click code here |
---|
1743 | DisplayHelpTopic/Z/K=1 "Rescaled Axis" |
---|
1744 | if(V_flag !=0) |
---|
1745 | DoAlert 0,"The Rescaled Axis Help file could not be found" |
---|
1746 | endif |
---|
1747 | break |
---|
1748 | endswitch |
---|
1749 | |
---|
1750 | return 0 |
---|
1751 | End |
---|
1752 | |
---|
1753 | Proc ExportData(ctrlName): ButtonControl |
---|
1754 | string ctrlName |
---|
1755 | WriteRescaledData() |
---|
1756 | End |
---|
1757 | |
---|
1758 | |
---|
1759 | Function RescalePlot (ctrlName): ButtonControl |
---|
1760 | String ctrlName |
---|
1761 | SetDataFolder root: |
---|
1762 | String topGraph= WinName(0,1) //this is the topmost graph |
---|
1763 | if(strlen(topGraph)==0) |
---|
1764 | Abort "There is no graph" |
---|
1765 | endif |
---|
1766 | |
---|
1767 | DoWindow/F $topGraph |
---|
1768 | GetWindow/Z $topGraph, wavelist |
---|
1769 | wave/t W_Wavelist |
---|
1770 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1771 | if (exists("W_WaveList")==1) |
---|
1772 | KillWaves/Z root:Packages:NIST:RescaleAxis:W_WaveList |
---|
1773 | endif |
---|
1774 | MoveWave root:W_WaveList, root:Packages:NIST:RescaleAxis:W_WaveList |
---|
1775 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1776 | variable i,j,k |
---|
1777 | string DF,DF1,temp, temp2, t1 |
---|
1778 | for (i=0; i < numpnts(W_WaveList)/3; i+=1) |
---|
1779 | temp = W_WaveList[i][1] |
---|
1780 | if (stringmatch(temp, "*_i") || stringmatch(temp, "*_i_RA")) |
---|
1781 | temp = W_WaveList[i][0] |
---|
1782 | if(stringmatch(temp, "*_i")) |
---|
1783 | temp = removeending(temp, "_i") |
---|
1784 | elseif(stringmatch(temp, "*_i_RA")) |
---|
1785 | temp = removeending(temp, "_i_RA") |
---|
1786 | endif |
---|
1787 | Make/T/O $temp/Wave=tempWave |
---|
1788 | DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") |
---|
1789 | if (strlen(DF) ==0) |
---|
1790 | DF = ":" |
---|
1791 | endif |
---|
1792 | DF1 = "root"+DF |
---|
1793 | tempWave[0] = DF1 |
---|
1794 | k = 1 |
---|
1795 | for(j=0;j<numpnts(W_WaveList)/3; j+=1) |
---|
1796 | if (stringmatch(W_WaveList[j][1], "*"+temp+"*")) |
---|
1797 | tempWave[k] = W_WaveList[j][0] |
---|
1798 | k = k+1 |
---|
1799 | endif |
---|
1800 | endfor |
---|
1801 | redimension/N=(k) tempWave |
---|
1802 | elseif(stringmatch(temp, "*ywave*")) |
---|
1803 | temp = W_WaveList[i][0] |
---|
1804 | if(stringmatch(temp, "*_RA")) |
---|
1805 | temp = removeending(temp, "_RA") |
---|
1806 | endif |
---|
1807 | Make/T/O $temp/Wave=tempWave |
---|
1808 | DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") |
---|
1809 | if (strlen(DF) ==0) |
---|
1810 | DF = ":" |
---|
1811 | endif |
---|
1812 | DF1 = "root"+DF |
---|
1813 | tempWave[0] = DF1 |
---|
1814 | temp2 = replacestring("ywave", temp, "") |
---|
1815 | k = 1 |
---|
1816 | for(j=0;j<numpnts(W_WaveList)/3; j+=1) |
---|
1817 | t1 = W_Wavelist[j][1] |
---|
1818 | if (stringmatch(W_WaveList[j][1], "*wave"+temp2+"*")) |
---|
1819 | tempWave[k] = W_WaveList[j][1] |
---|
1820 | k = k+1 |
---|
1821 | endif |
---|
1822 | endfor |
---|
1823 | redimension/N=(k) tempWave |
---|
1824 | endif |
---|
1825 | endfor |
---|
1826 | KillWaves/Z W_Wavelist |
---|
1827 | string listWave = Wavelist("*", ";", "TEXT:1") |
---|
1828 | string WaveToRescale, WaveDataFolder,xwave, ywave, swave |
---|
1829 | |
---|
1830 | for (i = 0; i < ItemsInList(listWave,";"); i+=1) |
---|
1831 | temp = StringFromList(i,listWave,";") |
---|
1832 | Wave/T WaveString = $temp |
---|
1833 | for (j=1; j < numpnts(WaveString); j+=1) |
---|
1834 | WaveToRescale = Wavestring[j] |
---|
1835 | if (stringmatch(WaveToRescale, "*_RA")) |
---|
1836 | WaveToRescale = RemoveEnding(WaveToRescale, "_RA") |
---|
1837 | endif |
---|
1838 | WaveDataFolder = WaveString[0] |
---|
1839 | SetDataFolder $WaveDataFolder |
---|
1840 | if (stringmatch(WaveToRescale, "*_q")) |
---|
1841 | xwave = WaveToRescale |
---|
1842 | XRescale(xwave) |
---|
1843 | elseif (stringmatch(WaveToRescale, "*_i")) |
---|
1844 | ywave = WaveToRescale |
---|
1845 | xwave = RemoveEnding(WaveToRescale, "_i")+"_q" |
---|
1846 | YRescale(ywave, xwave) |
---|
1847 | elseif (stringmatch(WaveToRescale, "*_s")) |
---|
1848 | swave = WaveToRescale |
---|
1849 | ywave = RemoveEnding(WaveToRescale, "_s")+"_i" |
---|
1850 | xwave = RemoveEnding(WaveToRescale, "_s")+"_q" |
---|
1851 | ERescale(swave, ywave, xwave) |
---|
1852 | elseif (stringmatch(WaveToRescale, "xwave_*")) |
---|
1853 | xwave=WaveToRescale |
---|
1854 | XRescale(xwave) |
---|
1855 | elseif (stringmatch(WaveToRescale, "ywave_*")) |
---|
1856 | ywave = WaveToRescale |
---|
1857 | xwave= ReplaceString("ywave", WaveToRescale, "xwave") |
---|
1858 | YRescale(ywave, xwave) |
---|
1859 | elseif(stringmatch(WaveToRescale, "*_qvals")) |
---|
1860 | xwave = WaveToRescale |
---|
1861 | XRescale(xwave) |
---|
1862 | elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) |
---|
1863 | ywave = WaveToRescale |
---|
1864 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1865 | if (stringmatch(Wavestring[k], "*_qvals")) |
---|
1866 | xwave = Wavestring[k] |
---|
1867 | endif |
---|
1868 | endfor |
---|
1869 | YRescale(ywave, xwave) |
---|
1870 | else |
---|
1871 | ywave = WaveToRescale |
---|
1872 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1873 | if (stringmatch(Wavestring[k], "*_q")) |
---|
1874 | xwave = Wavestring[k] |
---|
1875 | endif |
---|
1876 | endfor |
---|
1877 | YRescale(ywave,xwave) |
---|
1878 | string yAxis = ywave+"_RA" |
---|
1879 | wave yAxisWave = $yAxis |
---|
1880 | SetFormula yAxisWave, "YRescale(ywave,xwave)" |
---|
1881 | endif |
---|
1882 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1883 | endfor |
---|
1884 | endfor |
---|
1885 | |
---|
1886 | string oldywave, xstr, ystr |
---|
1887 | for (i = 0; i < ItemsInList(listWave,";"); i+=1) |
---|
1888 | temp = StringFromList(i,listWave,";") |
---|
1889 | Wave/T WaveString = $temp |
---|
1890 | for (j=1; j < numpnts(WaveString); j+=1) |
---|
1891 | WaveToRescale = Wavestring[j] |
---|
1892 | WaveDataFolder = WaveString[0] |
---|
1893 | SetDataFolder $WaveDataFolder |
---|
1894 | ControlInfo/W=RescaleAxisPanel yModel |
---|
1895 | ystr = S_Value |
---|
1896 | ControlInfo/W=RescaleAxisPanel xModel |
---|
1897 | xstr = S_Value |
---|
1898 | if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) |
---|
1899 | if(stringmatch(WaveToRescale, "*_i_RA")) |
---|
1900 | oldywave = WaveToRescale |
---|
1901 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1902 | xwave = RemoveEnding(WaveToRescale, "_i_RA")+"_q" |
---|
1903 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1904 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1905 | swave = RemoveEnding(WaveToRescale, "_i_RA")+"_s" |
---|
1906 | if(exists(swave)==1) |
---|
1907 | ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) |
---|
1908 | endif |
---|
1909 | elseif (stringmatch(WaveToRescale, "smeared*")) |
---|
1910 | if(stringmatch(WaveToRescale,"*_RA") && stringmatch(WaveToRescale,"!*_qvals*") ) |
---|
1911 | oldywave = WaveToRescale |
---|
1912 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1913 | xwave = "smeared_qvals" |
---|
1914 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1915 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1916 | endif |
---|
1917 | elseif(stringmatch(WaveToRescale,"ywave*") && stringmatch(WaveToRescale,"*_RA")) |
---|
1918 | oldywave = WaveToRescale |
---|
1919 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1920 | xwave = ReplaceString("ywave",ywave,"xwave") |
---|
1921 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1922 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1923 | elseif(stringmatch(WaveToRescale, "*FitYw*") && stringmatch(WaveToRescale, "*_RA")) |
---|
1924 | oldywave = WaveToRescale |
---|
1925 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1926 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1927 | if (stringmatch(Wavestring[k], "*_q")) |
---|
1928 | xwave = Wavestring[k] |
---|
1929 | endif |
---|
1930 | endfor |
---|
1931 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1932 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1933 | endif |
---|
1934 | elseif(stringmatch(WaveToRescale, "*_RA")) |
---|
1935 | elseif (stringmatch(WaveToRescale, "*_i")) |
---|
1936 | DoWindow/F topGraph |
---|
1937 | oldywave = WaveToRescale |
---|
1938 | xwave = RemoveEnding(WaveToRescale, "_i")+"_q_RA" |
---|
1939 | ywave = WaveToRescale + "_RA" |
---|
1940 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1941 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1942 | ModifyGraph log=0 |
---|
1943 | swave = RemoveEnding(WaveToRescale, "_i")+"_s_RA" |
---|
1944 | if(exists(swave)==1) |
---|
1945 | ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) |
---|
1946 | endif |
---|
1947 | DoUpdate |
---|
1948 | elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) |
---|
1949 | oldywave = WaveToRescale |
---|
1950 | ywave = WaveToRescale + "_RA" |
---|
1951 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1952 | xwave = "smeared_qvals_RA" |
---|
1953 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1954 | elseif(stringmatch(WaveToRescale,"ywave*")) |
---|
1955 | oldywave = WaveToRescale |
---|
1956 | ywave = WaveToRescale + "_RA" |
---|
1957 | xwave = ReplaceString("ywave",ywave,"xwave") |
---|
1958 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1959 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1960 | elseif(stringmatch(WaveToRescale, "*FitYw*")) |
---|
1961 | oldywave = WaveToRescale |
---|
1962 | ywave = WaveToRescale+"_RA" |
---|
1963 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1964 | if (stringmatch(Wavestring[k], "*_q")) |
---|
1965 | xwave = Wavestring[k]+"_RA" |
---|
1966 | endif |
---|
1967 | endfor |
---|
1968 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1969 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1970 | endif |
---|
1971 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1972 | DoUpdate |
---|
1973 | endfor |
---|
1974 | endfor |
---|
1975 | KillWaves/A/Z |
---|
1976 | |
---|
1977 | string ylabel, xlabel |
---|
1978 | ControlInfo/W=RescaleAxisPanel yModel |
---|
1979 | ystr = S_Value |
---|
1980 | ControlInfo/W=RescaleAxisPanel xModel |
---|
1981 | xstr = S_Value |
---|
1982 | |
---|
1983 | if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) |
---|
1984 | modifygraph log=1 |
---|
1985 | else |
---|
1986 | modifygraph log=0 |
---|
1987 | endif |
---|
1988 | |
---|
1989 | Variable pow_a,pow_b,pow_c |
---|
1990 | ControlInfo/W=RescaleAxisPanel expa |
---|
1991 | pow_a = V_value |
---|
1992 | ControlInfo/W=RescaleAxisPanel expb |
---|
1993 | pow_b = V_value |
---|
1994 | ControlInfo/W=RescaleAxisPanel expc |
---|
1995 | pow_c = V_value |
---|
1996 | |
---|
1997 | If (cmpstr("I",ystr) == 0) |
---|
1998 | ylabel = "I(q)" |
---|
1999 | elseif (cmpstr("ln(I)",ystr) == 0) |
---|
2000 | ylabel = "ln(I)" |
---|
2001 | elseif (cmpstr("log(I)",ystr) == 0) |
---|
2002 | ylabel = "log(I)" |
---|
2003 | elseif (cmpstr("1/I",ystr) == 0) |
---|
2004 | ylabel = "1/I" |
---|
2005 | elseif (cmpstr("I^a",ystr) == 0) |
---|
2006 | ylabel = "I\S"+num2str(pow_a)+"\M" |
---|
2007 | elseif (cmpstr("Iq^a",ystr) == 0) |
---|
2008 | ylabel = "Iq\S"+num2str(pow_a)+"\M" |
---|
2009 | elseif (cmpstr("I^a q^b",ystr) == 0) |
---|
2010 | ylabel = "I\S"+num2str(pow_a)+"\Mq\S"+num2str(pow_b)+"\M" |
---|
2011 | elseif (cmpstr("1/sqrt(I)",ystr) == 0) |
---|
2012 | ylabel = "1/sqrt(I)" |
---|
2013 | elseif (cmpstr("ln(Iq)",ystr) == 0) |
---|
2014 | ylabel = "ln(Iq)" |
---|
2015 | elseif (cmpstr("ln(Iq^2)",ystr) == 0) |
---|
2016 | ylabel = "ln(Iq\S2\M)" |
---|
2017 | endif |
---|
2018 | |
---|
2019 | If (cmpstr("q",xstr) == 0) |
---|
2020 | xlabel = "q (A\S-1\M)" |
---|
2021 | elseif (cmpstr("q^2",xstr) == 0) |
---|
2022 | xlabel = "q\S2\M" |
---|
2023 | elseif (cmpstr("log(q)",xstr) == 0) |
---|
2024 | xlabel = "log(q)" |
---|
2025 | elseif (cmpstr("q^c",xstr) == 0) |
---|
2026 | xlabel = "q\S"+num2str(pow_c)+"\M" |
---|
2027 | endif |
---|
2028 | |
---|
2029 | SetAxis/A |
---|
2030 | Label left ylabel |
---|
2031 | Label bottom xlabel |
---|
2032 | |
---|
2033 | SetDataFolder root: |
---|
2034 | End |
---|
2035 | |
---|
2036 | Function YRescale(ywave, xwave) |
---|
2037 | String ywave,xwave |
---|
2038 | |
---|
2039 | Wave yw = $ywave |
---|
2040 | Wave xw = $xwave |
---|
2041 | |
---|
2042 | //Scaling exponents and background value |
---|
2043 | Variable pow_a,pow_b,pow_c |
---|
2044 | ControlInfo/W=RescaleAxisPanel expa |
---|
2045 | pow_a = V_value |
---|
2046 | ControlInfo/W=RescaleAxisPanel expb |
---|
2047 | pow_b = V_value |
---|
2048 | ControlInfo/W=RescaleAxisPanel expc |
---|
2049 | pow_c = V_value |
---|
2050 | |
---|
2051 | //check for physical limits on exponent values |
---|
2052 | // if bad values found, alert, and reset to good values so the rescaling can continue |
---|
2053 | NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA |
---|
2054 | NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB |
---|
2055 | NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC |
---|
2056 | if((pow_a < -2) || (pow_a > 10)) |
---|
2057 | DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" |
---|
2058 | gA = 1 |
---|
2059 | endif |
---|
2060 | if((pow_b < 0) || (pow_b > 10)) |
---|
2061 | DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" |
---|
2062 | gB = 1 |
---|
2063 | endif |
---|
2064 | //if q^c is the x-scaling, c must be be within limits and also non-zero |
---|
2065 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2066 | If (cmpstr("q^c",S_Value) == 0) |
---|
2067 | if(pow_c == 0) |
---|
2068 | DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" |
---|
2069 | gC = 1 |
---|
2070 | endif |
---|
2071 | if((pow_c < -10) || (pow_c > 10)) |
---|
2072 | DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" |
---|
2073 | gC = 1 |
---|
2074 | endif |
---|
2075 | endif |
---|
2076 | |
---|
2077 | //variables set for each model to control look of graph |
---|
2078 | String ystr, yAxis |
---|
2079 | //check for proper y-scaling selection, make the necessary waves |
---|
2080 | // Wave yAxisWave |
---|
2081 | |
---|
2082 | ControlInfo/W=RescaleAxisPanel yModel |
---|
2083 | ystr = S_Value |
---|
2084 | |
---|
2085 | do |
---|
2086 | If (cmpstr("I",S_Value) == 0) |
---|
2087 | yAxis = ywave+"_RA" |
---|
2088 | if (exists(yAxis)== 0) |
---|
2089 | Duplicate yw $yAxis |
---|
2090 | endif |
---|
2091 | SetScale d 0,0,"1/cm",$yAxis |
---|
2092 | wave yAxisWave = $yAxis |
---|
2093 | yAxisWave = yw |
---|
2094 | break |
---|
2095 | endif |
---|
2096 | If (cmpstr("ln(I)",S_Value) == 0) |
---|
2097 | yAxis = ywave+"_RA" |
---|
2098 | if (exists(yAxis)== 0) |
---|
2099 | Duplicate yw $yAxis |
---|
2100 | endif |
---|
2101 | SetScale d 0,0,"",$yAxis |
---|
2102 | wave yAxisWave = $yAxis |
---|
2103 | yAxisWave = ln(yw) |
---|
2104 | break |
---|
2105 | endif |
---|
2106 | If (cmpstr("log(I)",S_Value) == 0) |
---|
2107 | yAxis = ywave+"_RA" |
---|
2108 | if (exists(yAxis)== 0) |
---|
2109 | Duplicate yw $yAxis |
---|
2110 | endif |
---|
2111 | SetScale d 0,0,"",$yAxis |
---|
2112 | wave yAxisWave = $yAxis |
---|
2113 | yAxisWave = log(yw) |
---|
2114 | break |
---|
2115 | endif |
---|
2116 | If (cmpstr("1/I",S_Value) == 0) |
---|
2117 | yAxis = ywave+"_RA" |
---|
2118 | if (exists(yAxis)== 0) |
---|
2119 | Duplicate yw $yAxis |
---|
2120 | endif |
---|
2121 | SetScale d 0,0,"",$yAxis |
---|
2122 | wave yAxisWave = $yAxis |
---|
2123 | yAxisWave = 1/(yw) |
---|
2124 | break |
---|
2125 | endif |
---|
2126 | If (cmpstr("I^a",S_Value) == 0) |
---|
2127 | yAxis = ywave+"_RA" |
---|
2128 | if (exists(yAxis)== 0) |
---|
2129 | Duplicate yw $yAxis |
---|
2130 | endif |
---|
2131 | SetScale d 0,0,"",$yAxis |
---|
2132 | wave yAxisWave = $yAxis |
---|
2133 | yAxisWave = yw^pow_a |
---|
2134 | break |
---|
2135 | endif |
---|
2136 | If (cmpstr("Iq^a",S_Value) == 0) |
---|
2137 | yAxis = ywave+"_RA" |
---|
2138 | if (exists(yAxis)== 0) |
---|
2139 | Duplicate yw $yAxis |
---|
2140 | endif |
---|
2141 | SetScale d 0,0,"",$yAxis |
---|
2142 | wave yAxisWave = $yAxis |
---|
2143 | yAxisWave = yw*xw^pow_a |
---|
2144 | break |
---|
2145 | endif |
---|
2146 | If (cmpstr("I^a q^b",S_Value) == 0) |
---|
2147 | yAxis = ywave+"_RA" |
---|
2148 | if (exists(yAxis)== 0) |
---|
2149 | Duplicate yw $yAxis |
---|
2150 | endif |
---|
2151 | SetScale d 0,0,"",$yAxis |
---|
2152 | wave yAxisWave = $yAxis |
---|
2153 | yAxisWave = yw^pow_a*xw^pow_b |
---|
2154 | break |
---|
2155 | endif |
---|
2156 | If (cmpstr("1/sqrt(I)",S_Value) == 0) |
---|
2157 | yAxis = ywave+"_RA" |
---|
2158 | if (exists(yAxis)== 0) |
---|
2159 | Duplicate yw $yAxis |
---|
2160 | endif |
---|
2161 | SetScale d 0,0,"",$yAxis |
---|
2162 | wave yAxisWave = $yAxis |
---|
2163 | yAxisWave = 1/sqrt(yw) |
---|
2164 | break |
---|
2165 | endif |
---|
2166 | If (cmpstr("ln(Iq)",S_Value) == 0) |
---|
2167 | yAxis = ywave+"_RA" |
---|
2168 | if (exists(yAxis)== 0) |
---|
2169 | Duplicate yw $yAxis |
---|
2170 | endif |
---|
2171 | SetScale d 0,0,"",$yAxis |
---|
2172 | wave yAxisWave = $yAxis |
---|
2173 | yAxisWave = ln(xw*yw) |
---|
2174 | break |
---|
2175 | endif |
---|
2176 | If (cmpstr("ln(Iq^2)",S_Value) == 0) |
---|
2177 | yAxis = ywave+"_RA" |
---|
2178 | if (exists(yAxis)== 0) |
---|
2179 | Duplicate yw $yAxis |
---|
2180 | endif |
---|
2181 | SetScale d 0,0,"",$yAxis |
---|
2182 | wave yAxisWave = $yAxis |
---|
2183 | yAxisWave = ln(xw*xw*yw) |
---|
2184 | break |
---|
2185 | endif |
---|
2186 | //more ifs for each case |
---|
2187 | |
---|
2188 | // if selection not found, abort |
---|
2189 | DoAlert 0,"Y-axis scaling incorrect. Aborting" |
---|
2190 | Abort |
---|
2191 | while(0) |
---|
2192 | End |
---|
2193 | |
---|
2194 | Function XRescale(xwave) |
---|
2195 | String xwave |
---|
2196 | |
---|
2197 | Wave xw = $xwave |
---|
2198 | |
---|
2199 | //Scaling exponents and background value |
---|
2200 | Variable pow_a,pow_b,pow_c |
---|
2201 | ControlInfo/W=RescaleAxisPanel expa |
---|
2202 | pow_a = V_value |
---|
2203 | ControlInfo/W=RescaleAxisPanel expb |
---|
2204 | pow_b = V_value |
---|
2205 | ControlInfo/W=RescaleAxisPanel expc |
---|
2206 | pow_c = V_value |
---|
2207 | |
---|
2208 | //check for physical limits on exponent values |
---|
2209 | // if bad values found, alert, and reset to good values so the rescaling can continue |
---|
2210 | NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA |
---|
2211 | NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB |
---|
2212 | NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC |
---|
2213 | if((pow_a < -2) || (pow_a > 10)) |
---|
2214 | DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" |
---|
2215 | gA = 1 |
---|
2216 | endif |
---|
2217 | if((pow_b < 0) || (pow_b > 10)) |
---|
2218 | DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" |
---|
2219 | gB = 1 |
---|
2220 | endif |
---|
2221 | //if q^c is the x-scaling, c must be be within limits and also non-zero |
---|
2222 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2223 | If (cmpstr("q^c",S_Value) == 0) |
---|
2224 | if(pow_c == 0) |
---|
2225 | DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" |
---|
2226 | gC = 1 |
---|
2227 | endif |
---|
2228 | if((pow_c < -10) || (pow_c > 10)) |
---|
2229 | DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" |
---|
2230 | gC = 1 |
---|
2231 | endif |
---|
2232 | endif |
---|
2233 | |
---|
2234 | //variables set for each model to control look of graph |
---|
2235 | String xstr, xAxis |
---|
2236 | //check for proper y-scaling selection, make the necessary waves |
---|
2237 | // Wave xAxisWave |
---|
2238 | |
---|
2239 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2240 | xstr = S_Value |
---|
2241 | do |
---|
2242 | // make the new yaxis wave |
---|
2243 | If (cmpstr("q",S_Value) == 0) |
---|
2244 | xAxis = xwave+"_RA" |
---|
2245 | if (exists(xAxis)== 0) |
---|
2246 | Duplicate xw $xAxis |
---|
2247 | endif |
---|
2248 | SetScale d 0,0,"A^-1",$xAxis |
---|
2249 | wave xAxisWave = $xAxis |
---|
2250 | xAxisWave = xw |
---|
2251 | break |
---|
2252 | endif |
---|
2253 | If (cmpstr("q^2",S_Value) == 0) |
---|
2254 | xAxis = xwave+"_RA" |
---|
2255 | if (exists(xAxis)== 0) |
---|
2256 | Duplicate xw $xAxis |
---|
2257 | endif |
---|
2258 | SetScale d 0,0,"A^-2",$xAxis |
---|
2259 | wave xAxisWave = $xAxis |
---|
2260 | xAxisWave = xw*xw |
---|
2261 | break |
---|
2262 | endif |
---|
2263 | If (cmpstr("log(q)",S_Value) == 0) |
---|
2264 | xAxis = xwave+"_RA" |
---|
2265 | if (exists(xAxis)== 0) |
---|
2266 | Duplicate xw $xAxis |
---|
2267 | endif |
---|
2268 | SetScale d 0,0,"",$xAxis |
---|
2269 | wave xAxisWave = $xAxis |
---|
2270 | xAxisWave = log(xw) |
---|
2271 | break |
---|
2272 | endif |
---|
2273 | If (cmpstr("q^c",S_Value) == 0) |
---|
2274 | xAxis = xwave+"_RA" |
---|
2275 | if (exists(xAxis)== 0) |
---|
2276 | Duplicate xw $xAxis |
---|
2277 | endif |
---|
2278 | SetScale d 0,0,"", $xAxis |
---|
2279 | wave xAxisWave = $xAxis |
---|
2280 | xAxisWave = xw^pow_c |
---|
2281 | break |
---|
2282 | endif |
---|
2283 | |
---|
2284 | //more ifs for each case |
---|
2285 | // if selection not found, abort |
---|
2286 | DoAlert 0,"X-axis scaling incorrect. Aborting" |
---|
2287 | Abort |
---|
2288 | while(0) //end of "case" statement for x-axis scaling |
---|
2289 | End |
---|
2290 | |
---|
2291 | Function ERescale(swave, ywave, xwave) |
---|
2292 | String swave, ywave, xwave |
---|
2293 | |
---|
2294 | Wave ew = $swave |
---|
2295 | Wave yw = $ywave |
---|
2296 | Wave xw = $xwave |
---|
2297 | |
---|
2298 | //Scaling exponents and background value |
---|
2299 | Variable pow_a,pow_b,pow_c |
---|
2300 | ControlInfo/W=RescaleAxisPanel expa |
---|
2301 | pow_a = V_value |
---|
2302 | ControlInfo/W=RescaleAxisPanel expb |
---|
2303 | pow_b = V_value |
---|
2304 | ControlInfo/W=RescaleAxisPanel expc |
---|
2305 | pow_c = V_value |
---|
2306 | |
---|
2307 | //check for physical limits on exponent values |
---|
2308 | // if bad values found, alert, and reset to good values so the rescaling can continue |
---|
2309 | NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA |
---|
2310 | NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB |
---|
2311 | NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC |
---|
2312 | if((pow_a < -2) || (pow_a > 10)) |
---|
2313 | DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" |
---|
2314 | gA = 1 |
---|
2315 | endif |
---|
2316 | if((pow_b < 0) || (pow_b > 10)) |
---|
2317 | DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" |
---|
2318 | gB = 1 |
---|
2319 | endif |
---|
2320 | //if q^c is the x-scaling, c must be be within limits and also non-zero |
---|
2321 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2322 | If (cmpstr("q^c",S_Value) == 0) |
---|
2323 | if(pow_c == 0) |
---|
2324 | DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" |
---|
2325 | gC = 1 |
---|
2326 | endif |
---|
2327 | if((pow_c < -10) || (pow_c > 10)) |
---|
2328 | DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" |
---|
2329 | gC = 1 |
---|
2330 | endif |
---|
2331 | endif |
---|
2332 | |
---|
2333 | //variables set for each model to control look of graph |
---|
2334 | String ystr, eWave |
---|
2335 | //check for proper y-scaling selection, make the necessary waves |
---|
2336 | // Wave yErrWave |
---|
2337 | |
---|
2338 | ControlInfo/W=RescaleAxisPanel yModel |
---|
2339 | ystr = S_Value |
---|
2340 | do |
---|
2341 | |
---|
2342 | If (cmpstr("I",S_Value) == 0) |
---|
2343 | eWave = swave+"_RA" |
---|
2344 | if (exists(eWave) == 0) |
---|
2345 | Duplicate ew $eWave |
---|
2346 | endif |
---|
2347 | wave yErrWave = $eWave |
---|
2348 | yErrWave = ew |
---|
2349 | break |
---|
2350 | endif |
---|
2351 | If (cmpstr("ln(I)",S_Value) == 0) |
---|
2352 | eWave = swave+"_RA" |
---|
2353 | if (exists(eWave) == 0) |
---|
2354 | Duplicate ew $eWave |
---|
2355 | endif |
---|
2356 | wave yErrWave = $eWave |
---|
2357 | yErrWave = ew/yw |
---|
2358 | break |
---|
2359 | endif |
---|
2360 | If (cmpstr("log(I)",S_Value) == 0) |
---|
2361 | eWave = swave+"_RA" |
---|
2362 | if (exists(eWave) == 0) |
---|
2363 | Duplicate ew $eWave |
---|
2364 | endif |
---|
2365 | wave yErrWave = $eWave |
---|
2366 | yErrWave = ew/(2.30*yw) |
---|
2367 | break |
---|
2368 | endif |
---|
2369 | If (cmpstr("1/I",S_Value) == 0) |
---|
2370 | eWave = swave+"_RA" |
---|
2371 | if (exists(eWave) == 0) |
---|
2372 | Duplicate ew $eWave |
---|
2373 | endif |
---|
2374 | wave yErrWave = $eWave |
---|
2375 | yErrWave = ew/(yw^2) |
---|
2376 | break |
---|
2377 | endif |
---|
2378 | If (cmpstr("I^a",S_Value) == 0) |
---|
2379 | eWave = swave+"_RA" |
---|
2380 | if (exists(eWave) == 0) |
---|
2381 | Duplicate ew $eWave |
---|
2382 | endif |
---|
2383 | wave yErrWave = $eWave |
---|
2384 | yErrWave = ew*abs(pow_a*(yw^(pow_a-1))) |
---|
2385 | break |
---|
2386 | endif |
---|
2387 | If (cmpstr("Iq^a",S_Value) == 0) |
---|
2388 | eWave = swave+"_RA" |
---|
2389 | if (exists(eWave) == 0) |
---|
2390 | Duplicate ew $eWave |
---|
2391 | endif |
---|
2392 | wave yErrWave = $eWave |
---|
2393 | yErrWave = ew*xw^pow_a |
---|
2394 | break |
---|
2395 | endif |
---|
2396 | If (cmpstr("I^a q^b",S_Value) == 0) |
---|
2397 | eWave = swave+"_RA" |
---|
2398 | if (exists(eWave) == 0) |
---|
2399 | Duplicate ew $eWave |
---|
2400 | endif |
---|
2401 | wave yErrWave = $eWave |
---|
2402 | yErrWave = ew*abs(pow_a*(yw^(pow_a-1)))*xw^pow_b |
---|
2403 | break |
---|
2404 | endif |
---|
2405 | If (cmpstr("1/sqrt(I)",S_Value) == 0) |
---|
2406 | eWave = swave+"_RA" |
---|
2407 | if (exists(eWave) == 0) |
---|
2408 | Duplicate ew $eWave |
---|
2409 | endif |
---|
2410 | wave yErrWave = $eWave |
---|
2411 | yErrWave = 0.5*ew*yw^(-1.5) |
---|
2412 | break |
---|
2413 | endif |
---|
2414 | If (cmpstr("ln(Iq)",S_Value) == 0) |
---|
2415 | eWave = swave+"_RA" |
---|
2416 | if (exists(eWave) == 0) |
---|
2417 | Duplicate ew $eWave |
---|
2418 | endif |
---|
2419 | wave yErrWave = $eWave |
---|
2420 | yErrWave =ew/yw |
---|
2421 | break |
---|
2422 | endif |
---|
2423 | If (cmpstr("ln(Iq^2)",S_Value) == 0) |
---|
2424 | eWave = swave+"_RA" |
---|
2425 | if (exists(eWave) == 0) |
---|
2426 | Duplicate ew $eWave |
---|
2427 | endif |
---|
2428 | wave yErrWave = $eWave |
---|
2429 | yErrWave = ew/yw |
---|
2430 | break |
---|
2431 | endif |
---|
2432 | //more ifs for each case |
---|
2433 | |
---|
2434 | // if selection not found, abort |
---|
2435 | DoAlert 0,"Y-axis scaling incorrect. Aborting" |
---|
2436 | Abort |
---|
2437 | while(0) //end of "case" statement for y-axis scaling |
---|
2438 | |
---|
2439 | End |
---|
2440 | |
---|
2441 | /////////////////////////// |
---|
2442 | |
---|