source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/Nexus_VSANS_Write.ipf @ 960

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

more work with SANS and VSANS Nexus files, still trying to organize the r/w routines for just the basic testing of the first pass of NICE-generated files. Ditched the idea of generating the files from Igor, since DAS_log is not included. Now the plan is to start from a NICE/Nexus template. All still EXTREMELY fluid at this point.

File size: 9.5 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3///
4// for the simulator, routines to be able to write out a proper Nexus file
5// based on a template
6////
7
8
9
10// overwrites the dummy values as needed with VCALC information
11//
12// TODO
13// issues here with the potential for Nexus to have data as INTEGER
14// where I'd rather have the data here in Igor be DP, so there are no
15// conversion/assignment issues
16//
17// simuation data from VCALC = DP, but I need to assign to an Integer wave...
18// - sometimes this works, sometimes not...
19// may need to Redimension/I
20//
21/// break this up into several smaller procedures as this is a VERY lengthy task to do
22
23        // TODO
24// set the "accessible" copies of the data (these are really to be links in the file!)
25
26
27
28//
29// A "template" VSANS Nexus file has been loaded and is then filled in with
30// the simulation results. Some of teh file, will therefor be garbage, but the
31// overall structure and attributes should be correct.
32//
33// Hopefully this will make the maintenance and testing of the file structure easier...
34// AUG 2015
35//
36///////////////////////////
37//
38// these are all of the VCALC changes to the simulated files. ADD to these as needed, making these changes to the
39// folder structure after the "default" values have been re-filled in the waves (to make sure something is really there)
40//
41////////////////////////
42
43// TODO:
44//      -- Need to write all of the "accessors" to r/w all of the simulated bits to the data file... lots to do
45// -- THIS DOES NOT MATCH THE CURRENT NICE_GENERATED FILE !!!!
46//
47Proc H_Fill_VSANS_Template_wSim()
48
49//                              root:sans9:entry:entry1:instrument:beam:monochromator:wavelength
50                               
51                        SetDataFolder root:VSANS_file:entry1:instrument         
52                                SetDataFolder root:VSANS_file:entry1:instrument:monochromator           
53                                        wavelength      = VCALC_getWavelength()
54                                        SetDataFolder root:VSANS_file:entry1:instrument:monochromator:velocity_selector         
55                                                wavelength      = VCALC_getWavelength()
56                                                //      table (wave)   
57                                        SetDataFolder root:VSANS_file:entry1:instrument:monochromator:crystal           
58                                                wavelength      = VCALC_getWavelength()
59                                               
60                                        SetDataFolder root:VSANS_file:entry1:instrument:monochromator:white_beam               
61                                                wavelength      = VCALC_getWavelength()
62                                                //      description_of_distribution
63                                       
64
65                                       
66                        SetDataFolder root:VSANS_file:entry1:instrument:detector_B             
67                                data    = root:Packages:NIST:VSANS:VCALC:Back:det_B
68                                nx_distance     = VCALC_getSDD("B")
69
70                        SetDataFolder root:VSANS_file:entry1:instrument:detector_MR                     
71                                data    = root:Packages:NIST:VSANS:VCALC:Middle:det_MR
72                                nx_distance     = VCALC_getSDD("MR")
73                                separation      = VCALC_getPanelSeparation("MR")
74                                spatial_calibration[0][] = 1.072
75                                spatial_calibration[1][] = -4.0e-5
76                               
77                        SetDataFolder root:VSANS_file:entry1:instrument:detector_ML             
78                                data    = root:Packages:NIST:VSANS:VCALC:Middle:det_ML
79                                nx_distance     = VCALC_getSDD("ML")
80                                separation = VCALC_getPanelSeparation("ML")
81                                spatial_calibration[0][] = 1.072
82                                spatial_calibration[1][] = -4.0e-5
83
84                        SetDataFolder root:VSANS_file:entry1:instrument:detector_MT             
85                                data    = root:Packages:NIST:VSANS:VCALC:Middle:det_MT
86                                nx_distance     = VCALC_getSDD("MT")
87                                sdd_offset = VCALC_getTopBottomSDDOffset("MT")
88                                separation = VCALC_getPanelSeparation("MT")
89                                spatial_calibration[0][] = 1.072
90                                spatial_calibration[1][] = -4.0e-5
91
92                        SetDataFolder root:VSANS_file:entry1:instrument:detector_MB             
93                                data    = root:Packages:NIST:VSANS:VCALC:Middle:det_MB
94                                nx_distance     = VCALC_getSDD("MB")
95                                sdd_offset = VCALC_getTopBottomSDDOffset("MB")
96                                separation = VCALC_getPanelSeparation("MB")
97                                spatial_calibration[0][] = 1.072
98                                spatial_calibration[1][] = -4.0e-5
99
100                        SetDataFolder root:VSANS_file:entry1:instrument:detector_FR                     
101                                data    = root:Packages:NIST:VSANS:VCALC:Front:det_FR
102                                nx_distance     = VCALC_getSDD("FR")
103                                separation = VCALC_getPanelSeparation("FR")
104                                spatial_calibration[0][] = 1.072
105                                spatial_calibration[1][] = -4.0e-5
106
107                        SetDataFolder root:VSANS_file:entry1:instrument:detector_FL             
108                                data    = root:Packages:NIST:VSANS:VCALC:Front:det_FL
109                                nx_distance     = VCALC_getSDD("FL")
110                                separation = VCALC_getPanelSeparation("FL")
111                                spatial_calibration[0][] = 1.072
112                                spatial_calibration[1][] = -4.0e-5
113
114                        SetDataFolder root:VSANS_file:entry1:instrument:detector_FT             
115                                data    = root:Packages:NIST:VSANS:VCALC:Front:det_FT
116                                nx_distance     = VCALC_getSDD("FT")
117                                sdd_offset = VCALC_getTopBottomSDDOffset("FT")
118                                separation = VCALC_getPanelSeparation("FT")
119                                spatial_calibration[0][] = 1.072
120                                spatial_calibration[1][] = -4.0e-5
121
122                        SetDataFolder root:VSANS_file:entry1:instrument:detector_FB             
123                                data    = root:Packages:NIST:VSANS:VCALC:Front:det_FB
124                                nx_distance     = VCALC_getSDD("FB")
125                                sdd_offset = VCALC_getTopBottomSDDOffset("FB")
126                                separation = VCALC_getPanelSeparation("FB")
127                                spatial_calibration[0][] = 1.072
128                                spatial_calibration[1][] = -4.0e-5
129
130                                       
131// SRK -set the top level copies of the data                                   
132                SetDataFolder root:VSANS_file:entry1:data_B     
133                        data    = root:Packages:NIST:VSANS:VCALC:Back:det_B
134
135                SetDataFolder root:VSANS_file:entry1:data_MR   
136                        data    = root:Packages:NIST:VSANS:VCALC:Middle:det_MR
137                       
138                SetDataFolder root:VSANS_file:entry1:data_ML   
139                        data    = root:Packages:NIST:VSANS:VCALC:Middle:det_ML
140                       
141                SetDataFolder root:VSANS_file:entry1:data_MT   
142                        data    = root:Packages:NIST:VSANS:VCALC:Middle:det_MT
143                        data    = (data ==   2147483647) ? 0 : data             //the NaN "mask" in the sim data shows up as an ugly integer
144                       
145                SetDataFolder root:VSANS_file:entry1:data_MB   
146                        data    = root:Packages:NIST:VSANS:VCALC:Middle:det_MB
147                        data    = (data ==   2147483647) ? 0 : data             //the NaN "mask" in the sim data shows up as an ugly integer
148                       
149                SetDataFolder root:VSANS_file:entry1:data_FR   
150                        data    = root:Packages:NIST:VSANS:VCALC:Front:det_FR
151                       
152                SetDataFolder root:VSANS_file:entry1:data_FL   
153                        data    = root:Packages:NIST:VSANS:VCALC:Front:det_FL
154                       
155                SetDataFolder root:VSANS_file:entry1:data_FT   
156                        data    = root:Packages:NIST:VSANS:VCALC:Front:det_FT
157                        data    = (data ==   2147483647) ? 0 : data             //the NaN "mask" in the sim data shows up as an ugly integer
158                       
159                SetDataFolder root:VSANS_file:entry1:data_FB   
160                        data    = root:Packages:NIST:VSANS:VCALC:Front:det_FB
161                        data    = (data ==   2147483647) ? 0 : data             //the NaN "mask" in the sim data shows up as an ugly integer
162                       
163                               
164//              SetDataFolder root:VSANS_file:entry1:reduction         
165//                      intent  = "SCATTER"
166//                      transmission_file_name  = "SANSFile_TRN.h5"
167//                      empty_beam_file_name    = "SANSFile_EB.h5"
168//                      background_file_name    = "SANSFile_BKG.h5"
169//                      empty_file_name = "SANSFile_EMP.h5"
170//                      sensitivity_file_name   = "SANSFile_DIV.h5"
171//                      mask_file_name  = "SANSFile_MASK.h5"
172//                      sans_log_file_name      = "SANSFile_log.txt"
173//                      whole_trans     = 0.888
174//                      whole_trans_error       = 0.008
175//                      box_count       = 23232
176//                      box_count_error = 22
177//                      box_coordinates = {50,80,45,75}
178//                      comments        = "extra data comments"
179//                      absolute_scaling        = {1,1,1e5,1}
180//                      SetDataFolder root:VSANS_file:entry1:reduction:pol_sans                 
181//                              pol_sans_purpose        = "name from the list"
182//                              cell_name       = "Burgundy"
183//                              cell_parameters = {1,2,3,4,5}
184                                       
185
186        SetDataFolder root:
187
188End
189
190
191////////////// fake DIV file tests
192
193//
194//      Make/O/T/N=1    file_name       = "VSANS_DIV_test.h5"
195//
196// simple generation of a fake div file. for sans, nothing other than the creation date was written to the
197// file header. nothing more is needed (possibly)
198//
199// TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved
200//   during the generation of the file, but there's no reason it couldn't. the idea is that the plex
201//   is counted so long that the errors are insignificant compared to the data errors, but that may not
202//   always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different.
203//
204Proc H_Setup_VSANS_DIV_Structure()
205       
206        NewDataFolder/O/S root:VSANS_DIV_file           
207
208        NewDataFolder/O/S root:VSANS_DIV_file:entry1           
209                Make/O/T/N=1    title   = "title of entry1"
210                Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00"
211                NewDataFolder/O/S root:VSANS_DIV_file:entry1:instrument         
212                        Make/O/T/N=1    name    = "NGB30mSANS"
213                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_B             
214                        Make/O/I/N=(320,320)    data    = trunc(abs(gnoise(p+q)))
215                        Make/O/D/N=(320,320)    error   = 0.01*abs(gnoise(p+q))
216                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_MR           
217                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
218                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
219                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_ML           
220                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
221                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
222                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_MT           
223                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
224                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
225                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_MB           
226                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
227                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
228                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FR           
229                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
230                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
231                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FL           
232                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
233                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
234                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FT           
235                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
236                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
237                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FB           
238                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
239                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
240                       
241        SetDataFolder root:
242
243End
Note: See TracBrowser for help on using the repository browser.