source: sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/CatVSTable.ipf @ 80

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

2nd pass of pulling out NCNR calls. Also cleared a lot of deadwood from the code, removing depricated functions that were mostly already commented out.

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