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

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

more minor changes

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