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

Last change on this file since 955 was 955, checked in by srkline, 8 years ago

some reorganization of the r/w routines to generate HDF test files for SANS and VSANS (all are housed together for testing). also some reorganization of the detector binning routines to get functions grouped in more logical locations.

File size: 6.0 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//
30Function V_fBinDetector_byRows(folderStr,type)
31        String folderStr,type
32       
33        SetDataFolder root:Packages:NIST:VSANS:VCALC   
34       
35        Variable pixSizeX,pixSizeY,delQx, delQy
36
37        WAVE inten = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":det_"+type)                // 2D detector data
38        WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation
39        Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":qTot_"+type)                      // 2D q-values
40        Wave qx = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":qx_"+type)
41        Wave qy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":qy_"+type)
42       
43        pixSizeX = VCALC_getPixSizeX(type)
44        pixSizeY = VCALC_getPixSizeY(type)
45       
46        delQx = abs(qx[0][0] - qx[1][0])
47        delQy = abs(qy[0][1] - qy[0][0])
48       
49        // delta Qx is set by the pixel X dimension of the detector, which is the limiting resolution
50
51        Variable nq,val
52        nq = DimSize(inten,0)           //nq == the number of columns (x dimension)
53       
54        SetDataFolder root:Packages:NIST:VSANS:VCALC   
55
56        Make/O/D/N=(nq)  $("iBin_qxqy_"+type)
57        Make/O/D/N=(nq)  $("qBin_qxqy_"+type)
58        Make/O/D/N=(nq)  $("nBin_qxqy_"+type)
59        Make/O/D/N=(nq)  $("iBin2_qxqy_"+type)
60        Make/O/D/N=(nq)  $("eBin_qxqy_"+type)
61        Make/O/D/N=(nq)  $("eBin2D_qxqy_"+type)
62       
63        Wave iBin_qxqy = $("iBin_qxqy_"+type)
64        Wave qBin_qxqy = $("qBin_qxqy_"+type)
65        Wave nBin_qxqy = $("nBin_qxqy_"+type)
66        Wave iBin2_qxqy = $("iBin2_qxqy_"+type)
67        Wave eBin_qxqy = $("eBin_qxqy_"+type)
68        Wave eBin2D_qxqy = $("eBin2D_qxqy_"+type)
69
70// sum the rows
71        MatrixOp/O iBin_qxqy = sumRows(inten)   //automatically generates the destination
72
73// if the detectors are "L", then the values are all negative...
74// if the detectors are T/B, then half is negative, and there's a very nearly zero point in the middle...       
75// and it may make no sense to use T/B anyways...
76        qBin_qxqy = abs(qx[p][0])
77
78       
79        //now get the scaling correct
80        // q-integration (rectangular), matrixOp simply summed, so I need to multiply by dy (pixelSizeY -> as Qy?)
81       
82        iBin_qxqy *= delQy
83       
84// TODO
85//      iBin_qxqy *= 4          //why the factor of 4??? -- this is what I needed to do with FFT->USANS. Do I need it here?
86
87
88/// TODO -- this is not correct, but just for getting the I(Q) display to look "pretty"
89        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
90
91
92        SetDataFolder root:
93       
94        return(0)
95End
96
97
98Proc CopyIQWaves()
99
100        SetDataFolder root:Packages:NIST:VSANS:VCALC   
101
102        duplicate/O iBin_qxqy_B iBin_qxqy_B_pin
103        duplicate/O qBin_qxqy_B qBin_qxqy_B_pin
104       
105        duplicate/O iBin_qxqy_MR iBin_qxqy_MR_pin
106        duplicate/O qBin_qxqy_MR qBin_qxqy_MR_pin
107        duplicate/O iBin_qxqy_MT iBin_qxqy_MT_pin
108        duplicate/O qBin_qxqy_MT qBin_qxqy_MT_pin
109        duplicate/O iBin_qxqy_ML iBin_qxqy_ML_pin
110        duplicate/O qBin_qxqy_ML qBin_qxqy_ML_pin
111        duplicate/O iBin_qxqy_MB iBin_qxqy_MB_pin
112        duplicate/O qBin_qxqy_MB qBin_qxqy_MB_pin
113
114        duplicate/O iBin_qxqy_FR iBin_qxqy_FR_pin
115        duplicate/O qBin_qxqy_FR qBin_qxqy_FR_pin
116        duplicate/O iBin_qxqy_FT iBin_qxqy_FT_pin
117        duplicate/O qBin_qxqy_FT qBin_qxqy_FT_pin
118        duplicate/O iBin_qxqy_FL iBin_qxqy_FL_pin
119        duplicate/O qBin_qxqy_FL qBin_qxqy_FL_pin
120        duplicate/O iBin_qxqy_FB iBin_qxqy_FB_pin
121        duplicate/O qBin_qxqy_FB qBin_qxqy_FB_pin
122
123        SetDataFolder root:
124End
125
126Window slit_vs_pin_graph() : Graph
127        PauseUpdate; Silent 1           // building window...
128        String fldrSav0= GetDataFolder(1)
129        SetDataFolder root:Packages:NIST:VSANS:VCALC:
130        Display /W=(1296,44,1976,696) iBin_qxqy_B vs qBin_qxqy_B
131        AppendToGraph iBin_qxqy_B_pin vs qBin_qxqy_B_pin
132        AppendToGraph iBin_qxqy_MR vs qBin_qxqy_MR
133        AppendToGraph iBin_qxqy_MR_pin vs qBin_qxqy_MR_pin
134        AppendToGraph iBin_qxqy_MT vs qBin_qxqy_MT
135        AppendToGraph iBin_qxqy_MT_pin vs qBin_qxqy_MT_pin
136        AppendToGraph iBin_qxqy_FR vs qBin_qxqy_FR
137        AppendToGraph iBin_qxqy_FR_pin vs qBin_qxqy_FR_pin
138        AppendToGraph iBin_qxqy_FT vs qBin_qxqy_FT
139        AppendToGraph iBin_qxqy_FT_pin vs qBin_qxqy_FT_pin
140        SetDataFolder fldrSav0
141        ModifyGraph mode=4
142        ModifyGraph marker=19
143        ModifyGraph lSize=2
144        ModifyGraph rgb(iBin_qxqy_B)=(0,0,0),rgb(iBin_qxqy_B_pin)=(65535,16385,16385),rgb(iBin_qxqy_MR)=(2,39321,1)
145        ModifyGraph rgb(iBin_qxqy_MR_pin)=(0,0,65535),rgb(iBin_qxqy_MT)=(39321,1,31457)
146        ModifyGraph rgb(iBin_qxqy_MT_pin)=(48059,48059,48059),rgb(iBin_qxqy_FR)=(65535,32768,32768)
147        ModifyGraph rgb(iBin_qxqy_FR_pin)=(0,65535,0),rgb(iBin_qxqy_FT)=(16385,65535,65535)
148        ModifyGraph rgb(iBin_qxqy_FT_pin)=(65535,32768,58981)
149        ModifyGraph msize=2
150        ModifyGraph grid=1
151        ModifyGraph log=1
152        ModifyGraph mirror=1
153        SetAxis bottom 1e-05,0.05287132
154        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"
155        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"
156        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"
157EndMacro
Note: See TracBrowser for help on using the repository browser.