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 | //TODO: be sure that 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 | V_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 | Function/S ShortFileNameString(inStr) |
---|
1090 | String inStr |
---|
1091 | |
---|
1092 | String outStr="" |
---|
1093 | Variable maxLength=25 |
---|
1094 | Variable nameTooLong=0 |
---|
1095 | String/G root:Packages:NIST:gShortNameStr = inStr[0,maxLength-1] |
---|
1096 | SVAR newStr = root:Packages:NIST:gShortNameStr |
---|
1097 | |
---|
1098 | if(strlen(inStr) <= maxLength) |
---|
1099 | return (inStr) //length OK |
---|
1100 | else |
---|
1101 | do |
---|
1102 | nameTooLong = 0 |
---|
1103 | |
---|
1104 | DoAlert 1,"File name is too long. Is\r"+inStr[0,maxLength-1]+"\rOK?" |
---|
1105 | if(V_flag==1) //my suggested name is OK, so trim the output |
---|
1106 | outStr = inStr[0,maxLength-1] |
---|
1107 | //Print "modified ",outStr |
---|
1108 | newStr=outStr |
---|
1109 | return(outStr) |
---|
1110 | endif |
---|
1111 | |
---|
1112 | |
---|
1113 | if(V_flag == 2) //not OK, do something about it |
---|
1114 | |
---|
1115 | DoWindow/F ShorterNameInput //it really shouldn't exist... |
---|
1116 | if(V_flag==0) |
---|
1117 | |
---|
1118 | NewPanel /W=(166,90,666,230) as "Enter a Shorter Name" |
---|
1119 | DoWindow/C ShorterNameInput |
---|
1120 | SetDrawLayer UserBack |
---|
1121 | TitleBox title0,pos={35,8},size={261,20},title=" Enter a shorter file name. It must be 25 characters or less " |
---|
1122 | TitleBox title0,fSize=12,fStyle=1 |
---|
1123 | SetVariable setvar0,pos={21,52},size={300,15},title="New name",value= _STR:newStr |
---|
1124 | SetVariable setvar0,proc=ShorterNameSetVarProc,fsize=12 |
---|
1125 | SetVariable setvar0 valueBackColor=(65535,49151,49151) |
---|
1126 | Button button0,pos={259,87},size={60,20},title="Done" |
---|
1127 | Button button0,proc=ShorterNameDoneButtonProc |
---|
1128 | |
---|
1129 | endif |
---|
1130 | |
---|
1131 | PauseForUser ShorterNameInput |
---|
1132 | |
---|
1133 | // this really should force a good name, but there could be errors that I'm not catching |
---|
1134 | // Print newStr, strlen(newStr) |
---|
1135 | nameTooLong = 0 |
---|
1136 | endif |
---|
1137 | |
---|
1138 | while (nameTooLong) |
---|
1139 | |
---|
1140 | return(newStr) |
---|
1141 | |
---|
1142 | endif |
---|
1143 | |
---|
1144 | End |
---|
1145 | |
---|
1146 | |
---|
1147 | // for the ShortFileNameString() - PauseForUser to get a shorter file name |
---|
1148 | Function ShorterNameSetVarProc(sva) : SetVariableControl |
---|
1149 | STRUCT WMSetVariableAction &sva |
---|
1150 | |
---|
1151 | switch( sva.eventCode ) |
---|
1152 | case 1: // mouse up |
---|
1153 | case 2: // Enter key |
---|
1154 | case 3: // Live update |
---|
1155 | String sv = sva.sval |
---|
1156 | if( strlen(sv) > 25 ) |
---|
1157 | sv= sv[0,24] |
---|
1158 | SetVariable $(sva.ctrlName),win=$(sva.win),value=_STR:sv |
---|
1159 | SetVariable setvar0 valueBackColor=(65535,49151,49151) |
---|
1160 | Beep |
---|
1161 | else |
---|
1162 | SetVariable setvar0 valueBackColor=(65535,65535,65535) |
---|
1163 | endif |
---|
1164 | break |
---|
1165 | endswitch |
---|
1166 | return 0 |
---|
1167 | End |
---|
1168 | |
---|
1169 | // for the ShortFileNameString() - PauseForUser to get a shorter file name |
---|
1170 | Function ShorterNameDoneButtonProc(ba) : ButtonControl |
---|
1171 | STRUCT WMButtonAction &ba |
---|
1172 | |
---|
1173 | String win = ba.win |
---|
1174 | |
---|
1175 | switch (ba.eventCode) |
---|
1176 | case 2: |
---|
1177 | SVAR newStr = root:Packages:NIST:gShortNameStr |
---|
1178 | ControlInfo setvar0 |
---|
1179 | newStr = S_value |
---|
1180 | DoWindow/K ShorterNameInput |
---|
1181 | |
---|
1182 | break |
---|
1183 | endswitch |
---|
1184 | |
---|
1185 | return 0 |
---|
1186 | End |
---|
1187 | |
---|
1188 | |
---|
1189 | // a function common to many panels, so put the basic version here that simply |
---|
1190 | // returns null string if no functions are present. Calling procedures can |
---|
1191 | // add to the list to customize as needed. |
---|
1192 | // show the available models |
---|
1193 | // not the f*(cw,xw) point calculations |
---|
1194 | // not the *X(cw,xw) XOPS |
---|
1195 | // |
---|
1196 | // KIND:10 should show only user-defined curve fitting functions |
---|
1197 | // - not XOPs |
---|
1198 | // - not other user-defined functions |
---|
1199 | Function/S User_FunctionPopupList() |
---|
1200 | String list,tmp |
---|
1201 | list = FunctionList("*",";","KIND:10") //get every user defined curve fit function |
---|
1202 | |
---|
1203 | //now start to remove everything the user doesn't need to see... |
---|
1204 | |
---|
1205 | tmp = FunctionList("*_proto",";","KIND:10") //prototypes |
---|
1206 | list = RemoveFromList(tmp, list ,";") |
---|
1207 | |
---|
1208 | //prototypes that show up if GF is loaded |
---|
1209 | list = RemoveFromList("GFFitFuncTemplate", list) |
---|
1210 | list = RemoveFromList("GFFitAllAtOnceTemplate", list) |
---|
1211 | list = RemoveFromList("NewGlblFitFunc", list) |
---|
1212 | list = RemoveFromList("NewGlblFitFuncAllAtOnce", list) |
---|
1213 | list = RemoveFromList("GlobalFitFunc", list) |
---|
1214 | list = RemoveFromList("GlobalFitAllAtOnce", list) |
---|
1215 | list = RemoveFromList("GFFitAAOStructTemplate", list) |
---|
1216 | list = RemoveFromList("NewGF_SetXWaveInList", list) |
---|
1217 | list = RemoveFromList("NewGlblFitFuncAAOStruct", list) |
---|
1218 | |
---|
1219 | // more to remove as a result of 2D/Gizmo |
---|
1220 | list = RemoveFromList("A_WMRunLessThanDelta", list) |
---|
1221 | list = RemoveFromList("WMFindNaNValue", list) |
---|
1222 | list = RemoveFromList("WM_Make3DBarChartParametricWave", list) |
---|
1223 | list = RemoveFromList("UpdateQxQy2Mat", list) |
---|
1224 | list = RemoveFromList("MakeBSMask", list) |
---|
1225 | |
---|
1226 | // MOTOFIT/GenFit bits |
---|
1227 | tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;GeneticFit_UnSmearedModel;GeneticFit_SmearedModel;" |
---|
1228 | list = RemoveFromList(tmp, list ,";") |
---|
1229 | |
---|
1230 | // SANS Reduction bits |
---|
1231 | tmp = "ASStandardFunction;Ann_1D_Graph;Avg_1D_Graph;BStandardFunction;CStandardFunction;Draw_Plot1D;MyMat2XYZ;" |
---|
1232 | list = RemoveFromList(tmp, list ,";") |
---|
1233 | 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;" |
---|
1234 | list = RemoveFromList(tmp, list ,";") |
---|
1235 | |
---|
1236 | |
---|
1237 | // USANS Reduction bits |
---|
1238 | tmp = "DSM_Guinier_Fit;RemoveMaskedPoints;" |
---|
1239 | list = RemoveFromList(tmp, list ,";") |
---|
1240 | |
---|
1241 | //more functions from analysis models (2008) |
---|
1242 | tmp = "Barbell_Inner;Barbell_Outer;Barbell_integrand;BCC_Integrand;Integrand_BCC_Inner;Integrand_BCC_Outer;" |
---|
1243 | list = RemoveFromList(tmp, list ,";") |
---|
1244 | tmp = "CapCyl;CapCyl_Inner;CapCyl_Outer;ConvLens;ConvLens_Inner;ConvLens_Outer;" |
---|
1245 | list = RemoveFromList(tmp, list ,";") |
---|
1246 | tmp = "Dumb;Dumb_Inner;Dumb_Outer;FCC_Integrand;Integrand_FCC_Inner;Integrand_FCC_Outer;" |
---|
1247 | list = RemoveFromList(tmp, list ,";") |
---|
1248 | tmp = "Integrand_SC_Inner;Integrand_SC_Outer;SC_Integrand;SphCyl;SphCyl_Inner;SphCyl_Outer;" |
---|
1249 | list = RemoveFromList(tmp, list ,";") |
---|
1250 | tmp = "CSPP_Outer;CSPP_Inner;PP_Outer;PP_Inner;" |
---|
1251 | list = RemoveFromList(tmp, list ,";") |
---|
1252 | tmp = "Guinier_Fit;" |
---|
1253 | list = RemoveFromList(tmp, list ,";") |
---|
1254 | |
---|
1255 | tmp = FunctionList("f*",";","NPARAMS:2") //point calculations |
---|
1256 | list = RemoveFromList(tmp, list ,";") |
---|
1257 | |
---|
1258 | tmp = FunctionList("fSmear*",";","NPARAMS:3") //smeared dependency calculations |
---|
1259 | list = RemoveFromList(tmp, list ,";") |
---|
1260 | |
---|
1261 | // anything that might be included in Irena |
---|
1262 | tmp = FunctionList("GEN_*",";","KIND:10") |
---|
1263 | list = RemoveFromList(tmp, list ,";") |
---|
1264 | tmp = FunctionList("IN2G_*",";","KIND:10") |
---|
1265 | list = RemoveFromList(tmp, list ,";") |
---|
1266 | tmp = FunctionList("IR1A_*",";","KIND:10") |
---|
1267 | list = RemoveFromList(tmp, list ,";") |
---|
1268 | tmp = FunctionList("IR1B_*",";","KIND:10") |
---|
1269 | list = RemoveFromList(tmp, list ,";") |
---|
1270 | tmp = FunctionList("IR1U_*",";","KIND:10") |
---|
1271 | list = RemoveFromList(tmp, list ,";") |
---|
1272 | tmp = FunctionList("IR1V_*",";","KIND:10") |
---|
1273 | list = RemoveFromList(tmp, list ,";") |
---|
1274 | tmp = FunctionList("IR1_*",";","KIND:10") |
---|
1275 | list = RemoveFromList(tmp, list ,";") |
---|
1276 | tmp = FunctionList("IR2D_*",";","KIND:10") |
---|
1277 | list = RemoveFromList(tmp, list ,";") |
---|
1278 | |
---|
1279 | tmp = FunctionList("IR2D_*",";","KIND:10") |
---|
1280 | list = RemoveFromList(tmp, list ,";") |
---|
1281 | tmp = FunctionList("IR2H_*",";","KIND:10") |
---|
1282 | list = RemoveFromList(tmp, list ,";") |
---|
1283 | tmp = FunctionList("IR2L_*",";","KIND:10") |
---|
1284 | list = RemoveFromList(tmp, list ,";") |
---|
1285 | tmp = FunctionList("IR2Pr_*",";","KIND:10") |
---|
1286 | list = RemoveFromList(tmp, list ,";") |
---|
1287 | tmp = FunctionList("IR2R_*",";","KIND:10") |
---|
1288 | list = RemoveFromList(tmp, list ,";") |
---|
1289 | tmp = FunctionList("IR2S_*",";","KIND:10") |
---|
1290 | list = RemoveFromList(tmp, list ,";") |
---|
1291 | tmp = FunctionList("IR2_*",";","KIND:10") |
---|
1292 | list = RemoveFromList(tmp, list ,";") |
---|
1293 | tmp = FunctionList("*LogLog",";","KIND:10") |
---|
1294 | list = RemoveFromList(tmp, list ,";") |
---|
1295 | |
---|
1296 | //functions included in Nika |
---|
1297 | tmp = FunctionList("NI1*",";","KIND:10") |
---|
1298 | list = RemoveFromList(tmp, list ,";") |
---|
1299 | tmp = FunctionList("TransAx_*",";","KIND:10") |
---|
1300 | list = RemoveFromList(tmp, list ,";") |
---|
1301 | tmp = FunctionList("TransformAxis*",";","KIND:10") |
---|
1302 | list = RemoveFromList(tmp, list ,";") |
---|
1303 | tmp = FunctionList("erfForNormal*",";","KIND:10") |
---|
1304 | list = RemoveFromList(tmp, list ,";") |
---|
1305 | |
---|
1306 | // functions in Indra (USAXS) |
---|
1307 | tmp = FunctionList("IN2Q_*",";","KIND:10") |
---|
1308 | list = RemoveFromList(tmp, list ,";") |
---|
1309 | tmp = FunctionList("IN3_*",";","KIND:10") |
---|
1310 | list = RemoveFromList(tmp, list ,";") |
---|
1311 | |
---|
1312 | // tmp = FunctionList("*X",";","KIND:4") //XOPs, but these shouldn't show up if KIND:10 is used initially |
---|
1313 | // Print "X* = ",tmp |
---|
1314 | // print " " |
---|
1315 | // list = RemoveFromList(tmp, list ,";") |
---|
1316 | |
---|
1317 | //non-fit functions that I can't seem to filter out |
---|
1318 | list = RemoveFromList("BinaryHS_PSF11;BinaryHS_PSF12;BinaryHS_PSF22;EllipCyl_Integrand;PP_Inner;PP_Outer;Phi_EC;TaE_Inner;TaE_Outer;",list,";") |
---|
1319 | |
---|
1320 | // from 2010 model functions |
---|
1321 | list = RemoveFromList("fTwoYukawa;DoBoxGraph;Gauss2D_theta;",list,";") |
---|
1322 | |
---|
1323 | // from Debye Sphere method |
---|
1324 | list = RemoveFromList("CalcIQRfromMat;ConnectPoints2D;ConnectPoints3D;ConnectPoints3D_old;ConnectedRodFill;ConvertXYZto3N;CylindersAtPoints;",list,";") |
---|
1325 | list = RemoveFromList("FillSphere;FillSphere3;FillSphereRadius;FillSphereRadiusNoOverlap;FillXCylinder;FillXYCircle;FillXZCircle;FillYCylinder;",list,";") |
---|
1326 | list = RemoveFromList("FillYZCircle;FillZCylinder;PadMatrix;RandomFill3DMat;RandomPoints2D;SobolFill3DMat;SphereAtEachPoint;UnConnectedRodFill;XYZV_toByteVoxels;",list,";") |
---|
1327 | list = RemoveFromList("MakeTriplet;SobolPoints2D;X_CylindersAtPoints;X_CylindersHexagonalGrid;X_CylindersSquareGrid;maxDistance_Threaded;KR_MultiCylinder;KR_MultiCylinder_Units;",list,";") |
---|
1328 | list = RemoveFromList("X_CoreShellCylinderHexGrid;FillPlaneHexagonal;FillPlaneSquareGrid;FillSphereRadiusPeriodic;",list,";") |
---|
1329 | list = RemoveFromList("Setup_Ur;M_energy;DoRotation;Copy_xyz_to_xyz3d;MultiCyl_Loop;",list,";") |
---|
1330 | |
---|
1331 | // from Polarization |
---|
1332 | list = RemoveFromList("ParseDecayRow;ParseFlipperRow;",list,";") |
---|
1333 | |
---|
1334 | // from 2012 models |
---|
1335 | list = RemoveFromList("cng_integ;",list,";") |
---|
1336 | |
---|
1337 | // from 2012 Event Mode Processing |
---|
1338 | list = RemoveFromList("CleanupTimes;IndexForHistogram;JointHistogram;MakeFibonacciWave;Osc_ProcessEvents;SetFibonacciBins;SetLinearBins;SetLogBins;Stream_ProcessEvents;",list,";") |
---|
1339 | |
---|
1340 | // from 2013 Simulation |
---|
1341 | // list = RemoveFromList("EC_Empirical;SmearedEC_Empirical;",list,";") |
---|
1342 | list = RemoveFromList("SAS_XS_Sphere;Generate_UofR;Setup_Ur_HS;",list,";") |
---|
1343 | |
---|
1344 | |
---|
1345 | // from 2014 Automation of reduction |
---|
1346 | list = RemoveFromList("DoAnnulusGraph;DoArcGraph;",list,";") |
---|
1347 | |
---|
1348 | // from 2017-2018 VSANS reduction |
---|
1349 | list = RemoveFromList("V_BroadPeak_Pix2D;V_BroadPeak_Pix2D_noThread;V_CleanupTimes;V_I_BroadPeak_Pix2D;V_IndexForHistogram;V_MakeFibonacciWave;V_UpdatePix2Mat;xJointHistogram;",list,";") |
---|
1350 | |
---|
1351 | list = SortList(list) |
---|
1352 | return(list) |
---|
1353 | End |
---|
1354 | |
---|
1355 | |
---|
1356 | /////////////////////////////////////////////////// |
---|
1357 | // old SANSPreferences have been moved here to a common place and renamed to "NCNR Preferences" so that they |
---|
1358 | // are common to all of the packages (and will appear on all of the menus) |
---|
1359 | // |
---|
1360 | // globals moved to root:Packages:NIST: since this is generated by all packages. |
---|
1361 | // |
---|
1362 | /////////////////////////// |
---|
1363 | // user preferences |
---|
1364 | // |
---|
1365 | // globals are created in initialize.ipf |
---|
1366 | // |
---|
1367 | // this panel allows for user modification |
---|
1368 | /////////////////////////// |
---|
1369 | Proc Show_Preferences_Panel() |
---|
1370 | |
---|
1371 | DoWindow/F Pref_Panel |
---|
1372 | if(V_flag==0) |
---|
1373 | // only re-initialize if the variables don't exist, so you don't overwrite what users have changed |
---|
1374 | if( exists("root:Packages:NIST:gXML_Write") != 2 ) //if the global variable does not exist, initialize |
---|
1375 | Initialize_Preferences() |
---|
1376 | endif |
---|
1377 | Pref_Panel() |
---|
1378 | Endif |
---|
1379 | // Print "Preferences Panel stub" |
---|
1380 | End |
---|
1381 | |
---|
1382 | Proc Initialize_Preferences() |
---|
1383 | // create the globals here if they are not already present |
---|
1384 | |
---|
1385 | // each package initialization should call this to repeat the initialization |
---|
1386 | // without overwriting what was already set |
---|
1387 | |
---|
1388 | Variable val |
---|
1389 | |
---|
1390 | ///// items for SANS reduction |
---|
1391 | val = NumVarOrDefault("root:Packages:NIST:gLogScalingAsDefault", 1 ) |
---|
1392 | Variable/G root:Packages:NIST:gLogScalingAsDefault=val |
---|
1393 | |
---|
1394 | val = NumVarOrDefault("root:Packages:NIST:gAllowDRK", 0 ) |
---|
1395 | Variable/G root:Packages:NIST:gAllowDRK=val //don't show DRK as default |
---|
1396 | |
---|
1397 | val = NumVarOrDefault("root:Packages:NIST:gDoTransCheck", 1 ) |
---|
1398 | Variable/G root:Packages:NIST:gDoTransCheck=val |
---|
1399 | |
---|
1400 | val = NumVarOrDefault("root:Packages:NIST:gBinWidth", 1 ) |
---|
1401 | Variable/G root:Packages:NIST:gBinWidth=val |
---|
1402 | |
---|
1403 | val = NumVarOrDefault("root:Packages:NIST:gNPhiSteps", 72 ) |
---|
1404 | Variable/G root:Packages:NIST:gNPhiSteps=val |
---|
1405 | |
---|
1406 | // flags to turn detector corrections on/off for testing (you should leave these ON) |
---|
1407 | val = NumVarOrDefault("root:Packages:NIST:gDoDetectorEffCorr", 1 ) |
---|
1408 | Variable/G root:Packages:NIST:gDoDetectorEffCorr = 1 |
---|
1409 | |
---|
1410 | val = NumVarOrDefault("root:Packages:NIST:gDoTransmissionCorr", 1 ) |
---|
1411 | Variable/G root:Packages:NIST:gDoTransmissionCorr = 1 |
---|
1412 | |
---|
1413 | // flag to allow adding raw data files with different attenuation (normally not done) |
---|
1414 | val = NumVarOrDefault("root:Packages:NIST:gDoAdjustRAW_Atten",0) |
---|
1415 | Variable/G root:Packages:NIST:gDoAdjustRAW_Atten=val |
---|
1416 | |
---|
1417 | /// items for SANS Analysis |
---|
1418 | |
---|
1419 | |
---|
1420 | /// items for USANS Reduction |
---|
1421 | |
---|
1422 | |
---|
1423 | /// items for everyone |
---|
1424 | val = NumVarOrDefault("root:Packages:NIST:gXML_Write", 0 ) |
---|
1425 | Variable/G root:Packages:NIST:gXML_Write = val |
---|
1426 | |
---|
1427 | |
---|
1428 | end |
---|
1429 | |
---|
1430 | Function LogScalePrefCheck(ctrlName,checked) : CheckBoxControl |
---|
1431 | String ctrlName |
---|
1432 | Variable checked |
---|
1433 | |
---|
1434 | NVAR gLog = root:Packages:NIST:gLogScalingAsDefault |
---|
1435 | glog=checked |
---|
1436 | //print "log pref checked = ",checked |
---|
1437 | End |
---|
1438 | |
---|
1439 | Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl |
---|
1440 | String ctrlName |
---|
1441 | Variable checked |
---|
1442 | |
---|
1443 | NVAR gDRK = root:Packages:NIST:gAllowDRK |
---|
1444 | gDRK = checked |
---|
1445 | //Print "DRK preference = ",checked |
---|
1446 | End |
---|
1447 | |
---|
1448 | Function UnityTransPref(ctrlName,checked) : CheckBoxControl |
---|
1449 | String ctrlName |
---|
1450 | Variable checked |
---|
1451 | |
---|
1452 | NVAR gVal = root:Packages:NIST:gDoTransCheck |
---|
1453 | gVal = checked |
---|
1454 | End |
---|
1455 | |
---|
1456 | Function XMLWritePref(ctrlName,checked) : CheckBoxControl |
---|
1457 | String ctrlName |
---|
1458 | Variable checked |
---|
1459 | |
---|
1460 | NVAR gVal = root:Packages:NIST:gXML_Write |
---|
1461 | gVal = checked |
---|
1462 | End |
---|
1463 | |
---|
1464 | Function DoTransCorrPref(ctrlName,checked) : CheckBoxControl |
---|
1465 | String ctrlName |
---|
1466 | Variable checked |
---|
1467 | |
---|
1468 | NVAR gVal = root:Packages:NIST:gDoTransmissionCorr |
---|
1469 | gVal = checked |
---|
1470 | End |
---|
1471 | |
---|
1472 | Function DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl |
---|
1473 | String ctrlName |
---|
1474 | Variable checked |
---|
1475 | |
---|
1476 | NVAR gVal = root:Packages:NIST:gDoDetectorEffCorr |
---|
1477 | gVal = checked |
---|
1478 | End |
---|
1479 | |
---|
1480 | Function DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl |
---|
1481 | String ctrlName |
---|
1482 | Variable checked |
---|
1483 | |
---|
1484 | NVAR gVal = root:Packages:NIST:gDoAdjustRAW_Atten |
---|
1485 | gVal = checked |
---|
1486 | End |
---|
1487 | |
---|
1488 | Function PrefDoneButtonProc(ctrlName) : ButtonControl |
---|
1489 | String ctrlName |
---|
1490 | |
---|
1491 | DoWindow/K pref_panel |
---|
1492 | End |
---|
1493 | |
---|
1494 | Proc Pref_Panel() |
---|
1495 | PauseUpdate; Silent 1 // building window... |
---|
1496 | NewPanel /W=(646,208,1070,468)/K=2 as "NCNR Preference Panel" |
---|
1497 | DoWindow/C pref_panel |
---|
1498 | ModifyPanel cbRGB=(49694,61514,27679) |
---|
1499 | SetDrawLayer UserBack |
---|
1500 | ModifyPanel fixedSize=1 |
---|
1501 | ////// |
---|
1502 | //on main portion of panel, always visible |
---|
1503 | Button PrefPanelButtonA,pos={354,12},size={50,20},proc=PrefDoneButtonProc,title="Done" |
---|
1504 | |
---|
1505 | TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=PrefTabProc |
---|
1506 | TabControl PrefTab,tabLabel(1)="SANS",tabLabel(2)="USANS",tabLabel(3)="Analysis" |
---|
1507 | TabControl PrefTab,value=0 |
---|
1508 | TabControl PrefTab labelBack=(49694,61514,27679) |
---|
1509 | |
---|
1510 | //on tab(0) - General - initially visible |
---|
1511 | CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=XMLWritePref,title="Use canSAS XML Output" |
---|
1512 | CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"} |
---|
1513 | CheckBox PrefCtrl_0a,value= root:Packages:NIST:gXML_Write |
---|
1514 | |
---|
1515 | //on tab(1) - SANS |
---|
1516 | CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=LogScalePrefCheck,title="Use Log scaling for 2D data display" |
---|
1517 | 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."} |
---|
1518 | CheckBox PrefCtrl_1a,value= root:Packages:NIST:gLogScalingAsDefault |
---|
1519 | CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=DRKProtocolPref,title="Allow DRK correction in protocols" |
---|
1520 | 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."} |
---|
1521 | CheckBox PrefCtrl_1b,value= root:Packages:NIST:gAllowDRK |
---|
1522 | CheckBox PrefCtrl_1c,pos={21,140},size={137,14},proc=UnityTransPref,title="Check for Transmission = 1" |
---|
1523 | CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"} |
---|
1524 | CheckBox PrefCtrl_1c,value= root:Packages:NIST:gDoTransCheck |
---|
1525 | SetVariable PrefCtrl_1d,pos={21,170},size={200,15},title="Averaging Bin Width (pixels)" |
---|
1526 | SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:gBinWidth |
---|
1527 | SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)" |
---|
1528 | SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:gNPhiSteps |
---|
1529 | CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:gDoTransmissionCorr,proc=DoTransCorrPref |
---|
1530 | CheckBox PrefCtrl_1f pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."} |
---|
1531 | CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=DoEfficiencyCorrPref |
---|
1532 | 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."} |
---|
1533 | CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=DoRawAttenAdjPref |
---|
1534 | CheckBox PrefCtrl_1h value=root:Packages:NIST:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"} |
---|
1535 | |
---|
1536 | CheckBox PrefCtrl_1a,disable=1 |
---|
1537 | CheckBox PrefCtrl_1b,disable=1 |
---|
1538 | CheckBox PrefCtrl_1c,disable=1 |
---|
1539 | SetVariable PrefCtrl_1d,disable=1 |
---|
1540 | SetVariable PrefCtrl_1e,disable=1 |
---|
1541 | CheckBox PrefCtrl_1f,disable=1 |
---|
1542 | CheckBox PrefCtrl_1g,disable=1 |
---|
1543 | CheckBox PrefCtrl_1h,disable=1 |
---|
1544 | |
---|
1545 | //on tab(2) - USANS |
---|
1546 | GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
1547 | |
---|
1548 | GroupBox PrefCtrl_2a,disable=1 |
---|
1549 | |
---|
1550 | |
---|
1551 | //on tab(3) - Analysis |
---|
1552 | GroupBox PrefCtrl_3a pos={21,100},size={1,1},title="nothing to set",fSize=12 |
---|
1553 | |
---|
1554 | GroupBox PrefCtrl_3a,disable=1 |
---|
1555 | |
---|
1556 | EndMacro |
---|
1557 | |
---|
1558 | // function to control the drawing of controls in the TabControl on the main panel |
---|
1559 | // Naming scheme for the controls MUST be strictly adhered to... else controls will |
---|
1560 | // appear in odd places... |
---|
1561 | // all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting |
---|
1562 | // the controls position on that particular tab. |
---|
1563 | // in this way, they will always be drawn correctly.. |
---|
1564 | // |
---|
1565 | Function PrefTabProc(name,tab) |
---|
1566 | String name |
---|
1567 | Variable tab |
---|
1568 | |
---|
1569 | // Print "name,number",name,tab |
---|
1570 | String ctrlList = ControlNameList("",";"),item="",nameStr="" |
---|
1571 | Variable num = ItemsinList(ctrlList,";"),ii,onTab |
---|
1572 | for(ii=0;ii<num;ii+=1) |
---|
1573 | //items all start w/"PrefCtrl_", 9 characters |
---|
1574 | item=StringFromList(ii, ctrlList ,";") |
---|
1575 | nameStr=item[0,8] |
---|
1576 | if(cmpstr(nameStr,"PrefCtrl_")==0) |
---|
1577 | onTab = str2num(item[9]) //[9] is a number |
---|
1578 | ControlInfo $item |
---|
1579 | switch(abs(V_flag)) |
---|
1580 | case 1: |
---|
1581 | Button $item,disable=(tab!=onTab) |
---|
1582 | break |
---|
1583 | case 2: |
---|
1584 | CheckBox $item,disable=(tab!=onTab) |
---|
1585 | break |
---|
1586 | case 5: |
---|
1587 | SetVariable $item,disable=(tab!=onTab) |
---|
1588 | break |
---|
1589 | case 10: |
---|
1590 | TitleBox $item,disable=(tab!=onTab) |
---|
1591 | break |
---|
1592 | case 4: |
---|
1593 | ValDisplay $item,disable=(tab!=onTab) |
---|
1594 | break |
---|
1595 | case 9: |
---|
1596 | GroupBox $item,disable=(tab!=onTab) |
---|
1597 | break |
---|
1598 | // add more items to the switch if different control types are used |
---|
1599 | endswitch |
---|
1600 | endif |
---|
1601 | endfor |
---|
1602 | return(0) |
---|
1603 | End |
---|
1604 | |
---|
1605 | |
---|
1606 | //////////////////////////////////// |
---|
1607 | // Modification from Matt Wasbrough to allow rescaling of the |
---|
1608 | // axes while plotting and fitting. allows export of the rescaled |
---|
1609 | // data and of the rescaled model |
---|
1610 | // Nov 2012 |
---|
1611 | /// |
---|
1612 | |
---|
1613 | Function UseRescaleAxisCheckProc(cba) : CheckBoxControl |
---|
1614 | STRUCT WMCheckboxAction &cba |
---|
1615 | |
---|
1616 | switch( cba.eventCode ) |
---|
1617 | case 2: // mouse up |
---|
1618 | Variable checked = cba.checked |
---|
1619 | if(checked) |
---|
1620 | Execute "OpenAxisPanel()" |
---|
1621 | else |
---|
1622 | if(exists("RescaleAxisPanel") !=0) |
---|
1623 | DoWindow/K RescaleAxisPanel |
---|
1624 | endif |
---|
1625 | endif |
---|
1626 | break |
---|
1627 | endswitch |
---|
1628 | |
---|
1629 | return 0 |
---|
1630 | End |
---|
1631 | |
---|
1632 | Proc OpenAxisPanel() |
---|
1633 | If(WinType("RescaleAxisPanel") == 0) |
---|
1634 | //create the necessary data folder |
---|
1635 | NewDataFolder/O root:Packages |
---|
1636 | NewDataFolder/O root:Packages:NIST |
---|
1637 | NewDataFolder/O root:Packages:NIST:RescaleAxis |
---|
1638 | //initialize the values |
---|
1639 | Variable/G root:Packages:NIST:RescaleAxis:gRAExpA = 1 |
---|
1640 | Variable/G root:Packages:NIST:RescaleAxis:gRAExpB = 1 |
---|
1641 | Variable/G root:Packages:NIST:RescaleAxis:gRAExpC = 1 |
---|
1642 | RescaleAxisPanel() |
---|
1643 | else |
---|
1644 | //window already exists, just bring to front for update |
---|
1645 | DoWindow/F RescaleAxisPanel |
---|
1646 | endif |
---|
1647 | End |
---|
1648 | |
---|
1649 | Window RescaleAxisPanel() |
---|
1650 | PauseUpdate; Silent 1 // building window... |
---|
1651 | NewPanel /W=(461,46,735,195)/K=1 |
---|
1652 | ModifyPanel cbRGB=(49360,30954,64507), fixedSize=1 |
---|
1653 | SetDrawLayer UserBack |
---|
1654 | PopupMenu ymodel,pos={20,10},size={76,19},title="y-axis" |
---|
1655 | PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"} |
---|
1656 | 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)\"" |
---|
1657 | Button GoRescale,pos={50,80},size={70,20},proc=RescalePlot,title="Rescale" |
---|
1658 | Button GoRescale,help={"This button will rescale the axis using the selections in this panel"} |
---|
1659 | Button DoneButton,pos={170,80},size={70,20},proc=RADoneButton,title="Done" |
---|
1660 | Button DoneButton,help={"This button will close the panel"} |
---|
1661 | Button ExportData, pos={100,110}, size={90,20}, proc=ExportData, title="Export Data" |
---|
1662 | Button ExportData, help={"This button will export data from the top graph"} |
---|
1663 | SetVariable expa,pos={13,45},size={80,17},title="pow \"a\"" |
---|
1664 | 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"} |
---|
1665 | SetVariable expa,limits={-2,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpA |
---|
1666 | SetVariable expb,pos={98,45},size={80,17},title="pow \"b\"" |
---|
1667 | 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"} |
---|
1668 | SetVariable expb,limits={0,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpB |
---|
1669 | PopupMenu xmodel,pos={155,10},size={79,19},title="x-axis" |
---|
1670 | PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"} |
---|
1671 | PopupMenu xmodel,mode=1,value= #"\"q;log(q);q^2;q^c\"" |
---|
1672 | SetVariable expc,pos={182,45},size={80,17},title="pow \"c\"" |
---|
1673 | 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"} |
---|
1674 | SetVariable expc,limits={-10,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpC |
---|
1675 | Button RAHelp, pos={220,110}, size={20,20}, proc=RAHelpButtonProc, title="?" |
---|
1676 | EndMacro |
---|
1677 | |
---|
1678 | Proc RADoneButton(ctrlName): ButtonControl |
---|
1679 | String ctrlName |
---|
1680 | DoWindow/K RescaleAxisPanel |
---|
1681 | DoWindow/F WrapperPanel |
---|
1682 | CheckBox check_8 value=0 |
---|
1683 | end |
---|
1684 | |
---|
1685 | Function RAHelpButtonProc(ba) : ButtonControl |
---|
1686 | STRUCT WMButtonAction &ba |
---|
1687 | |
---|
1688 | switch( ba.eventCode ) |
---|
1689 | case 2: // mouse up |
---|
1690 | // click code here |
---|
1691 | DisplayHelpTopic/Z/K=1 "Rescaled Axis" |
---|
1692 | if(V_flag !=0) |
---|
1693 | DoAlert 0,"The Rescaled Axis Help file could not be found" |
---|
1694 | endif |
---|
1695 | break |
---|
1696 | endswitch |
---|
1697 | |
---|
1698 | return 0 |
---|
1699 | End |
---|
1700 | |
---|
1701 | Proc ExportData(ctrlName): ButtonControl |
---|
1702 | string ctrlName |
---|
1703 | WriteRescaledData() |
---|
1704 | End |
---|
1705 | |
---|
1706 | |
---|
1707 | Function RescalePlot (ctrlName): ButtonControl |
---|
1708 | String ctrlName |
---|
1709 | SetDataFolder root: |
---|
1710 | String topGraph= WinName(0,1) //this is the topmost graph |
---|
1711 | if(strlen(topGraph)==0) |
---|
1712 | Abort "There is no graph" |
---|
1713 | endif |
---|
1714 | |
---|
1715 | DoWindow/F $topGraph |
---|
1716 | GetWindow/Z $topGraph, wavelist |
---|
1717 | wave/t W_Wavelist |
---|
1718 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1719 | if (exists("W_WaveList")==1) |
---|
1720 | KillWaves/Z root:Packages:NIST:RescaleAxis:W_WaveList |
---|
1721 | endif |
---|
1722 | MoveWave root:W_WaveList, root:Packages:NIST:RescaleAxis:W_WaveList |
---|
1723 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1724 | variable i,j,k |
---|
1725 | string DF,DF1,temp, temp2, t1 |
---|
1726 | for (i=0; i < numpnts(W_WaveList)/3; i+=1) |
---|
1727 | temp = W_WaveList[i][1] |
---|
1728 | if (stringmatch(temp, "*_i") || stringmatch(temp, "*_i_RA")) |
---|
1729 | temp = W_WaveList[i][0] |
---|
1730 | if(stringmatch(temp, "*_i")) |
---|
1731 | temp = removeending(temp, "_i") |
---|
1732 | elseif(stringmatch(temp, "*_i_RA")) |
---|
1733 | temp = removeending(temp, "_i_RA") |
---|
1734 | endif |
---|
1735 | Make/T/O $temp/Wave=tempWave |
---|
1736 | DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") |
---|
1737 | if (strlen(DF) ==0) |
---|
1738 | DF = ":" |
---|
1739 | endif |
---|
1740 | DF1 = "root"+DF |
---|
1741 | tempWave[0] = DF1 |
---|
1742 | k = 1 |
---|
1743 | for(j=0;j<numpnts(W_WaveList)/3; j+=1) |
---|
1744 | if (stringmatch(W_WaveList[j][1], "*"+temp+"*")) |
---|
1745 | tempWave[k] = W_WaveList[j][0] |
---|
1746 | k = k+1 |
---|
1747 | endif |
---|
1748 | endfor |
---|
1749 | redimension/N=(k) tempWave |
---|
1750 | elseif(stringmatch(temp, "*ywave*")) |
---|
1751 | temp = W_WaveList[i][0] |
---|
1752 | if(stringmatch(temp, "*_RA")) |
---|
1753 | temp = removeending(temp, "_RA") |
---|
1754 | endif |
---|
1755 | Make/T/O $temp/Wave=tempWave |
---|
1756 | DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") |
---|
1757 | if (strlen(DF) ==0) |
---|
1758 | DF = ":" |
---|
1759 | endif |
---|
1760 | DF1 = "root"+DF |
---|
1761 | tempWave[0] = DF1 |
---|
1762 | temp2 = replacestring("ywave", temp, "") |
---|
1763 | k = 1 |
---|
1764 | for(j=0;j<numpnts(W_WaveList)/3; j+=1) |
---|
1765 | t1 = W_Wavelist[j][1] |
---|
1766 | if (stringmatch(W_WaveList[j][1], "*wave"+temp2+"*")) |
---|
1767 | tempWave[k] = W_WaveList[j][1] |
---|
1768 | k = k+1 |
---|
1769 | endif |
---|
1770 | endfor |
---|
1771 | redimension/N=(k) tempWave |
---|
1772 | endif |
---|
1773 | endfor |
---|
1774 | KillWaves/Z W_Wavelist |
---|
1775 | string listWave = Wavelist("*", ";", "TEXT:1") |
---|
1776 | string WaveToRescale, WaveDataFolder,xwave, ywave, swave |
---|
1777 | |
---|
1778 | for (i = 0; i < ItemsInList(listWave,";"); i+=1) |
---|
1779 | temp = StringFromList(i,listWave,";") |
---|
1780 | Wave/T WaveString = $temp |
---|
1781 | for (j=1; j < numpnts(WaveString); j+=1) |
---|
1782 | WaveToRescale = Wavestring[j] |
---|
1783 | if (stringmatch(WaveToRescale, "*_RA")) |
---|
1784 | WaveToRescale = RemoveEnding(WaveToRescale, "_RA") |
---|
1785 | endif |
---|
1786 | WaveDataFolder = WaveString[0] |
---|
1787 | SetDataFolder $WaveDataFolder |
---|
1788 | if (stringmatch(WaveToRescale, "*_q")) |
---|
1789 | xwave = WaveToRescale |
---|
1790 | XRescale(xwave) |
---|
1791 | elseif (stringmatch(WaveToRescale, "*_i")) |
---|
1792 | ywave = WaveToRescale |
---|
1793 | xwave = RemoveEnding(WaveToRescale, "_i")+"_q" |
---|
1794 | YRescale(ywave, xwave) |
---|
1795 | elseif (stringmatch(WaveToRescale, "*_s")) |
---|
1796 | swave = WaveToRescale |
---|
1797 | ywave = RemoveEnding(WaveToRescale, "_s")+"_i" |
---|
1798 | xwave = RemoveEnding(WaveToRescale, "_s")+"_q" |
---|
1799 | ERescale(swave, ywave, xwave) |
---|
1800 | elseif (stringmatch(WaveToRescale, "xwave_*")) |
---|
1801 | xwave=WaveToRescale |
---|
1802 | XRescale(xwave) |
---|
1803 | elseif (stringmatch(WaveToRescale, "ywave_*")) |
---|
1804 | ywave = WaveToRescale |
---|
1805 | xwave= ReplaceString("ywave", WaveToRescale, "xwave") |
---|
1806 | YRescale(ywave, xwave) |
---|
1807 | elseif(stringmatch(WaveToRescale, "*_qvals")) |
---|
1808 | xwave = WaveToRescale |
---|
1809 | XRescale(xwave) |
---|
1810 | elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) |
---|
1811 | ywave = WaveToRescale |
---|
1812 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1813 | if (stringmatch(Wavestring[k], "*_qvals")) |
---|
1814 | xwave = Wavestring[k] |
---|
1815 | endif |
---|
1816 | endfor |
---|
1817 | YRescale(ywave, xwave) |
---|
1818 | else |
---|
1819 | ywave = WaveToRescale |
---|
1820 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1821 | if (stringmatch(Wavestring[k], "*_q")) |
---|
1822 | xwave = Wavestring[k] |
---|
1823 | endif |
---|
1824 | endfor |
---|
1825 | YRescale(ywave,xwave) |
---|
1826 | string yAxis = ywave+"_RA" |
---|
1827 | wave yAxisWave = $yAxis |
---|
1828 | SetFormula yAxisWave, "YRescale(ywave,xwave)" |
---|
1829 | endif |
---|
1830 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1831 | endfor |
---|
1832 | endfor |
---|
1833 | |
---|
1834 | string oldywave, xstr, ystr |
---|
1835 | for (i = 0; i < ItemsInList(listWave,";"); i+=1) |
---|
1836 | temp = StringFromList(i,listWave,";") |
---|
1837 | Wave/T WaveString = $temp |
---|
1838 | for (j=1; j < numpnts(WaveString); j+=1) |
---|
1839 | WaveToRescale = Wavestring[j] |
---|
1840 | WaveDataFolder = WaveString[0] |
---|
1841 | SetDataFolder $WaveDataFolder |
---|
1842 | ControlInfo/W=RescaleAxisPanel yModel |
---|
1843 | ystr = S_Value |
---|
1844 | ControlInfo/W=RescaleAxisPanel xModel |
---|
1845 | xstr = S_Value |
---|
1846 | if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) |
---|
1847 | if(stringmatch(WaveToRescale, "*_i_RA")) |
---|
1848 | oldywave = WaveToRescale |
---|
1849 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1850 | xwave = RemoveEnding(WaveToRescale, "_i_RA")+"_q" |
---|
1851 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1852 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1853 | swave = RemoveEnding(WaveToRescale, "_i_RA")+"_s" |
---|
1854 | if(exists(swave)==1) |
---|
1855 | ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) |
---|
1856 | endif |
---|
1857 | elseif (stringmatch(WaveToRescale, "smeared*")) |
---|
1858 | if(stringmatch(WaveToRescale,"*_RA") && stringmatch(WaveToRescale,"!*_qvals*") ) |
---|
1859 | oldywave = WaveToRescale |
---|
1860 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1861 | xwave = "smeared_qvals" |
---|
1862 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1863 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1864 | endif |
---|
1865 | elseif(stringmatch(WaveToRescale,"ywave*") && stringmatch(WaveToRescale,"*_RA")) |
---|
1866 | oldywave = WaveToRescale |
---|
1867 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1868 | xwave = ReplaceString("ywave",ywave,"xwave") |
---|
1869 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1870 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1871 | elseif(stringmatch(WaveToRescale, "*FitYw*") && stringmatch(WaveToRescale, "*_RA")) |
---|
1872 | oldywave = WaveToRescale |
---|
1873 | ywave = RemoveEnding(WaveToRescale,"_RA") |
---|
1874 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1875 | if (stringmatch(Wavestring[k], "*_q")) |
---|
1876 | xwave = Wavestring[k] |
---|
1877 | endif |
---|
1878 | endfor |
---|
1879 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1880 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1881 | endif |
---|
1882 | elseif(stringmatch(WaveToRescale, "*_RA")) |
---|
1883 | elseif (stringmatch(WaveToRescale, "*_i")) |
---|
1884 | DoWindow/F topGraph |
---|
1885 | oldywave = WaveToRescale |
---|
1886 | xwave = RemoveEnding(WaveToRescale, "_i")+"_q_RA" |
---|
1887 | ywave = WaveToRescale + "_RA" |
---|
1888 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1889 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1890 | ModifyGraph log=0 |
---|
1891 | swave = RemoveEnding(WaveToRescale, "_i")+"_s_RA" |
---|
1892 | if(exists(swave)==1) |
---|
1893 | ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) |
---|
1894 | endif |
---|
1895 | DoUpdate |
---|
1896 | elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) |
---|
1897 | oldywave = WaveToRescale |
---|
1898 | ywave = WaveToRescale + "_RA" |
---|
1899 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1900 | xwave = "smeared_qvals_RA" |
---|
1901 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1902 | elseif(stringmatch(WaveToRescale,"ywave*")) |
---|
1903 | oldywave = WaveToRescale |
---|
1904 | ywave = WaveToRescale + "_RA" |
---|
1905 | xwave = ReplaceString("ywave",ywave,"xwave") |
---|
1906 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1907 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1908 | elseif(stringmatch(WaveToRescale, "*FitYw*")) |
---|
1909 | oldywave = WaveToRescale |
---|
1910 | ywave = WaveToRescale+"_RA" |
---|
1911 | for (k=1; k < numpnts(WaveString); k+=1) |
---|
1912 | if (stringmatch(Wavestring[k], "*_q")) |
---|
1913 | xwave = Wavestring[k]+"_RA" |
---|
1914 | endif |
---|
1915 | endfor |
---|
1916 | replacewave/Y/W=$topGraph trace=$oldywave, $ywave |
---|
1917 | replacewave/X/W=$topGraph trace=$ywave, $xwave |
---|
1918 | endif |
---|
1919 | SetDataFolder root:Packages:NIST:RescaleAxis |
---|
1920 | DoUpdate |
---|
1921 | endfor |
---|
1922 | endfor |
---|
1923 | KillWaves/A/Z |
---|
1924 | |
---|
1925 | string ylabel, xlabel |
---|
1926 | ControlInfo/W=RescaleAxisPanel yModel |
---|
1927 | ystr = S_Value |
---|
1928 | ControlInfo/W=RescaleAxisPanel xModel |
---|
1929 | xstr = S_Value |
---|
1930 | |
---|
1931 | if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) |
---|
1932 | modifygraph log=1 |
---|
1933 | else |
---|
1934 | modifygraph log=0 |
---|
1935 | endif |
---|
1936 | |
---|
1937 | Variable pow_a,pow_b,pow_c |
---|
1938 | ControlInfo/W=RescaleAxisPanel expa |
---|
1939 | pow_a = V_value |
---|
1940 | ControlInfo/W=RescaleAxisPanel expb |
---|
1941 | pow_b = V_value |
---|
1942 | ControlInfo/W=RescaleAxisPanel expc |
---|
1943 | pow_c = V_value |
---|
1944 | |
---|
1945 | If (cmpstr("I",ystr) == 0) |
---|
1946 | ylabel = "I(q)" |
---|
1947 | elseif (cmpstr("ln(I)",ystr) == 0) |
---|
1948 | ylabel = "ln(I)" |
---|
1949 | elseif (cmpstr("log(I)",ystr) == 0) |
---|
1950 | ylabel = "log(I)" |
---|
1951 | elseif (cmpstr("1/I",ystr) == 0) |
---|
1952 | ylabel = "1/I" |
---|
1953 | elseif (cmpstr("I^a",ystr) == 0) |
---|
1954 | ylabel = "I\S"+num2str(pow_a)+"\M" |
---|
1955 | elseif (cmpstr("Iq^a",ystr) == 0) |
---|
1956 | ylabel = "Iq\S"+num2str(pow_a)+"\M" |
---|
1957 | elseif (cmpstr("I^a q^b",ystr) == 0) |
---|
1958 | ylabel = "I\S"+num2str(pow_a)+"\Mq\S"+num2str(pow_b)+"\M" |
---|
1959 | elseif (cmpstr("1/sqrt(I)",ystr) == 0) |
---|
1960 | ylabel = "1/sqrt(I)" |
---|
1961 | elseif (cmpstr("ln(Iq)",ystr) == 0) |
---|
1962 | ylabel = "ln(Iq)" |
---|
1963 | elseif (cmpstr("ln(Iq^2)",ystr) == 0) |
---|
1964 | ylabel = "ln(Iq\S2\M)" |
---|
1965 | endif |
---|
1966 | |
---|
1967 | If (cmpstr("q",xstr) == 0) |
---|
1968 | xlabel = "q (A\S-1\M)" |
---|
1969 | elseif (cmpstr("q^2",xstr) == 0) |
---|
1970 | xlabel = "q\S2\M" |
---|
1971 | elseif (cmpstr("log(q)",xstr) == 0) |
---|
1972 | xlabel = "log(q)" |
---|
1973 | elseif (cmpstr("q^c",xstr) == 0) |
---|
1974 | xlabel = "q\S"+num2str(pow_c)+"\M" |
---|
1975 | endif |
---|
1976 | |
---|
1977 | SetAxis/A |
---|
1978 | Label left ylabel |
---|
1979 | Label bottom xlabel |
---|
1980 | |
---|
1981 | SetDataFolder root: |
---|
1982 | End |
---|
1983 | |
---|
1984 | Function YRescale(ywave, xwave) |
---|
1985 | String ywave,xwave |
---|
1986 | |
---|
1987 | Wave yw = $ywave |
---|
1988 | Wave xw = $xwave |
---|
1989 | |
---|
1990 | //Scaling exponents and background value |
---|
1991 | Variable pow_a,pow_b,pow_c |
---|
1992 | ControlInfo/W=RescaleAxisPanel expa |
---|
1993 | pow_a = V_value |
---|
1994 | ControlInfo/W=RescaleAxisPanel expb |
---|
1995 | pow_b = V_value |
---|
1996 | ControlInfo/W=RescaleAxisPanel expc |
---|
1997 | pow_c = V_value |
---|
1998 | |
---|
1999 | //check for physical limits on exponent values |
---|
2000 | // if bad values found, alert, and reset to good values so the rescaling can continue |
---|
2001 | NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA |
---|
2002 | NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB |
---|
2003 | NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC |
---|
2004 | if((pow_a < -2) || (pow_a > 10)) |
---|
2005 | DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" |
---|
2006 | gA = 1 |
---|
2007 | endif |
---|
2008 | if((pow_b < 0) || (pow_b > 10)) |
---|
2009 | DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" |
---|
2010 | gB = 1 |
---|
2011 | endif |
---|
2012 | //if q^c is the x-scaling, c must be be within limits and also non-zero |
---|
2013 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2014 | If (cmpstr("q^c",S_Value) == 0) |
---|
2015 | if(pow_c == 0) |
---|
2016 | DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" |
---|
2017 | gC = 1 |
---|
2018 | endif |
---|
2019 | if((pow_c < -10) || (pow_c > 10)) |
---|
2020 | DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" |
---|
2021 | gC = 1 |
---|
2022 | endif |
---|
2023 | endif |
---|
2024 | |
---|
2025 | //variables set for each model to control look of graph |
---|
2026 | String ystr, yAxis |
---|
2027 | //check for proper y-scaling selection, make the necessary waves |
---|
2028 | // Wave yAxisWave |
---|
2029 | |
---|
2030 | ControlInfo/W=RescaleAxisPanel yModel |
---|
2031 | ystr = S_Value |
---|
2032 | |
---|
2033 | do |
---|
2034 | If (cmpstr("I",S_Value) == 0) |
---|
2035 | yAxis = ywave+"_RA" |
---|
2036 | if (exists(yAxis)== 0) |
---|
2037 | Duplicate yw $yAxis |
---|
2038 | endif |
---|
2039 | SetScale d 0,0,"1/cm",$yAxis |
---|
2040 | wave yAxisWave = $yAxis |
---|
2041 | yAxisWave = yw |
---|
2042 | break |
---|
2043 | endif |
---|
2044 | If (cmpstr("ln(I)",S_Value) == 0) |
---|
2045 | yAxis = ywave+"_RA" |
---|
2046 | if (exists(yAxis)== 0) |
---|
2047 | Duplicate yw $yAxis |
---|
2048 | endif |
---|
2049 | SetScale d 0,0,"",$yAxis |
---|
2050 | wave yAxisWave = $yAxis |
---|
2051 | yAxisWave = ln(yw) |
---|
2052 | break |
---|
2053 | endif |
---|
2054 | If (cmpstr("log(I)",S_Value) == 0) |
---|
2055 | yAxis = ywave+"_RA" |
---|
2056 | if (exists(yAxis)== 0) |
---|
2057 | Duplicate yw $yAxis |
---|
2058 | endif |
---|
2059 | SetScale d 0,0,"",$yAxis |
---|
2060 | wave yAxisWave = $yAxis |
---|
2061 | yAxisWave = log(yw) |
---|
2062 | break |
---|
2063 | endif |
---|
2064 | If (cmpstr("1/I",S_Value) == 0) |
---|
2065 | yAxis = ywave+"_RA" |
---|
2066 | if (exists(yAxis)== 0) |
---|
2067 | Duplicate yw $yAxis |
---|
2068 | endif |
---|
2069 | SetScale d 0,0,"",$yAxis |
---|
2070 | wave yAxisWave = $yAxis |
---|
2071 | yAxisWave = 1/(yw) |
---|
2072 | break |
---|
2073 | endif |
---|
2074 | If (cmpstr("I^a",S_Value) == 0) |
---|
2075 | yAxis = ywave+"_RA" |
---|
2076 | if (exists(yAxis)== 0) |
---|
2077 | Duplicate yw $yAxis |
---|
2078 | endif |
---|
2079 | SetScale d 0,0,"",$yAxis |
---|
2080 | wave yAxisWave = $yAxis |
---|
2081 | yAxisWave = yw^pow_a |
---|
2082 | break |
---|
2083 | endif |
---|
2084 | If (cmpstr("Iq^a",S_Value) == 0) |
---|
2085 | yAxis = ywave+"_RA" |
---|
2086 | if (exists(yAxis)== 0) |
---|
2087 | Duplicate yw $yAxis |
---|
2088 | endif |
---|
2089 | SetScale d 0,0,"",$yAxis |
---|
2090 | wave yAxisWave = $yAxis |
---|
2091 | yAxisWave = yw*xw^pow_a |
---|
2092 | break |
---|
2093 | endif |
---|
2094 | If (cmpstr("I^a q^b",S_Value) == 0) |
---|
2095 | yAxis = ywave+"_RA" |
---|
2096 | if (exists(yAxis)== 0) |
---|
2097 | Duplicate yw $yAxis |
---|
2098 | endif |
---|
2099 | SetScale d 0,0,"",$yAxis |
---|
2100 | wave yAxisWave = $yAxis |
---|
2101 | yAxisWave = yw^pow_a*xw^pow_b |
---|
2102 | break |
---|
2103 | endif |
---|
2104 | If (cmpstr("1/sqrt(I)",S_Value) == 0) |
---|
2105 | yAxis = ywave+"_RA" |
---|
2106 | if (exists(yAxis)== 0) |
---|
2107 | Duplicate yw $yAxis |
---|
2108 | endif |
---|
2109 | SetScale d 0,0,"",$yAxis |
---|
2110 | wave yAxisWave = $yAxis |
---|
2111 | yAxisWave = 1/sqrt(yw) |
---|
2112 | break |
---|
2113 | endif |
---|
2114 | If (cmpstr("ln(Iq)",S_Value) == 0) |
---|
2115 | yAxis = ywave+"_RA" |
---|
2116 | if (exists(yAxis)== 0) |
---|
2117 | Duplicate yw $yAxis |
---|
2118 | endif |
---|
2119 | SetScale d 0,0,"",$yAxis |
---|
2120 | wave yAxisWave = $yAxis |
---|
2121 | yAxisWave = ln(xw*yw) |
---|
2122 | break |
---|
2123 | endif |
---|
2124 | If (cmpstr("ln(Iq^2)",S_Value) == 0) |
---|
2125 | yAxis = ywave+"_RA" |
---|
2126 | if (exists(yAxis)== 0) |
---|
2127 | Duplicate yw $yAxis |
---|
2128 | endif |
---|
2129 | SetScale d 0,0,"",$yAxis |
---|
2130 | wave yAxisWave = $yAxis |
---|
2131 | yAxisWave = ln(xw*xw*yw) |
---|
2132 | break |
---|
2133 | endif |
---|
2134 | //more ifs for each case |
---|
2135 | |
---|
2136 | // if selection not found, abort |
---|
2137 | DoAlert 0,"Y-axis scaling incorrect. Aborting" |
---|
2138 | Abort |
---|
2139 | while(0) |
---|
2140 | End |
---|
2141 | |
---|
2142 | Function XRescale(xwave) |
---|
2143 | String xwave |
---|
2144 | |
---|
2145 | Wave xw = $xwave |
---|
2146 | |
---|
2147 | //Scaling exponents and background value |
---|
2148 | Variable pow_a,pow_b,pow_c |
---|
2149 | ControlInfo/W=RescaleAxisPanel expa |
---|
2150 | pow_a = V_value |
---|
2151 | ControlInfo/W=RescaleAxisPanel expb |
---|
2152 | pow_b = V_value |
---|
2153 | ControlInfo/W=RescaleAxisPanel expc |
---|
2154 | pow_c = V_value |
---|
2155 | |
---|
2156 | //check for physical limits on exponent values |
---|
2157 | // if bad values found, alert, and reset to good values so the rescaling can continue |
---|
2158 | NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA |
---|
2159 | NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB |
---|
2160 | NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC |
---|
2161 | if((pow_a < -2) || (pow_a > 10)) |
---|
2162 | DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" |
---|
2163 | gA = 1 |
---|
2164 | endif |
---|
2165 | if((pow_b < 0) || (pow_b > 10)) |
---|
2166 | DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" |
---|
2167 | gB = 1 |
---|
2168 | endif |
---|
2169 | //if q^c is the x-scaling, c must be be within limits and also non-zero |
---|
2170 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2171 | If (cmpstr("q^c",S_Value) == 0) |
---|
2172 | if(pow_c == 0) |
---|
2173 | DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" |
---|
2174 | gC = 1 |
---|
2175 | endif |
---|
2176 | if((pow_c < -10) || (pow_c > 10)) |
---|
2177 | DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" |
---|
2178 | gC = 1 |
---|
2179 | endif |
---|
2180 | endif |
---|
2181 | |
---|
2182 | //variables set for each model to control look of graph |
---|
2183 | String xstr, xAxis |
---|
2184 | //check for proper y-scaling selection, make the necessary waves |
---|
2185 | // Wave xAxisWave |
---|
2186 | |
---|
2187 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2188 | xstr = S_Value |
---|
2189 | do |
---|
2190 | // make the new yaxis wave |
---|
2191 | If (cmpstr("q",S_Value) == 0) |
---|
2192 | xAxis = xwave+"_RA" |
---|
2193 | if (exists(xAxis)== 0) |
---|
2194 | Duplicate xw $xAxis |
---|
2195 | endif |
---|
2196 | SetScale d 0,0,"A^-1",$xAxis |
---|
2197 | wave xAxisWave = $xAxis |
---|
2198 | xAxisWave = xw |
---|
2199 | break |
---|
2200 | endif |
---|
2201 | If (cmpstr("q^2",S_Value) == 0) |
---|
2202 | xAxis = xwave+"_RA" |
---|
2203 | if (exists(xAxis)== 0) |
---|
2204 | Duplicate xw $xAxis |
---|
2205 | endif |
---|
2206 | SetScale d 0,0,"A^-2",$xAxis |
---|
2207 | wave xAxisWave = $xAxis |
---|
2208 | xAxisWave = xw*xw |
---|
2209 | break |
---|
2210 | endif |
---|
2211 | If (cmpstr("log(q)",S_Value) == 0) |
---|
2212 | xAxis = xwave+"_RA" |
---|
2213 | if (exists(xAxis)== 0) |
---|
2214 | Duplicate xw $xAxis |
---|
2215 | endif |
---|
2216 | SetScale d 0,0,"",$xAxis |
---|
2217 | wave xAxisWave = $xAxis |
---|
2218 | xAxisWave = log(xw) |
---|
2219 | break |
---|
2220 | endif |
---|
2221 | If (cmpstr("q^c",S_Value) == 0) |
---|
2222 | xAxis = xwave+"_RA" |
---|
2223 | if (exists(xAxis)== 0) |
---|
2224 | Duplicate xw $xAxis |
---|
2225 | endif |
---|
2226 | SetScale d 0,0,"", $xAxis |
---|
2227 | wave xAxisWave = $xAxis |
---|
2228 | xAxisWave = xw^pow_c |
---|
2229 | break |
---|
2230 | endif |
---|
2231 | |
---|
2232 | //more ifs for each case |
---|
2233 | // if selection not found, abort |
---|
2234 | DoAlert 0,"X-axis scaling incorrect. Aborting" |
---|
2235 | Abort |
---|
2236 | while(0) //end of "case" statement for x-axis scaling |
---|
2237 | End |
---|
2238 | |
---|
2239 | Function ERescale(swave, ywave, xwave) |
---|
2240 | String swave, ywave, xwave |
---|
2241 | |
---|
2242 | Wave ew = $swave |
---|
2243 | Wave yw = $ywave |
---|
2244 | Wave xw = $xwave |
---|
2245 | |
---|
2246 | //Scaling exponents and background value |
---|
2247 | Variable pow_a,pow_b,pow_c |
---|
2248 | ControlInfo/W=RescaleAxisPanel expa |
---|
2249 | pow_a = V_value |
---|
2250 | ControlInfo/W=RescaleAxisPanel expb |
---|
2251 | pow_b = V_value |
---|
2252 | ControlInfo/W=RescaleAxisPanel expc |
---|
2253 | pow_c = V_value |
---|
2254 | |
---|
2255 | //check for physical limits on exponent values |
---|
2256 | // if bad values found, alert, and reset to good values so the rescaling can continue |
---|
2257 | NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA |
---|
2258 | NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB |
---|
2259 | NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC |
---|
2260 | if((pow_a < -2) || (pow_a > 10)) |
---|
2261 | DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" |
---|
2262 | gA = 1 |
---|
2263 | endif |
---|
2264 | if((pow_b < 0) || (pow_b > 10)) |
---|
2265 | DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" |
---|
2266 | gB = 1 |
---|
2267 | endif |
---|
2268 | //if q^c is the x-scaling, c must be be within limits and also non-zero |
---|
2269 | ControlInfo/W=RescaleAxisPanel xModel |
---|
2270 | If (cmpstr("q^c",S_Value) == 0) |
---|
2271 | if(pow_c == 0) |
---|
2272 | DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" |
---|
2273 | gC = 1 |
---|
2274 | endif |
---|
2275 | if((pow_c < -10) || (pow_c > 10)) |
---|
2276 | DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" |
---|
2277 | gC = 1 |
---|
2278 | endif |
---|
2279 | endif |
---|
2280 | |
---|
2281 | //variables set for each model to control look of graph |
---|
2282 | String ystr, eWave |
---|
2283 | //check for proper y-scaling selection, make the necessary waves |
---|
2284 | // Wave yErrWave |
---|
2285 | |
---|
2286 | ControlInfo/W=RescaleAxisPanel yModel |
---|
2287 | ystr = S_Value |
---|
2288 | do |
---|
2289 | |
---|
2290 | If (cmpstr("I",S_Value) == 0) |
---|
2291 | eWave = swave+"_RA" |
---|
2292 | if (exists(eWave) == 0) |
---|
2293 | Duplicate ew $eWave |
---|
2294 | endif |
---|
2295 | wave yErrWave = $eWave |
---|
2296 | yErrWave = ew |
---|
2297 | break |
---|
2298 | endif |
---|
2299 | If (cmpstr("ln(I)",S_Value) == 0) |
---|
2300 | eWave = swave+"_RA" |
---|
2301 | if (exists(eWave) == 0) |
---|
2302 | Duplicate ew $eWave |
---|
2303 | endif |
---|
2304 | wave yErrWave = $eWave |
---|
2305 | yErrWave = ew/yw |
---|
2306 | break |
---|
2307 | endif |
---|
2308 | If (cmpstr("log(I)",S_Value) == 0) |
---|
2309 | eWave = swave+"_RA" |
---|
2310 | if (exists(eWave) == 0) |
---|
2311 | Duplicate ew $eWave |
---|
2312 | endif |
---|
2313 | wave yErrWave = $eWave |
---|
2314 | yErrWave = ew/(2.30*yw) |
---|
2315 | break |
---|
2316 | endif |
---|
2317 | If (cmpstr("1/I",S_Value) == 0) |
---|
2318 | eWave = swave+"_RA" |
---|
2319 | if (exists(eWave) == 0) |
---|
2320 | Duplicate ew $eWave |
---|
2321 | endif |
---|
2322 | wave yErrWave = $eWave |
---|
2323 | yErrWave = ew/(yw^2) |
---|
2324 | break |
---|
2325 | endif |
---|
2326 | If (cmpstr("I^a",S_Value) == 0) |
---|
2327 | eWave = swave+"_RA" |
---|
2328 | if (exists(eWave) == 0) |
---|
2329 | Duplicate ew $eWave |
---|
2330 | endif |
---|
2331 | wave yErrWave = $eWave |
---|
2332 | yErrWave = ew*abs(pow_a*(yw^(pow_a-1))) |
---|
2333 | break |
---|
2334 | endif |
---|
2335 | If (cmpstr("Iq^a",S_Value) == 0) |
---|
2336 | eWave = swave+"_RA" |
---|
2337 | if (exists(eWave) == 0) |
---|
2338 | Duplicate ew $eWave |
---|
2339 | endif |
---|
2340 | wave yErrWave = $eWave |
---|
2341 | yErrWave = ew*xw^pow_a |
---|
2342 | break |
---|
2343 | endif |
---|
2344 | If (cmpstr("I^a q^b",S_Value) == 0) |
---|
2345 | eWave = swave+"_RA" |
---|
2346 | if (exists(eWave) == 0) |
---|
2347 | Duplicate ew $eWave |
---|
2348 | endif |
---|
2349 | wave yErrWave = $eWave |
---|
2350 | yErrWave = ew*abs(pow_a*(yw^(pow_a-1)))*xw^pow_b |
---|
2351 | break |
---|
2352 | endif |
---|
2353 | If (cmpstr("1/sqrt(I)",S_Value) == 0) |
---|
2354 | eWave = swave+"_RA" |
---|
2355 | if (exists(eWave) == 0) |
---|
2356 | Duplicate ew $eWave |
---|
2357 | endif |
---|
2358 | wave yErrWave = $eWave |
---|
2359 | yErrWave = 0.5*ew*yw^(-1.5) |
---|
2360 | break |
---|
2361 | endif |
---|
2362 | If (cmpstr("ln(Iq)",S_Value) == 0) |
---|
2363 | eWave = swave+"_RA" |
---|
2364 | if (exists(eWave) == 0) |
---|
2365 | Duplicate ew $eWave |
---|
2366 | endif |
---|
2367 | wave yErrWave = $eWave |
---|
2368 | yErrWave =ew/yw |
---|
2369 | break |
---|
2370 | endif |
---|
2371 | If (cmpstr("ln(Iq^2)",S_Value) == 0) |
---|
2372 | eWave = swave+"_RA" |
---|
2373 | if (exists(eWave) == 0) |
---|
2374 | Duplicate ew $eWave |
---|
2375 | endif |
---|
2376 | wave yErrWave = $eWave |
---|
2377 | yErrWave = ew/yw |
---|
2378 | break |
---|
2379 | endif |
---|
2380 | //more ifs for each case |
---|
2381 | |
---|
2382 | // if selection not found, abort |
---|
2383 | DoAlert 0,"Y-axis scaling incorrect. Aborting" |
---|
2384 | Abort |
---|
2385 | while(0) //end of "case" statement for y-axis scaling |
---|
2386 | |
---|
2387 | End |
---|
2388 | |
---|
2389 | /////////////////////////// |
---|
2390 | |
---|