source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf @ 1022

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

ADDED:

included common NCNR procedures for the PlotManager?, to allow plotting of 1D data sets using a familiar interface

greatly expanded Patch functionality to include input in the multiple sections of the Nexus file, including separate panels to handle patching of waves to the file - needed for non-linear coefficients, dead time, and XY beam centers. All patch operations are expandable as more fields become necessary to patch.

removed bug of group_id being defined in /reduction and in /sample (removed R/W that referenced /reduction)

added panel to "isolate" a single detector panel, allowing the corrections to be applied/removed/recalculated as needed to directly see their effects.

linked new procedures to their appropriate action buttons

Added more data fields (label, intent, etc.) to the VCALC to Nexus data writer to get more realistic values into the fake data files for testing

Added VCALC simulation functions with EMP and BGD in anticipation of testing the CORRECT step

more little bug and documentation fixes which I can't remember, but they are all important...

File size: 7.7 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3
4
5
6//////// function to take VCALC information and
7// fill in the simulated information as needed to make a "fake" data file
8//
9// TODO:
10// -- identify all of the necessary bits to change
11// -- maybe want a panel to make it easier to decide what inputs to change in the file
12// -- decide if it's better to write wholesale, or as individual waves
13//
14Macro Copy_VCALC_to_VSANSFile(labelStr,intent,group_id)
15        String labelStr = "sample label"
16        String intent = "SAMPLE"
17        variable group_id = 75
18       
19        String fileName = V_DoSaveFileDialog("pick the file to write to")
20        print fileName
21//     
22        if(strlen(fileName) > 0)
23                writeVCALC_to_file(fileName,labelStr,intent,group_id)
24        endif
25End
26
27//
28// TODO -- fill this in as needed to get fake data that's different
29//
30Function writeVCALC_to_file(fileName,labelStr,intent,group_id)
31        String fileName,labelStr,intent
32        Variable group_id
33
34
35// the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels
36// the data itself (as INT32)
37// the front SDD (correct units)
38// the middle SDD (correct units)
39// the back SDD (correct units)
40        Variable ii,val,sumCts=0
41        String detStr
42        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1)
43                detStr = StringFromList(ii, ksDetectorListAll, ";")
44                Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData
45                Redimension/I tmpData
46                tmpData = (tmpData ==   2147483647) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer
47                V_writeDetectorData(fileName,detStr,tmpData)
48               
49                val = VCALC_getSDD(detStr)*100          // make sure value is in cm
50                print val
51                V_writeDet_distance(fileName,detStr,val)
52               
53                val = VCALC_getTopBottomSDDOffset(detStr)               //val is in mm, as for data file
54                if(val != 0)
55                        V_writeDet_TBSetback(fileName,detStr,val)
56                endif
57               
58                // x and y pixel sizes for each detector should be correct in the "base" file - but if not...
59                //Function VCALC_getPixSizeX(type)              // returns the pixel X size, in [cm]
60                //Function VCALC_getPixSizeY(type)
61                V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10)           // data file is expecting mm
62                V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10)
63       
64                // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels()
65                V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr))
66                V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr))
67               
68               
69                // the calibration data for each detector (except B) is already correct in the "base" file
70                //V_writeDetTube_spatialCalib(fname,detStr,inW)
71                // and for "B"
72                //V_writeDet_cal_x(fname,detStr,inW)
73                //V_writeDet_cal_y(fname,detStr,inW)
74               
75                               
76                // the dead time for each detector is already correct in the "base" file
77                // V_writeDetector_deadtime(fname,detStr,inW)
78                // TODO: need a new, separate function to write the single deadtime value in/out of "B"
79               
80                // integrated count value on each detector bank
81                sumCts += sum(tmpData)
82                V_writeDet_IntegratedCount(fileName,detStr,sum(tmpData))
83
84        endfor
85
86       
87// writes out "perfect" detector calibration constants for all 8 tube banks
88        V_WritePerfectSpatialCalib(filename)
89// writes out "perfect" dead time constants for all 8 tube banks + back detector
90        V_WritePerfectDeadTime(filename)
91       
92//? other detector geometry - lateral separation?
93
94// the wavelength
95//      Variable lam = V_getWavelength("VCALC")         //doesn't work, the corresponding folder in VCALC has not been defined
96        V_writeWavelength(fileName,VCALC_getWavelength())
97
98       
99// fake the information about the count setup, so I have different numbers to read
100// count time = fake time of 100 s
101        V_writeCount_time(fileName,100)
102
103        // monitor count (= imon)
104                // returns the number of neutrons on the sample
105                //Function VCALC_getImon()
106        V_writeMonitorCount(fileName,VCALC_getImon())
107
108        // total detector count (sum of everything)
109        V_writeDetector_counts(fileName,sumCts)
110
111        // sample description
112        V_writeSampleDescription(fileName,labelStr)
113       
114        // reduction intent
115        V_writeReductionIntent(fileName,intent)
116       
117        // reduction group_id
118        // TODO - skip for now. group_id is incorrectly written to the data file as a text value. trac ticket
119        //        has been written to fix in the future.
120//      V_writeReduction_group_ID(fileName,group_id)
121
122
123
124// ?? anything else that I'd like to see on the catalog - I could change them here to see different values
125// different collimation types?
126//
127
128
129
130        return(0)
131end
132
133
134
135
136// writes out "perfect" detector calibration constants for all 8 tube banks + back detector
137Function V_WritePerfectSpatialCalib(filename)
138        String filename
139       
140//      String fileName = V_DoSaveFileDialog("pick the file to write to")
141       
142        Make/O/D/N=(3,48) tmpCalib
143        // for the "tall" L/R banks
144        tmpCalib[0][] = -512
145        tmpCalib[1][] = 8
146        tmpCalib[2][] = 0
147       
148        V_writeDetTube_spatialCalib(filename,"FR",tmpCalib)
149        V_writeDetTube_spatialCalib(filename,"FL",tmpCalib)
150        V_writeDetTube_spatialCalib(filename,"MR",tmpCalib)
151        V_writeDetTube_spatialCalib(filename,"ML",tmpCalib)
152
153        // for the "short" T/B banks
154        tmpCalib[0][] = -256
155        tmpCalib[1][] = 4
156        tmpCalib[2][] = 0
157       
158        V_writeDetTube_spatialCalib(filename,"FT",tmpCalib)
159        V_writeDetTube_spatialCalib(filename,"FB",tmpCalib)
160        V_writeDetTube_spatialCalib(filename,"MT",tmpCalib)
161        V_writeDetTube_spatialCalib(filename,"MB",tmpCalib)
162       
163        KillWaves tmpCalib
164       
165        // and for the back detector "B"
166        Make/O/D/N=3 tmpCalib
167        tmpCalib[0] = 1
168        tmpCalib[1] = 1
169        tmpcalib[2] = 10000
170        V_writeDet_cal_x(filename,"B",tmpCalib)
171        V_writeDet_cal_y(filename,"B",tmpCalib)
172
173        KillWaves tmpCalib
174
175        return(0)
176end
177
178// TODO -- need a function to write out "bad" and "perfect" dead time values
179// to the HDF file
180//V_writeDetector_deadtime(fname,detStr,inW)
181//V_writeDetector_deadtime_B(fname,detStr,val)
182// simulated count rate per tube can be Å 10^8, so I need dt >> 10^-15 to completely cancel this out
183// (partly due to fake I(q), fake count time in file...)
184
185// writes out "perfect" dead time constants for all 8 tube banks + back detector
186Function V_WritePerfectDeadTime(filename)
187        String filename
188               
189        Make/O/D/N=(48) tmpDT
190        tmpDT = 1e-18
191        V_writeDetector_deadtime(filename,"FT",tmpDT)
192        V_writeDetector_deadtime(filename,"FB",tmpDT)
193        V_writeDetector_deadtime(filename,"FL",tmpDT)
194        V_writeDetector_deadtime(filename,"FR",tmpDT)
195        V_writeDetector_deadtime(filename,"MT",tmpDT)
196        V_writeDetector_deadtime(filename,"MB",tmpDT)
197        V_writeDetector_deadtime(filename,"ML",tmpDT)
198        V_writeDetector_deadtime(filename,"MR",tmpDT)
199
200
201        // and for the back detector "B", a single value, not a wave
202        V_writeDetector_deadtime_B(filename,"B",1e-20)
203
204        KillWaves tmpDT
205
206        return(0)
207end
208
209
210Function V_FakeBeamCenters()
211// fake beam center values
212        V_putDet_beam_center_x("RAW","B",75)
213        V_putDet_beam_center_y("RAW","B",75)
214
215        V_putDet_beam_center_x("RAW","MB",64)
216        V_putDet_beam_center_y("RAW","MB",55)
217        V_putDet_beam_center_x("RAW","MT",64)
218        V_putDet_beam_center_y("RAW","MT",-8.1)
219        V_putDet_beam_center_x("RAW","MR",-8.1)
220        V_putDet_beam_center_y("RAW","MR",64)
221        V_putDet_beam_center_x("RAW","ML",55)
222        V_putDet_beam_center_y("RAW","ML",64)
223
224        V_putDet_beam_center_x("RAW","FB",64)
225        V_putDet_beam_center_y("RAW","FB",55)
226        V_putDet_beam_center_x("RAW","FT",64)
227        V_putDet_beam_center_y("RAW","FT",-8.7)
228        V_putDet_beam_center_x("RAW","FR",-8.1)
229        V_putDet_beam_center_y("RAW","FR",64)
230        V_putDet_beam_center_x("RAW","FL",55)
231        V_putDet_beam_center_y("RAW","FL",64)
232       
233        return(0)
234end
235
236Function V_FakeScaleToCenter()
237
238        V_RescaleToBeamCenter("RAW","MB",64,55)
239        V_RescaleToBeamCenter("RAW","MT",64,-8.7)
240        V_RescaleToBeamCenter("RAW","MR",-8.1,64)
241        V_RescaleToBeamCenter("RAW","ML",55,64)
242        V_RescaleToBeamCenter("RAW","FL",55,64)
243        V_RescaleToBeamCenter("RAW","FR",-8.1,64)
244        V_RescaleToBeamCenter("RAW","FT",64,-8.7)
245        V_RescaleToBeamCenter("RAW","FB",64,55)
246       
247        return(0)
248End
Note: See TracBrowser for help on using the repository browser.