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

Last change on this file since 577 was 577, checked in by srkline, 13 years ago

Fixed logic error in writing the XY box count values to the empty beam header that could result in INF transmission.

Updated critera for "RAW" data files to include "SIM" as well.

Added NCNR_Utils to the includes list for Analysis.

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