source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/CatVSTable.ipf @ 890

Last change on this file since 890 was 886, checked in by srkline, 10 years ago

Changes to SASCALC and other locations in the code that identify the instrument from the account name that is stored in the file header. New designation of NGA for the 10-m SANS, and NGB is reserved for the NG3 30-m SANS when it is moved into the new guide hall. Changes to incorporate the 10m SANS are functional, but INCOMPLETE since many of the instrument details have not been filled in yet (they haven't been measured yet).

File size: 30.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//      SRK modified 30 JAN07 to include Rotation angle, Temperature, and B-field in the table (at the end)
7//
8
9//**************
10// Vers 1.2 090401
11//
12// Procedures for creating the Catalog listings of the SANS datafiles in the folder
13// specified by catPathName.
14// Header information from each of the dataifles is organized in a table for
15// easy identification of each file. CatVSTable is the preferred invocation,
16// although CatVSNotebook and CatNotebook can also be used.
17// Files in the folder that are not RAW SANS data are appended to the end of the listing.
18//**************
19
20//this main procedure does all the work, obtaining the folder path,
21//parsing the filenames in the list and (dispatching) to write out the
22//appropriate information to the notebook window
23Function BuildCatVeryShortTable()
24       
25        Variable err
26        Variable t1 = ticks
27       
28        PathInfo catPathName
29        if(v_flag==0)
30                err = PickPath()                //sets the local path to the data (catPathName)
31                if(err)
32                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
33                Endif
34        Endif
35       
36        DoWindow/F CatVSTable
37       
38        Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:Filenames"
39        Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:Suffix"
40        Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:Labels"
41        Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:DateAndTime"
42        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:SDD"
43        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Lambda"
44        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:CntTime"
45        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:TotCnts"
46        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:CntRate"
47        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Transmission"
48        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Thickness"
49        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:XCenter"
50        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:YCenter"
51        Make/O/B/N=0 $"root:myGlobals:CatVSHeaderInfo:nGuides"
52        Make/O/B/N=0 $"root:myGlobals:CatVSHeaderInfo:NumAttens"
53        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:RunNumber"
54        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:IsTrans"
55        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:RotAngle"
56        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Temperature"
57        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Field"
58        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:MCR"              //added Mar 2008
59        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Pos"              //added Mar 2010
60        //For ANSTO
61        Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:SICS"     
62        Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:HDF"
63       
64        Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Reactorpower"       //only used for for ILL, June 2008,
65        WAVE ReactorPower = $"root:myGlobals:CatVSHeaderInfo:Reactorpower"
66
67        WAVE/T Filenames = $"root:myGlobals:CatVSHeaderInfo:Filenames"
68        WAVE/T Suffix = $"root:myGlobals:CatVSHeaderInfo:Suffix"
69        WAVE/T Labels = $"root:myGlobals:CatVSHeaderInfo:Labels"
70        WAVE/T DateAndTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime"
71        WAVE SDD = $"root:myGlobals:CatVSHeaderInfo:SDD"
72        WAVE Lambda = $"root:myGlobals:CatVSHeaderInfo:Lambda"
73        WAVE CntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime"
74        WAVE TotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts"
75        WAVE CntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate"
76        WAVE Transmission = $"root:myGlobals:CatVSHeaderInfo:Transmission"
77        WAVE Thickness = $"root:myGlobals:CatVSHeaderInfo:Thickness"
78        WAVE XCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter"
79        WAVE YCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter"
80        WAVE/B nGuides = $"root:myGlobals:CatVSHeaderInfo:nGuides"
81        WAVE/B NumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens"
82        WAVE RunNumber = $"root:myGlobals:CatVSHeaderInfo:RunNumber"
83        WAVE IsTrans = $"root:myGlobals:CatVSHeaderInfo:IsTrans"
84        WAVE RotAngle = $"root:myGlobals:CatVSHeaderInfo:RotAngle"
85        WAVE Temperature = $"root:myGlobals:CatVSHeaderInfo:Temperature"
86        WAVE Field = $"root:myGlobals:CatVSHeaderInfo:Field"
87        WAVE MCR = $"root:myGlobals:CatVSHeaderInfo:MCR"                //added Mar 2008
88        WAVE Pos = $"root:myGlobals:CatVSHeaderInfo:Pos"
89        //For ANSTO
90        WAVE SICS = $"root:myGlobals:CatVSHeaderInfo:SICS"     
91        WAVE HDF = $"root:myGlobals:CatVSHeaderInfo:HDF"
92       
93        If(V_Flag==0)
94                BuildTableWindow()
95                ModifyTable width(:myGlobals:CatVSHeaderInfo:SDD)=40
96                ModifyTable width(:myGlobals:CatVSHeaderInfo:Lambda)=40
97                ModifyTable width(:myGlobals:CatVSHeaderInfo:CntTime)=50
98                ModifyTable width(:myGlobals:CatVSHeaderInfo:TotCnts)=60
99                ModifyTable width(:myGlobals:CatVSHeaderInfo:CntRate)=60
100                ModifyTable width(:myGlobals:CatVSHeaderInfo:Transmission)=40
101                ModifyTable width(:myGlobals:CatVSHeaderInfo:Thickness)=40
102                ModifyTable width(:myGlobals:CatVSHeaderInfo:XCenter)=40
103                ModifyTable width(:myGlobals:CatVSHeaderInfo:YCenter)=40
104                ModifyTable width(:myGlobals:CatVSHeaderInfo:NumAttens)=30
105                ModifyTable width(:myGlobals:CatVSHeaderInfo:RotAngle)=50
106                ModifyTable width(:myGlobals:CatVSHeaderInfo:Field)=50
107                ModifyTable width(:myGlobals:CatVSHeaderInfo:MCR)=50
108#if (exists("QUOKKA")==6)
109                //ANSTO
110                ModifyTable width(:myGlobals:CatVSHeaderInfo:SICS)=80
111                ModifyTable width(:myGlobals:CatVSHeaderInfo:HDF)=40
112#endif         
113               
114#if (exists("ILL_D22")==6)
115                ModifyTable width(:myGlobals:CatVSHeaderInfo:Reactorpower)=50           //activate for ILL, June 2008
116#endif
117
118#if (exists("NCNR")==6)
119                ModifyTable width(:myGlobals:CatVSHeaderInfo:nGuides)=40
120                ModifyTable width(:myGlobals:CatVSHeaderInfo:Pos)=30
121                ModifyTable sigDigits(:myGlobals:CatVSHeaderInfo:Pos)=3                 //to make the display look nice, given the floating point values from ICE
122                ModifyTable sigDigits(:myGlobals:CatVSHeaderInfo:Lambda)=3              //may not work in all situations, but an improvement
123                ModifyTable sigDigits(:myGlobals:CatVSHeaderInfo:SDD)=5
124                ModifyTable trailingZeros(:myGlobals:CatVSHeaderInfo:Temperature)=1
125                ModifyTable sigDigits(:myGlobals:CatVSHeaderInfo:Temperature)=4
126#endif
127
128                ModifyTable width(Point)=0              //JUN04, remove point numbers - confuses users since point != run
129        Endif
130
131        //get a list of all files in the folder, some will be junk version numbers that don't exist     
132        String list,partialName,tempName,temp=""
133        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
134        Variable numitems,ii,ok
135       
136        //remove version numbers from semicolon-delimited list
137        list =  RemoveVersNumsFromList(list)
138        numitems = ItemsInList(list,";")
139       
140        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
141        //***version numbers have been removed***
142        String str,fullName
143        Variable lastPoint
144        ii=0
145       
146        Make/T/O/N=0 notRAWlist
147        do
148       
149                //get current item in the list
150                partialName = StringFromList(ii, list, ";")
151                //get a valid file based on this partialName and catPathName
152                tempName = FindValidFilename(partialName)
153               
154               
155                If(cmpstr(tempName,"")==0)              //a null string was returned
156                        //write to notebook that file was not found
157                        //if string is not a number, report the error
158                        if(numtype(str2num(partialName)) == 2)
159                                str = "this file was not found: "+partialName+"\r\r"
160                                //Notebook CatWin,font="Times",fsize=12,text=str
161                        Endif
162                else
163                        //prepend path to tempName for read routine
164                        PathInfo catPathName
165                        FullName = S_path + tempName
166                        //make sure the file is really a RAW data file
167                        ok = CheckIfRawData(fullName)
168               
169                        if (!ok)
170                                //write to notebook that file was not a RAW SANS file
171                                lastPoint = numpnts(notRAWlist)
172                                InsertPoints lastPoint,1,notRAWlist
173                                notRAWlist[lastPoint]=tempname
174                        else
175                                //go write the header information to the Notebook
176                                GetHeaderInfoToWave(fullName,tempName)
177                        Endif
178                Endif
179                ii+=1
180        while(ii<numitems)
181//Now sort them all based on some criterion that may be facility dependent (aim is to order them as collected)
182        SortWaves()
183//Append the files that are not raw files to the list
184        AppendNotRAWFiles(notRAWlist)   
185        KillWaves/Z notRAWlist
186//
187//      Print "Total time (s) = ",(ticks - t1)/60.15
188//      Print "Time per raw data file (s) = ",(ticks - t1)/60.15/(numItems-numpnts(notRawList))
189        return(0)
190End
191
192//appends the list of files that are not RAW SANS data to the filename wave (1st column)
193//for display in the table. Note that the filenames column will now be longer than all other
194//waves in the table
195Function AppendNotRAWFiles(w)
196        Wave/T w
197        Wave/T Filenames = $"root:myGlobals:CatVSHeaderInfo:Filenames"
198        Variable lastPoint
199        lastPoint = numpnts(Filenames)
200        InsertPoints lastPoint,numpnts(w),Filenames
201        Filenames[lastPoint,numpnts(Filenames)-1] = w[p-lastPoint]
202        return(0)
203End
204
205//sorts all of the waves of header information using the suffix (A123)
206//the result is that all of the data is in the order that it was collected,
207// regardless of how the prefix or run numbers were changed by the user
208Function SortWaves()
209        Wave/T GFilenames = $"root:myGlobals:CatVSHeaderInfo:Filenames"
210        Wave/T GSuffix = $"root:myGlobals:CatVSHeaderInfo:Suffix"
211        Wave/T GLabels = $"root:myGlobals:CatVSHeaderInfo:Labels"
212        Wave/T GDateTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime"
213        Wave GSDD = $"root:myGlobals:CatVSHeaderInfo:SDD"
214        Wave GLambda = $"root:myGlobals:CatVSHeaderInfo:Lambda"
215        Wave GCntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime"
216        Wave GTotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts"
217        Wave GCntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate"
218        Wave GTransmission = $"root:myGlobals:CatVSHeaderInfo:Transmission"
219        Wave GThickness = $"root:myGlobals:CatVSHeaderInfo:Thickness"
220        Wave GXCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter"
221        Wave GYCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter"
222        Wave/B GNumGuides = $"root:myGlobals:CatVSHeaderInfo:nGuides"
223        Wave/B GNumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens"
224        Wave GRunNumber = $"root:myGlobals:CatVSHeaderInfo:RunNumber"
225        Wave GIsTrans = $"root:myGlobals:CatVSHeaderInfo:IsTrans"
226        Wave GRot = $"root:myGlobals:CatVSHeaderInfo:RotAngle"
227        Wave GTemp = $"root:myGlobals:CatVSHeaderInfo:Temperature"
228        Wave GField = $"root:myGlobals:CatVSHeaderInfo:Field"
229        Wave GMCR = $"root:myGlobals:CatVSHeaderInfo:MCR"               //added Mar 2008
230        Wave GPos = $"root:myGlobals:CatVSHeaderInfo:Pos"
231        Wave/Z GReactPow = $"root:myGlobals:CatVSHeaderInfo:ReactorPower"               //activate for ILL June 2008 ( and the sort line too)
232        //For ANSTO
233        Wave/T GSICS = $"root:myGlobals:CatVSHeaderInfo:SICS"
234        Wave/T GHDF = $"root:myGlobals:CatVSHeaderInfo:HDF"
235
236#if (exists("ILL_D22")==6)
237        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,GReactPow
238#elif (exists("NCNR")==6)
239        //      Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR
240        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,GPos,gNumGuides
241#elif (exists("QUOKKA")==6)
242    //ANSTO
243        Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR, GSICS, GHDF
244#else
245//      Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR
246        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR
247#endif
248
249
250        return(0)
251End
252
253//function to create the CAT/VSTable to display the header information
254//this table is just like any other table
255Function BuildTableWindow()
256        Wave/T Filenames = $"root:myGlobals:CatVSHeaderInfo:Filenames"
257        Wave/T Labels = $"root:myGlobals:CatVSHeaderInfo:Labels"
258        Wave/T DateAndTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime"
259        Wave SDD = $"root:myGlobals:CatVSHeaderInfo:SDD"
260        Wave Lambda = $"root:myGlobals:CatVSHeaderInfo:Lambda"
261        Wave CntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime"
262        Wave TotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts"
263        Wave CntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate"
264        Wave Transmission = $"root:myGlobals:CatVSHeaderInfo:Transmission"
265        Wave Thickness = $"root:myGlobals:CatVSHeaderInfo:Thickness"
266        Wave XCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter"
267        Wave YCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter"
268        Wave/B NumGuides = $"root:myGlobals:CatVSHeaderInfo:nGuides"
269        Wave/B NumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens"
270        Wave RotAngle =  $"root:myGlobals:CatVSHeaderInfo:RotAngle"
271        Wave Temperature = $"root:myGlobals:CatVSHeaderInfo:Temperature"
272        Wave Field= $"root:myGlobals:CatVSHeaderInfo:Field"
273        Wave MCR = $"root:myGlobals:CatVSHeaderInfo:MCR"                //added Mar 2008
274        Wave Pos = $"root:myGlobals:CatVSHeaderInfo:Pos"
275        Wave/Z ReactorPower = $"root:myGlobals:CatVSHeaderInfo:reactorpower"       //activate for ILL, June 08 (+ edit line)
276        Wave/Z SICS = $"root:myGlobals:CatVSHeaderInfo:SICS" // For ANSTO June 2010
277        Wave/Z HDF = $"root:myGlobals:CatVSHeaderInfo:HDF" // For ANSTO June 2010
278       
279#if (exists("ILL_D22")==6)
280        Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR, ReactorPower as "Data File Catalog"
281#elif (exists("NCNR")==6)
282// original order, magnetic at the end
283//      Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog"
284// with numGuides
285        Edit Filenames, Labels, DateAndTime, SDD, Lambda, numGuides, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR, Pos as "Data File Catalog"
286// alternate ordering, put the magnetic information first
287//      Edit Filenames, Labels, RotAngle, Temperature, Field, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens as "Data File Catalog"
288#elif (exists("QUOKKA")==6)
289        //ANSTO
290        Edit Filenames, Labels, DateAndTime,  SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR,SICS, HDF as "Data File Catalog"
291#else
292        // HFIR or anything else
293        Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog"
294#endif
295
296        String name="CatVSTable"
297        DoWindow/C $name
298        return(0)
299End
300
301//reads header information and puts it in the appropriate waves for display in the table.
302//fname is the full path for opening (and reading) information from the file
303//which alreay was found to exist. sname is the file;vers to be written out,
304//avoiding the need to re-extract it from fname.
305Function GetHeaderInfoToWave(fname,sname)
306        String fname,sname
307       
308//      String textstr,temp,lbl,date_time,suffix
309//      Variable ,lambda,sdd,,refNum,trans,thick,xcenter,ycenter,numatten
310//      Variable lastPoint, beamstop,dum
311        Variable lastPoint,ctime,detcnt,cntrate//,instrumentNum
312
313        Wave/T GFilenames = $"root:myGlobals:CatVSHeaderInfo:Filenames"
314        Wave/T GSuffix = $"root:myGlobals:CatVSHeaderInfo:Suffix"
315        Wave/T GLabels = $"root:myGlobals:CatVSHeaderInfo:Labels"
316        Wave/T GDateTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime"
317        //ANSTO
318        Wave/T GSICS = $"root:myGlobals:CatVSHeaderInfo:SICS"
319        Wave/T GHDF = $"root:myGlobals:CatVSHeaderInfo:HDF"
320        //END ANSTO
321        Wave GSDD = $"root:myGlobals:CatVSHeaderInfo:SDD"
322        Wave GLambda = $"root:myGlobals:CatVSHeaderInfo:Lambda"
323        Wave GCntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime"
324        Wave GTotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts"
325        Wave GCntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate"
326        Wave GTransmission = $"root:myGlobals:CatVSHeaderInfo:Transmission"
327        Wave GThickness = $"root:myGlobals:CatVSHeaderInfo:Thickness"
328        Wave GXCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter"
329        Wave GYCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter"
330        Wave/B GNumGuides = $"root:myGlobals:CatVSHeaderInfo:nGuides"
331        Wave/B GNumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens"
332        Wave GRunNumber = $"root:myGlobals:CatVSHeaderInfo:RunNumber"
333        Wave GIsTrans = $"root:myGlobals:CatVSHeaderInfo:IsTrans"
334        Wave GRot = $"root:myGlobals:CatVSHeaderInfo:RotAngle"
335        Wave GTemp = $"root:myGlobals:CatVSHeaderInfo:Temperature"
336        Wave GField = $"root:myGlobals:CatVSHeaderInfo:Field"
337        Wave GMCR = $"root:myGlobals:CatVSHeaderInfo:MCR"
338        Wave GPos = $"root:myGlobals:CatVSHeaderInfo:Pos"
339        Wave GReactpow = $"root:myGlobals:CatVSHeaderInfo:reactorpower"         //activate for ILL, Jne 2008, (+ last insert @ end of function)
340
341        lastPoint = numpnts(GLambda)
342               
343        //filename
344        InsertPoints lastPoint,1,GFilenames
345        GFilenames[lastPoint]=sname
346       
347        //read the file alphanumeric suffix
348        InsertPoints lastPoint,1,GSuffix
349        GSuffix[lastPoint]=getSuffix(fname)
350
351        //read the counting time (integer)
352        InsertPoints lastPoint,1,GCntTime
353        ctime = getCountTime(fname)
354        GCntTime[lastPoint]=ctime
355       
356        //read the file creation date
357        InsertPoints lastPoint,1,GDateTime
358        GDateTime[lastPoint]=getFileCreationDate(fname)
359
360        // read the sample.label text field
361        InsertPoints lastPoint,1,GLabels
362        GLabels[lastPoint]=getSampleLabel(fname)
363       
364        #if (exists("QUOKKA")==6)
365                InsertPoints lastPoint,1,GSICS
366                GSICS[lastPoint]=getSICSVersion(fname)
367                       
368                //read the HDF version
369                InsertPoints lastPoint,1,GHDF
370                GHDF[lastPoint]=getHDFVersion(fname)
371        #endif
372               
373        //read the reals
374        //detector count and (derived) count rate
375        detcnt = getDetCount(fname)
376        cntrate = detcnt/ctime
377        InsertPoints lastPoint,1,GTotCnts
378        GTotCnts[lastPoint]=detcnt
379        InsertPoints lastPoint,1,GCntRate
380        GCntRate[lastPoint]=cntrate
381       
382        //Attenuators
383        InsertPoints lastPoint,1,GNumAttens
384        GNumAttens[lastPoint]=getAttenNumber(fname)
385       
386        //Transmission
387        InsertPoints lastPoint,1,GTransmission
388        GTransmission[lastPoint]=getSampleTrans(fname)
389       
390        //Thickness
391        InsertPoints lastPoint,1,GThickness
392        GThickness[lastPoint]=getSampleThickness(fname)
393
394        //XCenter of beam on detector
395        InsertPoints lastPoint,1,GXCenter
396        GXCenter[lastPoint]=getBeamXPos(fname)
397
398        //YCenter
399        InsertPoints lastPoint,1,GYCenter
400        GYCenter[lastPoint]=getBeamYPos(fname)
401
402        //SDD
403        InsertPoints lastPoint,1,GSDD
404        GSDD[lastPoint]=getSDD(fname)
405       
406        //wavelength
407        InsertPoints lastPoint,1,GLambda
408        GLambda[lastPoint]=getWavelength(fname)
409       
410        //Rotation Angle
411        InsertPoints lastPoint,1,GRot
412        GRot[lastPoint]=getSampleRotationAngle(fname)
413       
414        //Sample Temperature
415        InsertPoints lastPoint,1,GTemp
416        GTemp[lastPoint]=getTemperature(fname)
417       
418        //Sample Field
419        InsertPoints lastPoint,1,GField
420        GField[lastPoint]=getFieldStrength(fname)
421       
422        //Beamstop position (not reported)
423        //strToExecute = GBLoadStr + "/S=368/U=1" + "\"" + fname + "\""
424
425        //the run number (not displayed in the table, but carried along)
426        InsertPoints lastPoint,1,GRunNumber
427        GRunNumber[lastPoint] = GetRunNumFromFile(sname)
428
429        // 0 if the file is a scattering  file, 1 (truth) if the file is a transmission file
430        InsertPoints lastPoint,1,GIsTrans
431        GIsTrans[lastPoint]  = isTransFile(fname)               //returns one if beamstop is "out"
432       
433        // Monitor Count Rate
434        InsertPoints lastPoint,1,GMCR
435        GMCR[lastPoint]  = getMonitorCount(fname)/ctime         //total monitor count / total count time
436
437
438
439#if (exists("ILL_D22")==6)
440        // Reactor Power (activate for ILL)
441        InsertPoints lastPoint,1,GReactpow
442        GReactPow[lastPoint]  = getReactorPower(fname)
443#endif 
444
445// number of guides and sample position, only for NCNR
446#if (exists("NCNR")==6)
447//      instrumentNum = str2num(getAcctName(fname)[3])          // "[NGxSANSxx]" -- [3] should be then instrument number
448//      Variable/G root:Packages:NIST:SAS:instrument = instrumentNum            //so that Ng can be correctly calculated
449
450        // acct name is "[NGxSANSxx]" -- [1,3] is the instrument "name" "NGx"
451        //so that Ng can be correctly calculated
452        String/G root:Packages:NIST:SAS:gInstStr = getAcctName(fname)[1,3]
453       
454        InsertPoints lastPoint,1,GNumGuides
455        GNumGuides[lastPoint]  = numGuides(getSourceToSampleDist(fname))
456       
457        //Sample Position
458        InsertPoints lastPoint,1,GPos
459        GPos[lastPoint] = getSamplePosition(fname)
460#endif
461
462        return(0)
463End
464
465
466//this main procedure does all the work for making the cat notebook,
467// obtaining the folder path, parsing the filenames in the list,
468// and (dispatching) to write out the appropriate information to the notebook window
469Proc BuildCatShortNotebook()
470
471        DoWindow/F CatWin
472        If(V_Flag ==0)
473                String nb = "CatWin"
474                NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window"
475                Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72}
476                Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60}
477                Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}
478                Notebook $nb ruler=Normal; Notebook $nb  margins={0,0,544}
479        Endif
480       
481        Variable err
482        PathInfo catPathName
483        if(v_flag==0)
484                err = PickPath()                //sets the local path to the data (catPathName)
485                if(err)
486                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
487                Endif
488        Endif
489       
490        String temp=""
491        //clear old window contents, reset the path
492        Notebook CatWin,selection={startOfFile,EndOfFile}
493        Notebook CatWin,text="\r"
494       
495        PathInfo catPathName
496        temp = "FOLDER: "+S_path+"\r\r"
497        Notebook CatWin,font="Times",fsize=12,text = temp
498       
499        //get a list of all files in the folder, some will be junk version numbers that don't exist     
500        String list,partialName,tempName
501        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
502        Variable numitems,ii,ok
503       
504        //remove version numbers from semicolon-delimited list
505        list =  RemoveVersNumsFromList(list)
506       
507        numitems = ItemsInList(list,";")
508       
509        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
510        //***version numbers have been removed***
511        String str,fullName,notRAWlist
512        ii=0
513        notRAWlist = ""
514        do
515                //get current item in the list
516                partialName = StringFromList(ii, list, ";")
517                //get a valid file based on this partialName and catPathName
518                tempName = FindValidFilename(partialName)
519                If(cmpstr(tempName,"")==0)              //a null string was returned
520                        //write to notebook that file was not found
521                        //if string is not a number, report the error
522                        if(numtype(str2num(partialName)) == 2)
523                                str = "this file was not found: "+partialName+"\r\r"
524                                Notebook CatWin,font="Times",fsize=12,text=str
525                        Endif
526                else
527                        //prepend path to tempName for read routine
528                        PathInfo catPathName
529                        FullName = S_path + tempName
530                        //make sure the file is really a RAW data file
531                        ok = CheckIfRawData(fullName)
532                        if (!ok)
533                                //write to notebook that file was not a RAW SANS file
534                                notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r"
535                                //Notebook CatWin,font="Times",fsize=12,text=str
536                        else
537                                //go write the header information to the Notebook
538                                WriteCatToNotebook(fullName,tempName)
539                        Endif
540                Endif
541                ii+=1
542        while(ii<numitems)
543        Notebook CatWin,font="Times",fsize=12,text=notRAWlist
544End
545
546//writes out the CATalog information to the notebook named CatWin (which must exist)
547//fname is the full path for opening (and reading) information from the file
548//which alreay was found to exist. sname is the file;vers to be written out,
549//avoiding the need to re-extract it from fname.
550Function WriteCatToNotebook(fname,sname)
551        String fname,sname
552       
553        String textstr,temp,lbl,date_time
554        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick
555       
556        //read the file creation date
557        date_time = getFileCreationDate(fname)
558
559        // read the sample.label text field
560        lbl = getSampleLabel(fname)
561       
562        //read the counting time (integer)
563        ctime = getCountTime(fname)
564               
565        //read the reals
566       
567        //detector count + countrate
568        detcnt = getDetCount(fname)
569        cntrate = detcnt/ctime
570       
571        //wavelength
572        lambda = getWavelength(fname)
573       
574        //SDD
575        sdd = getSDD(fname)
576       
577        //Transmission
578        trans = getSampleTrans(fname)
579       
580        //Thickness
581        thick = getSampleThickness(fname)
582               
583        temp = "FILE:  "
584        Notebook CatWin,textRGB=(0,0,0),text=temp
585        Notebook CatWin,fstyle=1,text=sname
586        temp = "\t\t"+date_time+"\r"
587        Notebook CatWin,fstyle=0,text=temp
588        temp = "LABEL: "+lbl+"\r"
589        Notebook CatWin,text=temp
590        temp = "COUNTING TIME: "+num2str(ctime)+" secs \t\tDETECTOR COUNT: "+num2str(detcnt)+"\r"
591        Notebook CatWin,text=temp
592        temp = "WAVELENGTH: "+num2str(lambda)+" A \tSDD: "+num2str(sdd)+" m \t"
593        temp += "DET. CNT. RATE: "+num2str(cntrate)+"  cts/sec\r"
594        Notebook CatWin,text=temp
595        temp = "TRANS: "
596        Notebook CatWin,text=temp
597        temp =  num2str(trans)
598        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
599        temp =  "\t\tTHICKNESS: "
600        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
601        temp =  num2str(thick)
602        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
603        temp = " cm\r\r"
604        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
605End
606
607
608//****************
609// main procedure for CAT/VS Notebook ******
610//this main procedure does all the work, obtaining the folder path,
611//parsing the filenames in the list and (dispatching) to write out the
612//appropriate information to the notebook window
613Proc BuildCatVeryShortNotebook()
614
615        DoWindow/F CatWin
616        If(V_Flag ==0)
617                String nb = "CatWin"
618                NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window"
619                Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72}
620                Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60}
621                Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}
622                Notebook $nb ruler=Normal; Notebook $nb  margins={0,0,544}
623        Endif
624       
625        Variable err
626        PathInfo catPathName
627        if(v_flag==0)
628                err = PickPath()                //sets the local path to the data (catPathName)
629                if(err)
630                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
631                Endif
632        Endif
633       
634        String temp=""
635        //clear old window contents, reset the path
636        Notebook CatWin,selection={startOfFile,EndOfFile}
637        Notebook CatWin,text="\r"
638       
639        PathInfo catPathName
640        temp = "FOLDER: "+S_path+"\r\r"
641        Notebook CatWin,font="Times",fsize=12,text = temp
642        Notebook CatWin,fstyle=1,text="NAME"+", "
643        temp = "Label"+", "
644        Notebook CatWin,fstyle=0, text=temp
645        temp = "CntTime"
646        Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp
647        temp = ", TotDetCnts, "
648        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
649        temp = "Lambda"
650        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
651        temp = ", SDD, "
652        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
653        temp = "CountRate"
654        Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp
655        temp =  ", Transmission, "
656        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
657        temp =  "Thickness"
658        Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp
659        temp = ", Xposition"
660        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
661        temp = ", Yposition"
662        Notebook CatWin,textRGB=(50000,0,0),fStyle = 0,text=temp
663        temp = "\r\r"
664        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
665
666       
667        //get a list of all files in the folder, some will be junk version numbers that don't exist     
668        String list,partialName,tempName
669        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
670        Variable numitems,ii,ok
671       
672        //remove version numbers from semicolon-delimited list
673        list =  RemoveVersNumsFromList(list)
674       
675        numitems = ItemsInList(list,";")
676       
677        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
678        //***version numbers have been removed***
679        String str,fullName,notRAWlist
680        ii=0
681       
682        notRAWlist=""
683        do
684                //get current item in the list
685                partialName = StringFromList(ii, list, ";")
686                //get a valid file based on this partialName and catPathName
687                tempName = FindValidFilename(partialName)
688                If(cmpstr(tempName,"")==0)              //a null string was returned
689                        //write to notebook that file was not found
690                        //if string is not a number, report the error
691                        if(numtype(str2num(partialName)) == 2)
692                                str = "this file was not found: "+partialName+"\r\r"
693                                Notebook CatWin,font="Times",fsize=12,text=str
694                        Endif
695                else
696                        //prepend path to tempName for read routine
697                        PathInfo catPathName
698                        FullName = S_path + tempName
699                        //make sure the file is really a RAW data file
700                        ok = CheckIfRawData(fullName)
701                        if (!ok)
702                                //write to notebook that file was not a RAW SANS file
703                                notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r"
704                                //Notebook CatWin,font="Times",fsize=12,text=str
705                        else
706                                //go write the header information to the Notebook
707                                WriteCatVSToNotebook(fullName,tempName)
708                        Endif
709                Endif
710                ii+=1
711        while(ii<numitems)
712        Notebook CatWin,font="Times",fsize=12,text=notRAWlist
713End
714
715//writes out the CATalog information to the notebook named CatWin (which must exist)
716//fname is the full path for opening (and reading) information from the file
717//which alreay was found to exist. sname is the file;vers to be written out,
718//avoiding the need to re-extract it from fname.
719Function WriteCatVSToNotebook(fname,sname)
720        String fname,sname
721       
722        String textstr,temp,lbl,date_time
723        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten
724       
725        //read the file creation date
726        date_time = getFileCreationDate(fname)
727
728        // read the sample.label text field
729        lbl = getSampleLabel(fname)
730       
731        //read the counting time (integer)
732        ctime = getCountTime(fname)
733               
734        //read the reals
735        //detector count + countrate
736        detcnt = getDetCount(fname)
737        cntrate = detcnt/ctime
738       
739        //wavelength
740        lambda = getWavelength(fname)
741       
742        //SDD
743        sdd = getSDD(fname)
744       
745        //Transmission
746        trans = getSampleTrans(fname)
747       
748        //Thickness
749        thick = getSampleThickness(fname)
750               
751        //Attenuators
752        numatten = getAttenNumber(fname)
753
754        //XCenter
755        xCenter = getBeamXPos(fname)
756
757        //YCenter
758        yCenter = getBeamYPos(fname)
759
760       
761        temp = ""
762        Notebook CatWin,textRGB=(0,0,0),text=temp
763        Notebook CatWin,fstyle=1,text=sname+", "
764//      temp = ", "+date_time+", "
765//      Notebook CatWin,fstyle=0,text=temp
766        temp = lbl+", "
767        Notebook CatWin,fstyle=0, text=temp
768        temp = num2str(ctime)
769        Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp
770        temp = ", " + num2str(detcnt) + ", "
771        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
772        temp = num2str(lambda)
773        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
774        temp = ", "+num2str(sdd)+", "
775        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
776        temp = num2str(cntrate)
777        Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp
778        temp =  ", "+num2str(trans)+", "
779        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
780        temp =  num2str(thick)
781        Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp
782        temp = ", "+num2str(xCenter)+", "
783        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
784        temp = num2str(yCenter)+"\r"
785        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
786        //temp = num2str(numatten)+", "
787        //Notebook CatWin,text=temp
788End
Note: See TracBrowser for help on using the repository browser.