source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DIVUtils.ipf @ 1037

Last change on this file since 1037 was 1033, checked in by srkline, 5 years ago

Adding utilities to calculate transmission. Added V_Transmission.ipf file. Getting the functionality to work, user interface or incorporation into the data reduction protocol is still to be decided.

File size: 6.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3//
4// ********
5// TODO -- this is only a fake DIV file. need to identify how to generate a real DIV file
6//     for the different detectors, and how to fill it into a file. ProDIV for SANS may be a good
7//     starting point, or it may be cumbersome. Not sure how it will be measured in practice
8//     on VSANS.
9//
10//   JAN 2017
11//
12// TODO:
13// -- complete the description of the steps needed...
14// Data needs to be reduced to the "COR" level - that means that the
15// PLEX data has been added to work files, and the empty and blocked beam have been
16// subtracted off.
17// -- but what detector corrections should/ should not be done?
18// -- non-linear corrections are not needed, since this will strictly be a per-pixel correction
19// -- solid angle?
20// -- dead time?
21// -- efficiency?
22// -- large angle transmission?
23//
24// we may need to think more carefully about some of these since the front carriage may need to be
25// closer than the nominal 4m distance on SANS that was deemed far enough back to be "safe" from
26// the high angle issues.
27//
28//
29
30
31
32/// TODO:
33// -- this is the basic renormalization that is done in PRODIV. see that file for all of the
34//    details of how it's used
35// -- update to VSANS file locations and data reads
36// -- expand this to do a basic renormalization of all 9 panels, and move the data into the
37//    appropriate locations for saving as a DIV file.
38//
39//
40
41
42
43
44
45
46//works on the data in "type" folder (expecting data to be reduced to the COR level)
47//sums all of the data, and normalizes by the number of cells (=pixelX*pixelY)
48// calling procedure must make sure that the folder is on linear scale FIRST
49Function V_NormalizeDIV(type)
50        String type
51       
52        WAVE data=$("root:Packages:NIST:"+type+":data")
53        WAVE data_lin=$("root:Packages:NIST:"+type+":linear_data")
54        WAVE data_err=$("root:Packages:NIST:"+type+":linear_data_error")
55       
56        Variable totCts=sum(data,Inf,-Inf)              //sum all of the data
57        NVAR pixelX = root:myGlobals:gNPixelsX
58        NVAR pixelY = root:myGlobals:gNPixelsY
59
60       
61        data /= totCts
62        data *= pixelX*pixelY
63       
64        data_lin /= totCts
65        data_lin *= pixelX*pixelY
66       
67        data_err /= totCts
68        data_err *= pixelX*pixelY
69               
70        return(0)
71End
72
73
74
75
76
77
78
79// TODO
80// currently, there are no dummy fill values or attributes for the fake DIV file
81//
82Proc Setup_VSANS_DIV_Struct()
83
84        // lays out the tree and fills with dummy values
85        H_Setup_VSANS_DIV_Structure()
86       
87        // writes in the attributes
88//      H_Fill_VSANS_Attributes()
89       
90        // fill in with VCALC simulation bits
91//      H_Fill_VSANS_wSim()
92       
93End
94
95Proc Save_VSANS_DIV_Nexus(fileName)
96        String fileName="Test_VSANS_DIV_file"
97
98        // save as HDF5 (no attributes saved yet)
99        Save_VSANS_file("root:VSANS_DIV_file", fileName+".h5")
100       
101//      // read in a data file using the gateway-- reads from the home path
102//      H_HDF5Gate_Read_Raw(fileName+".h5")
103//     
104//      // after reading in a "partial" file using the gateway (to generate the xref)
105//      // Save the xref to disk (for later use)
106//      Save_HDF5___xref("root:"+fileName,"HDF5___xref")
107//     
108//      // after you've generated the HDF5___xref, load it in and copy it
109//      // to the necessary folder location.
110//      Copy_HDF5___xref("root:VSANS_DIV_file", "HDF5___xref")
111//     
112//      // writes out the contents of a data folder using the gateway
113//      H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5")
114//
115//      // re-load the data file using the gateway-- reads from the home path
116//      // now with attributes
117//      H_HDF5Gate_Read_Raw(fileName+".h5")
118       
119End
120
121////////////// fake DIV file tests
122//
123//
124//      Make/O/T/N=1    file_name       = "VSANS_DIV_test.h5"
125//
126// simple generation of a fake div file. for sans, nothing other than the creation date was written to the
127// file header. nothing more is needed (possibly)
128//
129// TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved
130//   during the generation of the file, but there's no reason it couldn't. the idea is that the plex
131//   is counted so long that the errors are insignificant compared to the data errors, but that may not
132//   always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different.
133//
134//
135// TODO -- make the number of pixels GLOBAL
136// TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the
137//      9 data sets to become the DIV file contents. More complexity here than for the simple SANS case.
138//
139Proc H_Setup_VSANS_DIV_Structure()
140       
141        NewDataFolder/O/S root:VSANS_DIV_file           
142
143        NewDataFolder/O/S root:VSANS_DIV_file:entry     
144                Make/O/T/N=1    title   = "This is a DIV file for VSANS: VSANS_DIV"
145                Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00"
146                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument         
147                        Make/O/T/N=1    name    = "NG3_VSANS"
148                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B       
149                        Make/O/D/N=(150,150)    data    = 1 + (enoise(0.1))
150                        Make/O/D/N=(150,150)    linear_data_error       = 0.01*abs(gnoise(1))
151                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR             
152                        Make/O/D/N=(48,128)     data
153                        data[][0] = 1+enoise(0.1)
154                        data[][] = data[p][0]
155                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
156                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML             
157                        Make/O/D/N=(48,128)     data
158                        data[][0] = 1+enoise(0.1)
159                        data[][] = data[p][0]
160                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
161                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT             
162                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
163                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
164                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB             
165                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
166                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
167                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR             
168                        Make/O/D/N=(48,128)     data
169                        data[][0] = 1+enoise(0.1)
170                        data[][] = data[p][0]
171                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
172                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL             
173                        Make/O/D/N=(48,128)     data
174                        data[][0] = 1+enoise(0.1)
175                        data[][] = data[p][0]
176                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
177                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT             
178                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
179                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
180                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB             
181                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
182                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
183               
184                // fake, empty folders so that the generic loaders can be used
185                NewDataFolder/O root:VSANS_DIV_file:entry:DAS_logs
186                NewDataFolder/O root:VSANS_DIV_file:entry:control
187                NewDataFolder/O root:VSANS_DIV_file:entry:reduction
188                NewDataFolder/O root:VSANS_DIV_file:entry:sample
189                NewDataFolder/O root:VSANS_DIV_file:entry:user
190
191                       
192        SetDataFolder root:
193
194End
Note: See TracBrowser for help on using the repository browser.