source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/FACILITY_DataReadWrite.ipf

Last change on this file was 940, checked in by srkline, 8 years ago

Updated the reduction Read/Write? and corresponding factility stubs to accomodate detector dead time written to the VAX header. It is currently not written to the header, but may be with NICE (hopefully).

With the move of NG3 SANS to CGB(upper), the NG3 designation in the account name [NGxSANSxx] has been replaced with CGB. Folders on charlotte and radio button on SASCALC are labeled "NGB30" to be more obvious which instrument it is.

FFT routines have minor typos cleaned up.

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