source: sans/Dev/trunk/NCNR_User_Procedures/USANS/PlotUtils_USANS.ipf @ 360

Last change on this file since 360 was 328, checked in by ajj, 15 years ago

Rearranging files

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