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

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

Modified installer to copy folders, rather than move them. This allows the installer to be re-run without downloading or unzipping a fresh copy.

Added a "refresh" button to the PlotManager?. Streamlined the filtering out of non-plottable data.

Made XML the default (set the global to 1 in Wrapper, Initialize, and Main_USANS).

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