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

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

changed the number of significant digits visible in the Catalog table, so that the wavelength, SDD, and sample position don't show up as odd floating point values, when they're only off by a smidgen. If they are significantly off, the real value will be seen.

Modified the file loader for Linearized fits to correctly handle files that are loaded with file names that are too long. Now they are loaded and plotted correctly, as the plot manager does. Now, when fitting, if the file name is too long (from the popup) then the user is prompted to pick the data set, since I don't know which one it is anymore, since the name was changed. Not too big of an issue. Most (All, I hope) of the file writing routines now enforce short, compliant names. this is ticket #363

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