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

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

(1) fixed file numbering scheme in HFIR_Utils to generate 4-digit number
(2) moved transmission beta operations to new buttons on the transmission panel
(3) cleared transmissin beta operations from the beta menu

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