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

Last change on this file since 328 was 328, checked in by ajj, 14 years ago

Rearranging files

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