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

Last change on this file since 1004 was 1004, checked in by srkline, 6 years ago

changes to handle an arbitrary run number, rather than insisting on 3 or 4 digits.

fix to SANS file catalog where the last file name was cleared from the table, if there are no extra non-raw data files present. not a typical case, but it can happen.

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