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