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

Last change on this file since 605 was 605, checked in by srkline, 13 years ago

USANS:

  • added warning for mutliple scattering to the panel (red if trouble)
  • improved handling of .bt5 files if the peak can't be found
  • added a routine to save the fake "cor" file along with the .bt5 files. The cor file is much more useful.

SANS:

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