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

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

Updated the display of the "beam center finder" to better display the panels with an appropriate aspect ratio for the pixels.

Made the number of pixels (x,y) on each of the panels as globals, plus access functions. Large panels were coded for 256, but will likely be 128 pixels in reality. Make global for easy changes. Made sure that exsting functions used the global and were not hard-wired.

File size: 10.4 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//
218// TODO -- make the number of pixels GLOBAL
219//
220Proc H_Setup_VSANS_DIV_Structure()
221       
222        NewDataFolder/O/S root:VSANS_DIV_file           
223
224        NewDataFolder/O/S root:VSANS_DIV_file:entry1           
225                Make/O/T/N=1    title   = "title of entry1"
226                Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00"
227                NewDataFolder/O/S root:VSANS_DIV_file:entry1:instrument         
228                        Make/O/T/N=1    name    = "NGB30mSANS"
229                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_B             
230                        Make/O/I/N=(320,320)    data    = trunc(abs(gnoise(p+q)))
231                        Make/O/D/N=(320,320)    error   = 0.01*abs(gnoise(p+q))
232                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_MR           
233                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
234                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
235                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_ML           
236                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
237                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
238                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_MT           
239                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
240                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
241                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_MB           
242                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
243                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
244                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FR           
245                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
246                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
247                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FL           
248                        Make/O/I/N=(48,256)     data    = trunc(abs(gnoise(p+q)))
249                        Make/O/D/N=(48,256)     error   = 0.01*abs(gnoise(p+q))
250                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FT           
251                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
252                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
253                NewDataFolder/O/S root:VSANS_DIV_file:entry1:data_FB           
254                        Make/O/I/N=(128,48)     data    = trunc(abs(gnoise(p+q)))
255                        Make/O/D/N=(128,48)     error   = 0.01*abs(gnoise(p+q))
256                       
257        SetDataFolder root:
258
259End
Note: See TracBrowser for help on using the repository browser.