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