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

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

more transferring of functions to NCNR_* files.

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