source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Slit.ipf @ 982

Last change on this file since 982 was 982, checked in by srkline, 7 years ago

more changes and additons to display VSANS data

adding functions for IvsQ plotting

coverted much of VCALC to have similar folder structure as HDF to allow re-use of the Q-binning procedures from VCALC with real data in work files.

re-working the beam center finder to get it to work with work file data rather then only VCALC.

new plotting routines for the panels to rescale to the beam center (still in pixels, though)

File size: 6.8 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4//////////////////
5//
6// Procedures to average data taken in "slit" apertuere geometry. The fake data on the detector panels
7//  is as would be collected in PINHOLE geometry - I do not currently have a simulation for slit
8//  apertures (this would need to be MonteCarlo) - the I(q) averaging here gives the I(q) that you
9//  would measure in 1D using slit geometry. It is done by simply summing the columns of data on each detector.
10//
11//////////////////
12//
13//
14// TODO - big question about averaging in this way...
15// can the T/B panels really be used at all for slit mode? - since there's a big "hole" in the scattering data
16// collected -- you're not getting the full column of data covering a wide range of Qy. L/R panels should be fine.
17//
18// - best answer so far is to skip the T/B panels, and simply not use them
19//
20// TODO -- be sure that the absolute scaling of this is correct. I have no guarantee that
21//                      it'll be correct.
22//
23/////////////////
24
25
26//
27// seems backwards to call this "byRows", but this is the way that Igor indexes
28// LR banks are defined as (48,256) (n,m), sumRows gives sum w/ dimension (n x 1)
29//
30// updated to new folder structure Feb 2016
31// folderStr = RAW,SAM, VCALC or other
32// detStr is the panel identifer "ML", etc.
33Function VC_fBinDetector_byRows(folderStr,detStr)
34        String folderStr,detStr
35       
36//      SetDataFolder root:Packages:NIST:VSANS:VCALC   
37       
38        Variable pixSizeX,pixSizeY,delQx, delQy
39        Variable isVCALC=0
40       
41        if(cmpstr(folderStr,"VCALC") == 0)
42                isVCALC = 1
43        endif
44
45        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
46        String instPath = ":entry:entry:instrument:detector_"   
47       
48        if(isVCALC)
49                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr)               // 2D detector data
50                WAVE/Z iErr = $("asdf_iErr_"+detStr)                    // TODO: 2D errors -- may not exist, especially for simulation
51        else
52                Wave inten = V_getDetectorDataW(folderStr,detStr)
53                Wave iErr = V_getDetectorDataErrW(folderStr,detStr)
54        endif
55
56        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values
57        Wave qx = $(folderPath+instPath+detStr+":qx_"+detStr)
58        Wave qy = $(folderPath+instPath+detStr+":qy_"+detStr)
59
60// ?? TODO not needed here?     
61//      pixSizeX = VCALC_getPixSizeX(detStr)
62//      pixSizeY = VCALC_getPixSizeY(detStr)
63       
64        delQx = abs(qx[0][0] - qx[1][0])
65        delQy = abs(qy[0][1] - qy[0][0])
66       
67        // delta Qx is set by the pixel X dimension of the detector, which is the limiting resolution
68
69        Variable nq,val
70        nq = DimSize(inten,0)           //nq == the number of columns (x dimension)
71       
72//      SetDataFolder $(folderPath+instPath+detStr)     
73
74        Make/O/D/N=(nq)  $(folderPath+":"+"iBin_qxqy_"+detStr)
75        Make/O/D/N=(nq)  $(folderPath+":"+"qBin_qxqy_"+detStr)
76        Make/O/D/N=(nq)  $(folderPath+":"+"nBin_qxqy_"+detStr)
77        Make/O/D/N=(nq)  $(folderPath+":"+"iBin2_qxqy_"+detStr)
78        Make/O/D/N=(nq)  $(folderPath+":"+"eBin_qxqy_"+detStr)
79        Make/O/D/N=(nq)  $(folderPath+":"+"eBin2D_qxqy_"+detStr)
80       
81        Wave iBin_qxqy = $(folderPath+":"+"iBin_qxqy_"+detStr)
82        Wave qBin_qxqy = $(folderPath+":"+"qBin_qxqy_"+detStr)
83        Wave nBin_qxqy = $(folderPath+":"+"nBin_qxqy_"+detStr)
84        Wave iBin2_qxqy = $(folderPath+":"+"iBin2_qxqy_"+detStr)
85        Wave eBin_qxqy = $(folderPath+":"+"eBin_qxqy_"+detStr)
86        Wave eBin2D_qxqy = $(folderPath+":"+"eBin2D_qxqy_"+detStr)
87
88// sum the rows
89        MatrixOp/O iBin_qxqy = sumRows(inten)   //automatically generates the destination
90
91// if the detectors are "L", then the values are all negative...
92// if the detectors are T/B, then half is negative, and there's a very nearly zero point in the middle...       
93// and it may make no sense to use T/B anyways...
94        qBin_qxqy = abs(qx[p][0])
95
96       
97        //now get the scaling correct
98        // q-integration (rectangular), matrixOp simply summed, so I need to multiply by dy (pixelSizeY -> as Qy?)
99       
100        iBin_qxqy *= delQy
101       
102// TODO
103//      iBin_qxqy *= 4          //why the factor of 4??? -- this is what I needed to do with FFT->USANS. Do I need it here?
104
105
106/// TODO -- this is not correct, but just for getting the I(Q) display to look "pretty"
107        qBin_qxqy = (abs(qBin_qxqy[p][q]) < 1e-5) ? NaN : qBin_qxqy[p][q]                       // clean out the near-zero Q point in the T/B  and Back detectors
108
109
110        SetDataFolder root:
111       
112        return(0)
113End
114
115
116// TODO -- update to new folder structure
117// unused -- update if necessary
118Proc CopyIQWaves()
119
120        SetDataFolder root:Packages:NIST:VSANS:VCALC   
121
122        duplicate/O iBin_qxqy_B iBin_qxqy_B_pin
123        duplicate/O qBin_qxqy_B qBin_qxqy_B_pin
124       
125        duplicate/O iBin_qxqy_MR iBin_qxqy_MR_pin
126        duplicate/O qBin_qxqy_MR qBin_qxqy_MR_pin
127        duplicate/O iBin_qxqy_MT iBin_qxqy_MT_pin
128        duplicate/O qBin_qxqy_MT qBin_qxqy_MT_pin
129        duplicate/O iBin_qxqy_ML iBin_qxqy_ML_pin
130        duplicate/O qBin_qxqy_ML qBin_qxqy_ML_pin
131        duplicate/O iBin_qxqy_MB iBin_qxqy_MB_pin
132        duplicate/O qBin_qxqy_MB qBin_qxqy_MB_pin
133
134        duplicate/O iBin_qxqy_FR iBin_qxqy_FR_pin
135        duplicate/O qBin_qxqy_FR qBin_qxqy_FR_pin
136        duplicate/O iBin_qxqy_FT iBin_qxqy_FT_pin
137        duplicate/O qBin_qxqy_FT qBin_qxqy_FT_pin
138        duplicate/O iBin_qxqy_FL iBin_qxqy_FL_pin
139        duplicate/O qBin_qxqy_FL qBin_qxqy_FL_pin
140        duplicate/O iBin_qxqy_FB iBin_qxqy_FB_pin
141        duplicate/O qBin_qxqy_FB qBin_qxqy_FB_pin
142
143        SetDataFolder root:
144End
145
146// TODO -- update to new folder structure
147// unused -- update if necessary
148Window slit_vs_pin_graph() : Graph
149        PauseUpdate; Silent 1           // building window...
150        String fldrSav0= GetDataFolder(1)
151        SetDataFolder root:Packages:NIST:VSANS:VCALC:
152        Display /W=(1296,44,1976,696) iBin_qxqy_B vs qBin_qxqy_B
153        AppendToGraph iBin_qxqy_B_pin vs qBin_qxqy_B_pin
154        AppendToGraph iBin_qxqy_MR vs qBin_qxqy_MR
155        AppendToGraph iBin_qxqy_MR_pin vs qBin_qxqy_MR_pin
156        AppendToGraph iBin_qxqy_MT vs qBin_qxqy_MT
157        AppendToGraph iBin_qxqy_MT_pin vs qBin_qxqy_MT_pin
158        AppendToGraph iBin_qxqy_FR vs qBin_qxqy_FR
159        AppendToGraph iBin_qxqy_FR_pin vs qBin_qxqy_FR_pin
160        AppendToGraph iBin_qxqy_FT vs qBin_qxqy_FT
161        AppendToGraph iBin_qxqy_FT_pin vs qBin_qxqy_FT_pin
162        SetDataFolder fldrSav0
163        ModifyGraph mode=4
164        ModifyGraph marker=19
165        ModifyGraph lSize=2
166        ModifyGraph rgb(iBin_qxqy_B)=(0,0,0),rgb(iBin_qxqy_B_pin)=(65535,16385,16385),rgb(iBin_qxqy_MR)=(2,39321,1)
167        ModifyGraph rgb(iBin_qxqy_MR_pin)=(0,0,65535),rgb(iBin_qxqy_MT)=(39321,1,31457)
168        ModifyGraph rgb(iBin_qxqy_MT_pin)=(48059,48059,48059),rgb(iBin_qxqy_FR)=(65535,32768,32768)
169        ModifyGraph rgb(iBin_qxqy_FR_pin)=(0,65535,0),rgb(iBin_qxqy_FT)=(16385,65535,65535)
170        ModifyGraph rgb(iBin_qxqy_FT_pin)=(65535,32768,58981)
171        ModifyGraph msize=2
172        ModifyGraph grid=1
173        ModifyGraph log=1
174        ModifyGraph mirror=1
175        SetAxis bottom 1e-05,0.05287132
176        Legend/C/N=text0/J/X=64.73/Y=7.25 "\\Z12\\s(iBin_qxqy_B) iBin_qxqy_B\r\\s(iBin_qxqy_B_pin) iBin_qxqy_B_pin\r\\s(iBin_qxqy_MR) iBin_qxqy_MR"
177        AppendText "\\s(iBin_qxqy_MR_pin) iBin_qxqy_MR_pin\r\\s(iBin_qxqy_MT) iBin_qxqy_MT\r\\s(iBin_qxqy_MT_pin) iBin_qxqy_MT_pin\r\\s(iBin_qxqy_FR) iBin_qxqy_FR"
178        AppendText "\\s(iBin_qxqy_FR_pin) iBin_qxqy_FR_pin\r\\s(iBin_qxqy_FT) iBin_qxqy_FT\r\\s(iBin_qxqy_FT_pin) iBin_qxqy_FT_pin"
179EndMacro
Note: See TracBrowser for help on using the repository browser.