source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ANSTO_Utils.ipf @ 575

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

Added ANSTO files to the repository for SANS reduction

Changed #include files for each facility to have a #define SYMBOL at the top to allow small facility-specific changes in the main body of the code that are controlled with compiler directives

File size: 23.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=6.1
4
5// this file contains globals and functions that are specific to a
6// particular facility or data file format
7// branched out 29MAR07 - SRK
8//
9// functions are either labeled with the procedure file that calls them,
10// or noted that they are local to this file
11
12
13// initializes globals that are specific to a particular facility
14// - number of XY pixels
15// - pixexl resolution [cm]
16// - detector deadtime constant [s]
17//
18// called by Initialize.ipf
19//
20Function InitFacilityGlobals()
21
22        //Detector -specific globals
23        Variable/G root:myGlobals:gNPixelsX=192                                 // number of X and Y pixels
24        Variable/G root:myGlobals:gNPixelsY=192
25       
26        // pixel dimensions are now read directly from the file header.
27//      Variable/G root:myGlobals:PixelResDefault = 0.5                 //pixel resolution in cm
28       
29        Variable/G root:myGlobals:DeadtimeDefault = 3.4e-6              //deadtime in seconds ???nha
30
31        Variable/G root:myGlobals:apOff = 5.0           // (cm) distance from sample aperture to sample position
32
33        // flags to turn detector corrections on/off for testing (nha. this overrides the default, turning these corrections OFF)
34        Variable/G root:myGlobals:gDoDetectorEffCorr = 0
35        Variable/G root:myGlobals:gDoTransmissionCorr = 0
36
37End
38
39
40//**********************
41// Resolution calculation - used by the averaging routines
42// to calculate the resolution function at each q-value
43// - the return value is not used
44//
45// equivalent to John's routine on the VAX Q_SIGMA_AVE.FOR
46// Incorporates eqn. 3-15 from J. Appl. Cryst. (1995) v. 28 p105-114
47//
48// - 21 MAR 07 uses projected BS diameter on the detector
49// - APR 07 still need to add resolution with lenses. currently there is no flag in the
50//          raw data header to indicate the presence of lenses.
51//
52// - Aug 07 - added input to switch calculation based on lenses (==1 if in)
53//
54// - called by CircSectAvg.ipf and RectAnnulAvg.ipf
55//
56// passed values are read from RealsRead
57// except DDet and apOff, which are set from globals before passing
58//
59//
60Function/S getResolution(inQ,lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,SigmaQ,QBar,fSubS)
61        Variable inQ, lambda, lambdaWidth, DDet, apOff, S1, S2, L1, L2, BS, del_r,usingLenses
62        Variable &fSubS, &QBar, &SigmaQ         //these are the output quantities at the input Q value
63       
64        //lots of calculation variables
65        Variable a2, q_small, lp, v_lambda, v_b, v_d, vz, yg, v_g
66        Variable r0, delta, inc_gamma, fr, fv, rmd, v_r1, rm, v_r
67
68        //Constants
69        Variable vz_1 = 3.956e5         //velocity [cm/s] of 1 A neutron
70        Variable g = 981.0                              //gravity acceleration [cm/s^2]
71
72        String results
73        results ="Failure"
74
75        S1 *= 0.5*0.1                   //convert to radius and [cm]
76        S2 *= 0.5*0.1
77
78        L1 *= 100.0                     // [cm]
79        L1 -= apOff                             //correct the distance
80
81        L2 *= 100.0
82        L2 += apOff
83        del_r *= 0.1                            //width of annulus, convert mm to [cm]
84       
85        BS *= 0.5*0.1                   //nominal BS diameter passed in, convert to radius and [cm]
86        // 21 MAR 07 SRK - use the projected BS diameter, based on a point sample aperture
87        Variable LB
88        LB = 20.1 + 1.61*BS                     //distance in cm from beamstop to anode plane (empirical)
89        BS = bs + bs*lb/(l2-lb)         //adjusted diameter of shadow from parallax
90       
91        //Start resolution calculation
92        a2 = S1*L2/L1 + S2*(L1+L2)/L1
93        q_small = 2.0*Pi*(BS-a2)*(1.0-lambdaWidth)/(lambda*L2)
94        lp = 1.0/( 1.0/L1 + 1.0/L2)
95
96        v_lambda = lambdaWidth^2/6.0
97       
98//      if(usingLenses==1)                      //SRK 2007
99        if(usingLenses != 0)                    //SRK 2008 allows for the possibility of different numbers of lenses in header
100                v_b = 0.25*(S1*L2/L1)^2 +0.25*(2/3)*(lambdaWidth/lambda)^2*(S2*L2/lp)^2         //correction to 2nd term
101        else
102                v_b = 0.25*(S1*L2/L1)^2 +0.25*(S2*L2/lp)^2              //original form
103        endif
104       
105        v_d = (DDet/2.3548)^2 + del_r^2/12.0
106        vz = vz_1 / lambda
107        yg = 0.5*g*L2*(L1+L2)/vz^2
108        v_g = 2.0*(2.0*yg^2*v_lambda)                                   //factor of 2 correction, B. Hammouda, 2007
109
110        r0 = L2*tan(2.0*asin(lambda*inQ/(4.0*Pi) ))
111        delta = 0.5*(BS - r0)^2/v_d
112
113        if (r0 < BS)
114                inc_gamma=exp(gammln(1.5))*(1-gammp(1.5,delta))
115        else
116                inc_gamma=exp(gammln(1.5))*(1+gammp(1.5,delta))
117        endif
118
119        fSubS = 0.5*(1.0+erf( (r0-BS)/sqrt(2.0*v_d) ) )
120        if (fSubS <= 0.0)
121                fSubS = 1.e-10
122        endif
123        fr = 1.0 + sqrt(v_d)*exp(-1.0*delta) /(r0*fSubS*sqrt(2.0*Pi))
124        fv = inc_gamma/(fSubS*sqrt(Pi)) - r0^2*(fr-1.0)^2/v_d
125
126        rmd = fr*r0
127        v_r1 = v_b + fv*v_d +v_g
128
129        rm = rmd + 0.5*v_r1/rmd
130        v_r = v_r1 - 0.5*(v_r1/rmd)^2
131        if (v_r < 0.0)
132                v_r = 0.0
133        endif
134        QBar = (4.0*Pi/lambda)*sin(0.5*atan(rm/L2))
135        SigmaQ = QBar*sqrt(v_r/rmd^2 +v_lambda)
136
137        results = "success"
138        Return results
139End
140
141
142//Utility function that returns the detector resolution (in cm)
143//Global values are set in the Initialize procedure
144//
145// - called by CircSectAvg.ipf, RectAnnulAvg.ipf, and ProtocolAsPanel.ipf
146//
147// fileStr is passed as TextRead[3]
148// detStr is passed as TextRead[9]
149//
150// *** as of Jan 2008, depricated. Now detector pixel sizes are read from the file header
151// rw[10] = x size (mm); rw[13] = y size (mm)
152//
153// depricated - pixel dimensions are read directly from the file header
154Function xDetectorPixelResolution(fileStr,detStr)
155        String fileStr,detStr
156       
157        Variable DDet
158
159        //your code here
160       
161        return(DDet)
162End
163
164//Utility function that returns the detector deadtime (in seconds)
165//Global values are set in the Initialize procedure
166//
167// - called by WorkFileUtils.ipf
168//
169// fileStr is passed as TextRead[3] and is the filename
170// detStr is passed as TextRead[9] and is an identifier for the detector
171//
172Function DetectorDeadtime(fileStr,detStr)
173        String fileStr,detStr
174       
175        Variable deadtime
176       
177// your code here
178
179        return(deadtime)
180End
181
182
183// item is a filename
184//
185// this function extracts some sort of number from the file
186// presumably some sort of automatically incrementing run number set by the
187// acquisition system
188//
189// this run number should be a unique identifier for the file
190//
191Function GetRunNumFromFile(item)
192        String item
193
194        Variable num=-1         // an invalid return value
195       
196        //your code here
197       
198        return (num)
199End
200
201// item is a filename
202//
203// this function extracts some sort of number from the file
204// presumably some sort of automatically incrementing run number set by the
205// acquisition system
206//
207// this run number should be a unique identifier for the file
208//
209// same as GetRunNumFromFile(0), just with a string return
210//
211// "ABC" returned as an invalid result
212Function/S GetRunNumStrFromFile(item)
213        String item
214       
215        String invalid = "ABC"  //"ABC" is not a valid run number, since it's text
216        String retStr
217        retStr=invalid
218       
219        //your code here
220       
221        return(retStr)
222End
223
224//returns a string containing the full path to the file containing the
225//run number "num". The null string is returned if no valid file can be found.
226//
227//
228// search in the path "catPathName" (hard-wired), will abort if this path does not exist
229//the file returned will be a RAW SANS data file, other types of files are
230//filtered out.
231//
232// called by Buttons.ipf and Transmission.ipf, and locally by parsing routines
233//
234Function/S FindFileFromRunNumber(num)
235        Variable num
236       
237        String fullName="",partialName="",item=""
238       
239        //make sure that path exists
240        PathInfo catPathName
241        String path = S_path
242        if (V_flag == 0)
243                Abort "folder path does not exist - use Pick Path button"
244        Endif
245
246        //your code here       
247
248        return(fullname)
249       
250End
251
252//function to test a file to see if it is a RAW SANS file
253//
254// returns truth 0/1
255//
256// called by many procedures (both external and local)
257//
258Function CheckIfRawData(fname)
259        String fname
260        Variable value = 0
261       
262        if(cmpStr(FindValidFilename(fname),fname)==0)
263                value = 1
264        endif
265        return(value)
266End
267
268Function isScatFile(fname)
269        String fname
270        Variable isTrans, isEmp
271        Variable value =1
272       
273        isTrans = isTransFile(fname)
274        isEmp = isEmpFile(fname)
275       
276        if(isTrans)
277                value = 0
278        endif
279        if(isEmp)
280                value = 0
281        endif
282        return(value)
283End
284
285Function isEmpFile(fName)
286        String fname
287
288        variable err
289        string dfName = ""
290        variable value = 0
291       
292        err = hdfRead(fname, dfName)
293        //err not handled here
294
295        Wave/T wSampleName = $(dfName+":entry1:sample:name")
296        String sampleName = wSampleName[0]
297       
298        if (cmpstr(sampleName,"MT beam")==0)
299                value = 1
300        endif
301       
302        return(value)
303End
304
305
306// function returns 1 if file is a transmission file, 0 if not
307//
308// called by Transmission.ipf, CatVSTable.ipf, NSORT.ipf
309//
310Function isTransFile(fName)
311        String fname
312
313// nha. TO DO. entry1 will have to change when the new naming convention for nxentry is implemented.
314
315        variable err
316        string dfName = ""
317        variable value = 0
318       
319        err = hdfRead(fname, dfName)
320        //err not handled here
321
322        Wave wTransmission_Flag = $(dfName+":entry1:sample:transmission_flag") //is only being set after 27/5/2009. ???
323        value = wTransmission_Flag[0]
324       
325        //workaround - determine by bsx position
326        Wave wBSX = $(dfName+":entry1:instrument:beam_stop:geometry:position:BSPosXmm")
327        variable bsx = wBSX[0]
328       
329        if (bsx >= -10 )
330                value = 1
331        endif
332
333        return(value)
334End
335
336
337//function to remove all spaces from names when searching for filenames
338//the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn)
339//but the text field in the header may
340//
341//returns a string identical to the original string, except with the interior spaces removed
342//
343// local function for file name manipulation
344//
345// no change needed here
346Function/S RemoveAllSpaces(str)
347        String str
348       
349        String tempstr = str
350        Variable ii,spc,len             //should never be more than 2 or 3 trailing spaces in a filename
351        ii=0
352        do
353                len = strlen(tempStr)
354                spc = strsearch(tempStr," ",0)          //is the last character a space?
355                if (spc == -1)
356                        break           //no more spaces found, get out
357                endif
358                str = tempstr
359                tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string
360        While(1)        //should never be more than 2 or 3
361       
362        If(strlen(tempStr) < 1)
363                tempStr = ""            //be sure to return a null string if problem found
364        Endif
365       
366        //Print strlen(tempstr)
367       
368        Return(tempStr)
369               
370End
371
372
373//Function attempts to find valid filename from partial name by checking for
374// the existence of the file on disk
375//
376// returns a valid filename (No path prepended) or a null string
377//
378// called by any functions, both external and local
379//
380Function/S FindValidFilename(partialName)
381        String PartialName
382       
383        String retStr=""
384       
385        //your code here
386        //nha. look for non-NeXus files
387        if (strsearch(partialName, "nx.hdf", 0) == -1)
388                return(retStr)
389        endif
390       
391        return(partialName)
392
393End
394
395
396//returns a string containing filename (WITHOUT the ;vers)
397//the input string is a full path to the file (Mac-style, still works on Win in IGOR)
398//with the folders separated by colons
399//
400// called by MaskUtils.ipf, ProtocolAsPanel.ipf, WriteQIS.ipf
401//
402// NEEDS NO CHANGES
403//
404Function/S GetFileNameFromPathNoSemi(fullPath)
405        String fullPath
406       
407        Variable offset1,offset2
408        String filename=""
409        //String PartialPath
410        offset1 = 0
411        do
412                offset2 = StrSearch(fullPath, ":", offset1)
413                if (offset2 == -1)                              // no more colons ?
414                        fileName = FullPath[offset1,strlen(FullPath) ]
415                        //PartialPath = FullPath[0, offset1-1]
416                        break
417                endif
418                offset1 = offset2+1
419        while (1)
420       
421        //remove version number from name, if it's there - format should be: filename;N
422        filename =  StringFromList(0,filename,";")              //returns null if error
423       
424        Return filename
425End
426
427//returns a string containing filename (INCLUDING the ;vers)
428//the input string is a full path to the file (Mac-style, still works on Win in IGOR)
429//with the folders separated by colons
430//
431// local, currently unused
432//
433// NEEDS NO CHANGES
434//
435Function/S GetFileNameFromPathKeepSemi(fullPath)
436        String fullPath
437       
438        Variable offset1,offset2
439        String filename
440        //String PartialPath
441        offset1 = 0
442        do
443                offset2 = StrSearch(fullPath, ":", offset1)
444                if (offset2 == -1)                              // no more colons ?
445                        fileName = FullPath[offset1,strlen(FullPath) ]
446                        //PartialPath = FullPath[0, offset1-1]
447                        break
448                endif
449                offset1 = offset2+1
450        while (1)
451       
452        //keep version number from name, if it's there - format should be: filename;N
453       
454        Return filename
455End
456
457//given the full path and filename (fullPath), strips the data path
458//(Mac-style, separated by colons) and returns this path
459//this partial path is the same string that would be returned from PathInfo, for example
460//
461// - allows the user to save to a different path than catPathName
462//
463// called by WriteQIS.ipf
464//
465// NEEDS NO CHANGES
466//
467Function/S GetPathStrFromfullName(fullPath)
468        String fullPath
469       
470        Variable offset1,offset2
471        //String filename
472        String PartialPath
473        offset1 = 0
474        do
475                offset2 = StrSearch(fullPath, ":", offset1)
476                if (offset2 == -1)                              // no more colons ?
477                        //fileName = FullPath[offset1,strlen(FullPath) ]
478                        PartialPath = FullPath[0, offset1-1]
479                        break
480                endif
481                offset1 = offset2+1
482        while (1)
483       
484        Return PartialPath
485End
486
487//given the filename trim or modify the filename to get a new
488//file string that can be used for naming averaged 1-d files
489//
490// called by ProtocolAsPanel.ipf and Tile_2D.ipf
491//
492Function/S GetNameFromHeader(fullName)
493        String fullName
494        String newName = ""
495
496        //your code here
497       
498        Return(newName)
499End
500
501//list (input) is a list, typically returned from IndexedFile()
502//which is semicolon-delimited, and may contain filenames from the VAX
503//that contain version numbers, where the version number appears as a separate list item
504//(and also as a non-existent file)
505//these numbers must be purged from the list, especially for display in a popup
506//or list processing of filenames
507//the function returns the list, cleaned of version numbers (up to 11)
508//raw data files will typically never have a version number other than 1.
509//
510// if there are no version numbers in the list, the input list is returned
511//
512// called by CatVSTable.ipf, NSORT.ipf, Transmission.ipf, WorkFileUtils.ipf
513//
514//
515// NO CHANGE NEEDED
516//
517Function/S RemoveVersNumsFromList(list)
518        String list
519       
520        //get rid of version numbers first (up to 11)
521        Variable ii,num
522        String item
523        num = ItemsInList(list,";")
524        ii=1
525        do
526                item = num2str(ii)
527                list = RemoveFromList(item, list ,";" )
528                ii+=1
529        while(ii<12)
530       
531        return (list)
532End
533
534//input is a list of run numbers, and output is a list of filenames (not the full path)
535//*** input list must be COMMA delimited***
536//output is equivalent to selecting from the CAT table
537//if some or all of the list items are valid filenames, keep them...
538//if an error is encountered, notify of the offending element and return a null list
539//
540//output is COMMA delimited
541//
542// this routine is expecting that the "ask", "none" special cases are handled elsewhere
543//and not passed here
544//
545// called by Marquee.ipf, MultipleReduce.ipf, ProtocolAsPanel.ipf
546//
547// NO CHANGE NEEDED
548//
549Function/S ParseRunNumberList(list)
550        String list
551       
552        String newList="",item="",tempStr=""
553        Variable num,ii,runNum
554       
555        //expand number ranges, if any
556        list = ExpandNumRanges(list)
557       
558        num=itemsinlist(list,",")
559       
560        for(ii=0;ii<num;ii+=1)
561                //get the item
562                item = StringFromList(ii,list,",")
563
564                //hardcode the mask filename - ??? bad
565                if(strlen(item)==4)
566                        item = "QKK000"+item+".nx.hdf"
567                endif
568                //is it already a valid filename?
569
570                //hardcode the mask filename - ??? bad
571                if(cmpstr(item,"mask.bin")==0)
572                        tempStr = item
573                else
574                tempStr=FindValidFilename(item) //returns filename if good, null if error
575                endif
576                if(strlen(tempstr)!=0)
577                        //valid name, add to list
578                        //Print "it's a file"
579                        newList += tempStr + ","
580                else
581                        //not a valid name
582                        //is it a number?
583                        runNum=str2num(item)
584                        //print runnum
585                        if(numtype(runNum) != 0)
586                                //not a number -  maybe an error                       
587                                DoAlert 0,"List item "+item+" is not a valid run number or filename. Please enter a valid number or filename."
588                                return("")
589                        else
590                                //a run number or an error
591                                tempStr = GetFileNameFromPathNoSemi( FindFileFromRunNumber(runNum) )
592                                if(strlen(tempstr)==0)
593                                        //file not found, error
594                                        DoAlert 0,"List item "+item+" is not a valid run number. Please enter a valid number."
595                                        return("")
596                                else
597                                        newList += tempStr + ","
598                                endif
599                        endif
600                endif
601        endfor          //loop over all items in list
602       
603        return(newList)
604End
605
606//takes a comma delimited list that MAY contain number range, and
607//expands any range of run numbers into a comma-delimited list...
608//and returns the new list - if not a range, return unchanged
609//
610// local function
611//
612// NO CHANGE NEEDED
613//
614Function/S ExpandNumRanges(list)
615        String list
616       
617        String newList="",dash="-",item,str
618        Variable num,ii,hasDash
619       
620        num=itemsinlist(list,",")
621//      print num
622        for(ii=0;ii<num;ii+=1)
623                //get the item
624                item = StringFromList(ii,list,",")
625                //does it contain a dash?
626                hasDash = strsearch(item,dash,0)                //-1 if no dash found
627                if(hasDash == -1)
628                        //not a range, keep it in the list
629                        newList += item + ","
630                else
631                        //has a dash (so it's a range), expand (or add null)
632                        newList += ListFromDash(item)           
633                endif
634        endfor
635       
636        return newList
637End
638
639//be sure to add a trailing comma to the return string...
640//
641// local function
642//
643// NO CHANGE NEEDED
644//
645Function/S ListFromDash(item)
646        String item
647       
648        String numList="",loStr="",hiStr=""
649        Variable lo,hi,ii
650       
651        loStr=StringFromList(0,item,"-")        //treat the range as a list
652        hiStr=StringFromList(1,item,"-")
653        lo=str2num(loStr)
654        hi=str2num(hiStr)
655        if( (numtype(lo) != 0) || (numtype(hi) !=0 ) || (lo > hi) )
656                numList=""
657                return numList
658        endif
659        for(ii=lo;ii<=hi;ii+=1)
660                numList += num2str(ii) + ","
661        endfor
662       
663        Return numList
664End
665
666
667//returns the proper attenuation factor based on the instrument
668//
669// filestr is passed from TextRead[3] = the default directory, used to identify the instrument
670// lam is passed from RealsRead[26]
671// AttenNo is passed from ReaslRead[3]
672//
673// Attenuation factor as defined here is <= 1
674//
675// Facilities can pass ("",1,attenuationFactor) and have this function simply
676// spit back the attenuationFactor (that was read into rw[3])
677//
678// called by Correct.ipf, ProtocolAsPanel.ipf, Transmission.ipf
679//
680Function AttenuationFactor(fileStr,lam,attenNo)
681       
682        //
683        String fileStr //
684        Variable lam,attenNo
685       
686        Variable attenFactor=1
687
688        // your code here       
689        attenFactor = LookupAtten(lam,attenNo)
690
691        return(attenFactor)
692End
693
694Function LookupAtten(lambda,attenNo)
695        Variable lambda, attenNo
696       
697        Variable trans
698        String attStr="root:myGlobals:Attenuators:att"+num2str(trunc(attenNo))
699        String lamStr = "root:myGlobals:Attenuators:lambda"
700       
701        if(attenNo == 0)
702                return (1)              //no attenuation, return trans == 1
703        endif
704       
705        if( (lambda < 5) || (lambda > 5 ) )
706                Abort "Wavelength out of calibration range (5A). You must manually enter the absolute parameters"
707        Endif
708       
709        if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) )
710                Execute "MakeAttenTable()"
711        Endif
712        //just in case creating the tables fails....
713        if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) )
714                Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters"
715        Endif
716       
717        //lookup the value by interpolating the wavelength
718        //the attenuator must always be an integer
719       
720
721        Wave att = $attStr
722        Wave lam = $lamstr
723        //nha - commented below out until we have attenuation factors over multiple lambda values
724        //trans = interp(lambda,lam,att)
725       
726//      Print "trans = ",trans
727        //nha - delete this line when multiple lambda values
728        trans = att
729       
730        return trans
731End
732
733Proc MakeAttenTable()
734
735        NewDataFolder/O root:myGlobals:Attenuators
736        //do explicitly to avoid data folder problems, redundant, but it must work without fail
737
738        //Quokka specific nha.
739        Variable num=12         
740       
741        Make/O/N=(num) root:myGlobals:Attenuators:att0
742        Make/O/N=(num) root:myGlobals:Attenuators:att1
743        Make/O/N=(num) root:myGlobals:Attenuators:att2
744        Make/O/N=(num) root:myGlobals:Attenuators:att3
745        Make/O/N=(num) root:myGlobals:Attenuators:att4
746        Make/O/N=(num) root:myGlobals:Attenuators:att5
747        Make/O/N=(num) root:myGlobals:Attenuators:att6
748        Make/O/N=(num) root:myGlobals:Attenuators:att7
749        Make/O/N=(num) root:myGlobals:Attenuators:att8
750        Make/O/N=(num) root:myGlobals:Attenuators:att9
751        Make/O/N=(num) root:myGlobals:Attenuators:att10
752        Make/O/N=(num) root:myGlobals:Attenuators:att11
753       
754        // epg
755        // note 5A only at this stage but other wavelengths as measured
756        // these values have to be re-determined as were measured on time and not monitor counts
757        Make/O/N=(num) root:myGlobals:Attenuators:lambda={5}
758
759        //Quokka attenuator factors. 19/1/09 nha
760        //20/3/09 nha updated to
761        //file://fianna/Sections/Bragg/Data_Analysis_Team/Project/P025 Quokka Commissioning DRV/3_Development/ATTest-timeseries.pdf
762       
763        root:myGlobals:Attenuators:att0 = {1}
764        root:myGlobals:Attenuators:att1 = {0.499}
765        root:myGlobals:Attenuators:att2 = {0.175}
766        root:myGlobals:Attenuators:att3 = {0.0727}
767        root:myGlobals:Attenuators:att4 = {0.0326}
768        root:myGlobals:Attenuators:att5 = {0.0124}
769        root:myGlobals:Attenuators:att6 = {0.00573}
770        root:myGlobals:Attenuators:att7 = {0.00257}
771        root:myGlobals:Attenuators:att8 = {0.000929}
772        root:myGlobals:Attenuators:att9 = {6.93e-5}
773        root:myGlobals:Attenuators:att10 = {5.46e-6}
774        root:myGlobals:Attenuators:att11 = {1.55e-6}
775
776End
777
778//function called by the popups to get a file list of data that can be sorted
779// this procedure simply removes the raw data files from the string - there
780//can be lots of other junk present, but this is very fast...
781//
782// could also use the alternate procedure of keeping only file with the proper extension
783//
784// another possibility is to get a listing of the text files, but is unreliable on
785// Windows, where the data file must be .txt (and possibly OSX)
786//
787// called by FIT_Ops.ipf, NSORT.ipf, PlotUtils.ipf
788//
789// modify for specific facilities by changing the "*.SA1*","*.SA2*","*.SA3*" stringmatch
790// items which are specific to NCNR
791//
792Function/S ReducedDataFileList(ctrlName)
793        String ctrlName
794
795        String list="",newList="",item=""
796        Variable num,ii
797       
798        //check for the path
799        PathInfo catPathName
800        if(V_Flag==0)
801                DoAlert 0, "Data path does not exist - pick the data path from the button on the main panel"
802                Return("")
803        Endif
804       
805        list = IndexedFile(catpathName,-1,"????")
806        num=ItemsInList(list,";")
807        //print "num = ",num
808        for(ii=(num-1);ii>=0;ii-=1)
809                item = StringFromList(ii, list  ,";")
810                //simply remove all that are not raw data files (SA1 SA2 SA3)
811                if( !stringmatch(item,"*.SA1*") && !stringmatch(item,"*.SA2*") && !stringmatch(item,"*.SA3*") )
812                        if( !stringmatch(item,".*") && !stringmatch(item,"*.pxp") && !stringmatch(item,"*.DIV"))                //eliminate mac "hidden" files, pxp, and div files
813                                newlist += item + ";"
814                        endif
815                endif
816        endfor
817        //remove VAX version numbers
818        newList = RemoveVersNumsFromList(newList)
819        //sort
820        newList = SortList(newList,";",0)
821
822        return newlist
823End
824
825// returns a list of raw data files in the catPathName directory on disk
826// - list is SEMICOLON-delimited
827//
828// called by PatchFiles.ipf, Tile_2D.ipf
829//
830Function/S GetRawDataFileList()
831       
832        //nha. Reads Quokka file names 5/2/09
833       
834        //make sure that path exists
835        PathInfo catPathName
836        if (V_flag == 0)
837                Abort "Folder path does not exist - use Pick Path button on Main Panel"
838        Endif
839
840        String list=IndexedFile(catPathName,-1,"????")
841        String newList="",item=""
842        Variable num=ItemsInList(list,";"),ii
843        for(ii=0;ii<num;ii+=1)
844                item = StringFromList(ii, list  ,";")
845                if( stringmatch(item,"*.nx.hdf") )
846                        newlist += item + ";"
847                endif
848                //print "ii=",ii
849        endfor
850        newList = SortList(newList,";",0)
851        return(newList)
852       
853        // your code here
854       
855        return(list)
856End
857
858//**********************
859// 2D resolution function calculation - in terms of X and Y
860//
861// based on notes from David Mildner, 2008
862//
863// the final NCNR version is located in NCNR_Utils.ipf
864//
865Function/S get2DResolution(inQ,phi,lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,del_r,usingLenses,r_dist,SigmaQX,SigmaQY,fSubS)
866        Variable inQ, phi,lambda, lambdaWidth, DDet, apOff, S1, S2, L1, L2, BS, del_r,usingLenses,r_dist
867        Variable &SigmaQX,&SigmaQY,&fSubS               //these are the output quantities at the input Q value
868       
869        return("Function Empty")
870End
Note: See TracBrowser for help on using the repository browser.