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

Revision 570, 24.3 KB checked in by srkline, 5 years ago (diff)

Change (1):
In preparation for release, updated pragma IgorVersion?=6.1 in all procedures

Change (2):
As a side benefit of requiring 6.1, we can use the MultiThread? keyword to thread any model function we like. The speed benefit is only noticeable on functions that require at least one integration and at least 100 points (resolution smearing is NOT threaded, too many threadSafe issues, too little benefit). I have chosen to use the MultiThread? only on the XOP assignment. In the Igor code there are too many functions that are not explicitly declared threadsafe, making for a mess.

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