1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=5.0 |
---|
3 | #pragma IgorVersion=6.0 |
---|
4 | |
---|
5 | //************************** |
---|
6 | // Vers. 1.2 092101 |
---|
7 | // |
---|
8 | //must be using IGOR Pro v. 3.14 or higher for StringFromList() |
---|
9 | //loads 3-column or 6-column data into the experiment with appropriate extensions |
---|
10 | // added to the cleaned-up filenames |
---|
11 | // |
---|
12 | // 2 versions - one to always present dialog, and a second if the filename |
---|
13 | // is already known |
---|
14 | // |
---|
15 | //***************************** |
---|
16 | |
---|
17 | |
---|
18 | // loads a 1-d (ascii) datafile and plots the data |
---|
19 | // will not overwrite existing data (old data must be deleted first) |
---|
20 | // - multiple datasets can be automatically plotted on the same graph |
---|
21 | // |
---|
22 | //substantially easier to write this as a Proc rather than a function... |
---|
23 | // |
---|
24 | Proc LoadOneDData() |
---|
25 | |
---|
26 | //Load the waves, using default waveX names |
---|
27 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
28 | LoadWave/G/D/A |
---|
29 | String filename = S_fileName |
---|
30 | Variable numCols = V_flag |
---|
31 | |
---|
32 | //changes JIL |
---|
33 | if(numCols==2) //no errors |
---|
34 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
35 | Duplicate/O $("root:"+n1), errorTmp |
---|
36 | errorTmp = 0.01*(errorTmp)+ 0.03*sqrt(errorTmp) |
---|
37 | S_waveNames+="errorTmp;" |
---|
38 | numCols=3 |
---|
39 | endif |
---|
40 | |
---|
41 | if(numCols==3) |
---|
42 | String w0,w1,w2,n0,n1,n2,wt |
---|
43 | Variable rr,gg,bb |
---|
44 | |
---|
45 | // put the names of the three loaded waves into local names |
---|
46 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
47 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
48 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
49 | |
---|
50 | //remove the semicolon AND period from files from the VAX |
---|
51 | w0 = CleanupName((S_fileName + "_q"),0) |
---|
52 | w1 = CleanupName((S_fileName + "_i"),0) |
---|
53 | w2 = CleanupName((S_fileName + "_s"),0) |
---|
54 | wt = CleanupName((S_fileName + "wt"),0) //create a name for the weighting wave |
---|
55 | |
---|
56 | if(exists(w0) !=0) |
---|
57 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
58 | if(V_flag==2) //user selected No |
---|
59 | KillWaves/Z $n0,$n1,$n2 // kill the default waveX that were loaded |
---|
60 | String/G root:myGlobals:gLastFileName = filename //set the last file loaded to the one NOT loaded |
---|
61 | return //quits the macro |
---|
62 | endif |
---|
63 | endif |
---|
64 | |
---|
65 | ////overwrite the existing data, if it exists |
---|
66 | Duplicate/O $n0, $w0 |
---|
67 | Duplicate/O $n1, $w1 |
---|
68 | Duplicate/O $n2, $w2 |
---|
69 | KillWaves $n0,$n1,$n2 |
---|
70 | |
---|
71 | String/G root:myGlobals:gLastFileName = filename |
---|
72 | Duplicate/o $w2 $wt |
---|
73 | $wt = 1/$w2 //assign the weighting wave |
---|
74 | |
---|
75 | // set data units for the waves |
---|
76 | String angst = root:myGlobals:gAngstStr |
---|
77 | SetScale d,0,0,"1/"+angst,$w0 |
---|
78 | SetScale d,0,0,"1/cm",$w1 |
---|
79 | |
---|
80 | // assign colors randomly |
---|
81 | rr = abs(trunc(enoise(65535))) |
---|
82 | gg = abs(trunc(enoise(65535))) |
---|
83 | bb = abs(trunc(enoise(65535))) |
---|
84 | |
---|
85 | // if target window is a graph, and user wants to append, do so |
---|
86 | DoWindow/B Plot_Manager |
---|
87 | if(WinType("") == 1) |
---|
88 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
89 | if(V_Flag == 1) |
---|
90 | AppendToGraph $w1 vs $w0 |
---|
91 | ModifyGraph mode=3,marker=19,msize=2,rgb ($w1) =(rr,gg,bb) |
---|
92 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
93 | else |
---|
94 | //new graph |
---|
95 | Display $w1 vs $w0 |
---|
96 | ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) |
---|
97 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
98 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
99 | Legend |
---|
100 | endif |
---|
101 | else |
---|
102 | // graph window was not target, make new one |
---|
103 | Display $w1 vs $w0 |
---|
104 | ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) |
---|
105 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
106 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
107 | Legend |
---|
108 | endif |
---|
109 | |
---|
110 | // Annotate graph |
---|
111 | //Textbox/A=LT "XY data loaded from " + S_fileName |
---|
112 | DoWindow/F Plot_Manager |
---|
113 | return |
---|
114 | endif |
---|
115 | |
---|
116 | if(numCols == 6) |
---|
117 | String w0,w1,w2,n0,n1,n2,wt |
---|
118 | String w3,w4,w5,n3,n4,n5 //3 extra waves to load |
---|
119 | Variable rr,gg,bb |
---|
120 | |
---|
121 | |
---|
122 | // put the names of the three loaded waves into local names |
---|
123 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
124 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
125 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
126 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
127 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
128 | n5 = StringFromList(5, S_waveNames ,";" ) |
---|
129 | |
---|
130 | //remove the semicolon AND period from files from the VAX |
---|
131 | w0 = CleanupName((S_fileName + "_q"),0) |
---|
132 | w1 = CleanupName((S_fileName + "_i"),0) |
---|
133 | w2 = CleanupName((S_fileName + "_s"),0) |
---|
134 | w3 = CleanupName((S_fileName + "sq"),0) |
---|
135 | w4 = CleanupName((S_fileName + "qb"),0) |
---|
136 | w5 = CleanupName((S_fileName + "fs"),0) |
---|
137 | wt = CleanupName((S_fileName + "wt"),0) //create a name for the weighting wave |
---|
138 | |
---|
139 | if(exists(w0) !=0) //the wave already exists |
---|
140 | DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
141 | if(V_flag==2) //user selected No |
---|
142 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 // kill the default waveX that were loaded |
---|
143 | String/G root:myGlobals:gLastFileName = filename //set the last file loaded to the one NOT loaded |
---|
144 | return //quits the macro |
---|
145 | endif |
---|
146 | endif |
---|
147 | |
---|
148 | ////overwrite the existing data, if it exists |
---|
149 | Duplicate/O $n0, $w0 |
---|
150 | Duplicate/O $n1, $w1 |
---|
151 | Duplicate/O $n2, $w2 |
---|
152 | Duplicate/O $n3, $w3 |
---|
153 | Duplicate/O $n4, $w4 |
---|
154 | Duplicate/O $n5, $w5 |
---|
155 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 |
---|
156 | |
---|
157 | Duplicate/o $w2 $wt |
---|
158 | $wt = 1/$w2 //assign the weighting wave |
---|
159 | |
---|
160 | // copy waves to global strings for use in the smearing calculation |
---|
161 | String/G root:myGlobals:gLastFileName = filename |
---|
162 | String/G gQVals = w0 |
---|
163 | String/G gSig_Q = w3 |
---|
164 | String/G gQ_bar = w4 |
---|
165 | String/G gShadow = w5 |
---|
166 | |
---|
167 | // set data units for the waves |
---|
168 | String angst = root:myGlobals:gAngstStr |
---|
169 | SetScale d,0,0,"1/"+angst,$w0 |
---|
170 | SetScale d,0,0,"1/cm",$w1 |
---|
171 | |
---|
172 | // assign colors randomly |
---|
173 | rr = abs(trunc(enoise(65535))) |
---|
174 | gg = abs(trunc(enoise(65535))) |
---|
175 | bb = abs(trunc(enoise(65535))) |
---|
176 | |
---|
177 | // if target window is a graph, and user wants to append, do so |
---|
178 | DoWindow/B Plot_Manager |
---|
179 | if(WinType("") == 1) |
---|
180 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
181 | if(V_Flag == 1) |
---|
182 | AppendToGraph $w1 vs $w0 |
---|
183 | ModifyGraph mode=3,marker=19,msize=2,rgb ($w1) =(rr,gg,bb) |
---|
184 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
185 | else |
---|
186 | //new graph |
---|
187 | Display $w1 vs $w0 |
---|
188 | ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) |
---|
189 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
190 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
191 | Legend |
---|
192 | endif |
---|
193 | else |
---|
194 | // graph window was not target, make new one |
---|
195 | Display $w1 vs $w0 |
---|
196 | ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb) |
---|
197 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
198 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
199 | Legend |
---|
200 | endif |
---|
201 | |
---|
202 | // Annotate graph |
---|
203 | //Textbox/A=LT "XY data loaded from " + S_fileName |
---|
204 | DoWindow/F Plot_Manager |
---|
205 | return |
---|
206 | endif |
---|
207 | |
---|
208 | if(numCols==5) //old USANS desmeared data |
---|
209 | String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 |
---|
210 | Variable rr,gg,bb |
---|
211 | |
---|
212 | // put the names of the three loaded waves into local names |
---|
213 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
214 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
215 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
216 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
217 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
218 | |
---|
219 | |
---|
220 | //remove the semicolon AND period from files from the VAX |
---|
221 | w0 = CleanupName((S_fileName+"_q"),0) |
---|
222 | w1 = CleanupName((S_fileName+"_i"),0) |
---|
223 | w2 = CleanupName((S_fileName+"_s"),0) |
---|
224 | w3 = CleanupName((S_fileName+"_ism"),0) |
---|
225 | w4 = CleanupName((S_fileName+"_fit_ism"),0) |
---|
226 | |
---|
227 | if(exists(w0) !=0) //the wave already exists |
---|
228 | DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
229 | if(V_flag==2) //user selected No |
---|
230 | KillWaves $n0,$n1,$n2,$n3,$n4 // kill the default waveX that were loaded |
---|
231 | String/G root:myGlobals:gLastFileName = filename //set the last file loaded to the one NOT loaded |
---|
232 | return //quits the macro |
---|
233 | endif |
---|
234 | endif |
---|
235 | |
---|
236 | ////overwrite the existing data, if it exists |
---|
237 | Duplicate/O $n0, $w0 |
---|
238 | Duplicate/O $n1, $w1 |
---|
239 | Duplicate/O $n2, $w2 |
---|
240 | Duplicate/O $n3, $w3 |
---|
241 | Duplicate/O $n4, $w4 |
---|
242 | KillWaves $n0,$n1,$n2,$n3,$n4 |
---|
243 | |
---|
244 | String/G root:myGlobals:gLastFileName = filename |
---|
245 | |
---|
246 | // assign colors randomly |
---|
247 | rr = abs(trunc(enoise(65535))) |
---|
248 | gg = abs(trunc(enoise(65535))) |
---|
249 | bb = abs(trunc(enoise(65535))) |
---|
250 | |
---|
251 | // if target window is a graph, and user wants to append, do so |
---|
252 | if(WinType("") == 1) |
---|
253 | DoAlert 1,"Do you want to append this data to the current graph?" |
---|
254 | if(V_Flag == 1) |
---|
255 | AppendToGraph $w1 vs $w0 |
---|
256 | ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
257 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
258 | else |
---|
259 | //new graph |
---|
260 | Display $w1 vs $w0 |
---|
261 | ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
262 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
263 | Legend |
---|
264 | endif |
---|
265 | else |
---|
266 | // graph window was not target, make new one |
---|
267 | Display $w1 vs $w0 |
---|
268 | ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2 |
---|
269 | ErrorBars $w1 Y,wave=($w2,$w2) |
---|
270 | Legend |
---|
271 | endif |
---|
272 | |
---|
273 | return |
---|
274 | endif |
---|
275 | |
---|
276 | End |
---|
277 | |
---|
278 | //load the data specified by fileStr (a full path:name) |
---|
279 | // Does not graph the data - just loads it |
---|
280 | // |
---|
281 | Proc LoadOneDDataWithName(fileStr) |
---|
282 | String fileStr |
---|
283 | //Load the waves, using default waveX names |
---|
284 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
285 | LoadWave/G/D/A/Q fileStr |
---|
286 | String fileName = S_fileName |
---|
287 | Variable numCols = V_flag |
---|
288 | |
---|
289 | //changes JIL |
---|
290 | if(numCols==2) //no errors |
---|
291 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
292 | Duplicate/O $("root:"+n1), errorTmp |
---|
293 | errorTmp = 0.01*(errorTmp)+ 0.03*sqrt(errorTmp) |
---|
294 | S_waveNames+="errorTmp;" |
---|
295 | numCols=3 |
---|
296 | endif |
---|
297 | |
---|
298 | if(numCols==3) |
---|
299 | String w0,w1,w2,n0,n1,n2,wt |
---|
300 | |
---|
301 | // put the names of the three loaded waves into local names |
---|
302 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
303 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
304 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
305 | |
---|
306 | //remove the semicolon AND period from files from the VAX |
---|
307 | w0 = CleanupName((S_fileName + "_q"),0) |
---|
308 | w1 = CleanupName((S_fileName + "_i"),0) |
---|
309 | w2 = CleanupName((S_fileName + "_s"),0) |
---|
310 | wt = CleanupName((S_fileName + "wt"),0) //create a name for the weighting wave |
---|
311 | |
---|
312 | if(exists(w0) !=0) |
---|
313 | // DoAlert 0,"This file has already been loaded. Use Append to Graph..." |
---|
314 | // KillWaves $n0,$n1,$n2 // kill the default waveX that were loaded |
---|
315 | // return |
---|
316 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
317 | if(V_flag==2) //user selected No |
---|
318 | KillWaves/Z $n0,$n1,$n2 // kill the default waveX that were loaded |
---|
319 | String/G root:myGlobals:gLastFileName = filename //set the last file loaded to the one NOT loaded |
---|
320 | return //quits the macro |
---|
321 | endif |
---|
322 | endif |
---|
323 | |
---|
324 | ////overwrite the existing data, if it exists |
---|
325 | Duplicate/O $n0, $w0 |
---|
326 | Duplicate/O $n1, $w1 |
---|
327 | Duplicate/O $n2, $w2 |
---|
328 | KillWaves $n0,$n1,$n2 |
---|
329 | |
---|
330 | Duplicate/o $w2 $wt |
---|
331 | $wt = 1/$w2 //assign the weighting wave |
---|
332 | |
---|
333 | String/G root:myGlobals:gLastFileName = filename |
---|
334 | String/G gQVals = w0 |
---|
335 | String/G gInten = w1 |
---|
336 | String/G gSigma = w2 |
---|
337 | |
---|
338 | endif |
---|
339 | |
---|
340 | if(numCols == 6) |
---|
341 | String w0,w1,w2,n0,n1,n2,wt |
---|
342 | String w3,w4,w5,n3,n4,n5 //3 extra waves to load |
---|
343 | |
---|
344 | |
---|
345 | // put the names of the three loaded waves into local names |
---|
346 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
347 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
348 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
349 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
350 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
351 | n5 = StringFromList(5, S_waveNames ,";" ) |
---|
352 | |
---|
353 | //remove the semicolon AND period from files from the VAX |
---|
354 | w0 = CleanupName((S_fileName + "_q"),0) |
---|
355 | w1 = CleanupName((S_fileName + "_i"),0) |
---|
356 | w2 = CleanupName((S_fileName + "_s"),0) |
---|
357 | w3 = CleanupName((S_fileName + "sq"),0) |
---|
358 | w4 = CleanupName((S_fileName + "qb"),0) |
---|
359 | w5 = CleanupName((S_fileName + "fs"),0) |
---|
360 | wt = CleanupName((S_fileName + "wt"),0) //create a name for the weighting wave |
---|
361 | |
---|
362 | if(exists(w0) !=0) //the wave already exists |
---|
363 | // DoAlert 0,"This file has already been loaded." |
---|
364 | // KillWaves $n0,$n1,$n2,$n3,$n4,$n5 // kill the default waveX that were loaded |
---|
365 | // return //quits the macro |
---|
366 | DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
367 | if(V_flag==2) //user selected No |
---|
368 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 // kill the default waveX that were loaded |
---|
369 | String/G root:myGlobals:gLastFileName = filename //set the last file loaded to the one NOT loaded |
---|
370 | return //quits the macro |
---|
371 | endif |
---|
372 | endif |
---|
373 | |
---|
374 | ////overwrite the existing data, if it exists |
---|
375 | Duplicate/O $n0, $w0 |
---|
376 | Duplicate/O $n1, $w1 |
---|
377 | Duplicate/O $n2, $w2 |
---|
378 | Duplicate/O $n3, $w3 |
---|
379 | Duplicate/O $n4, $w4 |
---|
380 | Duplicate/O $n5, $w5 |
---|
381 | KillWaves $n0,$n1,$n2,$n3,$n4,$n5 |
---|
382 | |
---|
383 | Duplicate/o $w2 $wt |
---|
384 | $wt = 1/$w2 //assign the weighting wave |
---|
385 | |
---|
386 | // copy waves to global strings for use in the smearing calculation |
---|
387 | String/G root:myGlobals:gLastFileName = filename |
---|
388 | String/G gQVals = w0 |
---|
389 | String/G gInten = w1 |
---|
390 | String/G gSigma = w2 |
---|
391 | String/G gSig_Q = w3 |
---|
392 | String/G gQ_bar = w4 |
---|
393 | String/G gShadow = w5 |
---|
394 | |
---|
395 | endif |
---|
396 | |
---|
397 | if(numCols==5) |
---|
398 | String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4 |
---|
399 | Variable rr,gg,bb |
---|
400 | |
---|
401 | // put the names of the three loaded waves into local names |
---|
402 | n0 = StringFromList(0, S_waveNames ,";" ) |
---|
403 | n1 = StringFromList(1, S_waveNames ,";" ) |
---|
404 | n2 = StringFromList(2, S_waveNames ,";" ) |
---|
405 | n3 = StringFromList(3, S_waveNames ,";" ) |
---|
406 | n4 = StringFromList(4, S_waveNames ,";" ) |
---|
407 | |
---|
408 | |
---|
409 | //remove the semicolon AND period from files from the VAX |
---|
410 | w0 = CleanupName((S_fileName+"_q"),0) |
---|
411 | w1 = CleanupName((S_fileName+"_i"),0) |
---|
412 | w2 = CleanupName((S_fileName+"_s"),0) |
---|
413 | w3 = CleanupName((S_fileName+"_ism"),0) |
---|
414 | w4 = CleanupName((S_fileName+"_fit_ism"),0) |
---|
415 | |
---|
416 | if(exists(w0) !=0) //the wave already exists |
---|
417 | DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
418 | if(V_flag==2) //user selected No |
---|
419 | KillWaves $n0,$n1,$n2,$n3,$n4 // kill the default waveX that were loaded |
---|
420 | if(DataFolderExists("root:myGlobals")) |
---|
421 | String/G root:myGlobals:gLastFileName = filename |
---|
422 | endif //set the last file loaded to the one NOT loaded |
---|
423 | return //quits the macro |
---|
424 | endif |
---|
425 | endif |
---|
426 | |
---|
427 | ////overwrite the existing data, if it exists |
---|
428 | Duplicate/O $n0, $w0 |
---|
429 | Duplicate/O $n1, $w1 |
---|
430 | Duplicate/O $n2, $w2 |
---|
431 | Duplicate/O $n3, $w3 |
---|
432 | Duplicate/O $n4, $w4 |
---|
433 | KillWaves $n0,$n1,$n2,$n3,$n4 |
---|
434 | |
---|
435 | if(DataFolderExists("root:myGlobals")) |
---|
436 | String/G root:myGlobals:gLastFileName = filename |
---|
437 | endif |
---|
438 | |
---|
439 | endif |
---|
440 | End |
---|
441 | |
---|
442 | |
---|
443 | |
---|
444 | ////////////////////////////////////////// |
---|
445 | Proc Show_Plot_Manager() |
---|
446 | DoWindow/F Plot_Manager |
---|
447 | if(V_flag==0) |
---|
448 | Plot_Manager() |
---|
449 | endif |
---|
450 | End |
---|
451 | |
---|
452 | Proc Plot_Manager() |
---|
453 | PauseUpdate; Silent 1 // building window... |
---|
454 | NewPanel /W=(658,347,920,562)/K=1 |
---|
455 | DoWindow/C Plot_Manager |
---|
456 | ModifyPanel cbRGB=(37265,65535,32896),fixedSize=1 |
---|
457 | Button button0,pos={161,178},size={50,20},proc=PlotManager_Done,title="Done" |
---|
458 | PopupMenu popup0,pos={11,50},size={211,20},title="Data in Memory" |
---|
459 | PopupMenu popup0,mode=1,value= #"OneDDataInMemory()" |
---|
460 | Button button1,pos={60,14},size={140,20},proc=PlotManger_Load,title="Load Data From File" |
---|
461 | Button button2,pos={118,84},size={100,20},proc=PlotManager_Append,title="Append Data" |
---|
462 | Button button3,pos={11,84},size={80,20},proc=PlotManager_newGraph,title="New Graph" |
---|
463 | Button button4,pos={11,118},size={220,20},proc=PlotManager_Kill,title="Remove Selection From Memory" |
---|
464 | Button button5,pos={11,148},size={220,20},proc=PlotManager_KillAll,title="Remove All Data From Memory" |
---|
465 | EndMacro |
---|
466 | |
---|
467 | //lists the intensity waves in the current data folder |
---|
468 | // only looks for data ending in "i" |
---|
469 | // |
---|
470 | Function/S OneDDataInMemory() |
---|
471 | //SetDataFolder root: |
---|
472 | String list = WaveList("*i", ";", "" ) |
---|
473 | list = SortList(list,";",0) //re-alphabetize the list |
---|
474 | return(list) |
---|
475 | end |
---|
476 | |
---|
477 | |
---|
478 | Function PlotManager_Done(ctrlName) : ButtonControl |
---|
479 | String ctrlName |
---|
480 | DoWindow/K Plot_Manager |
---|
481 | End |
---|
482 | |
---|
483 | Proc PlotManger_Load(ctrlName) : ButtonControl |
---|
484 | String ctrlName |
---|
485 | |
---|
486 | OneDLoader_Panel() |
---|
487 | //LoadOneDData() |
---|
488 | ControlUpdate/W=Plot_Manager popup0 |
---|
489 | End |
---|
490 | |
---|
491 | Function PlotManager_Append(ctrlName) : ButtonControl |
---|
492 | String ctrlName |
---|
493 | //appends data set from memory |
---|
494 | String iStr,qStr,eStr |
---|
495 | Variable rr,gg,bb |
---|
496 | |
---|
497 | //get the current selection |
---|
498 | ControlInfo popup0 |
---|
499 | if(strlen(S_Value)==0) |
---|
500 | Abort "You must load data from a file into memory before appending the data" |
---|
501 | Endif |
---|
502 | |
---|
503 | PM_doAppend(S_Value) |
---|
504 | |
---|
505 | DoWindow/F Plot_Manager |
---|
506 | End |
---|
507 | |
---|
508 | //actually does the appending |
---|
509 | //pass it the name of the wave, find the q-i-s waves |
---|
510 | Function PM_doAppend(iStr) |
---|
511 | String iStr |
---|
512 | //appends data set from memory |
---|
513 | String qStr,eStr |
---|
514 | Variable rr,gg,bb |
---|
515 | |
---|
516 | if(cmpstr(WinList("*", ";","WIN:1"),"") == 0 ) |
---|
517 | DoAlert 0,"There are no open graphs. Please use the New Graph button" |
---|
518 | return(0) |
---|
519 | endif |
---|
520 | |
---|
521 | //this assumes that iStr IS the i-wave, and the name ends in "i" |
---|
522 | qStr=iStr[0,strlen(iStr)-2]+"q" |
---|
523 | eStr=iStr[0,strlen(iStr)-2]+"s" |
---|
524 | |
---|
525 | rr = abs(trunc(enoise(65535))) |
---|
526 | gg = abs(trunc(enoise(65535))) |
---|
527 | bb = abs(trunc(enoise(65535))) |
---|
528 | |
---|
529 | // append to whatever is top-most graph |
---|
530 | AppendToGraph $iStr vs $qStr |
---|
531 | ModifyGraph log=1,mode($istr)=3,marker($iStr)=19,msize($iStr)=2,rgb($iStr)=(rr,gg,bb) |
---|
532 | ErrorBars $iStr Y,wave=($eStr,$eStr) |
---|
533 | End |
---|
534 | |
---|
535 | Proc PlotManager_newGraph(ctrlName) : ButtonControl |
---|
536 | String ctrlName |
---|
537 | |
---|
538 | String iStr,qStr,eStr |
---|
539 | Variable rr,gg,bb |
---|
540 | |
---|
541 | //get the current selection |
---|
542 | ControlInfo popup0 |
---|
543 | if(strlen(S_Value)==0) |
---|
544 | Abort "You must load data from a file into memory before plotting the data" |
---|
545 | Endif |
---|
546 | PM_doNewGraph(S_Value) |
---|
547 | DoWindow/F Plot_Manager |
---|
548 | End |
---|
549 | |
---|
550 | Function PM_doNewGraph(iStr) |
---|
551 | String iStr |
---|
552 | |
---|
553 | String qStr,eStr |
---|
554 | Variable rr,gg,bb |
---|
555 | |
---|
556 | //iStr will end in "i" |
---|
557 | qStr=iStr[0,strlen(iStr)-2]+"q" |
---|
558 | eStr=iStr[0,strlen(iStr)-2]+"s" |
---|
559 | |
---|
560 | rr = abs(trunc(enoise(65535))) |
---|
561 | gg = abs(trunc(enoise(65535))) |
---|
562 | bb = abs(trunc(enoise(65535))) |
---|
563 | |
---|
564 | // always make a new graph |
---|
565 | Display $iStr vs $qStr |
---|
566 | ModifyGraph log=1,mode($istr)=3,marker($iStr)=19,msize($iStr)=2,rgb=(rr,gg,bb) |
---|
567 | ModifyGraph grid=1,mirror=2,standoff=0 |
---|
568 | ErrorBars $iStr Y,wave=($eStr,$eStr) |
---|
569 | |
---|
570 | Label left "I(q)" |
---|
571 | SVAR angst = root:myGlobals:gAngstStr |
---|
572 | Label bottom "q ("+angst+"\\S-1\\M)" |
---|
573 | |
---|
574 | Legend |
---|
575 | End |
---|
576 | |
---|
577 | //kill the specified wave (if possible) |
---|
578 | Proc PlotManager_Kill(ctrlName) : ButtonControl |
---|
579 | String ctrlName |
---|
580 | |
---|
581 | String iStr,qStr,eStr,sqStr,qbStr,fsStr,wtStr |
---|
582 | |
---|
583 | ControlInfo popup0 |
---|
584 | iStr=S_Value //this will end in "i" |
---|
585 | qStr=iStr[0,strlen(iStr)-2]+"q" |
---|
586 | eStr=iStr[0,strlen(iStr)-2]+"s" |
---|
587 | sqStr=iStr[0,strlen(iStr)-3]+"sq" //remove the underscore from these names |
---|
588 | qbStr=iStr[0,strlen(iStr)-3]+"qb" |
---|
589 | fsStr=iStr[0,strlen(iStr)-3]+"fs" |
---|
590 | wtStr=iStr[0,strlen(iStr)-3]+"wt" |
---|
591 | |
---|
592 | CheckDisplayed/A $iStr //is the intensity data in use? |
---|
593 | if(V_flag==0) |
---|
594 | Killwaves/Z $iStr,$qStr,$eStr,$sqStr,$qbStr,$fsStr,$wtStr |
---|
595 | endif |
---|
596 | ControlUpdate popup0 //refresh the popup, very important if last item removed |
---|
597 | End |
---|
598 | |
---|
599 | //kill the specified wave (if possible) |
---|
600 | Proc PlotManager_KillAll(ctrlName) : ButtonControl |
---|
601 | String ctrlName |
---|
602 | |
---|
603 | String iStr,qStr,eStr,sqStr,qbStr,fsStr,wtStr |
---|
604 | |
---|
605 | String list = OneDDataInMemory() |
---|
606 | Variable num=ItemsInList(list),ii |
---|
607 | |
---|
608 | ii=0 |
---|
609 | do |
---|
610 | iStr=StringFromList(ii, list ,";") |
---|
611 | qStr=iStr[0,strlen(iStr)-2]+"q" |
---|
612 | eStr=iStr[0,strlen(iStr)-2]+"s" |
---|
613 | sqStr=iStr[0,strlen(iStr)-3]+"sq" //remove the underscore from these names |
---|
614 | qbStr=iStr[0,strlen(iStr)-3]+"qb" |
---|
615 | fsStr=iStr[0,strlen(iStr)-3]+"fs" |
---|
616 | wtStr=iStr[0,strlen(iStr)-3]+"wt" |
---|
617 | |
---|
618 | CheckDisplayed/A $iStr //is the intensity data in use? |
---|
619 | if(V_flag==0) |
---|
620 | Killwaves/Z $iStr,$qStr,$eStr,$sqStr,$qbStr,$fsStr,$wtStr |
---|
621 | endif |
---|
622 | ii+=1 |
---|
623 | while(ii<num) |
---|
624 | ControlUpdate popup0 //refresh the popup, very important if all items are removed |
---|
625 | End |
---|
626 | |
---|
627 | Proc Init_OneDLoader() |
---|
628 | //create the data folder |
---|
629 | NewDataFolder/O/S root:myGlobals:OneDLoader |
---|
630 | //create the waves |
---|
631 | Make/O/T/N=1 fileWave="" |
---|
632 | Make/O/N=1 selWave=0 |
---|
633 | Variable/G ind=0 |
---|
634 | SetDataFolder root: |
---|
635 | End |
---|
636 | |
---|
637 | // main procedure for invoking the raw to ascii panel |
---|
638 | // initializes each time to make sure |
---|
639 | Proc OneDLoader_Panel() |
---|
640 | Init_OneDLoader() |
---|
641 | DoWindow/F OneDLoader |
---|
642 | if(V_Flag==0) |
---|
643 | OneDLoader() |
---|
644 | endif |
---|
645 | OneDLoader_GetListButton("") |
---|
646 | End |
---|
647 | |
---|
648 | //procedure for drawing the simple panel to export raw->ascii |
---|
649 | // |
---|
650 | Proc OneDLoader() |
---|
651 | PauseUpdate; Silent 1 // building window... |
---|
652 | NewPanel /W=(501,97,885,282) /K=2 |
---|
653 | DoWindow/C OneDLoader |
---|
654 | SetDrawLayer UserBack |
---|
655 | DrawText 237,38,"Shift-click to load" |
---|
656 | DrawText 254,58,"multiple files" |
---|
657 | ListBox fileList,pos={4,3},size={206,179} |
---|
658 | ListBox fileList,listWave=root:myGlobals:OneDLoader:fileWave |
---|
659 | ListBox fileList,selWave=root:myGlobals:OneDLoader:selWave,mode= 4 |
---|
660 | Button button0,pos={239,78},size={110,20},proc=OneDLoader_LoadButton,title="Load File(s)" |
---|
661 | Button button0,help={"Loads the selected files into memory and will graph them if that option is checked"} |
---|
662 | Button button1,pos={260,150},size={70,20},proc=OneDLoader_CancelButton,title="Cancel" |
---|
663 | Button button1,help={"Closes the panel without loading any data"} |
---|
664 | CheckBox check0,pos={242,112},size={113,14},title="All in a new graph?",value= 1 |
---|
665 | CheckBox check0,help={"Makes a new graph with all of the selected data. Otherwise, you will be prompted to append data"} |
---|
666 | // Button button3,pos={230,16},size={60,20},proc=OneDLoader_GetListButton,title="Get List" |
---|
667 | // Button button3,help={"Refreshes the file listing"} |
---|
668 | EndMacro |
---|
669 | |
---|
670 | //closes the panel if user cancels |
---|
671 | Function OneDLoader_CancelButton(ctrlName) : ButtonControl |
---|
672 | String ctrlName |
---|
673 | |
---|
674 | //kill the panel |
---|
675 | DoWindow/K OneDLoader |
---|
676 | return(0) |
---|
677 | End |
---|
678 | |
---|
679 | //filters to remove only the files that are named like a raw data file, i.e. "*.SAn" |
---|
680 | //does not check to see if they really are RAW files though...(too tedious) |
---|
681 | Function OneDLoader_GetListButton(ctrlName) : ButtonControl |
---|
682 | String ctrlName |
---|
683 | |
---|
684 | //make sure that path exists |
---|
685 | PathInfo catPathName |
---|
686 | if (V_flag == 0) |
---|
687 | Abort "Folder path does not exist - use Pick Path button on Main Panel" |
---|
688 | Endif |
---|
689 | |
---|
690 | String newList = ReducedDataFileList("") |
---|
691 | Variable num |
---|
692 | |
---|
693 | num=ItemsInList(newlist,";") |
---|
694 | WAVE/T fileWave=$"root:myGlobals:OneDLoader:fileWave" |
---|
695 | WAVE selWave=$"root:myGlobals:OneDLoader:selWave" |
---|
696 | Redimension/N=(num) fileWave |
---|
697 | Redimension/N=(num) selWave |
---|
698 | fileWave = StringFromList(p,newlist,";") |
---|
699 | Sort filewave,filewave |
---|
700 | End |
---|
701 | |
---|
702 | Function OneDLoader_LoadButton(ctrlName) : ButtonControl |
---|
703 | String ctrlName |
---|
704 | |
---|
705 | //loop through the selected files in the list... |
---|
706 | Wave/T fileWave=$"root:myGlobals:OneDLoader:fileWave" |
---|
707 | Wave sel=$"root:myGlobals:OneDLoader:selWave" |
---|
708 | Variable num=numpnts(sel),ii=0 |
---|
709 | String fname="",pathStr="",fullPath="",newFileName="" |
---|
710 | |
---|
711 | PathInfo catPathName //this is where the files are |
---|
712 | pathStr=S_path |
---|
713 | |
---|
714 | Variable doGraph,cnt |
---|
715 | |
---|
716 | ControlInfo check0 |
---|
717 | doGraph=V_Value |
---|
718 | cnt=0 |
---|
719 | // get the current state |
---|
720 | do |
---|
721 | if(sel[ii] == 1) |
---|
722 | fname=pathStr + FindValidFilename(fileWave[ii]) //in case of VAX version numbers |
---|
723 | Execute "LoadOneDDataWithName(\""+fname+"\")" |
---|
724 | cnt += 1 //a file was loaded |
---|
725 | if(doGraph==1) |
---|
726 | SVAR fileName = root:myGlobals:gLastFileName //last file loaded |
---|
727 | if(cnt==1) |
---|
728 | PM_doNewGraph( CleanupName((fileName + "_i"),0) ) //create the name of the intensity wave loaded |
---|
729 | else |
---|
730 | PM_doAppend( CleanupName((fileName + "_i"),0) ) |
---|
731 | endif |
---|
732 | endif |
---|
733 | endif |
---|
734 | ii+=1 |
---|
735 | while(ii<num) |
---|
736 | //kill the panel |
---|
737 | DoWindow/K OneDLoader |
---|
738 | return(0) |
---|
739 | End |
---|