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

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

Fixed some typos in help files.

Fixed some incorrect logic in conditional compilation for CatVSTable with different facilities.

Use proper save path in UCALC so that the suggested .bt5 ending is preserved.

--this line, and those below, will be ignored--

M trunk/NCNR_User_Procedures/Reduction/SANS/CatVSTable.ipf
M trunk/NCNR_User_Procedures/Reduction/USANS/U_CALC.ipf
M trunk/NCNR_Help_Files/Scattering_Simulation_v1.0.ihf
M trunk/NCNR_Help_Files/SANS_Reduction_Help_v5.20.ihf
M trunk/NCNR_Help_Files/SANS_Model_Docs_v4.10.ihf
M trunk/NCNR_Help_Files/SANS_Analysis_Docs_v4.10.ihf
M trunk/NCNR_Help_Files/USANSReductionHelp_v2.3.ihf

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