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

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

A number of changes to provide the first - alpha version of event mode processing. Works for oscillatory mode data, and a continuous stream. Short on documentation, needs lots of testing.

File size: 29.9 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        InsertPoints lastPoint,1,GNumGuides
451        GNumGuides[lastPoint]  = numGuides(getSourceToSampleDist(fname))
452       
453        //Sample Position
454        InsertPoints lastPoint,1,GPos
455        GPos[lastPoint] = getSamplePosition(fname)
456#endif
457
458        return(0)
459End
460
461
462//this main procedure does all the work for making the cat notebook,
463// obtaining the folder path, parsing the filenames in the list,
464// and (dispatching) to write out the appropriate information to the notebook window
465Proc BuildCatShortNotebook()
466
467        DoWindow/F CatWin
468        If(V_Flag ==0)
469                String nb = "CatWin"
470                NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window"
471                Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72}
472                Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60}
473                Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}
474                Notebook $nb ruler=Normal; Notebook $nb  margins={0,0,544}
475        Endif
476       
477        Variable err
478        PathInfo catPathName
479        if(v_flag==0)
480                err = PickPath()                //sets the local path to the data (catPathName)
481                if(err)
482                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
483                Endif
484        Endif
485       
486        String temp=""
487        //clear old window contents, reset the path
488        Notebook CatWin,selection={startOfFile,EndOfFile}
489        Notebook CatWin,text="\r"
490       
491        PathInfo catPathName
492        temp = "FOLDER: "+S_path+"\r\r"
493        Notebook CatWin,font="Times",fsize=12,text = temp
494       
495        //get a list of all files in the folder, some will be junk version numbers that don't exist     
496        String list,partialName,tempName
497        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
498        Variable numitems,ii,ok
499       
500        //remove version numbers from semicolon-delimited list
501        list =  RemoveVersNumsFromList(list)
502       
503        numitems = ItemsInList(list,";")
504       
505        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
506        //***version numbers have been removed***
507        String str,fullName,notRAWlist
508        ii=0
509        notRAWlist = ""
510        do
511                //get current item in the list
512                partialName = StringFromList(ii, list, ";")
513                //get a valid file based on this partialName and catPathName
514                tempName = FindValidFilename(partialName)
515                If(cmpstr(tempName,"")==0)              //a null string was returned
516                        //write to notebook that file was not found
517                        //if string is not a number, report the error
518                        if(numtype(str2num(partialName)) == 2)
519                                str = "this file was not found: "+partialName+"\r\r"
520                                Notebook CatWin,font="Times",fsize=12,text=str
521                        Endif
522                else
523                        //prepend path to tempName for read routine
524                        PathInfo catPathName
525                        FullName = S_path + tempName
526                        //make sure the file is really a RAW data file
527                        ok = CheckIfRawData(fullName)
528                        if (!ok)
529                                //write to notebook that file was not a RAW SANS file
530                                notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r"
531                                //Notebook CatWin,font="Times",fsize=12,text=str
532                        else
533                                //go write the header information to the Notebook
534                                WriteCatToNotebook(fullName,tempName)
535                        Endif
536                Endif
537                ii+=1
538        while(ii<numitems)
539        Notebook CatWin,font="Times",fsize=12,text=notRAWlist
540End
541
542//writes out the CATalog information to the notebook named CatWin (which must exist)
543//fname is the full path for opening (and reading) information from the file
544//which alreay was found to exist. sname is the file;vers to be written out,
545//avoiding the need to re-extract it from fname.
546Function WriteCatToNotebook(fname,sname)
547        String fname,sname
548       
549        String textstr,temp,lbl,date_time
550        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick
551       
552        //read the file creation date
553        date_time = getFileCreationDate(fname)
554
555        // read the sample.label text field
556        lbl = getSampleLabel(fname)
557       
558        //read the counting time (integer)
559        ctime = getCountTime(fname)
560               
561        //read the reals
562       
563        //detector count + countrate
564        detcnt = getDetCount(fname)
565        cntrate = detcnt/ctime
566       
567        //wavelength
568        lambda = getWavelength(fname)
569       
570        //SDD
571        sdd = getSDD(fname)
572       
573        //Transmission
574        trans = getSampleTrans(fname)
575       
576        //Thickness
577        thick = getSampleThickness(fname)
578               
579        temp = "FILE:  "
580        Notebook CatWin,textRGB=(0,0,0),text=temp
581        Notebook CatWin,fstyle=1,text=sname
582        temp = "\t\t"+date_time+"\r"
583        Notebook CatWin,fstyle=0,text=temp
584        temp = "LABEL: "+lbl+"\r"
585        Notebook CatWin,text=temp
586        temp = "COUNTING TIME: "+num2str(ctime)+" secs \t\tDETECTOR COUNT: "+num2str(detcnt)+"\r"
587        Notebook CatWin,text=temp
588        temp = "WAVELENGTH: "+num2str(lambda)+" A \tSDD: "+num2str(sdd)+" m \t"
589        temp += "DET. CNT. RATE: "+num2str(cntrate)+"  cts/sec\r"
590        Notebook CatWin,text=temp
591        temp = "TRANS: "
592        Notebook CatWin,text=temp
593        temp =  num2str(trans)
594        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
595        temp =  "\t\tTHICKNESS: "
596        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
597        temp =  num2str(thick)
598        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
599        temp = " cm\r\r"
600        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
601End
602
603
604//****************
605// main procedure for CAT/VS Notebook ******
606//this main procedure does all the work, obtaining the folder path,
607//parsing the filenames in the list and (dispatching) to write out the
608//appropriate information to the notebook window
609Proc BuildCatVeryShortNotebook()
610
611        DoWindow/F CatWin
612        If(V_Flag ==0)
613                String nb = "CatWin"
614                NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window"
615                Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72}
616                Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60}
617                Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}
618                Notebook $nb ruler=Normal; Notebook $nb  margins={0,0,544}
619        Endif
620       
621        Variable err
622        PathInfo catPathName
623        if(v_flag==0)
624                err = PickPath()                //sets the local path to the data (catPathName)
625                if(err)
626                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
627                Endif
628        Endif
629       
630        String temp=""
631        //clear old window contents, reset the path
632        Notebook CatWin,selection={startOfFile,EndOfFile}
633        Notebook CatWin,text="\r"
634       
635        PathInfo catPathName
636        temp = "FOLDER: "+S_path+"\r\r"
637        Notebook CatWin,font="Times",fsize=12,text = temp
638        Notebook CatWin,fstyle=1,text="NAME"+", "
639        temp = "Label"+", "
640        Notebook CatWin,fstyle=0, text=temp
641        temp = "CntTime"
642        Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp
643        temp = ", TotDetCnts, "
644        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
645        temp = "Lambda"
646        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
647        temp = ", SDD, "
648        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
649        temp = "CountRate"
650        Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp
651        temp =  ", Transmission, "
652        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
653        temp =  "Thickness"
654        Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp
655        temp = ", Xposition"
656        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
657        temp = ", Yposition"
658        Notebook CatWin,textRGB=(50000,0,0),fStyle = 0,text=temp
659        temp = "\r\r"
660        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
661
662       
663        //get a list of all files in the folder, some will be junk version numbers that don't exist     
664        String list,partialName,tempName
665        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
666        Variable numitems,ii,ok
667       
668        //remove version numbers from semicolon-delimited list
669        list =  RemoveVersNumsFromList(list)
670       
671        numitems = ItemsInList(list,";")
672       
673        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
674        //***version numbers have been removed***
675        String str,fullName,notRAWlist
676        ii=0
677       
678        notRAWlist=""
679        do
680                //get current item in the list
681                partialName = StringFromList(ii, list, ";")
682                //get a valid file based on this partialName and catPathName
683                tempName = FindValidFilename(partialName)
684                If(cmpstr(tempName,"")==0)              //a null string was returned
685                        //write to notebook that file was not found
686                        //if string is not a number, report the error
687                        if(numtype(str2num(partialName)) == 2)
688                                str = "this file was not found: "+partialName+"\r\r"
689                                Notebook CatWin,font="Times",fsize=12,text=str
690                        Endif
691                else
692                        //prepend path to tempName for read routine
693                        PathInfo catPathName
694                        FullName = S_path + tempName
695                        //make sure the file is really a RAW data file
696                        ok = CheckIfRawData(fullName)
697                        if (!ok)
698                                //write to notebook that file was not a RAW SANS file
699                                notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r"
700                                //Notebook CatWin,font="Times",fsize=12,text=str
701                        else
702                                //go write the header information to the Notebook
703                                WriteCatVSToNotebook(fullName,tempName)
704                        Endif
705                Endif
706                ii+=1
707        while(ii<numitems)
708        Notebook CatWin,font="Times",fsize=12,text=notRAWlist
709End
710
711//writes out the CATalog information to the notebook named CatWin (which must exist)
712//fname is the full path for opening (and reading) information from the file
713//which alreay was found to exist. sname is the file;vers to be written out,
714//avoiding the need to re-extract it from fname.
715Function WriteCatVSToNotebook(fname,sname)
716        String fname,sname
717       
718        String textstr,temp,lbl,date_time
719        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten
720       
721        //read the file creation date
722        date_time = getFileCreationDate(fname)
723
724        // read the sample.label text field
725        lbl = getSampleLabel(fname)
726       
727        //read the counting time (integer)
728        ctime = getCountTime(fname)
729               
730        //read the reals
731        //detector count + countrate
732        detcnt = getDetCount(fname)
733        cntrate = detcnt/ctime
734       
735        //wavelength
736        lambda = getWavelength(fname)
737       
738        //SDD
739        sdd = getSDD(fname)
740       
741        //Transmission
742        trans = getSampleTrans(fname)
743       
744        //Thickness
745        thick = getSampleThickness(fname)
746               
747        //Attenuators
748        numatten = getAttenNumber(fname)
749
750        //XCenter
751        xCenter = getBeamXPos(fname)
752
753        //YCenter
754        yCenter = getBeamYPos(fname)
755
756       
757        temp = ""
758        Notebook CatWin,textRGB=(0,0,0),text=temp
759        Notebook CatWin,fstyle=1,text=sname+", "
760//      temp = ", "+date_time+", "
761//      Notebook CatWin,fstyle=0,text=temp
762        temp = lbl+", "
763        Notebook CatWin,fstyle=0, text=temp
764        temp = num2str(ctime)
765        Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp
766        temp = ", " + num2str(detcnt) + ", "
767        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
768        temp = num2str(lambda)
769        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
770        temp = ", "+num2str(sdd)+", "
771        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
772        temp = num2str(cntrate)
773        Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp
774        temp =  ", "+num2str(trans)+", "
775        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
776        temp =  num2str(thick)
777        Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp
778        temp = ", "+num2str(xCenter)+", "
779        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
780        temp = num2str(yCenter)+"\r"
781        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
782        //temp = num2str(numatten)+", "
783        //Notebook CatWin,text=temp
784End
Note: See TracBrowser for help on using the repository browser.