source: sans/USANSReduction/branches/AJJ-branch1/Put in User Procedures Folder/USANS Procedures v2.00/PlotUtils_USANS.ipf @ 28

Last change on this file since 28 was 28, checked in by ajj, 16 years ago

Used flip to convert files to Unix line endings from Mac.

  • Property eol-style set to native
  • Property svn:executable set to *
File size: 15.9 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma Version=2.00
3
4//loads 3-column or 6-column data into current folder, typically root:
5// 5-column data from average/qsig i loaded  below with U_LoadUSANSData() procedure
6//
7//
8Proc U_LoadOneDData()
9
10        //Load the waves, using default waveX names
11        //if no path or file is specified for LoadWave, the default Mac open dialog will appear
12        LoadWave/G/D/A
13        String filename = S_fileName
14       
15        if(V_flag==3)
16                String w0,w1,w2,n0,n1,n2,wt
17                Variable rr,gg,bb
18               
19                // put the names of the three loaded waves into local names
20                n0 = StringFromList(0, S_waveNames ,";" )
21                n1 = StringFromList(1, S_waveNames ,";" )
22                n2 = StringFromList(2, S_waveNames ,";" )
23               
24                //remove the semicolon AND period from files from the VAX
25                w0 = CleanupName((S_fileName + "_q"),0)
26                w1 = CleanupName((S_fileName + "_i"),0)
27                w2 = CleanupName((S_fileName + "_s"),0)
28                wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave
29               
30                if(exists(w0) !=0)
31                        DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
32                        if(V_flag==2)   //user selected No
33                                KillWaves/Z $n0,$n1,$n2         // kill the default waveX that were loaded
34                                if(DataFolderExists("root:myGlobals"))
35                                        String/G root:myGlobals:gLastFileName = filename
36                                endif           //set the last file loaded to the one NOT loaded
37                                return          //quits the macro
38                        endif
39                endif
40               
41                ////overwrite the existing data, if it exists
42                Duplicate/O $n0, $w0
43                Duplicate/O $n1, $w1
44                Duplicate/O $n2, $w2
45                KillWaves $n0,$n1,$n2
46               
47                if(DataFolderExists("root:myGlobals"))
48                        String/G root:myGlobals:gLastFileName = filename
49                endif
50               
51                Duplicate/o $w2 $wt
52                $wt = 1/$w2             //assign the weighting wave
53               
54                // set data units for the waves
55//                      if(DataFolderExists("root:myGlobals"))
56//                              String angst = root:myGlobals:gAngstStr
57//                      else
58                        String angst = "A"
59//                      endif
60                SetScale d,0,0,"1/"+angst,$w0
61                SetScale d,0,0,"1/cm",$w1
62               
63                // assign colors randomly
64                rr = abs(trunc(enoise(65535)))
65                gg = abs(trunc(enoise(65535)))
66                bb = abs(trunc(enoise(65535)))
67               
68                // if target window is a graph, and user wants to append, do so
69           DoWindow/B Plot_Manager
70                if(WinType("") == 1)
71                        DoAlert 1,"Do you want to append this data to the current graph?"
72                        if(V_Flag == 1)
73                                AppendToGraph $w1 vs $w0
74                                ModifyGraph mode=3,marker=19,msize=2,rgb ($w1) =(rr,gg,bb)
75                                ErrorBars $w1 Y,wave=($w2,$w2)
76                        else
77                        //new graph
78                                Display $w1 vs $w0
79                                ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb)
80                                ModifyGraph grid=1,mirror=2,standoff=0
81                                ErrorBars $w1 Y,wave=($w2,$w2)
82                                Legend
83                        endif
84                else
85                // graph window was not target, make new one
86                        Display $w1 vs $w0
87                        ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb)
88                        ModifyGraph grid=1,mirror=2,standoff=0
89                        ErrorBars $w1 Y,wave=($w2,$w2)
90                        Legend
91                endif
92                       
93                // Annotate graph
94                //Textbox/A=LT "XY data loaded from " + S_fileName
95            DoWindow/F Plot_Manager
96        endif
97       
98        if(V_flag == 6)
99                String w0,w1,w2,n0,n1,n2,wt
100                String w3,w4,w5,n3,n4,n5                        //3 extra waves to load
101                Variable rr,gg,bb
102               
103               
104                // put the names of the three loaded waves into local names
105                n0 = StringFromList(0, S_waveNames ,";" )
106                n1 = StringFromList(1, S_waveNames ,";" )
107                n2 = StringFromList(2, S_waveNames ,";" )
108                n3 = StringFromList(3, S_waveNames ,";" )
109                n4 = StringFromList(4, S_waveNames ,";" )
110                n5 = StringFromList(5, S_waveNames ,";" )
111               
112                //remove the semicolon AND period from files from the VAX
113                w0 = CleanupName((S_fileName + "_q"),0)
114                w1 = CleanupName((S_fileName + "_i"),0)
115                w2 = CleanupName((S_fileName + "_s"),0)
116                w3 = CleanupName((S_fileName + "sq"),0)
117                w4 = CleanupName((S_fileName + "qb"),0)
118                w5 = CleanupName((S_fileName + "fs"),0)
119                wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave
120               
121                if(exists(w0) !=0)              //the wave already exists
122                        DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
123                        if(V_flag==2)   //user selected No
124                                KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded
125                                if(DataFolderExists("root:myGlobals"))
126                                        String/G root:myGlobals:gLastFileName = filename
127                                endif           //set the last file loaded to the one NOT loaded
128                                return          //quits the macro
129                        endif
130                endif
131
132////overwrite the existing data, if it exists
133                Duplicate/O $n0, $w0
134                Duplicate/O $n1, $w1
135                Duplicate/O $n2, $w2
136                Duplicate/O $n3, $w3
137                Duplicate/O $n4, $w4
138                Duplicate/O $n5, $w5
139                KillWaves $n0,$n1,$n2,$n3,$n4,$n5
140               
141                Duplicate/o $w2 $wt
142                $wt = 1/$w2             //assign the weighting wave
143               
144                // copy waves to global strings for use in the smearing calculation
145                if(DataFolderExists("root:myGlobals"))
146                        String/G root:myGlobals:gLastFileName = filename
147                endif
148                String/G gQVals = w0
149                String/G gSig_Q = w3
150                String/G gQ_bar = w4
151                String/G gShadow = w5
152               
153                // set data units for the waves
154//                      if(DataFolderExists("root:myGlobals"))
155//                              String angst = root:myGlobals:gAngstStr
156//                      else
157                        String angst = "A"
158//                      endif
159                SetScale d,0,0,"1/"+angst,$w0
160                SetScale d,0,0,"1/cm",$w1
161               
162                // assign colors randomly
163                rr = abs(trunc(enoise(65535)))
164                gg = abs(trunc(enoise(65535)))
165                bb = abs(trunc(enoise(65535)))
166       
167                // if target window is a graph, and user wants to append, do so
168                DoWindow/B Plot_Manager
169                if(WinType("") == 1)
170                        DoAlert 1,"Do you want to append this data to the current graph?"
171                        if(V_Flag == 1)
172                                AppendToGraph $w1 vs $w0
173                                ModifyGraph mode=3,marker=19,msize=2,rgb ($w1) =(rr,gg,bb)
174                                ErrorBars $w1 Y,wave=($w2,$w2)
175                        else
176                        //new graph
177                                Display $w1 vs $w0
178                                ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb)
179                                ModifyGraph grid=1,mirror=2,standoff=0
180                                ErrorBars $w1 Y,wave=($w2,$w2)
181                                Legend
182                        endif
183                else
184                // graph window was not target, make new one
185                        Display $w1 vs $w0
186                        ModifyGraph log=1,mode=3,marker=19,msize=2,rgb=(rr,gg,bb)
187                        ModifyGraph grid=1,mirror=2,standoff=0
188                        ErrorBars $w1 Y,wave=($w2,$w2)
189                        Legend
190                endif
191                       
192                // Annotate graph
193                //Textbox/A=LT "XY data loaded from " + S_fileName
194            DoWindow/F Plot_Manager
195        endif
196
197        if(V_flag==5)
198                String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4
199                Variable rr,gg,bb
200               
201                // put the names of the three loaded waves into local names
202                n0 = StringFromList(0, S_waveNames ,";" )
203                n1 = StringFromList(1, S_waveNames ,";" )
204                n2 = StringFromList(2, S_waveNames ,";" )
205                n3 = StringFromList(3, S_waveNames ,";" )
206                n4 = StringFromList(4, S_waveNames ,";" )
207               
208               
209                //remove the semicolon AND period from files from the VAX
210                w0 = CleanupName((S_fileName+"_q"),0)
211                w1 = CleanupName((S_fileName+"_i"),0)
212                w2 = CleanupName((S_fileName+"_s"),0)
213                w3 = CleanupName((S_fileName+"_ism"),0)
214                w4 = CleanupName((S_fileName+"_fit_ism"),0)
215               
216                if(exists(w0) !=0)              //the wave already exists
217                        DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
218                        if(V_flag==2)   //user selected No
219                                KillWaves $n0,$n1,$n2,$n3,$n4           // kill the default waveX that were loaded
220                                if(DataFolderExists("root:myGlobals"))
221                                        String/G root:myGlobals:gLastFileName = filename
222                                endif           //set the last file loaded to the one NOT loaded
223                                return          //quits the macro
224                        endif
225                endif
226               
227                ////overwrite the existing data, if it exists
228                Duplicate/O $n0, $w0
229                Duplicate/O $n1, $w1
230                Duplicate/O $n2, $w2
231                Duplicate/O $n3, $w3
232                Duplicate/O $n4, $w4
233                KillWaves $n0,$n1,$n2,$n3,$n4
234       
235                if(DataFolderExists("root:myGlobals"))
236                        String/G root:myGlobals:gLastFileName = filename
237                endif
238                // assign colors randomly
239                rr = abs(trunc(enoise(65535)))
240                gg = abs(trunc(enoise(65535)))
241                bb = abs(trunc(enoise(65535)))
242               
243                        // if target window is a graph, and user wants to append, do so
244                if(WinType("") == 1)
245                        DoAlert 1,"Do you want to append this data to the current graph?"
246                        if(V_Flag == 1)
247                                AppendToGraph $w1 vs $w0
248                                ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2
249                                ErrorBars $w1 Y,wave=($w2,$w2)
250                        else
251                        //new graph
252                                Display $w1 vs $w0
253                                ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2
254                                ErrorBars $w1 Y,wave=($w2,$w2)
255                                Legend
256                        endif
257                else
258                // graph window was not target, make new one
259                        Display $w1 vs $w0
260                        ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2
261                        ErrorBars $w1 Y,wave=($w2,$w2)
262                        Legend
263                endif
264       
265        endif
266End
267
268
269//load the data specified by fileStr (a full path:name)
270// Does not graph the data - just loads it
271//
272Proc U_LoadOneDDataWithName(fileStr)
273        String fileStr
274        //Load the waves, using default waveX names
275        //if no path or file is specified for LoadWave, the default Mac open dialog will appear
276        LoadWave/G/D/A/Q fileStr
277        String fileName = S_fileName
278       
279        if(V_flag==3)
280                String w0,w1,w2,n0,n1,n2,wt
281               
282                // put the names of the three loaded waves into local names
283                n0 = StringFromList(0, S_waveNames ,";" )
284                n1 = StringFromList(1, S_waveNames ,";" )
285                n2 = StringFromList(2, S_waveNames ,";" )
286               
287                //remove the semicolon AND period from files from the VAX
288                w0 = CleanupName((S_fileName + "_q"),0)
289                w1 = CleanupName((S_fileName + "_i"),0)
290                w2 = CleanupName((S_fileName + "_s"),0)
291                wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave
292               
293                if(exists(w0) !=0)
294                        DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
295                        if(V_flag==2)   //user selected No
296                                KillWaves/Z $n0,$n1,$n2         // kill the default waveX that were loaded
297                                if(DataFolderExists("root:myGlobals"))
298                                        String/G root:myGlobals:gLastFileName = filename
299                                endif           //set the last file loaded to the one NOT loaded
300                                return          //quits the macro
301                        endif
302                endif
303               
304                ////overwrite the existing data, if it exists
305                Duplicate/O $n0, $w0
306                Duplicate/O $n1, $w1
307                Duplicate/O $n2, $w2
308                KillWaves $n0,$n1,$n2
309               
310                Duplicate/o $w2 $wt
311                $wt = 1/$w2             //assign the weighting wave
312               
313                if(DataFolderExists("root:myGlobals"))
314                        String/G root:myGlobals:gLastFileName = filename
315                endif
316                String/G gQVals = w0
317                String/G gInten = w1
318                String/G gSigma = w2
319               
320        endif
321       
322        if(V_flag == 6)
323                String w0,w1,w2,n0,n1,n2,wt
324                String w3,w4,w5,n3,n4,n5                        //3 extra waves to load
325               
326               
327                // put the names of the three loaded waves into local names
328                n0 = StringFromList(0, S_waveNames ,";" )
329                n1 = StringFromList(1, S_waveNames ,";" )
330                n2 = StringFromList(2, S_waveNames ,";" )
331                n3 = StringFromList(3, S_waveNames ,";" )
332                n4 = StringFromList(4, S_waveNames ,";" )
333                n5 = StringFromList(5, S_waveNames ,";" )
334               
335                //remove the semicolon AND period from files from the VAX
336                w0 = CleanupName((S_fileName + "_q"),0)
337                w1 = CleanupName((S_fileName + "_i"),0)
338                w2 = CleanupName((S_fileName + "_s"),0)
339                w3 = CleanupName((S_fileName + "sq"),0)
340                w4 = CleanupName((S_fileName + "qb"),0)
341                w5 = CleanupName((S_fileName + "fs"),0)
342                wt = CleanupName((S_fileName + "wt"),0)         //create a name for the weighting wave
343               
344                if(exists(w0) !=0)              //the wave already exists
345                        DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
346                        if(V_flag==2)   //user selected No
347                                KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded
348                                if(DataFolderExists("root:myGlobals"))
349                                        String/G root:myGlobals:gLastFileName = filename
350                                endif           //set the last file loaded to the one NOT loaded
351                                return          //quits the macro
352                        endif
353                endif
354
355////overwrite the existing data, if it exists
356                Duplicate/O $n0, $w0
357                Duplicate/O $n1, $w1
358                Duplicate/O $n2, $w2
359                Duplicate/O $n3, $w3
360                Duplicate/O $n4, $w4
361                Duplicate/O $n5, $w5
362                KillWaves $n0,$n1,$n2,$n3,$n4,$n5
363               
364                Duplicate/o $w2 $wt
365                $wt = 1/$w2             //assign the weighting wave
366               
367                // copy waves to global strings for use in the smearing calculation
368                if(DataFolderExists("root:myGlobals"))
369                        String/G root:myGlobals:gLastFileName = filename
370                endif
371                String/G gQVals = w0
372                String/G gInten = w1
373                String/G gSigma = w2
374                String/G gSig_Q = w3
375                String/G gQ_bar = w4
376                String/G gShadow = w5
377
378        endif
379
380        if(V_flag==5)
381                String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4
382                Variable rr,gg,bb
383               
384                // put the names of the three loaded waves into local names
385                n0 = StringFromList(0, S_waveNames ,";" )
386                n1 = StringFromList(1, S_waveNames ,";" )
387                n2 = StringFromList(2, S_waveNames ,";" )
388                n3 = StringFromList(3, S_waveNames ,";" )
389                n4 = StringFromList(4, S_waveNames ,";" )
390               
391               
392                //remove the semicolon AND period from files from the VAX
393                w0 = CleanupName((S_fileName+"_q"),0)
394                w1 = CleanupName((S_fileName+"_i"),0)
395                w2 = CleanupName((S_fileName+"_s"),0)
396                w3 = CleanupName((S_fileName+"_ism"),0)
397                w4 = CleanupName((S_fileName+"_fit_ism"),0)
398               
399                if(exists(w0) !=0)              //the wave already exists
400                        DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
401                        if(V_flag==2)   //user selected No
402                                KillWaves $n0,$n1,$n2,$n3,$n4           // kill the default waveX that were loaded
403                                if(DataFolderExists("root:myGlobals"))
404                                        String/G root:myGlobals:gLastFileName = filename
405                                endif           //set the last file loaded to the one NOT loaded
406                                return          //quits the macro
407                        endif
408                endif
409               
410                ////overwrite the existing data, if it exists
411                Duplicate/O $n0, $w0
412                Duplicate/O $n1, $w1
413                Duplicate/O $n2, $w2
414                Duplicate/O $n3, $w3
415                Duplicate/O $n4, $w4
416                KillWaves $n0,$n1,$n2,$n3,$n4
417       
418                if(DataFolderExists("root:myGlobals"))
419                        String/G root:myGlobals:gLastFileName = filename
420                endif
421
422        endif
423End
424
425
426//procedure for loading desmeared USANS data in the format (5-columns)
427// qvals - I(q) - sig I - Ism(q) - fitted Ism(q)
428//no weighting wave is created (not needed in IGOR 4)
429Proc U_LoadUSANSData()
430
431        //Load the waves, using default waveX names
432        //if no path or file is specified for LoadWave, the default Mac open dialog will appear
433        LoadWave/G/D/A
434   String filename = S_fileName
435       
436        String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4
437        Variable rr,gg,bb
438       
439        // put the names of the three loaded waves into local names
440        n0 = StringFromList(0, S_waveNames ,";" )
441        n1 = StringFromList(1, S_waveNames ,";" )
442        n2 = StringFromList(2, S_waveNames ,";" )
443        n3 = StringFromList(3, S_waveNames ,";" )
444        n4 = StringFromList(4, S_waveNames ,";" )
445       
446       
447        //remove the semicolon AND period from files from the VAX
448        w0 = CleanupName((S_fileName+"_q"),0)
449        w1 = CleanupName((S_fileName+"_i"),0)
450        w2 = CleanupName((S_fileName+"_s"),0)
451        w3 = CleanupName((S_fileName+"_ism"),0)
452        w4 = CleanupName((S_fileName+"_fit_ism"),0)
453       
454        if(exists(w0) !=0)              //the wave already exists
455                DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
456                if(V_flag==2)   //user selected No
457                        KillWaves $n0,$n1,$n2,$n3,$n4           // kill the default waveX that were loaded
458                        if(DataFolderExists("root:myGlobals"))
459                                String/G root:myGlobals:gLastFileName = filename
460                        endif           //set the last file loaded to the one NOT loaded
461                        return          //quits the macro
462                endif
463        endif
464       
465        ////overwrite the existing data, if it exists
466        Duplicate/O $n0, $w0
467        Duplicate/O $n1, $w1
468        Duplicate/O $n2, $w2
469        Duplicate/O $n3, $w3
470        Duplicate/O $n4, $w4
471        KillWaves $n0,$n1,$n2,$n3,$n4
472       
473        if(DataFolderExists("root:myGlobals"))
474                String/G root:myGlobals:gLastFileName = filename
475        endif
476               
477        // assign colors randomly
478        rr = abs(trunc(enoise(65535)))
479        gg = abs(trunc(enoise(65535)))
480        bb = abs(trunc(enoise(65535)))
481       
482                // if target window is a graph, and user wants to append, do so
483        if(WinType("") == 1)
484                DoAlert 1,"Do you want to append this data to the current graph?"
485                if(V_Flag == 1)
486                        AppendToGraph $w1 vs $w0
487                        ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2
488                        ErrorBars $w1 Y,wave=($w2,$w2)
489                else
490                //new graph
491                        Display $w1 vs $w0
492                        ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2
493                        ErrorBars $w1 Y,wave=($w2,$w2)
494                        Legend
495                endif
496        else
497        // graph window was not target, make new one
498                Display $w1 vs $w0
499                ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2
500                ErrorBars $w1 Y,wave=($w2,$w2)
501                Legend
502        endif
503               
504End
Note: See TracBrowser for help on using the repository browser.