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

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

main changes here are the addition of a first pass at the file catalog, and patch panel. each of these is based on the old SANS file (for now) and has been updated to at least compile.

Much more work needs to be done to get the functionality to be what VSANS needs, both in what is important to report in the file catalog, and how to best present the patch GUI for different situations

  • Property svn:executable set to *
File size: 26.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// 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
157
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        //XCenter of beam on detector
396        InsertPoints lastPoint,1,GXCenter
397        GXCenter[lastPoint]=123
398       
399        // TODO --  the x and y center have different meaning, since there are multiple panels
400        //YCenter
401        InsertPoints lastPoint,1,GYCenter
402        GYCenter[lastPoint]=321
403
404        // TODO -- SDD has no real meaning - since there are multiple distances to report
405        //SDD
406        InsertPoints lastPoint,1,GSDD
407        GSDD[lastPoint]=44
408       
409        //wavelength
410        InsertPoints lastPoint,1,GLambda
411        GLambda[lastPoint]=V_getWavelength(fname)
412       
413        //Rotation Angle
414        InsertPoints lastPoint,1,GRot
415        GRot[lastPoint]=V_getSampleRotationAngle(fname)
416       
417        // TODO -- this is not yet implemented
418        //Sample Temperature
419        InsertPoints lastPoint,1,GTemp
420        GTemp[lastPoint]=-273
421
422        // TODO -- this is not yet implemented
423        //Sample Field
424        InsertPoints lastPoint,1,GField
425        GField[lastPoint]=1000
426       
427        //Beamstop position (not reported)
428        //strToExecute = GBLoadStr + "/S=368/U=1" + "\"" + fname + "\""
429
430        //the run number (not displayed in the table, but carried along)
431        InsertPoints lastPoint,1,GRunNumber
432        GRunNumber[lastPoint] = V_GetRunNumFromFile(sname)
433
434        // TODO -- the isTransFile utility has not yet been written
435        // 0 if the file is a scattering  file, 1 (truth) if the file is a transmission file
436        InsertPoints lastPoint,1,GIsTrans
437        GIsTrans[lastPoint]  = V_isTransFile(fname)             //returns one if beamstop is "out"
438       
439        // Monitor Count Rate
440        InsertPoints lastPoint,1,GMCR
441        GMCR[lastPoint]  = V_getMonitorCount(fname)/ctime               //total monitor count / total count time
442
443
444// number of guides and sample position, only for NCNR (a string now)
445        InsertPoints lastPoint,1,GNumGuides
446        GNumGuides[lastPoint]  = V_getNumberOfGuides(fname)
447
448// TODO -- maybe this is better to convert to a text wave?     
449        //Sample Position (== number position in 10CB)
450        InsertPoints lastPoint,1,GPos
451        GPos[lastPoint] = str2num(V_getSamplePosition(fname))
452
453        return(0)
454End
455
456
457
458// just to call the function to generate the panel
459Macro Catalog_Sort()
460        V_BuildCatSortPanel()
461End
462
463// [davidm] create CAT Sort-Panel
464function V_BuildCatSortPanel()
465
466        // check if CatVSANSTable exists
467        DoWindow CatVSANSTable
468        if (V_flag==0)
469                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
470                return 0
471        endif
472       
473        // bring CatSortPanel to front
474        DoWindow/F CatSortPanel
475        if (V_flag != 0)
476                return 0
477        endif
478       
479        print "Creating CAT Sort-Panel..."
480               
481        //PauseUpdate
482        NewPanel /W=(600,360,790,730)/K=1 as "CAT - Sort Panel"
483        DoWindow/C CatSortPanel
484        ModifyPanel fixedSize=1, cbRGB = (42919, 53970, 60909)
485       
486        Button SortFilenamesButton,             pos={25, 8},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Filenames"
487        Button SortLabelsButton,                        pos={25,38},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Labels"
488        Button SortDateAndTimeButton,   pos={25,68},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Date and Time"
489        Button SortSSDButton,                   pos={25,98},            size={140,24},proc=V_CatVSANSTable_SortProc,title="SSD"
490        Button SortSDDButton,                   pos={25,128},   size={140,24},proc=V_CatVSANSTable_SortProc,title="SDD"
491        Button SortLambdaButton,                        pos={25,158},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Lambda"
492        Button SortCountTimButton,              pos={25,188},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Time"
493        Button SortTotalCountsButton,           pos={25,218},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Total Counts"
494        Button SortCountRateButton,             pos={25,248},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Rate"
495        Button SortMonitorCountsButton, pos={25,278},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Monitor Counts"
496        Button SortTransmissionButton,  pos={25,308},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Transmission"
497        Button SortThicknessButton,             pos={25,338},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Thickness"
498
499end
500
501Proc V_CatVSANSTable_SortProc(ctrlName) : ButtonControl // added by [davidm]
502        String ctrlName
503       
504        // check if CatVSANSTable exists
505        DoWindow CatVSANSTable
506        if (V_flag==0)
507                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
508                return
509        endif
510               
511        // have to use function
512        V_CatVSANSTable_SortFunction(ctrlName)
513       
514end
515
516function V_CatVSANSTable_SortFunction(ctrlName) // added by [davidm]
517        String ctrlName
518
519        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
520        Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
521        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
522        Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
523        Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
524        Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
525        Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
526        Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
527        Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
528        Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
529        Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
530        Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
531        Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
532        Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
533        Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
534        Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
535        Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
536        Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
537        Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
538        Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
539        Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
540        Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
541
542       
543        // take out the "not-RAW-Files"
544        Variable fileCount = numpnts(GFilenames)
545        Variable rawCount = numpnts(GLabels)
546        Variable notRAWcount = fileCount - rawCount
547       
548        if (notRAWcount > 0)
549                Make/T/O/N=(notRAWcount) notRAWlist
550                notRAWlist[0, notRAWcount-1] = GFilenames[p+rawCount]
551                DeletePoints rawCount, notRAWcount, GFilenames
552        endif
553       
554        strswitch (ctrlName)
555       
556                case "SortFilenamesButton":
557                        Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
558                        break
559                       
560                case "SortLabelsButton":
561                        Sort GLabels, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
562                        break
563                       
564                case "SortDateAndTimeButton":
565                        Sort GDateTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
566                        break
567                       
568                case "SortSSDButton":
569                        break
570                       
571                case "SortSDDButton":
572                        Sort GSDD, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
573                        break
574                       
575                case "SortLambdaButton":
576                        Sort GLambda, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
577                        break
578                       
579                case "SortCountTimButton":
580                        Sort GCntTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
581                        break
582                       
583                case "SortTotalCountsButton":
584                        Sort GTotCnts, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
585                        break
586                       
587                case "SortCountRateButton":
588                        Sort GCntRate, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
589                        break
590                       
591                case "SortMonitorCountsButton":
592                        break
593                       
594                case "SortTransmissionButton":
595                        Sort GTransmission, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
596                        break
597                       
598                case "SortThicknessButton":
599                        Sort GThickness, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
600                        break
601       
602        endswitch
603       
604        // insert the "not-RAW-Files" again
605        if (notRAWcount > 0)
606                InsertPoints rawCount, notRAWcount, GFilenames
607                GFilenames[rawCount, fileCount-1] = notRAWlist[p-rawCount]
608        endif
609end
Note: See TracBrowser for help on using the repository browser.