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

Last change on this file since 656 was 656, checked in by ajj, 12 years ago

Update to CatVSTable to show sample position, TISANE to fix a couple of startup bugs and FuzzySpheres? to add the lorentzian term.

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 NumGuides = $"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                ModifyTable width(:myGlobals:CatVSHedaerInfo:Pos)=30
105#if (exists("ILL_D22")==6)
106                ModifyTable width(:myGlobals:CatVSHeaderInfo:Reactorpower)=50           //activate for ILL, June 2008
107#endif
108
109#if (exists("NCNR")==6)
110                ModifyTable width(:myGlobals:CatVSHeaderInfo:nGuides)=40
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,GPos,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,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        //Sample Position
402        InsertPoints lastPoint,1,GPos
403        GPos[lastPoint] = getSamplePosition(fname)
404
405#if (exists("ILL_D22")==6)
406        // Reactor Power (activate for ILL)
407        InsertPoints lastPoint,1,GReactpow
408        GReactPow[lastPoint]  = getReactorPower(fname)
409#endif 
410
411// number of guides, only for NCNR
412#if (exists("NCNR")==6)
413        InsertPoints lastPoint,1,GNumGuides
414        GNumGuides[lastPoint]  = numGuides(getSourceToSampleDist(fname))
415#endif
416
417        return(0)
418End
419
420
421//this main procedure does all the work for making the cat notebook,
422// obtaining the folder path, parsing the filenames in the list,
423// and (dispatching) to write out the appropriate information to the notebook window
424Proc BuildCatShortNotebook()
425
426        DoWindow/F CatWin
427        If(V_Flag ==0)
428                String nb = "CatWin"
429                NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window"
430                Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72}
431                Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60}
432                Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}
433                Notebook $nb ruler=Normal; Notebook $nb  margins={0,0,544}
434        Endif
435       
436        Variable err
437        PathInfo catPathName
438        if(v_flag==0)
439                err = PickPath()                //sets the local path to the data (catPathName)
440                if(err)
441                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
442                Endif
443        Endif
444       
445        String temp=""
446        //clear old window contents, reset the path
447        Notebook CatWin,selection={startOfFile,EndOfFile}
448        Notebook CatWin,text="\r"
449       
450        PathInfo catPathName
451        temp = "FOLDER: "+S_path+"\r\r"
452        Notebook CatWin,font="Times",fsize=12,text = temp
453       
454        //get a list of all files in the folder, some will be junk version numbers that don't exist     
455        String list,partialName,tempName
456        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
457        Variable numitems,ii,ok
458       
459        //remove version numbers from semicolon-delimited list
460        list =  RemoveVersNumsFromList(list)
461       
462        numitems = ItemsInList(list,";")
463       
464        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
465        //***version numbers have been removed***
466        String str,fullName,notRAWlist
467        ii=0
468        notRAWlist = ""
469        do
470                //get current item in the list
471                partialName = StringFromList(ii, list, ";")
472                //get a valid file based on this partialName and catPathName
473                tempName = FindValidFilename(partialName)
474                If(cmpstr(tempName,"")==0)              //a null string was returned
475                        //write to notebook that file was not found
476                        //if string is not a number, report the error
477                        if(str2num(partialName) == NaN)
478                                str = "this file was not found: "+partialName+"\r\r"
479                                Notebook CatWin,font="Times",fsize=12,text=str
480                        Endif
481                else
482                        //prepend path to tempName for read routine
483                        PathInfo catPathName
484                        FullName = S_path + tempName
485                        //make sure the file is really a RAW data file
486                        ok = CheckIfRawData(fullName)
487                        if (!ok)
488                                //write to notebook that file was not a RAW SANS file
489                                notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r"
490                                //Notebook CatWin,font="Times",fsize=12,text=str
491                        else
492                                //go write the header information to the Notebook
493                                WriteCatToNotebook(fullName,tempName)
494                        Endif
495                Endif
496                ii+=1
497        while(ii<numitems)
498        Notebook CatWin,font="Times",fsize=12,text=notRAWlist
499End
500
501//writes out the CATalog information to the notebook named CatWin (which must exist)
502//fname is the full path for opening (and reading) information from the file
503//which alreay was found to exist. sname is the file;vers to be written out,
504//avoiding the need to re-extract it from fname.
505Function WriteCatToNotebook(fname,sname)
506        String fname,sname
507       
508        String textstr,temp,lbl,date_time
509        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick
510       
511        //read the file creation date
512        date_time = getFileCreationDate(fname)
513
514        // read the sample.label text field
515        lbl = getSampleLabel(fname)
516       
517        //read the counting time (integer)
518        ctime = getCountTime(fname)
519               
520        //read the reals
521       
522        //detector count + countrate
523        detcnt = getDetCount(fname)
524        cntrate = detcnt/ctime
525       
526        //wavelength
527        lambda = getWavelength(fname)
528       
529        //SDD
530        sdd = getSDD(fname)
531       
532        //Transmission
533        trans = getSampleTrans(fname)
534       
535        //Thickness
536        thick = getSampleThickness(fname)
537               
538        temp = "FILE:  "
539        Notebook CatWin,textRGB=(0,0,0),text=temp
540        Notebook CatWin,fstyle=1,text=sname
541        temp = "\t\t"+date_time+"\r"
542        Notebook CatWin,fstyle=0,text=temp
543        temp = "LABEL: "+lbl+"\r"
544        Notebook CatWin,text=temp
545        temp = "COUNTING TIME: "+num2str(ctime)+" secs \t\tDETECTOR COUNT: "+num2str(detcnt)+"\r"
546        Notebook CatWin,text=temp
547        temp = "WAVELENGTH: "+num2str(lambda)+" A \tSDD: "+num2str(sdd)+" m \t"
548        temp += "DET. CNT. RATE: "+num2str(cntrate)+"  cts/sec\r"
549        Notebook CatWin,text=temp
550        temp = "TRANS: "
551        Notebook CatWin,text=temp
552        temp =  num2str(trans)
553        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
554        temp =  "\t\tTHICKNESS: "
555        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
556        temp =  num2str(thick)
557        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
558        temp = " cm\r\r"
559        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
560End
561
562
563//****************
564// main procedure for CAT/VS Notebook ******
565//this main procedure does all the work, obtaining the folder path,
566//parsing the filenames in the list and (dispatching) to write out the
567//appropriate information to the notebook window
568Proc BuildCatVeryShortNotebook()
569
570        DoWindow/F CatWin
571        If(V_Flag ==0)
572                String nb = "CatWin"
573                NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window"
574                Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72}
575                Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60}
576                Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}
577                Notebook $nb ruler=Normal; Notebook $nb  margins={0,0,544}
578        Endif
579       
580        Variable err
581        PathInfo catPathName
582        if(v_flag==0)
583                err = PickPath()                //sets the local path to the data (catPathName)
584                if(err)
585                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
586                Endif
587        Endif
588       
589        String temp=""
590        //clear old window contents, reset the path
591        Notebook CatWin,selection={startOfFile,EndOfFile}
592        Notebook CatWin,text="\r"
593       
594        PathInfo catPathName
595        temp = "FOLDER: "+S_path+"\r\r"
596        Notebook CatWin,font="Times",fsize=12,text = temp
597        Notebook CatWin,fstyle=1,text="NAME"+", "
598        temp = "Label"+", "
599        Notebook CatWin,fstyle=0, text=temp
600        temp = "CntTime"
601        Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp
602        temp = ", TotDetCnts, "
603        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
604        temp = "Lambda"
605        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
606        temp = ", SDD, "
607        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
608        temp = "CountRate"
609        Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp
610        temp =  ", Transmission, "
611        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
612        temp =  "Thickness"
613        Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp
614        temp = ", Xposition"
615        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
616        temp = ", Yposition"
617        Notebook CatWin,textRGB=(50000,0,0),fStyle = 0,text=temp
618        temp = "\r\r"
619        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
620
621       
622        //get a list of all files in the folder, some will be junk version numbers that don't exist     
623        String list,partialName,tempName
624        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
625        Variable numitems,ii,ok
626       
627        //remove version numbers from semicolon-delimited list
628        list =  RemoveVersNumsFromList(list)
629       
630        numitems = ItemsInList(list,";")
631       
632        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
633        //***version numbers have been removed***
634        String str,fullName,notRAWlist
635        ii=0
636       
637        notRAWlist=""
638        do
639                //get current item in the list
640                partialName = StringFromList(ii, list, ";")
641                //get a valid file based on this partialName and catPathName
642                tempName = FindValidFilename(partialName)
643                If(cmpstr(tempName,"")==0)              //a null string was returned
644                        //write to notebook that file was not found
645                        //if string is not a number, report the error
646                        if(str2num(partialName) == NaN)
647                                str = "this file was not found: "+partialName+"\r\r"
648                                Notebook CatWin,font="Times",fsize=12,text=str
649                        Endif
650                else
651                        //prepend path to tempName for read routine
652                        PathInfo catPathName
653                        FullName = S_path + tempName
654                        //make sure the file is really a RAW data file
655                        ok = CheckIfRawData(fullName)
656                        if (!ok)
657                                //write to notebook that file was not a RAW SANS file
658                                notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r"
659                                //Notebook CatWin,font="Times",fsize=12,text=str
660                        else
661                                //go write the header information to the Notebook
662                                WriteCatVSToNotebook(fullName,tempName)
663                        Endif
664                Endif
665                ii+=1
666        while(ii<numitems)
667        Notebook CatWin,font="Times",fsize=12,text=notRAWlist
668End
669
670//writes out the CATalog information to the notebook named CatWin (which must exist)
671//fname is the full path for opening (and reading) information from the file
672//which alreay was found to exist. sname is the file;vers to be written out,
673//avoiding the need to re-extract it from fname.
674Function WriteCatVSToNotebook(fname,sname)
675        String fname,sname
676       
677        String textstr,temp,lbl,date_time
678        Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten
679       
680        //read the file creation date
681        date_time = getFileCreationDate(fname)
682
683        // read the sample.label text field
684        lbl = getSampleLabel(fname)
685       
686        //read the counting time (integer)
687        ctime = getCountTime(fname)
688               
689        //read the reals
690        //detector count + countrate
691        detcnt = getDetCount(fname)
692        cntrate = detcnt/ctime
693       
694        //wavelength
695        lambda = getWavelength(fname)
696       
697        //SDD
698        sdd = getSDD(fname)
699       
700        //Transmission
701        trans = getSampleTrans(fname)
702       
703        //Thickness
704        thick = getSampleThickness(fname)
705               
706        //Attenuators
707        numatten = getAttenNumber(fname)
708
709        //XCenter
710        xCenter = getBeamXPos(fname)
711
712        //YCenter
713        yCenter = getBeamYPos(fname)
714
715       
716        temp = ""
717        Notebook CatWin,textRGB=(0,0,0),text=temp
718        Notebook CatWin,fstyle=1,text=sname+", "
719//      temp = ", "+date_time+", "
720//      Notebook CatWin,fstyle=0,text=temp
721        temp = lbl+", "
722        Notebook CatWin,fstyle=0, text=temp
723        temp = num2str(ctime)
724        Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp
725        temp = ", " + num2str(detcnt) + ", "
726        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
727        temp = num2str(lambda)
728        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
729        temp = ", "+num2str(sdd)+", "
730        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
731        temp = num2str(cntrate)
732        Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp
733        temp =  ", "+num2str(trans)+", "
734        Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp
735        temp =  num2str(thick)
736        Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp
737        temp = ", "+num2str(xCenter)+", "
738        Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp
739        temp = num2str(yCenter)+"\r"
740        Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp
741        //temp = num2str(numatten)+", "
742        //Notebook CatWin,text=temp
743End
Note: See TracBrowser for help on using the repository browser.