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

Last change on this file since 570 was 570, checked in by srkline, 13 years ago

Change (1):
In preparation for release, updated pragma IgorVersion?=6.1 in all procedures

Change (2):
As a side benefit of requiring 6.1, we can use the MultiThread? keyword to thread any model function we like. The speed benefit is only noticeable on functions that require at least one integration and at least 100 points (resolution smearing is NOT threaded, too many threadSafe issues, too little benefit). I have chosen to use the MultiThread? only on the XOP assignment. In the Igor code there are too many functions that are not explicitly declared threadsafe, making for a mess.

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