1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=5.0 |
---|
3 | #pragma IgorVersion=6.1 |
---|
4 | |
---|
5 | //************************** |
---|
6 | // |
---|
7 | // Vers. 1.2 092101 |
---|
8 | // Vers. 5.0 29MAR07 - branched from main reduction to split out facility |
---|
9 | // specific calls |
---|
10 | // |
---|
11 | // functions for reading raw data files from the VAX |
---|
12 | // - RAW data files are read into the RAW folder - integer data from the detector |
---|
13 | // is decompressed and given the proper orientation |
---|
14 | // - header information is placed into real,integer, or text waves in the order they appear |
---|
15 | // in the file header |
---|
16 | // |
---|
17 | // Work data (DIV File) is read into the DIV folder |
---|
18 | // |
---|
19 | //***************************** |
---|
20 | |
---|
21 | //simple, main entry procedure that will load a RAW sans data file (not a work file) |
---|
22 | //into the RAW dataFolder. It is up to the calling procedure to display the file |
---|
23 | // |
---|
24 | // called by MainPanel.ipf and ProtocolAsPanel.ipf |
---|
25 | // |
---|
26 | Function LoadRawSANSData(msgStr) |
---|
27 | String msgStr |
---|
28 | |
---|
29 | String filename="" |
---|
30 | |
---|
31 | //each routine is responsible for checking the current (displayed) data folder |
---|
32 | //selecting it, and returning to root when done |
---|
33 | PathInfo/S catPathName //should set the next dialog to the proper path... |
---|
34 | //get the filename, then read it in |
---|
35 | filename = PromptForPath(msgStr) //in SANS_Utils.ipf |
---|
36 | //check for cancel from dialog |
---|
37 | if(strlen(filename)==0) |
---|
38 | //user cancelled, abort |
---|
39 | SetDataFolder root: |
---|
40 | DoAlert 0, "No file selected, action aborted" |
---|
41 | return(1) |
---|
42 | Endif |
---|
43 | |
---|
44 | ReadHeaderAndData(filename) //this is the full Path+file |
---|
45 | |
---|
46 | Return(0) |
---|
47 | End |
---|
48 | |
---|
49 | |
---|
50 | //function that does the guts of reading the binary data file |
---|
51 | //fname is the full path:name;vers required to open the file |
---|
52 | // |
---|
53 | // The final root:RAW:data wave is the real |
---|
54 | //neutron counts and can be directly operated on |
---|
55 | // |
---|
56 | // header information is put into three waves: integersRead, realsRead, and textRead |
---|
57 | // logicals in the header are currently skipped, since they are no use in the |
---|
58 | // data reduction process. |
---|
59 | // |
---|
60 | // The output is the three R/T/I waves that are filled at least with minimal values |
---|
61 | // and the detector data loaded into an array named "data" |
---|
62 | // |
---|
63 | // see documentation for the expected information in each element of the R/T/I waves |
---|
64 | // and the minimum set of information. These waves can be increased in length so that |
---|
65 | // more information can be accessed as needed (propagating changes...) |
---|
66 | // |
---|
67 | // called by multiple .ipfs (when the file name is known) |
---|
68 | // |
---|
69 | // |
---|
70 | // THIS FUNCTION DOES NOT NEED TO BE MODIFIED. ONLY THE DATA ACCESSORS NEED TO BE CONSTRUCTED |
---|
71 | // |
---|
72 | Function ReadHeaderAndData(fname) |
---|
73 | String fname |
---|
74 | //this function is for reading in RAW data only, so it will always put data in RAW folder |
---|
75 | String curPath = "root:Packages:NIST:RAW:" |
---|
76 | SetDataFolder curPath //use the full path, so it will always work |
---|
77 | Variable/G root:Packages:NIST:RAW:gIsLogScale = 0 //initial state is linear, keep this in RAW folder |
---|
78 | |
---|
79 | Variable refNum,integer,realval |
---|
80 | String sansfname,textstr |
---|
81 | |
---|
82 | Make/O/D/N=23 $"root:Packages:NIST:RAW:IntegersRead" |
---|
83 | Make/O/D/N=52 $"root:Packages:NIST:RAW:RealsRead" |
---|
84 | Make/O/T/N=11 $"root:Packages:NIST:RAW:TextRead" |
---|
85 | Make/O/N=7 $"root:Packages:NIST:RAW:LogicalsRead" |
---|
86 | |
---|
87 | Wave intw=$"root:Packages:NIST:RAW:IntegersRead" |
---|
88 | Wave realw=$"root:Packages:NIST:RAW:RealsRead" |
---|
89 | Wave/T textw=$"root:Packages:NIST:RAW:TextRead" |
---|
90 | Wave logw=$"root:Packages:NIST:RAW:LogicalsRead" |
---|
91 | |
---|
92 | // FILL IN 3 ARRAYS WITH HEADER INFORMATION FOR LATER USE |
---|
93 | // THESE ARE JUST THE MINIMALLY NECESSARY VALUES |
---|
94 | |
---|
95 | // filename as stored in the file header |
---|
96 | textw[0]= fname |
---|
97 | |
---|
98 | // date and time of collection |
---|
99 | textw[1]= getFileCreationDate(fname) |
---|
100 | |
---|
101 | // run type identifier (this is a reader for RAW data) |
---|
102 | textw[2]= "RAW" |
---|
103 | |
---|
104 | // user account identifier (currently used only for NCNR-specific operations) |
---|
105 | textw[3]= "" |
---|
106 | |
---|
107 | // sample label |
---|
108 | textw[6]= getSampleLabel(fname) |
---|
109 | |
---|
110 | // identifier of detector type, useful for setting detector constants |
---|
111 | //(currently used only for NCNR-specific operations) |
---|
112 | textw[9]= "" |
---|
113 | |
---|
114 | //total counting time in seconds |
---|
115 | intw[2] = getCountTime(fname) |
---|
116 | |
---|
117 | |
---|
118 | // total monitor count |
---|
119 | realw[0] = getMonitorCount(fname) |
---|
120 | |
---|
121 | // total detector count |
---|
122 | realw[2] = getDetCount(fname) |
---|
123 | |
---|
124 | // attenuator number (NCNR-specific, your stub returns 0) |
---|
125 | // may also be used to hold attenuator transmission (< 1) |
---|
126 | realw[3] = getAttenNumber(fname) |
---|
127 | |
---|
128 | // sample transmission |
---|
129 | realw[4] = getSampleTrans(fname) |
---|
130 | |
---|
131 | //sample thickness (cm) |
---|
132 | realw[5] = getSampleThickness(fname) |
---|
133 | |
---|
134 | // following 6 values are for non-linear spatial corrections to a detector (RC timing) |
---|
135 | // these values are set for a detctor that has a linear correspondence between |
---|
136 | // pixel number and real-space distance |
---|
137 | // 10 and 13 are the X and Y pixel dimensions, respectively (in mm!) |
---|
138 | //(11,12 and 13,14 are set to values for a linear response, as from a new Ordela detector) |
---|
139 | realw[10] = getDetectorPixelXSize(fname) |
---|
140 | realw[11] = 10000 |
---|
141 | realw[12] = 0 |
---|
142 | realw[13] = getDetectorPixelYSize(fname) |
---|
143 | realw[14] = 10000 |
---|
144 | realw[15] = 0 |
---|
145 | |
---|
146 | // beam center X,Y on the detector (in units of pixel coordinates (1,N)) |
---|
147 | realw[16] = getBeamXPos(fname) |
---|
148 | realw[17] = getBeamYPos(fname) |
---|
149 | |
---|
150 | // sample to detector distance (meters) |
---|
151 | realw[18] = getSDD(fname) |
---|
152 | |
---|
153 | // detector physical width (right now assumes square...) (in cm) |
---|
154 | realw[20] = 65 |
---|
155 | |
---|
156 | // beam stop diameter (assumes circular) (in mm) |
---|
157 | realw[21] = getBSDiameter(fname) |
---|
158 | |
---|
159 | // source aperture diameter (mm) |
---|
160 | realw[23] = getSourceApertureDiam(fname) |
---|
161 | |
---|
162 | // sample aperture diameter (mm) |
---|
163 | realw[24] = getSampleApertureDiam(fname) |
---|
164 | |
---|
165 | // source aperture to sample aperture distance |
---|
166 | realw[25] = getSourceToSampleDist(fname) |
---|
167 | |
---|
168 | // wavelength (A) |
---|
169 | realw[26] = getWavelength(fname) |
---|
170 | |
---|
171 | // wavelength spread (FWHM) |
---|
172 | realw[27] = getWavelengthSpread(fname) |
---|
173 | |
---|
174 | // beam stop X-position (motor reading, approximate cm from zero position) |
---|
175 | // currently NCNR-specific use to identify transmission measurements |
---|
176 | // you return 0 |
---|
177 | realw[37] = 0 |
---|
178 | |
---|
179 | // the actual data array, dimensions are set as globals in |
---|
180 | // InitFacilityGlobals() |
---|
181 | NVAR XPix = root:myGlobals:gNPixelsX |
---|
182 | NVAR YPix = root:myGlobals:gNPixelsX |
---|
183 | |
---|
184 | Make/D/O/N=(XPix,YPix) $"root:RAW:data" |
---|
185 | WAVE data=$"root:RAW:data" |
---|
186 | |
---|
187 | // fill the data array with the detector values |
---|
188 | getDetectorData(fname,data) |
---|
189 | |
---|
190 | //keep a string with the filename in the RAW folder |
---|
191 | String/G root:RAW:fileList = textw[0] |
---|
192 | |
---|
193 | Return 0 |
---|
194 | |
---|
195 | End |
---|
196 | |
---|
197 | //**************** |
---|
198 | //main entry procedure for reading a "WORK.DIV" file |
---|
199 | //displays a quick image of the file, to check that it's correct |
---|
200 | //data is deposited in root:Packages:NIST:DIV data folder |
---|
201 | // |
---|
202 | // local, currently unused |
---|
203 | // |
---|
204 | // |
---|
205 | Proc ReadWork_DIV() |
---|
206 | |
---|
207 | String fname = PromptForPath("Select detector sensitivity file") |
---|
208 | ReadHeaderAndWork("DIV",fname) //puts what is read in work.div |
---|
209 | |
---|
210 | String waveStr = "root:Packages:NIST:DIV:data" |
---|
211 | // NewImage/F/K=1/S=2 $waveStr //this is an experimental IGOR operation |
---|
212 | // ModifyImage '' ctab= {*,*,YellowHot,0} |
---|
213 | //Display;AppendImage $waveStr |
---|
214 | |
---|
215 | //change the title string to WORK.DIV, rather than PLEXnnn_TST_asdfa garbage |
---|
216 | // String/G root:Packages:NIST:DIV:fileList = "WORK.DIV" |
---|
217 | ChangeDisplay("DIV") |
---|
218 | |
---|
219 | SetDataFolder root: //(redundant) |
---|
220 | End |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | // Detector sensitivity files have the same header structure as RAW SANS data |
---|
225 | // as NCNR, just with a different data array (real, rather than integer data) |
---|
226 | // |
---|
227 | // So for your facility, make this reader specific to the format of whatever |
---|
228 | // file you use for a pixel-by-pixel division of the raw detector data |
---|
229 | // to correct for non-uniform sensitivities of the detector. This is typically a |
---|
230 | // measurement of water, plexiglas, or another uniform scattering sample. |
---|
231 | // |
---|
232 | // The data must be normalized to a mean value of 1 |
---|
233 | // |
---|
234 | // called from ProtocolAsPanel.ipf |
---|
235 | // |
---|
236 | // type is "DIV" on input |
---|
237 | Function ReadHeaderAndWork(type,fname) |
---|
238 | String type,fname |
---|
239 | |
---|
240 | //type is the desired folder to read the workfile to |
---|
241 | //this data will NOT be automatically displayed |
---|
242 | // gDataDisplayType is unchanged |
---|
243 | |
---|
244 | String cur_folder = type |
---|
245 | String curPath = "root:Packages:NIST:"+cur_folder |
---|
246 | SetDataFolder curPath //use the full path, so it will always work |
---|
247 | |
---|
248 | Variable refNum,integer,realval |
---|
249 | String sansfname,textstr |
---|
250 | Variable/G $(curPath + ":gIsLogScale") = 0 //initial state is linear, keep this in DIV folder |
---|
251 | |
---|
252 | Make/O/D/N=23 $(curPath + ":IntegersRead") |
---|
253 | Make/O/D/N=52 $(curPath + ":RealsRead") |
---|
254 | Make/O/T/N=11 $(curPath + ":TextRead") |
---|
255 | |
---|
256 | WAVE intw=$(curPath + ":IntegersRead") |
---|
257 | WAVE realw=$(curPath + ":RealsRead") |
---|
258 | WAVE/T textw=$(curPath + ":TextRead") |
---|
259 | |
---|
260 | // the actual data array, dimensions are set as globals in |
---|
261 | // InitFacilityGlobals() |
---|
262 | NVAR XPix = root:myGlobals:gNPixelsX |
---|
263 | NVAR YPix = root:myGlobals:gNPixelsX |
---|
264 | |
---|
265 | Make/O/D/N=(XPix,YPix) $(curPath + ":data") |
---|
266 | WAVE data = $(curPath + ":data") |
---|
267 | |
---|
268 | |
---|
269 | // (1) |
---|
270 | // fill in your reader for the header here so that intw, realw, and textW are filled in |
---|
271 | // ? possibly a duplication of the raw data reader |
---|
272 | |
---|
273 | |
---|
274 | |
---|
275 | //(2) |
---|
276 | // then fill in a reader for the data array that will DIVIDE your data |
---|
277 | // to get the corrected values. |
---|
278 | |
---|
279 | |
---|
280 | |
---|
281 | |
---|
282 | //keep a string with the filename in the DIV folder |
---|
283 | String/G $(curPath + ":fileList") = textw[0] |
---|
284 | |
---|
285 | //return the data folder to root |
---|
286 | SetDataFolder root: |
---|
287 | |
---|
288 | Return(0) |
---|
289 | End |
---|
290 | |
---|
291 | |
---|
292 | |
---|
293 | ///// ASC FORMAT READER ////// |
---|
294 | ///// FOR WORKFILE MATH PANEL ////// |
---|
295 | // |
---|
296 | //function to read in the ASC output of SANS reduction |
---|
297 | // currently the file has 20 header lines, followed by a single column |
---|
298 | // of 16384 values, Data is written by row, starting with Y=1 and X=(1->128) |
---|
299 | // |
---|
300 | //returns 0 if read was ok |
---|
301 | //returns 1 if there was an error |
---|
302 | // |
---|
303 | // called by WorkFileUtils.ipf |
---|
304 | // |
---|
305 | // |
---|
306 | // If the ASC data was generated by the NCNR data writer, then |
---|
307 | // NOTHING NEEDS TO BE CHANGED HERE |
---|
308 | // |
---|
309 | Function ReadASCData(fname,destPath) |
---|
310 | String fname, destPath |
---|
311 | //this function is for reading in ASCII data so put data in user-specified folder |
---|
312 | SetDataFolder "root:Packages:NIST:"+destPath |
---|
313 | |
---|
314 | NVAR pixelsX = root:myGlobals:gNPixelsX |
---|
315 | NVAR pixelsY = root:myGlobals:gNPixelsY |
---|
316 | Variable refNum=0,ii,p1,p2,tot,num=pixelsX,numHdrLines=20 |
---|
317 | String str="" |
---|
318 | //data is initially linear scale |
---|
319 | Variable/G :gIsLogScale=0 |
---|
320 | Make/O/T/N=(numHdrLines) hdrLines |
---|
321 | Make/O/D/N=(pixelsX*pixelsY) data //,linear_data |
---|
322 | |
---|
323 | //full filename and path is now passed in... |
---|
324 | //actually open the file |
---|
325 | // SetDataFolder destPath |
---|
326 | Open/R/Z refNum as fname // /Z flag means I must handle open errors |
---|
327 | if(refnum==0) //FNF error, get out |
---|
328 | DoAlert 0,"Could not find file: "+fname |
---|
329 | Close/A |
---|
330 | SetDataFolder root: |
---|
331 | return(1) |
---|
332 | endif |
---|
333 | if(V_flag!=0) |
---|
334 | DoAlert 0,"File open error: V_flag="+num2Str(V_Flag) |
---|
335 | Close/A |
---|
336 | SetDataFolder root: |
---|
337 | return(1) |
---|
338 | Endif |
---|
339 | // |
---|
340 | for(ii=0;ii<numHdrLines;ii+=1) //read (or skip) 18 header lines |
---|
341 | FReadLine refnum,str |
---|
342 | hdrLines[ii]=str |
---|
343 | endfor |
---|
344 | // |
---|
345 | Close refnum |
---|
346 | |
---|
347 | // SetDataFolder destPath |
---|
348 | LoadWave/Q/G/D/N=temp fName |
---|
349 | Wave/Z temp0=temp0 |
---|
350 | data=temp0 |
---|
351 | Redimension/N=(pixelsX,pixelsY) data //,linear_data |
---|
352 | |
---|
353 | //linear_data = data |
---|
354 | |
---|
355 | KillWaves/Z temp0 |
---|
356 | |
---|
357 | //return the data folder to root |
---|
358 | SetDataFolder root: |
---|
359 | |
---|
360 | Return(0) |
---|
361 | End |
---|
362 | |
---|
363 | // fills the "default" fake header so that the SANS Reduction machinery does not have to be altered |
---|
364 | // pay attention to what is/not to be trusted due to "fake" information. |
---|
365 | // uses what it can from the header lines from the ASC file (hdrLines wave) |
---|
366 | // |
---|
367 | // destFolder is of the form "myGlobals:WorkMath:AAA" |
---|
368 | // |
---|
369 | // |
---|
370 | // called by WorkFileUtils.ipf |
---|
371 | // |
---|
372 | // If the ASC data was generated by the NCNR data writer, then |
---|
373 | // NOTHING NEEDS TO BE CHANGED HERE |
---|
374 | // |
---|
375 | Function FillFakeHeader_ASC(destFolder) |
---|
376 | String destFolder |
---|
377 | Make/O/D/N=23 $("root:Packages:NIST:"+destFolder+":IntegersRead") |
---|
378 | Make/O/D/N=52 $("root:Packages:NIST:"+destFolder+":RealsRead") |
---|
379 | Make/O/T/N=11 $("root:Packages:NIST:"+destFolder+":TextRead") |
---|
380 | |
---|
381 | Wave intw=$("root:Packages:NIST:"+destFolder+":IntegersRead") |
---|
382 | Wave realw=$("root:Packages:NIST:"+destFolder+":RealsRead") |
---|
383 | Wave/T textw=$("root:Packages:NIST:"+destFolder+":TextRead") |
---|
384 | |
---|
385 | //Put in appropriate "fake" values |
---|
386 | //parse values as needed from headerLines |
---|
387 | Wave/T hdr=$("root:Packages:NIST:"+destFolder+":hdrLines") |
---|
388 | Variable monCt,lam,offset,sdd,trans,thick |
---|
389 | Variable xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam |
---|
390 | String detTyp="" |
---|
391 | String tempStr="",formatStr="",junkStr="" |
---|
392 | formatStr = "%g %g %g %g %g %g" |
---|
393 | tempStr=hdr[3] |
---|
394 | sscanf tempStr, formatStr, monCt,lam,offset,sdd,trans,thick |
---|
395 | // Print monCt,lam,offset,sdd,trans,thick,avStr,step |
---|
396 | formatStr = "%g %g %g %g %g %g %g %s" |
---|
397 | tempStr=hdr[5] |
---|
398 | sscanf tempStr,formatStr,xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp |
---|
399 | // Print xCtr,yCtr,a1,a2,a1a2Dist,dlam,bsDiam,detTyp |
---|
400 | |
---|
401 | realw[16]=xCtr //xCtr(pixels) |
---|
402 | realw[17]=yCtr //yCtr (pixels) |
---|
403 | realw[18]=sdd //SDD (m) |
---|
404 | realw[26]=lam //wavelength (A) |
---|
405 | // |
---|
406 | // necessary values |
---|
407 | realw[10]=5 //detector calibration constants, needed for averaging |
---|
408 | realw[11]=10000 |
---|
409 | realw[12]=0 |
---|
410 | realw[13]=5 |
---|
411 | realw[14]=10000 |
---|
412 | realw[15]=0 |
---|
413 | // |
---|
414 | // used in the resolution calculation, ONLY here to keep the routine from crashing |
---|
415 | realw[20]=65 //det size |
---|
416 | realw[27]=dlam //delta lambda |
---|
417 | realw[21]=bsDiam //BS size |
---|
418 | realw[23]=a1 //A1 |
---|
419 | realw[24]=a2 //A2 |
---|
420 | realw[25]=a1a2Dist //A1A2 distance |
---|
421 | realw[4]=trans //trans |
---|
422 | realw[3]=0 //atten |
---|
423 | realw[5]=thick //thick |
---|
424 | // |
---|
425 | // |
---|
426 | realw[0]=monCt //def mon cts |
---|
427 | |
---|
428 | // fake values to get valid deadtime and detector constants |
---|
429 | // |
---|
430 | textw[9]=detTyp+" " //6 characters 4+2 spaces |
---|
431 | textw[3]="[NGxSANS00]" //11 chars, NGx will return default values for atten trans, deadtime... |
---|
432 | |
---|
433 | //set the string values |
---|
434 | formatStr="FILE: %s CREATED: %s" |
---|
435 | sscanf hdr[0],formatStr,tempStr,junkStr |
---|
436 | // Print tempStr |
---|
437 | // Print junkStr |
---|
438 | String/G $("root:Packages:NIST:"+destFolder+":fileList") = tempStr |
---|
439 | textw[0] = tempStr //filename |
---|
440 | textw[1] = junkStr //run date-time |
---|
441 | |
---|
442 | //file label = hdr[1] |
---|
443 | tempStr = hdr[1] |
---|
444 | tempStr = tempStr[0,strlen(tempStr)-2] //clean off the last LF |
---|
445 | // Print tempStr |
---|
446 | textW[6] = tempStr //sample label |
---|
447 | |
---|
448 | return(0) |
---|
449 | End |
---|
450 | |
---|
451 | |
---|
452 | ///////// ACCESSORS FOR WRITING DATA TO HEADER ///////// |
---|
453 | ///// |
---|
454 | |
---|
455 | // Write* routines all must: |
---|
456 | // (1) open file "fname". fname is a full file path and name to the file on disk |
---|
457 | // (2) write the specified value to the header at the correct location in the file |
---|
458 | // (3) close the file |
---|
459 | |
---|
460 | //sample transmission (0<T<=1) |
---|
461 | Function WriteTransmissionToHeader(fname,trans) |
---|
462 | String fname |
---|
463 | Variable trans |
---|
464 | |
---|
465 | // your writer here |
---|
466 | |
---|
467 | return(0) |
---|
468 | End |
---|
469 | |
---|
470 | //whole transmission is NCNR-specific right now |
---|
471 | // leave this stub empty |
---|
472 | Function WriteWholeTransToHeader(fname,trans) |
---|
473 | String fname |
---|
474 | Variable trans |
---|
475 | |
---|
476 | // do nothing for now |
---|
477 | |
---|
478 | return(0) |
---|
479 | End |
---|
480 | |
---|
481 | //box sum counts is a real value |
---|
482 | // used for transmission calculation module |
---|
483 | Function WriteBoxCountsToHeader(fname,counts) |
---|
484 | String fname |
---|
485 | Variable counts |
---|
486 | |
---|
487 | // do nothing if not using NCNR Transmission module |
---|
488 | |
---|
489 | return(0) |
---|
490 | End |
---|
491 | |
---|
492 | //beam stop X-position |
---|
493 | // used for transmission module to manually tag transmission files |
---|
494 | Function WriteBSXPosToHeader(fname,xpos) |
---|
495 | String fname |
---|
496 | Variable xpos |
---|
497 | |
---|
498 | // do nothing if not using NCNR Transmission module |
---|
499 | |
---|
500 | return(0) |
---|
501 | End |
---|
502 | |
---|
503 | //sample thickness in cm |
---|
504 | Function WriteThicknessToHeader(fname,num) |
---|
505 | String fname |
---|
506 | Variable num |
---|
507 | |
---|
508 | // your code here |
---|
509 | |
---|
510 | return(0) |
---|
511 | End |
---|
512 | |
---|
513 | //beam center X pixel location (detector coordinates) |
---|
514 | Function WriteBeamCenterXToHeader(fname,num) |
---|
515 | String fname |
---|
516 | Variable num |
---|
517 | |
---|
518 | // your code here |
---|
519 | |
---|
520 | return(0) |
---|
521 | End |
---|
522 | |
---|
523 | //beam center Y pixel location (detector coordinates) |
---|
524 | Function WriteBeamCenterYToHeader(fname,num) |
---|
525 | String fname |
---|
526 | Variable num |
---|
527 | |
---|
528 | // your code here |
---|
529 | |
---|
530 | return(0) |
---|
531 | End |
---|
532 | |
---|
533 | //attenuator number (not its transmission) |
---|
534 | // if your beam attenuation is indexed in some way, use that number here |
---|
535 | // if not, write a 1 to the file here as a default |
---|
536 | // |
---|
537 | Function WriteAttenNumberToHeader(fname,num) |
---|
538 | String fname |
---|
539 | Variable num |
---|
540 | |
---|
541 | // your code here, default of 1 |
---|
542 | |
---|
543 | return(0) |
---|
544 | End |
---|
545 | |
---|
546 | // total monitor count during data collection |
---|
547 | Function WriteMonitorCountToHeader(fname,num) |
---|
548 | String fname |
---|
549 | Variable num |
---|
550 | |
---|
551 | // your code here |
---|
552 | |
---|
553 | return(0) |
---|
554 | End |
---|
555 | |
---|
556 | //total detector count |
---|
557 | Function WriteDetectorCountToHeader(fname,num) |
---|
558 | String fname |
---|
559 | Variable num |
---|
560 | |
---|
561 | // your code here |
---|
562 | |
---|
563 | return(0) |
---|
564 | End |
---|
565 | |
---|
566 | //transmission detector count |
---|
567 | // (currently unused in data reduction) |
---|
568 | Function WriteTransDetCountToHeader(fname,num) |
---|
569 | String fname |
---|
570 | Variable num |
---|
571 | |
---|
572 | // do nothing for now |
---|
573 | |
---|
574 | return(0) |
---|
575 | End |
---|
576 | |
---|
577 | //wavelength (Angstroms) |
---|
578 | Function WriteWavelengthToHeader(fname,num) |
---|
579 | String fname |
---|
580 | Variable num |
---|
581 | |
---|
582 | // your code here |
---|
583 | |
---|
584 | return(0) |
---|
585 | End |
---|
586 | |
---|
587 | //wavelength spread (FWHM) |
---|
588 | Function WriteWavelengthDistrToHeader(fname,num) |
---|
589 | String fname |
---|
590 | Variable num |
---|
591 | |
---|
592 | // your code here |
---|
593 | |
---|
594 | return(0) |
---|
595 | End |
---|
596 | |
---|
597 | //temperature of the sample (C) |
---|
598 | Function WriteTemperatureToHeader(fname,num) |
---|
599 | String fname |
---|
600 | Variable num |
---|
601 | |
---|
602 | // your code here |
---|
603 | |
---|
604 | return(0) |
---|
605 | End |
---|
606 | |
---|
607 | //magnetic field (Oe) |
---|
608 | Function WriteMagnFieldToHeader(fname,num) |
---|
609 | String fname |
---|
610 | Variable num |
---|
611 | |
---|
612 | // your code here |
---|
613 | |
---|
614 | return(0) |
---|
615 | End |
---|
616 | |
---|
617 | //Source Aperture diameter (millimeters) |
---|
618 | Function WriteSourceApDiamToHeader(fname,num) |
---|
619 | String fname |
---|
620 | Variable num |
---|
621 | |
---|
622 | // your code here |
---|
623 | |
---|
624 | return(0) |
---|
625 | End |
---|
626 | |
---|
627 | //Sample Aperture diameter (millimeters) |
---|
628 | Function WriteSampleApDiamToHeader(fname,num) |
---|
629 | String fname |
---|
630 | Variable num |
---|
631 | |
---|
632 | //your code here |
---|
633 | |
---|
634 | return(0) |
---|
635 | End |
---|
636 | |
---|
637 | //Source aperture to sample aperture distance (meters) |
---|
638 | Function WriteSrcToSamDistToHeader(fname,num) |
---|
639 | String fname |
---|
640 | Variable num |
---|
641 | |
---|
642 | // your code here |
---|
643 | |
---|
644 | return(0) |
---|
645 | End |
---|
646 | |
---|
647 | //lateral detector offset (centimeters) |
---|
648 | Function WriteDetectorOffsetToHeader(fname,num) |
---|
649 | String fname |
---|
650 | Variable num |
---|
651 | |
---|
652 | //your code here |
---|
653 | |
---|
654 | return(0) |
---|
655 | End |
---|
656 | |
---|
657 | //beam stop diameter (millimeters) |
---|
658 | Function WriteBeamStopDiamToHeader(fname,num) |
---|
659 | String fname |
---|
660 | Variable num |
---|
661 | |
---|
662 | // your code here |
---|
663 | |
---|
664 | return(0) |
---|
665 | End |
---|
666 | |
---|
667 | //sample to detector distance (meters) |
---|
668 | Function WriteSDDToHeader(fname,num) |
---|
669 | String fname |
---|
670 | Variable num |
---|
671 | |
---|
672 | //your code here |
---|
673 | |
---|
674 | return(0) |
---|
675 | End |
---|
676 | |
---|
677 | // physical dimension of detector x-pixel (mm) |
---|
678 | Function WriteDetPixelXToHeader(fname,num) |
---|
679 | String fname |
---|
680 | Variable num |
---|
681 | |
---|
682 | //your code here |
---|
683 | |
---|
684 | return(0) |
---|
685 | end |
---|
686 | |
---|
687 | // physical dimension of detector y-pixel (mm) |
---|
688 | Function WriteDetPixelYToHeader(fname,num) |
---|
689 | String fname |
---|
690 | Variable num |
---|
691 | |
---|
692 | //your code here |
---|
693 | |
---|
694 | return(0) |
---|
695 | end |
---|
696 | |
---|
697 | // sample label string |
---|
698 | Function WriteSamLabelToHeader(fname,str) |
---|
699 | String fname,str |
---|
700 | |
---|
701 | // your code here |
---|
702 | |
---|
703 | return(0) |
---|
704 | End |
---|
705 | |
---|
706 | // total counting time (seconds) |
---|
707 | Function WriteCountTimeToHeader(fname,num) |
---|
708 | String fname |
---|
709 | Variable num |
---|
710 | |
---|
711 | // your code here |
---|
712 | |
---|
713 | return(0) |
---|
714 | End |
---|
715 | |
---|
716 | |
---|
717 | |
---|
718 | //////// ACCESSORS FOR READING DATA FROM THE HEADER ////////////// |
---|
719 | // |
---|
720 | // read specific bits of information from the header |
---|
721 | // each of these operations MUST take care of open/close on their own |
---|
722 | // |
---|
723 | // fname is the full path and filname to the file on disk |
---|
724 | // return values are either strings or real values as appropriate |
---|
725 | // |
---|
726 | ////// |
---|
727 | |
---|
728 | |
---|
729 | // function that reads in the 2D detector data and fills the array |
---|
730 | // data[nx][ny] with the data values |
---|
731 | // fname is the full name and path to the data file for opening and closing |
---|
732 | // |
---|
733 | // |
---|
734 | Function getDetectorData(fname,data) |
---|
735 | String fname |
---|
736 | Wave data |
---|
737 | |
---|
738 | |
---|
739 | // your reader here |
---|
740 | |
---|
741 | return(0) |
---|
742 | End |
---|
743 | |
---|
744 | // file suffix (NCNR data file name specific) |
---|
745 | // return null string |
---|
746 | Function/S getSuffix(fname) |
---|
747 | String fname |
---|
748 | |
---|
749 | return("") |
---|
750 | End |
---|
751 | |
---|
752 | // associated file suffix (for transmission) |
---|
753 | // NCNR Transmission calculation specific |
---|
754 | // return null string |
---|
755 | Function/S getAssociatedFileSuffix(fname) |
---|
756 | String fname |
---|
757 | |
---|
758 | return("") |
---|
759 | End |
---|
760 | |
---|
761 | // sample label |
---|
762 | Function/S getSampleLabel(fname) |
---|
763 | String fname |
---|
764 | |
---|
765 | String str |
---|
766 | |
---|
767 | // your code, returning str |
---|
768 | |
---|
769 | return(str) |
---|
770 | End |
---|
771 | |
---|
772 | // file creation date |
---|
773 | Function/S getFileCreationDate(fname) |
---|
774 | String fname |
---|
775 | |
---|
776 | String str |
---|
777 | |
---|
778 | // your code, returning str |
---|
779 | |
---|
780 | return(str) |
---|
781 | End |
---|
782 | |
---|
783 | |
---|
784 | //monitor count |
---|
785 | Function getMonitorCount(fname) |
---|
786 | String fname |
---|
787 | |
---|
788 | Variable value |
---|
789 | |
---|
790 | // your code returning value |
---|
791 | |
---|
792 | return(value) |
---|
793 | end |
---|
794 | |
---|
795 | //saved monitor count |
---|
796 | // NCNR specific for pre-processed data, never used |
---|
797 | // return 0 |
---|
798 | Function getSavMon(fname) |
---|
799 | String fname |
---|
800 | |
---|
801 | Variable value |
---|
802 | |
---|
803 | // your code returning value |
---|
804 | |
---|
805 | return(0) |
---|
806 | end |
---|
807 | |
---|
808 | //total detector count |
---|
809 | Function getDetCount(fname) |
---|
810 | String fname |
---|
811 | |
---|
812 | Variable value |
---|
813 | |
---|
814 | // your code returning value |
---|
815 | |
---|
816 | return(value) |
---|
817 | end |
---|
818 | |
---|
819 | //Attenuator number, return 1 if your attenuators are not |
---|
820 | // indexed by number |
---|
821 | Function getAttenNumber(fname) |
---|
822 | String fname |
---|
823 | |
---|
824 | Variable value |
---|
825 | |
---|
826 | // your code returning value |
---|
827 | |
---|
828 | return(value) |
---|
829 | end |
---|
830 | |
---|
831 | //transmission |
---|
832 | Function getSampleTrans(fname) |
---|
833 | String fname |
---|
834 | |
---|
835 | Variable value |
---|
836 | |
---|
837 | // your code returning value |
---|
838 | |
---|
839 | return(value) |
---|
840 | end |
---|
841 | |
---|
842 | //box counts from stored transmission calculation |
---|
843 | // return 0 if not using NCNR transmission module |
---|
844 | Function getBoxCounts(fname) |
---|
845 | String fname |
---|
846 | |
---|
847 | Variable value |
---|
848 | |
---|
849 | // your code returning value |
---|
850 | |
---|
851 | return(value) |
---|
852 | end |
---|
853 | |
---|
854 | //whole detector trasmission |
---|
855 | // return 0 if not using NCNR transmission module |
---|
856 | Function getSampleTransWholeDetector(fname) |
---|
857 | String fname |
---|
858 | |
---|
859 | Variable value |
---|
860 | |
---|
861 | // your code returning value |
---|
862 | |
---|
863 | return(value) |
---|
864 | end |
---|
865 | |
---|
866 | //SampleThickness in centimeters |
---|
867 | Function getSampleThickness(fname) |
---|
868 | String fname |
---|
869 | |
---|
870 | Variable value |
---|
871 | |
---|
872 | // your code returning value |
---|
873 | |
---|
874 | return(value) |
---|
875 | end |
---|
876 | |
---|
877 | //Sample Rotation Angle (degrees) |
---|
878 | Function getSampleRotationAngle(fname) |
---|
879 | String fname |
---|
880 | |
---|
881 | Variable value |
---|
882 | |
---|
883 | // your code returning value |
---|
884 | |
---|
885 | return(value) |
---|
886 | end |
---|
887 | |
---|
888 | //temperature (C) |
---|
889 | Function getTemperature(fname) |
---|
890 | String fname |
---|
891 | |
---|
892 | Variable value |
---|
893 | |
---|
894 | // your code returning value |
---|
895 | |
---|
896 | return(value) |
---|
897 | end |
---|
898 | |
---|
899 | //field strength (Oe) |
---|
900 | Function getFieldStrength(fname) |
---|
901 | String fname |
---|
902 | |
---|
903 | Variable value |
---|
904 | |
---|
905 | // your code returning value |
---|
906 | |
---|
907 | return(value) |
---|
908 | end |
---|
909 | |
---|
910 | //center of beam xPos in pixel coordinates |
---|
911 | Function getBeamXPos(fname) |
---|
912 | String fname |
---|
913 | |
---|
914 | Variable value |
---|
915 | |
---|
916 | // your code returning value |
---|
917 | |
---|
918 | return(value) |
---|
919 | end |
---|
920 | |
---|
921 | //center of beam Y pos in pixel coordinates |
---|
922 | Function getBeamYPos(fname) |
---|
923 | String fname |
---|
924 | |
---|
925 | Variable value |
---|
926 | |
---|
927 | // your code returning value |
---|
928 | |
---|
929 | return(value) |
---|
930 | end |
---|
931 | |
---|
932 | //sample to detector distance (meters) |
---|
933 | Function getSDD(fname) |
---|
934 | String fname |
---|
935 | |
---|
936 | Variable value |
---|
937 | |
---|
938 | // your code returning value |
---|
939 | |
---|
940 | return(value) |
---|
941 | end |
---|
942 | |
---|
943 | //lateral detector offset (centimeters) |
---|
944 | Function getDetectorOffset(fname) |
---|
945 | String fname |
---|
946 | |
---|
947 | Variable value |
---|
948 | |
---|
949 | // your code returning value |
---|
950 | |
---|
951 | return(value) |
---|
952 | end |
---|
953 | |
---|
954 | //Beamstop diameter (millimeters) |
---|
955 | Function getBSDiameter(fname) |
---|
956 | String fname |
---|
957 | |
---|
958 | Variable value |
---|
959 | |
---|
960 | // your code returning value |
---|
961 | |
---|
962 | return(value) |
---|
963 | end |
---|
964 | |
---|
965 | //source aperture diameter (millimeters) |
---|
966 | Function getSourceApertureDiam(fname) |
---|
967 | String fname |
---|
968 | |
---|
969 | Variable value |
---|
970 | |
---|
971 | // your code returning value |
---|
972 | |
---|
973 | return(value) |
---|
974 | end |
---|
975 | |
---|
976 | //sample aperture diameter (millimeters) |
---|
977 | Function getSampleApertureDiam(fname) |
---|
978 | String fname |
---|
979 | |
---|
980 | Variable value |
---|
981 | |
---|
982 | // your code returning value |
---|
983 | |
---|
984 | return(value) |
---|
985 | end |
---|
986 | |
---|
987 | //source AP to Sample AP distance (meters) |
---|
988 | Function getSourceToSampleDist(fname) |
---|
989 | String fname |
---|
990 | |
---|
991 | Variable value |
---|
992 | |
---|
993 | // your code returning value |
---|
994 | |
---|
995 | return(value) |
---|
996 | end |
---|
997 | |
---|
998 | //wavelength (Angstroms) |
---|
999 | Function getWavelength(fname) |
---|
1000 | String fname |
---|
1001 | |
---|
1002 | Variable value |
---|
1003 | |
---|
1004 | // your code returning value |
---|
1005 | |
---|
1006 | return(value) |
---|
1007 | end |
---|
1008 | |
---|
1009 | //wavelength spread (FWHM) |
---|
1010 | Function getWavelengthSpread(fname) |
---|
1011 | String fname |
---|
1012 | |
---|
1013 | Variable value |
---|
1014 | |
---|
1015 | // your code returning value |
---|
1016 | |
---|
1017 | return(value) |
---|
1018 | end |
---|
1019 | |
---|
1020 | // physical x-dimension of a detector pixel, in mm |
---|
1021 | Function getDetectorPixelXSize(fname) |
---|
1022 | String fname |
---|
1023 | |
---|
1024 | Variable value |
---|
1025 | |
---|
1026 | // your code here returning value |
---|
1027 | |
---|
1028 | return(value) |
---|
1029 | end |
---|
1030 | |
---|
1031 | // physical y-dimension of a detector pixel, in mm |
---|
1032 | Function getDetectorPixelYSize(fname) |
---|
1033 | String fname |
---|
1034 | |
---|
1035 | Variable value |
---|
1036 | |
---|
1037 | // your code here returning value |
---|
1038 | |
---|
1039 | return(value) |
---|
1040 | end |
---|
1041 | |
---|
1042 | //transmission detector count (unused, return 0) |
---|
1043 | // |
---|
1044 | Function getTransDetectorCounts(fname) |
---|
1045 | String fname |
---|
1046 | |
---|
1047 | Variable value |
---|
1048 | |
---|
1049 | // your code returning value |
---|
1050 | |
---|
1051 | return(0) |
---|
1052 | end |
---|
1053 | |
---|
1054 | |
---|
1055 | //total count time (seconds) |
---|
1056 | Function getCountTime(fname) |
---|
1057 | String fname |
---|
1058 | |
---|
1059 | Variable value |
---|
1060 | |
---|
1061 | // your code returning value |
---|
1062 | |
---|
1063 | return(value) |
---|
1064 | end |
---|
1065 | |
---|
1066 | |
---|
1067 | //reads the wavelength from a reduced data file (not very reliable) |
---|
1068 | // - does not work with NSORTed files |
---|
1069 | // - only used in FIT/RPA (which itself is almost NEVER used...) |
---|
1070 | // |
---|
1071 | // DOES NOT NEED TO BE CHANGED IF USING NCNR DATA WRITER |
---|
1072 | Function GetLambdaFromReducedData(tempName) |
---|
1073 | String tempName |
---|
1074 | |
---|
1075 | String junkString |
---|
1076 | Variable lambdaFromFile, fileVar |
---|
1077 | lambdaFromFile = 6.0 |
---|
1078 | Open/R/P=catPathName fileVar as tempName |
---|
1079 | FReadLine fileVar, junkString |
---|
1080 | FReadLine fileVar, junkString |
---|
1081 | FReadLine fileVar, junkString |
---|
1082 | if(strsearch(LowerStr(junkString),"lambda",0) != -1) |
---|
1083 | FReadLine/N=11 fileVar, junkString |
---|
1084 | FReadLine/N=10 fileVar, junkString |
---|
1085 | lambdaFromFile = str2num(junkString) |
---|
1086 | endif |
---|
1087 | Close fileVar |
---|
1088 | |
---|
1089 | return(lambdaFromFile) |
---|
1090 | End |
---|
1091 | |
---|
1092 | ///// TRANSMISSION RELATED FUNCTIONS //////// |
---|
1093 | //box coordinate are returned by reference |
---|
1094 | // |
---|
1095 | // box to sum over is bounded (x1,y1) to (x2,y2) |
---|
1096 | // |
---|
1097 | // this function returns the bounding coordinates as stored in |
---|
1098 | // the header |
---|
1099 | // |
---|
1100 | // if not using the NCNR Transmission module, this function default to |
---|
1101 | // returning 0000, and no changes needed |
---|
1102 | Function getXYBoxFromFile(filename,x1,x2,y1,y2) |
---|
1103 | String filename |
---|
1104 | Variable &x1,&x2,&y1,&y2 |
---|
1105 | |
---|
1106 | Variable refnum |
---|
1107 | String tmpFile = FindValidFilename(filename) |
---|
1108 | // tmpFile is only a parital path |
---|
1109 | |
---|
1110 | // return your bounding box coordinates or default values of 0 |
---|
1111 | x1=0 |
---|
1112 | y1=0 |
---|
1113 | x2=0 |
---|
1114 | y2=0 |
---|
1115 | |
---|
1116 | return(0) |
---|
1117 | End |
---|
1118 | |
---|
1119 | // Writes the coordinates of the box to the header after user input |
---|
1120 | // |
---|
1121 | // box to sum over bounded (x1,y1) to (x2,y2) |
---|
1122 | // |
---|
1123 | // if not using the NCNR Transmission module, this function is null |
---|
1124 | Function WriteXYBoxToHeader(filename,x1,x2,y1,y2) |
---|
1125 | String filename |
---|
1126 | Variable x1,x2,y1,y2 |
---|
1127 | |
---|
1128 | // your code to write bounding box to the header, or nothing |
---|
1129 | |
---|
1130 | return(0) |
---|
1131 | End |
---|
1132 | |
---|
1133 | // for transmission calculation, writes an NCNR-specific alphanumeric identifier |
---|
1134 | // (suffix of the data file) |
---|
1135 | // |
---|
1136 | // if not using the NCNR Transmission module, this function is null |
---|
1137 | Function WriteAssocFileSuffixToHeader(fname,suffix) |
---|
1138 | String fname,suffix |
---|
1139 | |
---|
1140 | // your code to write bounding box to the header, or nothing |
---|
1141 | |
---|
1142 | return(0) |
---|
1143 | end |
---|
1144 | |
---|
1145 | ////// OCT 2009, facility specific bits from ProDiv() |
---|
1146 | //"type" is the data folder that has the corrected, patched, and normalized DIV data array |
---|
1147 | // |
---|
1148 | // the header of this file is rather unimportant. Filling in a title at least would be helpful/ |
---|
1149 | // |
---|
1150 | Function Write_DIV_File(type) |
---|
1151 | String type |
---|
1152 | |
---|
1153 | // Your file writing function here. Don't try to duplicate the VAX binary format... |
---|
1154 | Print "Write_DIV_File stub" |
---|
1155 | |
---|
1156 | return(0) |
---|
1157 | End |
---|
1158 | |
---|
1159 | ////// OCT 2009, facility specific bits from MonteCarlo functions() |
---|
1160 | //"type" is the data folder that has the data array that is to be (re)written as a full |
---|
1161 | // data file, as if it was a raw data file |
---|
1162 | // |
---|
1163 | // not really necessary |
---|
1164 | // |
---|
1165 | Function Write_RawData_File(type,fullpath,dialog) |
---|
1166 | String type |
---|
1167 | |
---|
1168 | // Your file writing function here. Don't try to duplicate the VAX binary format... |
---|
1169 | Print "Write_RawData_File stub" |
---|
1170 | |
---|
1171 | return(0) |
---|
1172 | End |
---|