source: sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/CatVSTable.ipf @ 40

Last change on this file since 40 was 40, checked in by srkline, 16 years ago

Initial checkin of V5.00 SANSReduction files

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