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

Last change on this file since 1081 was 1081, checked in by srkline, 5 years ago

additions to VCALC procedures to correctly account for panel motion (individual, not symmetric). Updated the plotting routines to all (mostly) pass through the same subroutines so that additional averaging modes will be easier to add.

File size: 9.4 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//
14Proc 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                //
47                // before, NaN became ugly integer -- now it seems to show up as -1?
48                // then, the "fake" error becomes NaN
49                tmpData = (tmpData ==   2147483647) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer
50                tmpData = (tmpData ==   -1) ? 0 : tmpData               //the NaN "mask" in the sim data (T/B only)shows up as -1
51                V_writeDetectorData(fileName,detStr,tmpData)
52               
53                val = VCALC_getSDD(detStr)              // make sure value is in cm
54                print val
55                V_writeDet_distance(fileName,detStr,val)
56               
57                val = VCALC_getTopBottomSDDSetback(detStr)*10           //val is in mm, as for data file
58                if(val != 0)
59                        V_writeDet_TBSetback(fileName,detStr,val)
60                endif
61               
62                // returns the total separation (assumed symmetric) in cm
63                val = VCALC_getPanelTranslation(detStr)         
64                // it's OK to call both of these. these functions check detStr for the correct value
65                if(cmpstr("T",detStr[1]) == 0 || cmpstr("B",detStr[1]) == 0)
66                        V_writeDet_LateralOffset(fileName,detStr,val)           // T/B panels
67                else
68                        V_writeDet_VerticalOffset(fileName,detStr,val)          //  L/R panels, or back detector
69                endif
70                // x and y pixel sizes for each detector should be correct in the "base" file - but if not...
71                //Function VCALC_getPixSizeX(type)              // returns the pixel X size, in [cm]
72                //Function VCALC_getPixSizeY(type)
73                V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10)           // data file is expecting mm
74                V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10)
75       
76                // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels()
77                if(kBCTR_CM)
78                //  -- now write out the beam center in cm, not pixels
79                        V_writeDet_beam_center_x(fileName,detStr,0)
80                        V_writeDet_beam_center_y(fileName,detStr,0)
81                else
82                        V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr))
83                        V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr))       
84                endif
85
86                if(cmpstr(detStr,"B") == 0)
87                        //always write out the center of the detector since this is dummy data
88                        V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr))
89                        V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr))                               
90                endif
91
92               
93               
94                // the calibration data for each detector (except B) is already correct in the "base" file
95                //V_writeDetTube_spatialCalib(fname,detStr,inW)
96                // and for "B"
97                //V_writeDet_cal_x(fname,detStr,inW)
98                //V_writeDet_cal_y(fname,detStr,inW)
99               
100                               
101                // the dead time for each detector is already correct in the "base" file
102                // V_writeDetector_deadtime(fname,detStr,inW)
103                // TODO: need a new, separate function to write the single deadtime value in/out of "B"
104               
105                // integrated count value on each detector bank
106                sumCts += sum(tmpData)
107                V_writeDet_IntegratedCount(fileName,detStr,sum(tmpData))
108
109        endfor
110
111       
112// writes out "perfect" detector calibration constants for all 8 tube banks
113        V_WritePerfectSpatialCalib(filename)
114// writes out "perfect" dead time constants for all 8 tube banks + back detector
115        V_WritePerfectDeadTime(filename)
116       
117//? other detector geometry - lateral separation?
118
119// the wavelength
120//      Variable lam = V_getWavelength("VCALC")         //doesn't work, the corresponding folder in VCALC has not been defined
121        V_writeWavelength(fileName,VCALC_getWavelength())
122
123       
124// fake the information about the count setup, so I have different numbers to read
125// count time = fake time of 100 s
126        V_writeCount_time(fileName,100)
127
128        // monitor count (= imon)
129                // returns the number of neutrons on the sample
130                //Function VCALC_getImon()
131        V_writeMonitorCount(fileName,VCALC_getImon())
132
133        // total detector count (sum of everything)
134        V_writeDetector_counts(fileName,sumCts)
135
136        // sample description
137        V_writeSampleDescription(fileName,labelStr)
138       
139        // reduction intent
140        V_writeReductionIntent(fileName,intent)
141       
142        // reduction group_id
143        // TODO x- (file has been corected)skip for now. group_id is incorrectly written to the data file as a text value. trac ticket
144        //        has been written to fix in the future.
145        V_writeSample_GroupID(fileName,group_id)
146
147
148
149// ?? anything else that I'd like to see on the catalog - I could change them here to see different values
150// different collimation types?
151//
152
153
154
155        return(0)
156end
157
158
159
160// writes out "perfect" detector calibration constants for all 8 tube banks + back detector
161Function V_WritePerfectSpatialCalib(filename)
162        String filename
163       
164//      String fileName = V_DoSaveFileDialog("pick the file to write to")
165       
166        Make/O/D/N=(3,48) tmpCalib
167        // for the "tall" L/R banks
168        tmpCalib[0][] = -512
169        tmpCalib[1][] = 8
170        tmpCalib[2][] = 0
171       
172        V_writeDetTube_spatialCalib(filename,"FR",tmpCalib)
173        V_writeDetTube_spatialCalib(filename,"FL",tmpCalib)
174        V_writeDetTube_spatialCalib(filename,"MR",tmpCalib)
175        V_writeDetTube_spatialCalib(filename,"ML",tmpCalib)
176
177        // for the "short" T/B banks
178        tmpCalib[0][] = -256
179        tmpCalib[1][] = 4
180        tmpCalib[2][] = 0
181       
182        V_writeDetTube_spatialCalib(filename,"FT",tmpCalib)
183        V_writeDetTube_spatialCalib(filename,"FB",tmpCalib)
184        V_writeDetTube_spatialCalib(filename,"MT",tmpCalib)
185        V_writeDetTube_spatialCalib(filename,"MB",tmpCalib)
186       
187        KillWaves tmpCalib
188       
189        // and for the back detector "B"
190        Make/O/D/N=3 tmpCalib
191        tmpCalib[0] = 1
192        tmpCalib[1] = 1
193        tmpcalib[2] = 10000
194        V_writeDet_cal_x(filename,"B",tmpCalib)
195        V_writeDet_cal_y(filename,"B",tmpCalib)
196
197        KillWaves tmpCalib
198
199        return(0)
200end
201
202// TODO -- need a function to write out "bad" and "perfect" dead time values
203// to the HDF file
204//V_writeDetector_deadtime(fname,detStr,inW)
205//V_writeDetector_deadtime_B(fname,detStr,val)
206// simulated count rate per tube can be Å 10^8, so I need dt >> 10^-15 to completely cancel this out
207// (partly due to fake I(q), fake count time in file...)
208
209// writes out "perfect" dead time constants for all 8 tube banks + back detector
210Function V_WritePerfectDeadTime(filename)
211        String filename
212               
213        Make/O/D/N=(48) tmpDT
214        tmpDT = 1e-18
215        V_writeDetector_deadtime(filename,"FT",tmpDT)
216        V_writeDetector_deadtime(filename,"FB",tmpDT)
217        V_writeDetector_deadtime(filename,"FL",tmpDT)
218        V_writeDetector_deadtime(filename,"FR",tmpDT)
219        V_writeDetector_deadtime(filename,"MT",tmpDT)
220        V_writeDetector_deadtime(filename,"MB",tmpDT)
221        V_writeDetector_deadtime(filename,"ML",tmpDT)
222        V_writeDetector_deadtime(filename,"MR",tmpDT)
223
224
225        // and for the back detector "B", a single value, not a wave
226        V_writeDetector_deadtime_B(filename,"B",1e-20)
227
228        KillWaves tmpDT
229
230        return(0)
231end
232
233
234Function V_FakeBeamCenters()
235// fake beam center values
236        V_putDet_beam_center_x("RAW","B",75)
237        V_putDet_beam_center_y("RAW","B",75)
238
239        V_putDet_beam_center_x("RAW","MB",64)
240        V_putDet_beam_center_y("RAW","MB",55)
241        V_putDet_beam_center_x("RAW","MT",64)
242        V_putDet_beam_center_y("RAW","MT",-8.1)
243        V_putDet_beam_center_x("RAW","MR",-8.1)
244        V_putDet_beam_center_y("RAW","MR",64)
245        V_putDet_beam_center_x("RAW","ML",55)
246        V_putDet_beam_center_y("RAW","ML",64)
247
248        V_putDet_beam_center_x("RAW","FB",64)
249        V_putDet_beam_center_y("RAW","FB",55)
250        V_putDet_beam_center_x("RAW","FT",64)
251        V_putDet_beam_center_y("RAW","FT",-8.7)
252        V_putDet_beam_center_x("RAW","FR",-8.1)
253        V_putDet_beam_center_y("RAW","FR",64)
254        V_putDet_beam_center_x("RAW","FL",55)
255        V_putDet_beam_center_y("RAW","FL",64)
256       
257        return(0)
258end
259
260Function V_FakeScaleToCenter()
261
262        V_RescaleToBeamCenter("RAW","MB",64,55)
263        V_RescaleToBeamCenter("RAW","MT",64,-8.7)
264        V_RescaleToBeamCenter("RAW","MR",-8.1,64)
265        V_RescaleToBeamCenter("RAW","ML",55,64)
266        V_RescaleToBeamCenter("RAW","FL",55,64)
267        V_RescaleToBeamCenter("RAW","FR",-8.1,64)
268        V_RescaleToBeamCenter("RAW","FT",64,-8.7)
269        V_RescaleToBeamCenter("RAW","FB",64,55)
270       
271        return(0)
272End
273
274//
275// a few utilities to patch up the data files so that they are useable
276// even without the Back detector containing real data
277//
278// TODO
279//
280// Hopefully, the data files as generated from NICE will have a dummy for the back detector
281// if not, there's going to be a big mess
282//
283//              V_writeDetectorData(fileName,detStr,tmpData)
284//
285Function V_Write_BackDet_to_VSANSFile()
286       
287        String fileName = V_DoSaveFileDialog("pick the file to write to")
288        print fileName
289//     
290        String detStr = "B"
291       
292        if(strlen(fileName) > 0)
293                Wave detW = V_getDetectorDataW(filename,detStr)
294                detW = 1
295                V_writeDetectorData(fileName,detStr,detW)
296        endif
297End
298
Note: See TracBrowser for help on using the repository browser.