source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_FileCatalog.ipf @ 1012

Last change on this file since 1012 was 1012, checked in by srkline, 6 years ago

Updating the patch panel for the VSANS variables, a first pass at including the essential values, and a section that has per-detector values.

Still needs to be fully stress tested to be sure that it does all of read/write operations correctly.

adjusted the "last file loaded" global variable that is displayed on the data display to only update when a file is loaded for display, not when any file is loaded for the catalog, or for the patch panel.

  • Property svn:executable set to *
File size: 27.0 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=6.1
4
5//
6// UPDATED for VSANS - only the simplest implementation to start with
7// June 2016  SRK
8// included ANSTO sort panel from david m
9//
10
11
12//
13// TODO
14// -- clean up and remove all of the references to other facilities, since they will not have VSANS modules
15// -- add in more appropriate and some missing fields more useful to VSANS (intent, multiple beam centers, etc.)
16//
17// TODO PRIORITY:
18// x- clean up the list of files that now accumulates in the RawVSANS folder!!! Everything is there, including
19//    files that are NOT RAW VSANS data (MASK and DIV, but these are HDF)
20// x- WHY -- because if I PATCH anything, then re-run the catalog, the changes are NOT shown, since the
21//    reader will g to the LOCAL copy first! So maybe I need to clear the folder out before I start the
22//    file catalog
23// -- maybe it's a good thing to wipe out the RawVSANS folder before an Experiment SAVE (to save a LOT of
24//    space on disk and a potentially VERY long save
25// x- see V_CleanOutRawVSANS() in V_Utilities_General for the start of this (this is now called in
26//    V_BuildCatVeryShortTable(), the starting point for generating the table.)
27//
28// NEW for VSANS
29// clear out the folders in the RawVSANS folder, otherwise any changes/patches written to disk
30// will not be read in, the "bad" local copy will be read in.
31// TODO:
32//  -- this *may* be a very slow operation. Warn users. Give them a choice to keep local copies. If
33//     the "patched" values are written locally too, then maybe the update from disk is not needed.
34//     But typically, I'd like to see that the disk version really did get updated...
35//
36
37//
38//      SRK modified 30 JAN07 to include Rotation angle, Temperature, and B-field in the table (at the end)
39//
40
41//**************
42// Vers 1.2 090401
43//
44// Procedures for creating the Catalog listings of the SANS datafiles in the folder
45// specified by catPathName.
46// Header information from each of the dataifles is organized in a table for
47// easy identification of each file. CatVSANSTable is the preferred invocation,
48// although CatVSNotebook and CatNotebook can also be used.
49// Files in the folder that are not RAW SANS data are appended to the end of the listing.
50//**************
51
52//this main procedure does all the work, obtaining the folder path,
53//parsing the filenames in the list and (dispatching) to write out the
54//appropriate information to the growing (table) of data. V_GetHeaderInfoToWave() does the individual reads
55Function V_BuildCatVeryShortTable()
56       
57        Variable err
58        Variable t1 = ticks
59       
60        PathInfo catPathName
61        if(v_flag==0)
62                err = V_PickPath()              //sets the local path to the data (catPathName)
63                if(err)
64                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
65                Endif
66        Endif
67       
68        DoWindow/F CatVSANSTable
69       
70        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
71        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
72        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
73        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
74        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
75        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
76        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
77        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
78        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
79        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
80        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
81        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
82        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
83        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
84        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
85        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
86        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
87        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
88        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
89        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
90        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"            //added Mar 2008
91        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"            //added Mar 2010
92
93
94        WAVE/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
95        WAVE/T Suffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
96        WAVE/T Labels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
97        WAVE/T DateAndTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
98        WAVE SDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
99        WAVE Lambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
100        WAVE CntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
101        WAVE TotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
102        WAVE CntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
103        WAVE Transmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
104        WAVE Thickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
105        WAVE XCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
106        WAVE YCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
107
108        WAVE/T nGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
109        WAVE NumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
110        WAVE RunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
111        WAVE IsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
112        WAVE RotAngle = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
113        WAVE Temperature = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
114        WAVE Field = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
115        WAVE MCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"              //added Mar 2008
116        WAVE Pos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
117
118       
119        If(V_Flag==0)
120                V_BuildTableWindow()
121                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD)=40
122                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda)=40
123                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime)=50
124                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts)=60
125                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate)=60
126                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission)=40
127                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness)=40
128                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter)=40
129                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter)=40
130                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens)=30
131                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle)=50
132                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Field)=50
133                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR)=50
134
135                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides)=40
136                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos)=30
137                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos)=3                   //to make the display look nice, given the floating point values from ICE
138                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda)=3                //may not work in all situations, but an improvement
139                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD)=5
140                ModifyTable trailingZeros(root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature)=1
141                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature)=4
142
143                ModifyTable width(Point)=0              //JUN04, remove point numbers - confuses users since point != run
144        Endif
145
146
147// NEW for VSANS
148// clear out the folders in the RawVSANS folder, otherwise any changes/patches written to disk
149// will not be read in, the "bad" local copy will be read in.
150// TODO:
151//  -- this *may* be a very slow operation. Warn users. Give them a choice to keep local copies. If
152//     the "patched" values are written locally too, then maybe the update from disk is not needed.
153//     But typically, I'd like to see that the disk version really did get updated...
154//
155        //      V_CleanOutRawVSANS()
156// This will display a progress bar
157        V_CleanupData_w_Progress(0,1)
158
159
160        //get a list of all files in the folder, some will be junk version numbers that don't exist     
161        String list,partialName,tempName,temp=""
162        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
163        Variable numitems,ii,ok
164       
165        numitems = ItemsInList(list,";")
166       
167        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
168        //***version numbers have been removed***
169        String str,fullName
170        Variable lastPoint
171        ii=0
172       
173        Make/T/O/N=0 notRAWlist
174        do
175       
176                //get current item in the list
177                partialName = StringFromList(ii, list, ";")
178                //get a valid file based on this partialName and catPathName
179                tempName = V_FindValidFilename(partialName)
180               
181               
182                If(cmpstr(tempName,"")==0)              //a null string was returned
183                        //write to notebook that file was not found
184                        //if string is not a number, report the error
185                        if(numtype(str2num(partialName)) == 2)
186                                str = "this file was not found: "+partialName+"\r\r"
187                                //Notebook CatWin,font="Times",fsize=12,text=str
188                        Endif
189                else
190                        //prepend path to tempName for read routine
191                        PathInfo catPathName
192                        FullName = S_path + tempName
193                        //make sure the file is really a RAW data file
194                        ok = V_CheckIfRawData(fullName)
195               
196                        if (!ok)
197                                //write to notebook that file was not a RAW SANS file
198                                lastPoint = numpnts(notRAWlist)
199                                InsertPoints lastPoint,1,notRAWlist
200                                notRAWlist[lastPoint]=tempname
201                        else
202                                //go write the header information to the Notebook
203                                V_GetHeaderInfoToWave(fullName,tempName)
204                        Endif
205                Endif
206                ii+=1
207        while(ii<numitems)
208//Now sort them all based on some criterion that may be facility dependent (aim is to order them as collected)
209        V_SortWaves()
210//Append the files that are not raw files to the list
211        V_AppendNotRAWFiles(notRAWlist)
212        KillWaves/Z notRAWlist
213//
214//      Print "Total time (s) = ",(ticks - t1)/60.15
215//      Print "Time per raw data file (s) = ",(ticks - t1)/60.15/(numItems-numpnts(notRawList))
216        //
217        // clean out again, so that the file SAVE is not slow due to the large experiment size
218        // TODO -- decide if this is really necessary
219//     
220//      V_CleanOutRawVSANS()
221                       
222                       
223        return(0)
224End
225
226//appends the list of files that are not RAW SANS data to the filename wave (1st column)
227//for display in the table. Note that the filenames column will now be longer than all other
228//waves in the table
229Function V_AppendNotRAWFiles(w)
230        Wave/T w
231        Wave/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
232        Variable lastPoint
233        lastPoint = numpnts(Filenames)
234        InsertPoints lastPoint,numpnts(w),Filenames
235        Filenames[lastPoint,numpnts(Filenames)-1] = w[p-lastPoint]
236        return(0)
237End
238
239//sorts all of the waves of header information using the suffix (A123)
240//the result is that all of the data is in the order that it was collected,
241// regardless of how the prefix or run numbers were changed by the user
242Function V_SortWaves()
243        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
244        Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
245        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
246        Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
247        Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
248        Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
249        Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
250        Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
251        Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
252        Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
253        Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
254        Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
255        Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
256
257        Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
258        Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
259        Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
260        Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
261        Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
262        Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
263        Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
264        Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"             //added Mar 2008
265        Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
266
267
268// TODO -- the default sort is by SUFFIX, which does not exist for VSANS. So decide on a better key
269        Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,GPos,gNumGuides
270
271        return(0)
272End
273
274//function to create the CAT/VSTable to display the header information
275//this table is just like any other table
276Function V_BuildTableWindow()
277        Wave/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
278        Wave/T Labels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
279        Wave/T DateAndTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
280        Wave SDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
281        Wave Lambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
282        Wave CntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
283        Wave TotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
284        Wave CntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
285        Wave Transmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
286        Wave Thickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
287        Wave XCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
288        Wave YCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
289
290        Wave/T NumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
291        Wave NumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
292        Wave RotAngle =  $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
293        Wave Temperature = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
294        Wave Field= $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
295        Wave MCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"              //added Mar 2008
296        Wave Pos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
297
298
299// original order, magnetic at the end
300//      Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog"
301// with numGuides
302        Edit Filenames, Labels, DateAndTime, SDD, Lambda, numGuides, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR, Pos as "Data File Catalog"
303// alternate ordering, put the magnetic information first
304//      Edit Filenames, Labels, RotAngle, Temperature, Field, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens as "Data File Catalog"
305
306
307        String name="CatVSANSTable"
308        DoWindow/C $name
309        return(0)
310End
311
312//reads header information and puts it in the appropriate waves for display in the table.
313//fname is the full path for opening (and reading) information from the file
314//which alreay was found to exist. sname is the file;vers to be written out,
315//avoiding the need to re-extract it from fname.
316Function V_GetHeaderInfoToWave(fname,sname)
317        String fname,sname
318       
319
320        Variable lastPoint,ctime,detcnt,cntrate
321
322        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
323        Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
324        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
325        Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
326
327        Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
328        Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
329        Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
330        Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
331        Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
332        Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
333        Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
334        Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
335        Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
336        Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
337        Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
338        Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
339        Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
340        Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
341        Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
342        Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
343        Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
344        Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
345
346        lastPoint = numpnts(GLambda)
347               
348        //filename
349        InsertPoints lastPoint,1,GFilenames
350        GFilenames[lastPoint]=sname
351       
352        //read the file alphanumeric suffix
353        // TODO -- this does not exist for VSANS - so is there an equivalent, or delete?
354        InsertPoints lastPoint,1,GSuffix
355        GSuffix[lastPoint]="unknown"
356
357        //read the counting time (integer)
358        InsertPoints lastPoint,1,GCntTime
359        ctime = V_getCount_time(fname)
360        GCntTime[lastPoint]=ctime
361       
362        //read the file creation date (string)
363        InsertPoints lastPoint,1,GDateTime
364        GDateTime[lastPoint]=V_getDataStartTime(fname)
365
366        // read the sample.label text field (string)
367        InsertPoints lastPoint,1,GLabels
368        GLabels[lastPoint]=V_getSampleDescription(fname)
369       
370               
371        //read the reals
372        //detector count and (derived) count rate
373        // TODO -- this is hard-wired for a single detector, which is WRONG
374        detcnt = V_getDet_IntegratedCount(fname,"FL")
375        cntrate = detcnt/ctime
376        InsertPoints lastPoint,1,GTotCnts
377        GTotCnts[lastPoint]=detcnt
378        InsertPoints lastPoint,1,GCntRate
379        GCntRate[lastPoint]=cntrate
380       
381        //Attenuators
382        // TODO -- this is not really the number --
383        InsertPoints lastPoint,1,GNumAttens
384        GNumAttens[lastPoint]=V_getAttenThickness(fname)
385       
386        //Transmission
387        InsertPoints lastPoint,1,GTransmission
388        GTransmission[lastPoint]=V_getSampleTransmission(fname)
389       
390        //Thickness
391        InsertPoints lastPoint,1,GThickness
392        GThickness[lastPoint]=V_getSampleThickness(fname)
393
394        // TODO --  the x and y center have different meaning, since there are multiple panels
395        // TODO -- remove the hard-wiring
396        String detStr = "FL"
397        //XCenter of beam on detector
398        InsertPoints lastPoint,1,GXCenter
399        GXCenter[lastPoint]=V_getDet_beam_center_x(fname,detStr)
400       
401        // TODO --  the x and y center have different meaning, since there are multiple panels
402        //YCenter
403        InsertPoints lastPoint,1,GYCenter
404        GYCenter[lastPoint]=V_getDet_beam_center_y(fname,detStr)
405
406        // TODO -- SDD has no real meaning - since there are multiple distances to report
407        //SDD
408        InsertPoints lastPoint,1,GSDD
409        GSDD[lastPoint]=V_getDet_ActualDistance(fname,detStr)
410       
411        //wavelength
412        InsertPoints lastPoint,1,GLambda
413        GLambda[lastPoint]=V_getWavelength(fname)
414       
415        //Rotation Angle
416        InsertPoints lastPoint,1,GRot
417        GRot[lastPoint]=V_getSampleRotationAngle(fname)
418       
419        // TODO -- this is not yet implemented
420        //Sample Temperature
421        InsertPoints lastPoint,1,GTemp
422        GTemp[lastPoint]=-273
423
424        // TODO -- this is not yet implemented
425        //Sample Field
426        InsertPoints lastPoint,1,GField
427        GField[lastPoint]=1000
428       
429        //Beamstop position (not reported)
430        //strToExecute = GBLoadStr + "/S=368/U=1" + "\"" + fname + "\""
431
432        //the run number (not displayed in the table, but carried along)
433        InsertPoints lastPoint,1,GRunNumber
434        GRunNumber[lastPoint] = V_GetRunNumFromFile(sname)
435
436        // TODO -- the isTransFile utility has not yet been written
437        // 0 if the file is a scattering  file, 1 (truth) if the file is a transmission file
438        InsertPoints lastPoint,1,GIsTrans
439        GIsTrans[lastPoint]  = V_isTransFile(fname)             //returns one if beamstop is "out"
440       
441        // Monitor Count Rate
442        InsertPoints lastPoint,1,GMCR
443        GMCR[lastPoint]  = V_getMonitorCount(fname)/ctime               //total monitor count / total count time
444
445
446// number of guides and sample position, only for NCNR (a string now)
447        InsertPoints lastPoint,1,GNumGuides
448        GNumGuides[lastPoint]  = V_getNumberOfGuides(fname)
449
450// TODO -- maybe this is better to convert to a text wave?     
451        //Sample Position (== number position in 10CB)
452        InsertPoints lastPoint,1,GPos
453        GPos[lastPoint] = str2num(V_getSamplePosition(fname))
454
455        return(0)
456End
457
458
459
460// just to call the function to generate the panel
461Macro Catalog_Sort()
462        V_BuildCatSortPanel()
463End
464
465// [davidm] create CAT Sort-Panel
466function V_BuildCatSortPanel()
467
468        // check if CatVSANSTable exists
469        DoWindow CatVSANSTable
470        if (V_flag==0)
471                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
472                return 0
473        endif
474       
475        // bring CatSortPanel to front
476        DoWindow/F CatSortPanel
477        if (V_flag != 0)
478                return 0
479        endif
480       
481        print "Creating CAT Sort-Panel..."
482               
483        //PauseUpdate
484        NewPanel /W=(600,360,790,730)/K=1 as "CAT - Sort Panel"
485        DoWindow/C CatSortPanel
486        ModifyPanel fixedSize=1, cbRGB = (42919, 53970, 60909)
487       
488        Button SortFilenamesButton,             pos={25, 8},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Filenames"
489        Button SortLabelsButton,                        pos={25,38},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Labels"
490        Button SortDateAndTimeButton,   pos={25,68},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Date and Time"
491        Button SortSSDButton,                   pos={25,98},            size={140,24},proc=V_CatVSANSTable_SortProc,title="SSD"
492        Button SortSDDButton,                   pos={25,128},   size={140,24},proc=V_CatVSANSTable_SortProc,title="SDD"
493        Button SortLambdaButton,                        pos={25,158},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Lambda"
494        Button SortCountTimButton,              pos={25,188},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Time"
495        Button SortTotalCountsButton,           pos={25,218},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Total Counts"
496        Button SortCountRateButton,             pos={25,248},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Rate"
497        Button SortMonitorCountsButton, pos={25,278},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Monitor Counts"
498        Button SortTransmissionButton,  pos={25,308},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Transmission"
499        Button SortThicknessButton,             pos={25,338},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Thickness"
500
501end
502
503Proc V_CatVSANSTable_SortProc(ctrlName) : ButtonControl // added by [davidm]
504        String ctrlName
505       
506        // check if CatVSANSTable exists
507        DoWindow CatVSANSTable
508        if (V_flag==0)
509                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
510                return
511        endif
512               
513        // have to use function
514        V_CatVSANSTable_SortFunction(ctrlName)
515       
516end
517
518function V_CatVSANSTable_SortFunction(ctrlName) // added by [davidm]
519        String ctrlName
520
521        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
522        Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
523        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
524        Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
525        Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
526        Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
527        Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
528        Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
529        Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
530        Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
531        Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
532        Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
533        Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
534        Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
535        Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
536        Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
537        Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
538        Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
539        Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
540        Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
541        Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
542        Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
543
544       
545        // take out the "not-RAW-Files"
546        Variable fileCount = numpnts(GFilenames)
547        Variable rawCount = numpnts(GLabels)
548        Variable notRAWcount = fileCount - rawCount
549       
550        if (notRAWcount > 0)
551                Make/T/O/N=(notRAWcount) notRAWlist
552                notRAWlist[0, notRAWcount-1] = GFilenames[p+rawCount]
553                DeletePoints rawCount, notRAWcount, GFilenames
554        endif
555       
556        strswitch (ctrlName)
557       
558                case "SortFilenamesButton":
559                        Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
560                        break
561                       
562                case "SortLabelsButton":
563                        Sort GLabels, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
564                        break
565                       
566                case "SortDateAndTimeButton":
567                        Sort GDateTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
568                        break
569                       
570                case "SortSSDButton":
571                        break
572                       
573                case "SortSDDButton":
574                        Sort GSDD, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
575                        break
576                       
577                case "SortLambdaButton":
578                        Sort GLambda, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
579                        break
580                       
581                case "SortCountTimButton":
582                        Sort GCntTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
583                        break
584                       
585                case "SortTotalCountsButton":
586                        Sort GTotCnts, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
587                        break
588                       
589                case "SortCountRateButton":
590                        Sort GCntRate, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
591                        break
592                       
593                case "SortMonitorCountsButton":
594                        break
595                       
596                case "SortTransmissionButton":
597                        Sort GTransmission, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
598                        break
599                       
600                case "SortThicknessButton":
601                        Sort GThickness, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
602                        break
603       
604        endswitch
605       
606        // insert the "not-RAW-Files" again
607        if (notRAWcount > 0)
608                InsertPoints rawCount, notRAWcount, GFilenames
609                GFilenames[rawCount, fileCount-1] = notRAWlist[p-rawCount]
610        endif
611end
Note: See TracBrowser for help on using the repository browser.