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

Last change on this file since 1106 was 1106, checked in by srkline, 4 years ago

Added functions to check that files in a protocol, including the sample data are all from the same configuration. In SANS, the only flag was a beam center mismatch. In VSANS, a more complete check of the configuration in necessary.

Changed all instances of calls to the read and normalize the monitor count to use the "norm"al monitor, not the value listed in the Control block.

  • Property svn:executable set to *
File size: 37.2 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 -
7// June 2016  SRK
8// more columns + improved handling Jan 2018
9//
10// included ANSTO sort panel from david m
11//
12
13// Adding columns to the table now means:
14// 1-Make the wave in V_BuildCatVeryShortTable
15// 2-Declare the wave in V_GetHeaderInfoToWave, and read/fill in the value
16//
17
18
19//
20// TODO
21// x- clean up and remove all of the references to other facilities, since they will not have VSANS modules
22// x- add in more appropriate and some missing fields more useful to VSANS (intent, multiple beam centers, etc.)
23// -- can I make the choice of columns customizable? There are "sets" of columns that are not used for
24//    some experiments (magnetic, rotation, temperature scans, etc.) but are necessary for others.
25// x- SortColumns operation may be of help in managing the long list of files to sort
26//
27// (DONE):
28// x- clean up the list of files that now accumulates in the RawVSANS folder!!! Everything is there, including
29//    files that are NOT RAW VSANS data (MASK and DIV, but these are HDF)
30// x- WHY -- because if I PATCH anything, then re-run the catalog, the changes are NOT shown, since the
31//    reader will go to the LOCAL copy first! So maybe I need to clear the folder out before I start the
32//    file catalog
33// x- maybe it's a good thing to wipe out the RawVSANS folder before an Experiment SAVE (to save a LOT of
34//    space on disk and a potentially VERY long save
35// x- see V_CleanOutRawVSANS() in V_Utilities_General for the start of this (this is now called in
36//    V_BuildCatVeryShortTable(), the starting point for generating the table.)
37//
38// NEW for VSANS
39// clear out the folders in the RawVSANS folder, otherwise any changes/patches written to disk
40// will not be read in, the "bad" local copy will be read in.
41// (DONE)
42//  x- this *may* be a very slow operation. Warn users. Give them a choice to keep local copies. If
43//     the "patched" values are written locally too, then maybe the update from disk is not needed.
44//     But typically, I'd like to see that the disk version really did get updated...
45// x- (NO)make a background task to periodically "kill" a few of the files? maybe too dangerous.
46// x- (NO)change the V_GetHeaderInfoToWave function to allow "refreshing" of a single row, say after
47//    a file has been patched - then the disk and local copies are in sync
48//
49// -- run a profiler on the catalog to see if there is an obvious place to speed up the process
50//
51
52Function catalogProfiler()
53        V_BuildCatVeryShortTable()
54End
55
56//
57//      SRK modified 30 JAN07 to include Rotation angle, Temperature, and B-field in the table (at the end)
58//
59
60//**************
61// Vers 1.2 090401
62//
63// Procedures for creating the Catalog listings of the SANS datafiles in the folder
64// specified by catPathName.
65// Header information from each of the dataifles is organized in a table for
66// easy identification of each file. CatVSANSTable is the preferred invocation,
67// although CatVSNotebook and CatNotebook can also be used.
68// Files in the folder that are not RAW SANS data are appended to the end of the listing.
69//**************
70
71//this main procedure does all the work, obtaining the folder path,
72//parsing the filenames in the list and (dispatching) to write out the
73//appropriate information to the growing (table) of data. V_GetHeaderInfoToWave() does the individual reads
74Function V_BuildCatVeryShortTable()
75       
76        Variable err
77        Variable t1 = ticks
78       
79        PathInfo catPathName
80        if(v_flag==0)
81                err = V_PickPath()              //sets the local path to the data (catPathName)
82                if(err)
83                        Abort "no path to data was selected, no catalog can be made - use PickPath button"
84                Endif
85        Endif
86
87//
88// WaveList will list waves in the order that they were created - so at a first pass,
89// create the waves in the order that I want them in the table.
90// The user can rearrange the columns, but likely won't
91//     
92        DoWindow/F CatVSANSTable
93       
94        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
95        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
96        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
97        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
98        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
99        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
100       
101        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_F"
102        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_F"
103        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_F"     
104       
105        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_M"
106        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_M"
107        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_M"     
108       
109        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_B"
110        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_B"
111        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_B"
112               
113        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
114        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
115        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
116
117
118        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
119        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
120       
121//      Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
122//      Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
123
124        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
125        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"            //added Mar 2008
126        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"            //added Mar 2010
127
128        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
129        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
130        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
131
132
133
134
135        WAVE/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
136        WAVE/T Labels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
137        WAVE/T DateAndTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
138//      WAVE SDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
139        WAVE Lambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
140        WAVE CntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
141        WAVE Transmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
142        WAVE Thickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
143//      WAVE XCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
144//      WAVE YCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
145
146        WAVE/T nGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
147        WAVE NumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
148        WAVE RotAngle = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
149        WAVE Temperature = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
150        WAVE Field = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
151        WAVE MCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"              //added Mar 2008
152        WAVE Pos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
153        WAVE/T Intent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
154        WAVE/T Purpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
155        WAVE Group_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
156
157       
158        If(V_Flag==0)
159                V_BuildTableWindow()
160                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda)=40
161                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime)=50
162                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission)=40
163                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness)=40
164//              ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter)=40
165//              ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter)=40
166                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens)=30
167                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle)=50
168                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Field)=50
169                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR)=50
170
171                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides)=40
172                ModifyTable width(root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos)=30
173                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos)=3                   //to make the display look nice, given the floating point values from ICE
174                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda)=3                //may not work in all situations, but an improvement
175//              ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD)=5
176                ModifyTable trailingZeros(root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature)=1
177                ModifyTable sigDigits(root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature)=4
178
179                ModifyTable width(Point)=0              //JUN04, remove point numbers - confuses users since point != run
180
181// (DONE)
182//  x- experimental hook with contextual menu
183//             
184                SetWindow kwTopWin hook=V_CatTableHook, hookevents=1    // mouse down events
185
186        Endif
187
188
189// NEW for VSANS
190// clear out the folders in the RawVSANS folder, otherwise any changes/patches written to disk
191// will not be read in, the "bad" local copy will be read in for any subsequent operations.
192// (DONE)
193//  x- this *may* be a very slow operation. Warn users. Give them a choice to keep local copies? If
194//     the "patched" values are written locally too, then maybe the update from disk is not needed.
195//     But typically, I'd like to see that the disk version really did get updated...
196//
197        //      V_CleanOutRawVSANS()
198// This will display a progress bar
199        Variable numToClean
200        numToClean = V_CleanupData_w_Progress(0,1)
201
202        Print "Cleaned # files = ",numToClean
203        Print "Cleanup time (s) = ",(ticks - t1)/60.15
204        Variable cleanupTime = (ticks - t1)/60.15
205
206        //get a list of all files in the folder, some will be junk version numbers that don't exist     
207        String list,partialName,tempName,temp=""
208        list = IndexedFile(catPathName,-1,"????")       //get all files in folder
209        Variable numitems,ii,ok
210       
211        numitems = ItemsInList(list,";")
212       
213        // show a progress bar for filling the file catalog
214        Variable indefinite=0,useIgorDraw=1
215        NewPanel /N=ProgressPanel /W=(285,111,739,193)
216        ValDisplay valdisp0,win=ProgressPanel,pos={18,32},size={342,18},limits={0,numitems,0},barmisc={0,0}
217        ValDisplay valdisp0,win=ProgressPanel,value= _NUM:0
218        DrawText 20,24,"Refreshing file catalog... Please Wait..."
219
220        if( indefinite )
221                ValDisplay valdisp0,win=ProgressPanel,mode= 4   // candy stripe
222        else
223                ValDisplay valdisp0,win=ProgressPanel,mode= 3   // bar with no fractional part
224        endif
225        if( useIgorDraw )
226                ValDisplay valdisp0,win=ProgressPanel,highColor=(49535,1000,1000)               //(0,65535,0)
227        endif
228        Button bStop,win=ProgressPanel,pos={375,32},size={50,20},title="Stop"
229        DoUpdate /W=ProgressPanel /E=1  // mark this as our progress window
230       
231       
232        //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS
233        String str,fullName
234        Variable lastPoint
235        ii=0
236       
237        Make/T/O/N=0 notRAWlist
238        do
239       
240                //get current item in the list
241                partialName = StringFromList(ii, list, ";")
242                //get a valid file based on this partialName and catPathName
243                tempName = V_FindValidFilename(partialName)
244               
245               
246                If(cmpstr(tempName,"")==0)              //a null string was returned
247                        //write to notebook that file was not found
248                        //if string is not a number, report the error
249                        if(numtype(str2num(partialName)) == 2)
250                                str = "this file was not found: "+partialName+"\r\r"
251                                //Notebook CatWin,font="Times",fsize=12,text=str
252                        Endif
253                else
254                        //prepend path to tempName for read routine
255                        PathInfo catPathName
256                        FullName = S_path + tempName
257                        //make sure the file is really a RAW data file
258                        ok = V_CheckIfRawData(fullName)
259               
260                        if (!ok)
261                                //write to notebook that file was not a RAW SANS file
262                                lastPoint = numpnts(notRAWlist)
263                                InsertPoints lastPoint,1,notRAWlist
264                                notRAWlist[lastPoint]=tempname
265                        else
266                                //go write the header information to the Notebook
267                                V_GetHeaderInfoToWave(fullName,tempName)
268                        Endif
269                Endif
270                ii+=1
271               
272                ValDisplay valdisp0,win=ProgressPanel,value= _NUM:ii
273                DoUpdate /W=ProgressPanel
274               
275        while(ii<numitems)
276       
277        KillWindow ProgressPanel
278
279//Now sort them all based on some criterion that may be facility dependent (aim is to order them as collected)
280        V_SortWaves()
281       
282//Append the files that are not raw files to the list
283        V_AppendNotRAWFiles(notRAWlist)
284        KillWaves/Z notRAWlist
285//
286        Print "Total time (s) = ",(ticks - t1)/60.15
287        Print "Time per raw data file (without cleanup time) (s) = ",( (ticks - t1)/60.15 - cleanupTime)/(numpnts(labels))
288        // (don't use numpnts(notRawList) to normalize, these aren't all raw data files)
289        //
290        // clean out again, so that the file SAVE is not slow due to the large experiment size
291        // (DONE) x- decide if this is really necessary (not necessary at this point)
292//     
293//      V_CleanOutRawVSANS()
294                       
295                       
296        return(0)
297End
298
299//
300// TODO:
301//  this is experimental...not been tested by any users yet
302// -- what else to add to the menu? (MSK and DIV now work)
303// -- add directly to WORK files?
304// -- "set" as some special file type, intent, use? (quick "patch" operations)
305// -- "check" the reduction protocol for completeness?
306//
307// x- seems to not "let go" of a selection (missing the mouse up?)
308//    (possibly) less annoying if I only handle mouseup and present a menu then.
309//
310Function V_CatTableHook(infoStr)
311        String infoStr
312        String event= StringByKey("EVENT",infoStr)
313//      Print "EVENT= ",event
314        strswitch(event)
315                case "mouseup":
316//                      Variable xpix= NumberByKey("MOUSEX",infoStr)
317//                      Variable ypix= NumberByKey("MOUSEY",infoStr)
318//                      PopupContextualMenu/C=(xpix, ypix) "yes;no;maybe;"
319                        PopupContextualMenu "Load RAW;Load MSK;Load DIV;"
320                       
321                        WAVE/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
322                        Variable err
323                        strswitch(S_selection)
324                                case "Load RAW":
325                                        GetSelection table,CatVSANSTable,1
326//                                      Print V_flag, V_startRow, V_startCol, V_endRow, V_endCol
327                                        Print "Loading " + FileNames[V_StartRow]
328                                        err = V_LoadHDF5Data(FileNames[V_StartRow],"RAW")
329                                        if(!err)                //directly from, and the same steps as DisplayMainButtonProc(ctrlName)
330                                                SVAR hdfDF = root:file_name                     // last file loaded, may not be the safest way to pass
331                                                String folder = StringFromList(0,hdfDF,".")
332                                               
333                                                // this (in SANS) just passes directly to fRawWindowHook()
334                                                V_UpdateDisplayInformation("RAW")               // plot the data in whatever folder type
335                                                                                               
336                                                // set the global to display ONLY if the load was called from here, not from the
337                                                // other routines that load data (to read in values)
338                                                SVAR gLast = root:Packages:NIST:VSANS:Globals:gLastLoadedFile
339                                                gLast = hdfDF
340                                               
341                                        endif
342                                        break;
343                                       
344                                case "Load MSK":
345                                        GetSelection table,CatVSANSTable,1
346//                                      Print V_flag, V_startRow, V_startCol, V_endRow, V_endCol
347                                        Print "Loading " + FileNames[V_StartRow]
348                                        err = V_LoadHDF5Data(FileNames[V_StartRow],"MSK")
349                                       
350                                        break;
351                                       
352                                case "Load DIV":
353                                        GetSelection table,CatVSANSTable,1
354//                                      Print V_flag, V_startRow, V_startCol, V_endRow, V_endCol
355                                        Print "Loading " + FileNames[V_StartRow]
356                                        err = V_LoadHDF5Data(FileNames[V_StartRow],"DIV")
357
358                                        break;
359                                       
360                        endswitch               //popup selection
361        endswitch       // event
362       
363        return 0
364End
365
366
367
368//appends the list of files that are not RAW SANS data to the filename wave (1st column)
369//for display in the table. Note that the filenames column will now be longer than all other
370//waves in the table
371//
372// skip this step if there are no files to tack on
373Function V_AppendNotRAWFiles(w)
374        Wave/T w
375        if(numpnts(w) != 0)
376                Wave/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
377                Variable lastPoint
378                lastPoint = numpnts(Filenames)
379                InsertPoints lastPoint,numpnts(w),Filenames
380                Filenames[lastPoint,numpnts(Filenames)-1] = w[p-lastPoint]
381        endif
382        return(0)
383End
384
385//
386// this is called BEFORE the notRAWfiles are added to the fileNames wave
387// so that the waves are still all the same length and can properly be sorted.
388//
389Function V_SortWaves()
390//      Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
391////    Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
392//      Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
393//      Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
394////    Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
395//      Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
396//      Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
397//      Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
398//      Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
399//      Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
400//      Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
401////    Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
402////    Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
403//
404//      Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
405//      Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
406////    Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
407////    Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
408//      Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
409//      Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
410//      Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
411//      Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"             //added Mar 2008
412//      Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
413//      Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
414//      Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
415//      Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
416//
417//
418//// DONE
419//// x- the default sort is by SUFFIX, which does not exist for VSANS. So decide on a better key
420////     now, the sort is by FileName by default
421////    Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,GPos,gNumGuides
422//
423//      Sort GFilenames, GFilenames, GLabels, GDateTime,  GIntent, GPurpose, G_ID, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,GRot,GTemp,GField,GMCR,GPos,gNumGuides
424
425        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
426       
427        String list = WaveList("*",",","")
428        String cmd
429       
430        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
431       
432        sprintf cmd, "Sort Filenames, %s", list
433//      Print cmd                       // For debugging
434       
435        Execute cmd
436       
437        SetDataFolder root:
438        return(0)
439End
440
441//function to create the CAT/VSTable to display the header information
442//this table is just like any other table
443Function V_BuildTableWindow()
444
445        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
446       
447        String list = WaveList("*",",","")
448        String cmd
449       
450        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
451       
452        sprintf cmd, "Edit %s", list
453//      Print cmd                       // For debugging
454       
455        Execute cmd
456
457        String name="CatVSANSTable"
458        DoWindow/C $name
459       
460        SetDataFolder root:
461       
462//      Wave/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
463//      Wave/T Labels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
464//      Wave/T DateAndTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
465////    Wave SDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
466//      Wave Lambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
467//      Wave CntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
468//      Wave TotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
469//      Wave CntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
470//      Wave Transmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
471//      Wave Thickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
472////    Wave XCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
473////    Wave YCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
474//
475//      Wave/T NumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
476//      Wave NumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
477//      Wave RotAngle =  $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
478//      Wave Temperature = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
479//      Wave Field= $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
480//      Wave MCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"              //added Mar 2008
481//      Wave Pos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
482//      Wave/T Intent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
483//      Wave/T Purpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
484//      Wave Group_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
485//
486//// original order, magnetic at the end
487////    Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog"
488//// with numGuides
489////    Edit Filenames, Labels, DateAndTime, SDD, Lambda, numGuides, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR, Pos as "Data File Catalog"
490
491//      Edit Filenames, Labels, DateAndTime,  Intent, Purpose, Group_ID, Lambda, numGuides, CntTime, TotCnts, CntRate, Transmission, Thickness, NumAttens, RotAngle, Temperature, Field, MCR, Pos as "Data File Catalog"
492
493
494        return(0)
495End
496
497//reads header information and puts it in the appropriate waves for display in the table.
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 V_GetHeaderInfoToWave(fname,sname)
502        String fname,sname
503       
504
505        Variable lastPoint,ctime,detcnt,cntrate
506
507        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
508//      Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
509        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
510        Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
511
512        WAVE sdd_f = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_F"
513        WAVE sdd_m = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_M"
514        WAVE sdd_b = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_B"
515
516        Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
517        Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
518
519        Wave TotCnts_F = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_F"
520        Wave CntRate_F = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_F"
521        Wave TotCnts_M = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_M"
522        Wave CntRate_M = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_M"
523        Wave TotCnts_B = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_B"
524        Wave CntRate_B = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_B"
525       
526        Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
527        Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
528//      Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
529//      Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
530        Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
531        Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
532//      Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
533//      Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
534        Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
535        Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
536        Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
537        Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
538        Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
539        Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
540        Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
541        Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
542
543        lastPoint = numpnts(GLambda)
544               
545        //filename
546        InsertPoints lastPoint,1,GFilenames
547        GFilenames[lastPoint]=sname
548       
549//      //read the file alphanumeric suffix
550//      // (DONE) x- this does not exist for VSANS - so is there an equivalent, or delete? ((delete))
551//      InsertPoints lastPoint,1,GSuffix
552//      GSuffix[lastPoint]="unknown"
553
554        //read the counting time (integer)
555        InsertPoints lastPoint,1,GCntTime
556        ctime = V_getCount_time(fname)
557        GCntTime[lastPoint]=ctime
558       
559        //read the file creation date (string)
560        InsertPoints lastPoint,1,GDateTime
561        GDateTime[lastPoint]=V_getDataStartTime(fname)
562
563        // read the sample.label text field (string)
564        InsertPoints lastPoint,1,GLabels
565        GLabels[lastPoint]=V_getSampleDescription(fname)
566       
567               
568        //read the reals
569        //detector count and (derived) count rate
570        detcnt = V_getDet_IntegratedCount(fname,"FL")
571        detcnt += V_getDet_IntegratedCount(fname,"FR")
572        detcnt += V_getDet_IntegratedCount(fname,"FT")
573        detcnt += V_getDet_IntegratedCount(fname,"FB")
574        cntrate = detcnt/ctime
575        InsertPoints lastPoint,1,TotCnts_F
576        TotCnts_F[lastPoint]=detcnt
577        InsertPoints lastPoint,1,CntRate_F
578        CntRate_F[lastPoint]=cntrate
579
580        detcnt = V_getDet_IntegratedCount(fname,"ML")
581        detcnt += V_getDet_IntegratedCount(fname,"MR")
582        detcnt += V_getDet_IntegratedCount(fname,"MT")
583        detcnt += V_getDet_IntegratedCount(fname,"MB")
584        cntrate = detcnt/ctime
585        InsertPoints lastPoint,1,TotCnts_M
586        TotCnts_M[lastPoint]=detcnt
587        InsertPoints lastPoint,1,CntRate_M
588        CntRate_M[lastPoint]=cntrate
589       
590        detcnt = V_getDet_IntegratedCount(fname,"B")
591        cntrate = detcnt/ctime
592        InsertPoints lastPoint,1,TotCnts_B
593        TotCnts_B[lastPoint]=detcnt
594        InsertPoints lastPoint,1,CntRate_B
595        CntRate_B[lastPoint]=cntrate
596               
597               
598        //Attenuators
599        // (DONE) x- this is the "number" of the attenuator
600        InsertPoints lastPoint,1,GNumAttens
601        GNumAttens[lastPoint]=V_getAtten_number(fname)
602       
603        //Transmission
604        InsertPoints lastPoint,1,GTransmission
605        GTransmission[lastPoint]=V_getSampleTransmission(fname)
606       
607        //Thickness
608        InsertPoints lastPoint,1,GThickness
609        GThickness[lastPoint]=V_getSampleThickness(fname)
610
611//      // TODO --  the x and y center have different meaning, since there are multiple panels
612//      // TODO -- remove the hard-wiring
613//      String detStr = "FL"
614//      //XCenter of beam on detector
615//      InsertPoints lastPoint,1,GXCenter
616//      GXCenter[lastPoint]=V_getDet_beam_center_x(fname,detStr)
617//     
618//      // TODO --  the x and y center have different meaning, since there are multiple panels
619//      //YCenter
620//      InsertPoints lastPoint,1,GYCenter
621//      GYCenter[lastPoint]=V_getDet_beam_center_y(fname,detStr)
622
623//       there are multiple distances to report
624//      //SDD
625        InsertPoints lastPoint,1,sdd_f
626        sdd_f[lastPoint]=V_getDet_ActualDistance(fname,"FL")
627
628        InsertPoints lastPoint,1,sdd_m
629        sdd_m[lastPoint]=V_getDet_ActualDistance(fname,"ML")
630       
631        InsertPoints lastPoint,1,sdd_b
632        sdd_b[lastPoint]=V_getDet_ActualDistance(fname,"B")
633               
634        //wavelength
635        InsertPoints lastPoint,1,GLambda
636        GLambda[lastPoint]=V_getWavelength(fname)
637       
638        //Rotation Angle
639        InsertPoints lastPoint,1,GRot
640        GRot[lastPoint]=V_getSampleRotationAngle(fname)
641       
642        //Sample Temperature
643        InsertPoints lastPoint,1,GTemp
644        GTemp[lastPoint]=V_getSampleTemperature(fname)
645
646        // TODO -- this is not yet implemented
647        //Sample Field
648        InsertPoints lastPoint,1,GField
649        GField[lastPoint]=-999
650               
651        // Monitor Count Rate
652        InsertPoints lastPoint,1,GMCR
653        GMCR[lastPoint]  = V_getBeamMonNormData(fname)/ctime            //total monitor count / total count time
654
655
656// number of guides and sample position, only for NCNR (a string now)
657        InsertPoints lastPoint,1,GNumGuides
658        GNumGuides[lastPoint]  = V_getNumberOfGuides(fname)
659
660// TODO -- maybe this is better to convert to a text wave?     
661        //Sample Position (== number position in 10CB)
662        InsertPoints lastPoint,1,GPos
663        GPos[lastPoint] = str2num(V_getSamplePosition(fname))
664
665// Intent (text)
666        InsertPoints lastPoint,1,GIntent
667        GIntent[lastPoint] = V_getReduction_intent(fname)
668
669// Purpose (text)
670        InsertPoints lastPoint,1,GPurpose
671        GPurpose[lastPoint] = V_getReduction_purpose(fname)
672               
673// group_id (sample)
674        InsertPoints lastPoint,1,G_ID
675        G_ID[lastPoint] = V_getSample_groupID(fname)
676
677        return(0)
678End
679
680
681
682// just to call the function to generate the panel
683Proc V_Catalog_Sort()
684        V_BuildCatSortPanel()
685End
686
687// [davidm] create CAT Sort-Panel
688function V_BuildCatSortPanel()
689
690        // check if CatVSANSTable exists
691        DoWindow CatVSANSTable
692        if (V_flag==0)
693                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
694                return 0
695        endif
696       
697        // bring CatSortPanel to front
698        DoWindow/F CatSortPanel
699        if (V_flag != 0)
700                return 0
701        endif
702       
703        print "Creating CAT Sort-Panel..."
704               
705        //PauseUpdate
706        NewPanel /W=(600,360,790,730)/K=1 as "CAT - Sort Panel"
707        DoWindow/C CatSortPanel
708        ModifyPanel fixedSize=1, cbRGB = (42919, 53970, 60909)
709       
710        Button SortFilenamesButton,             pos={25, 8},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Filenames"
711        Button SortLabelsButton,                        pos={25,38},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Labels"
712        Button SortDateAndTimeButton,   pos={25,68},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Date and Time"
713        Button SortIntentButton,                        pos={25,98},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Intent"
714        Button SortPurposeButton,               pos={25,128},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Purpose"
715        Button SortIDButton,                    pos={25,158},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Group ID"
716        Button SortLambdaButton,                        pos={25,188},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Lambda"
717        Button SortCountTimButton,              pos={25,218},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Time"
718        Button SortTotalCountsButton,           pos={25,248},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Total Counts"
719        Button SortCountRateButton,             pos={25,278},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Rate"
720        Button SortMonitorCountsButton, pos={25,308},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Monitor Counts"
721        Button SortTransmissionButton,  pos={25,338},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Transmission"
722
723end
724
725Proc V_CatVSANSTable_SortProc(ctrlName) : ButtonControl // added by [davidm]
726        String ctrlName
727       
728        // check if CatVSANSTable exists
729        DoWindow CatVSANSTable
730        if (V_flag==0)
731                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
732                return
733        endif
734               
735        // have to use function
736        V_CatVSANSTable_SortFunction(ctrlName)
737       
738end
739
740function V_CatVSANSTable_SortFunction(ctrlName) // added by [davidm]
741        String ctrlName
742
743// still need to declare these to access notRaw files and to get count of length
744        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
745        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
746
747//      Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
748////    Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
749//      Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
750//      Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
751//      Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
752//      Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
753//      Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
754//      Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
755////    Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
756////    Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
757//      Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
758//      Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
759////    Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
760////    Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
761//      Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
762//      Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
763//      Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
764//      Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
765//      Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
766//      Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
767//      Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
768//      Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
769
770       
771        // take out the "not-RAW-Files"
772        Variable fileCount = numpnts(GFilenames)
773        Variable rawCount = numpnts(GLabels)
774        Variable notRAWcount = fileCount - rawCount
775       
776        if (notRAWcount > 0)
777                Make/T/O/N=(notRAWcount) notRAWlist
778                notRAWlist[0, notRAWcount-1] = GFilenames[p+rawCount]
779                DeletePoints rawCount, notRAWcount, GFilenames
780        endif
781
782
783// get the list
784        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
785       
786        String list = WaveList("*",",",""),sortKey=""
787        String cmd
788       
789        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
790       
791// set the sortKey string       
792        strswitch (ctrlName)
793       
794                case "SortFilenamesButton":
795//                      Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
796//                      Sort GFilenames,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
797                        sortKey = "Filenames"
798                        break
799                       
800                case "SortLabelsButton":
801//                      Sort GLabels, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
802//                      Sort GLabels,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
803                        sortKey = "Labels"
804                        break
805                       
806                case "SortDateAndTimeButton":
807//                      Sort GDateTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
808//                      Sort GDateTime,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
809                        sortKey = "DateAndTime"
810
811                        break
812                       
813                case "SortIntentButton":
814//                      Sort GIntent,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
815                        sortKey = "Intent"
816
817                        break
818                       
819                case "SortIDButton":
820//                      Sort G_ID,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
821                        sortKey = "Group_ID"
822
823                        break
824                       
825                case "SortLambdaButton":
826//                      Sort GLambda, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
827//                      Sort GLambda,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
828                        sortKey = "Lambda"
829
830                        break
831                       
832                case "SortCountTimButton":
833//                      Sort GCntTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
834//                      Sort GCntTime,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
835                        sortKey = "CntTime"
836
837                        break
838                       
839                case "SortTotalCountsButton":
840//                      Sort GTotCnts, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
841//                      Sort GTotCnts,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
842                        sortKey = "TotCnts"
843
844                        break
845                       
846                case "SortCountRateButton":
847//                      Sort GCntRate, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
848//                      Sort GCntRate,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
849                        sortKey = "CntRate"
850
851                        break
852                       
853                case "SortMonitorCountsButton":
854                        sortKey = "MCR"
855
856                        break
857                       
858                case "SortTransmissionButton":
859//                      Sort GTransmission, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
860//                      Sort GTransmission,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
861                        sortKey = "Transmission"
862
863                        break
864                       
865                case "SortPurposeButton":
866//                      Sort GThickness, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
867//                      Sort GPurpose,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
868                        sortKey = "Purpose"
869
870                        break
871       
872        endswitch
873       
874        //do the sort
875        sprintf cmd, "Sort %s, %s", sortKey,list
876//      Print cmd                       // For debugging
877       
878        Execute cmd
879       
880       
881        // insert the "not-RAW-Files" again
882        if (notRAWcount > 0)
883                InsertPoints rawCount, notRAWcount, GFilenames
884                GFilenames[rawCount, fileCount-1] = notRAWlist[p-rawCount]
885        endif
886       
887        SetDataFolder root:
888
889end
890
Note: See TracBrowser for help on using the repository browser.