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

Last change on this file since 779 was 707, checked in by ajj, 13 years ago

Updates and fixes to make ANSTO data reduction work.

  • Translated existing code from 6.x version of macros to 7.x

Plus!

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