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

Last change on this file since 1030 was 1030, checked in by srkline, 6 years ago

First pass at routines to interactively combine and mask VSANS 1-D data sets. Based on masking as done in the USANS Desmearing panel.

File size: 6.0 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//
13//
14//
15//
16
17
18
19/// TODO:
20// -- this is the basic renormalization that is done in PRODIV. see that file for all of the
21//    details of how it's used
22// -- update to VSANS file locations and data reads
23// -- expand this to do a basic renormalization of all 9 panels, and move the data into the
24//    appropriate locations for saving as a DIV file.
25//
26//
27
28//works on the data in "type" folder (expecting data to be reduced to the COR level)
29//sums all of the data, and normalizes by the number of cells (=pixelX*pixelY)
30// calling procedure must make sure that the folder is on linear scale FIRST
31Function V_NormalizeDIV(type)
32        String type
33       
34        WAVE data=$("root:Packages:NIST:"+type+":data")
35        WAVE data_lin=$("root:Packages:NIST:"+type+":linear_data")
36        WAVE data_err=$("root:Packages:NIST:"+type+":linear_data_error")
37       
38        Variable totCts=sum(data,Inf,-Inf)              //sum all of the data
39        NVAR pixelX = root:myGlobals:gNPixelsX
40        NVAR pixelY = root:myGlobals:gNPixelsY
41
42       
43        data /= totCts
44        data *= pixelX*pixelY
45       
46        data_lin /= totCts
47        data_lin *= pixelX*pixelY
48       
49        data_err /= totCts
50        data_err *= pixelX*pixelY
51               
52        return(0)
53End
54
55
56
57
58
59
60
61// TODO
62// currently, there are no dummy fill values or attributes for the fake DIV file
63//
64Proc Setup_VSANS_DIV_Struct()
65
66        // lays out the tree and fills with dummy values
67        H_Setup_VSANS_DIV_Structure()
68       
69        // writes in the attributes
70//      H_Fill_VSANS_Attributes()
71       
72        // fill in with VCALC simulation bits
73//      H_Fill_VSANS_wSim()
74       
75End
76
77Proc Save_VSANS_DIV_Nexus(fileName)
78        String fileName="Test_VSANS_DIV_file"
79
80        // save as HDF5 (no attributes saved yet)
81        Save_VSANS_file("root:VSANS_DIV_file", fileName+".h5")
82       
83//      // read in a data file using the gateway-- reads from the home path
84//      H_HDF5Gate_Read_Raw(fileName+".h5")
85//     
86//      // after reading in a "partial" file using the gateway (to generate the xref)
87//      // Save the xref to disk (for later use)
88//      Save_HDF5___xref("root:"+fileName,"HDF5___xref")
89//     
90//      // after you've generated the HDF5___xref, load it in and copy it
91//      // to the necessary folder location.
92//      Copy_HDF5___xref("root:VSANS_DIV_file", "HDF5___xref")
93//     
94//      // writes out the contents of a data folder using the gateway
95//      H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5")
96//
97//      // re-load the data file using the gateway-- reads from the home path
98//      // now with attributes
99//      H_HDF5Gate_Read_Raw(fileName+".h5")
100       
101End
102
103////////////// fake DIV file tests
104//
105//
106//      Make/O/T/N=1    file_name       = "VSANS_DIV_test.h5"
107//
108// simple generation of a fake div file. for sans, nothing other than the creation date was written to the
109// file header. nothing more is needed (possibly)
110//
111// TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved
112//   during the generation of the file, but there's no reason it couldn't. the idea is that the plex
113//   is counted so long that the errors are insignificant compared to the data errors, but that may not
114//   always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different.
115//
116//
117// TODO -- make the number of pixels GLOBAL
118// TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the
119//      9 data sets to become the DIV file contents. More complexity here than for the simple SANS case.
120//
121Proc H_Setup_VSANS_DIV_Structure()
122       
123        NewDataFolder/O/S root:VSANS_DIV_file           
124
125        NewDataFolder/O/S root:VSANS_DIV_file:entry     
126                Make/O/T/N=1    title   = "This is a DIV file for VSANS: VSANS_DIV"
127                Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00"
128                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument         
129                        Make/O/T/N=1    name    = "NG3_VSANS"
130                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B       
131                        Make/O/D/N=(150,150)    data    = 1 + (enoise(0.1))
132                        Make/O/D/N=(150,150)    linear_data_error       = 0.01*abs(gnoise(1))
133                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR             
134                        Make/O/D/N=(48,128)     data
135                        data[][0] = 1+enoise(0.1)
136                        data[][] = data[p][0]
137                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
138                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML             
139                        Make/O/D/N=(48,128)     data
140                        data[][0] = 1+enoise(0.1)
141                        data[][] = data[p][0]
142                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
143                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT             
144                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
145                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
146                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB             
147                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
148                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
149                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR             
150                        Make/O/D/N=(48,128)     data
151                        data[][0] = 1+enoise(0.1)
152                        data[][] = data[p][0]
153                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
154                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL             
155                        Make/O/D/N=(48,128)     data
156                        data[][0] = 1+enoise(0.1)
157                        data[][] = data[p][0]
158                        Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1))
159                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT             
160                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
161                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
162                NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB             
163                        Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1))
164                        Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1))
165               
166                // fake, empty folders so that the generic loaders can be used
167                NewDataFolder/O root:VSANS_DIV_file:entry:DAS_logs
168                NewDataFolder/O root:VSANS_DIV_file:entry:control
169                NewDataFolder/O root:VSANS_DIV_file:entry:reduction
170                NewDataFolder/O root:VSANS_DIV_file:entry:sample
171                NewDataFolder/O root:VSANS_DIV_file:entry:user
172
173                       
174        SetDataFolder root:
175
176End
Note: See TracBrowser for help on using the repository browser.