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

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

Added conditional compile instructions to some reduction procedure files that have only minor facility-specific changes. These changes are not significant enough to merit a separate facility file that must be maintained with essentially duplicate functions.

#define SYMBOL was attempted, but did not work since the symbols weren't actually defined until after the compile... and I couldn't figure out how to define - then compile. in additon, the table is static until Igor is quit - so multiple symbols could be defined, and compiling would fail.

So... the method now that appears to work is to put a dummy function for each facility in its facility specific "Includes" file. Then the conditional compilation checks for exists("function").

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