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

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

a lot of little changes:

changed the name of the Raw Data display procedure file (removed test)

lots of bug fixes, moving items from the macros menu to proper locations, getting the file status to display properly, some error checking, and cleaning up a few TODO items.

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