source: sans/Dev/trunk/NCNR_User_Procedures/Analysis/VSANS/V_PlotUtils2D_VSANS.ipf @ 1220

Last change on this file since 1220 was 1220, checked in by srkline, 3 years ago

adding more super white beam files (models to test)

adding a simple utility (command line only) to load in VSANS data that was exported in QxQyASCII format.

File size: 4.8 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3
4
5//
6// Load in and plot the 9-column VSANS QxQy data file
7//
8//              Data columns are Qx - Qy - I(Qx,Qy) - err(I) - Qz - SigmaQ_parall - SigmaQ_perp - fSubS(beam stop shadow) - Mask
9
10Proc V_LoadQxQy_VSANS_TopBottom()
11        V_LoadQxQy_VSANS(128,48)
12End
13
14Proc V_LoadQxQy_VSANS_LeftRight()
15        V_LoadQxQy_VSANS(48,128)
16End
17
18
19Proc V_LoadQxQy_VSANS(numX,numY)
20        Variable numX,numY
21       
22        SetDataFolder root:
23       
24        LoadWave/G/D/W/A
25        String fileName = S_fileName
26        String path = S_Path
27        Variable numCols = V_flag
28
29        String w0,w1,w2,w3,w4,w5,w6,w7,w8
30        String n0,n1,n2,n3,n4,n5,n6,n7,n8
31               
32        if(numCols == 9)
33                // put the names of the 9 loaded waves into local names
34                n0 = StringFromList(0, S_waveNames ,";" )
35                n1 = StringFromList(1, S_waveNames ,";" )
36                n2 = StringFromList(2, S_waveNames ,";" )
37                n3 = StringFromList(3, S_waveNames ,";" )
38                n4 = StringFromList(4, S_waveNames ,";" )
39                n5 = StringFromList(5, S_waveNames ,";" )
40                n6 = StringFromList(6, S_waveNames ,";" )
41                n7 = StringFromList(7, S_waveNames ,";" )
42                n8 = StringFromList(8, S_waveNames ,";" )
43               
44                //remove the semicolon AND period from file names
45                w0 = CleanupName((S_fileName + "_qx"),0)
46                w1 = CleanupName((S_fileName + "_qy"),0)
47                w2 = CleanupName((S_fileName + "_i"),0)
48                w3 = CleanupName((S_fileName + "_iErr"),0)
49                w4 = CleanupName((S_fileName + "_qz"),0)
50                w5 = CleanupName((S_fileName + "_sQpl"),0)
51                w6 = CleanupName((S_fileName + "_sQpp"),0)
52                w7 = CleanupName((S_fileName + "_fs"),0)
53                w8 = CleanupName((S_fileName + "_msk"),0)
54       
55                String baseStr=w1[0,strlen(w1)-4]
56                if(DataFolderExists("root:"+baseStr))
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, don't load the data
59                                        SetDataFolder root:
60                                        KillWaves/Z $n0,$n1,$n2,$n3,$n4,$n5,$n6,$n7,$n8         // kill the default waveX that were loaded
61                                        return          //quits the macro
62                                endif
63                                SetDataFolder $("root:"+baseStr)
64                else
65                        NewDataFolder/S $("root:"+baseStr)
66                endif
67               
68                //read in the 30 lines of header (18th line starts w/ ASCII... 19th line is blank)
69                Variable nHeader=30
70                Make/O/T/N=(nHeader) header
71                Variable refnum,ii
72                string tmpStr=""
73                Open/R refNum  as (path+filename)
74                ii=0
75                do
76                        tmpStr = ""
77                        FReadLine refNum, tmpStr
78                        header[ii] = tmpStr
79                        ii+=1
80                while(ii < nHeader)             
81                Close refnum           
82               
83                ////overwrite the existing data, if it exists
84                Duplicate/O $("root:"+n0), $w0
85                Duplicate/O $("root:"+n1), $w1
86                Duplicate/O $("root:"+n2), $w2
87                Duplicate/O $("root:"+n3), $w3
88                Duplicate/O $("root:"+n4), $w4
89                Duplicate/O $("root:"+n5), $w5
90                Duplicate/O $("root:"+n6), $w6
91                Duplicate/O $("root:"+n7), $w7
92                Duplicate/O $("root:"+n8), $w8
93       
94        endif           //9-columns
95
96
97       
98        /// do this for all 2D data, whether or not resolution information was read in
99       
100        Variable/G gIsLogScale = 0
101       
102        Variable num=numpnts($w0)
103        // assume that the Q-grid is "uniform enough" for DISPLAY ONLY
104        // use the 3 original waves for all of the fitting...
105
106// for L/R x=48,y=128
107// for T/B x=128,y=48
108       
109        V_ConvertQxQy2Mat($w0,$w1,$w2,numX,numY,baseStr+"_mat")
110
111        V_ConvertQxQy2Mat($w0,$w1,$w8,numX,numY,baseStr+"_mat_mask")
112        Display/W=(40,400,40+3*numX,400+3*numY);Appendimage $(baseStr+"_mat_mask")
113
114        Duplicate/O $(baseStr+"_mat"),$(baseStr+"_lin")                 //keep a linear-scaled version of the data
115
116        Display/W=(40,40,40+3*numX,40+3*numY);Appendimage $(baseStr+"_mat")
117        ModifyImage $(baseStr+"_mat") ctab= {*,*,ColdWarm,0}
118
119        if(exists("root:Packages:NIST:VSANS:Globals:logLookupWave")==1)
120                ModifyImage $(baseStr+"_mat") ctabAutoscale=0,lookup= root:Packages:NIST:VSANS:Globals:logLookupWave
121        endif
122       
123//      PlotQxQy(baseStr)               //this sets the data folder back to root:!!
124
125        //clean up             
126        SetDataFolder root:
127        KillWaves/Z $n0,$n1,$n2,$n3,$n4,$n5,$n6,$n7,$n8
128       
129EndMacro
130
131
132
133
134// for reformatting the matrix of VSANS QxQy data after it's been read in
135//
136// this assumes that:
137// --QxQy data was written out in the format specified by the Igor macros, that is the x varies most rapidly
138//
139// TODO -- this needs to be made generic for reading in different panels with different XY dimensions
140// x- add the XY dimensions to the QxQyASCII file header somewhere so that it can be read in and used here
141//
142// the SANS analysis 2D loader assumes that the matrix is square, mangling the VSANS data.
143// the column data (for fitting) is still fine, but the matrix representation is incorrect.
144//
145Function V_ConvertQxQy2Mat(Qx,Qy,inten,numX,numY,matStr)
146        Wave Qx,Qy,inten
147        Variable numX,numY
148        String matStr
149       
150        String folderStr=GetWavesDataFolder(Qx,1)
151       
152//      Variable numX,numY
153//      numX=48
154//      numY=128
155        Make/O/D/N=(numX,numY) $(folderStr + matStr)
156        Wave mat=$(folderStr + matStr)
157       
158        WaveStats/Q Qx
159        SetScale/I x, V_min, V_max, "", mat
160        WaveStats/Q Qy
161        SetScale/I y, V_min, V_max, "", mat
162       
163        Variable xrows=numX
164       
165        mat = inten[q*xrows+p]
166       
167        return(0)
168End
169
Note: See TracBrowser for help on using the repository browser.