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

Last change on this file since 1148 was 1148, checked in by srkline, 3 years ago

added a batch patch routine to correct the sample aperture shape and size since it may be incorrectly written by NICE

defined the sector angles to match the SANS definition and updated the associated logic for the averaging and sector display

updated sorting of the file catalog to allow sorting by SDD_F and countRate_F. Also added a second sort key to keep the run numbers in order whenever sorting any other column.

  • Property svn:executable set to *
File size: 37.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 -
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:Lambda"
102        Make/O/T/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
103        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
104
105
106        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
107        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
108               
109        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_F"
110        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_F"
111        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_F"     
112       
113        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_M"
114        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_M"
115        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_M"     
116       
117        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_B"
118        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_B"
119        Make/O/D/N=0 $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_B"
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       
314        Variable ii
315       
316//      Print "EVENT= ",event
317        strswitch(event)
318                case "mouseup":
319//                      Variable xpix= NumberByKey("MOUSEX",infoStr)
320//                      Variable ypix= NumberByKey("MOUSEY",infoStr)
321//                      PopupContextualMenu/C=(xpix, ypix) "yes;no;maybe;"
322                        PopupContextualMenu "Load RAW;Load MSK;Load DIV;-;Send to MRED;"
323                       
324                        WAVE/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
325                        Variable err
326                        strswitch(S_selection)
327                                case "Load RAW":
328                                        GetSelection table,CatVSANSTable,1
329//                                      Print V_flag, V_startRow, V_startCol, V_endRow, V_endCol
330                                        Print "Loading " + FileNames[V_StartRow]
331                                        err = V_LoadHDF5Data(FileNames[V_StartRow],"RAW")
332                                        if(!err)                //directly from, and the same steps as DisplayMainButtonProc(ctrlName)
333                                                SVAR hdfDF = root:file_name                     // last file loaded, may not be the safest way to pass
334                                                String folder = StringFromList(0,hdfDF,".")
335                                               
336                                                // this (in SANS) just passes directly to fRawWindowHook()
337                                                V_UpdateDisplayInformation("RAW")               // plot the data in whatever folder type
338                                                                                               
339                                                // set the global to display ONLY if the load was called from here, not from the
340                                                // other routines that load data (to read in values)
341                                                SVAR gLast = root:Packages:NIST:VSANS:Globals:gLastLoadedFile
342                                                gLast = hdfDF
343                                               
344                                        endif
345                                        break
346                                       
347                                case "Load MSK":
348                                        GetSelection table,CatVSANSTable,1
349//                                      Print V_flag, V_startRow, V_startCol, V_endRow, V_endCol
350                                        Print "Loading " + FileNames[V_StartRow]
351                                        err = V_LoadHDF5Data(FileNames[V_StartRow],"MSK")
352                                       
353                                        break
354                                       
355                                case "Load DIV":
356                                        GetSelection table,CatVSANSTable,1
357//                                      Print V_flag, V_startRow, V_startCol, V_endRow, V_endCol
358                                        Print "Loading " + FileNames[V_StartRow]
359                                        err = V_LoadHDF5Data(FileNames[V_StartRow],"DIV")
360
361                                        break
362                                case "Send to MRED":
363                                        //
364                                        SVAR/Z numList=root:Packages:NIST:VSANS:Globals:MRED:gFileNumList
365                                        if(SVAR_Exists(numList))
366                                                GetSelection table,CatVSANSTable,1
367                                                for(ii=V_StartRow;ii<=V_endRow;ii+=1)
368        //                                              Print "selected " + FileNames[ii]
369                                                        numList += fileNames[ii] + ","
370                                                endfor
371                                                // pop the menu on the mred panel
372                                                V_MREDPopMenuProc("",1,"")
373                                        endif
374                                        break
375                                       
376                        endswitch               //popup selection
377        endswitch       // event
378       
379        return 0
380End
381
382
383
384//appends the list of files that are not RAW SANS data to the filename wave (1st column)
385//for display in the table. Note that the filenames column will now be longer than all other
386//waves in the table
387//
388// skip this step if there are no files to tack on
389Function V_AppendNotRAWFiles(w)
390        Wave/T w
391        if(numpnts(w) != 0)
392                Wave/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
393                Variable lastPoint
394                lastPoint = numpnts(Filenames)
395                InsertPoints lastPoint,numpnts(w),Filenames
396                Filenames[lastPoint,numpnts(Filenames)-1] = w[p-lastPoint]
397        endif
398        return(0)
399End
400
401//
402// this is called BEFORE the notRAWfiles are added to the fileNames wave
403// so that the waves are still all the same length and can properly be sorted.
404//
405Function V_SortWaves()
406//      Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
407////    Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
408//      Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
409//      Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
410////    Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
411//      Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
412//      Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
413//      Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
414//      Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
415//      Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
416//      Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
417////    Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
418////    Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
419//
420//      Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
421//      Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
422////    Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
423////    Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
424//      Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
425//      Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
426//      Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
427//      Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"             //added Mar 2008
428//      Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
429//      Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
430//      Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
431//      Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
432//
433//
434//// DONE
435//// x- the default sort is by SUFFIX, which does not exist for VSANS. So decide on a better key
436////     now, the sort is by FileName by default
437////    Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField,GMCR,GPos,gNumGuides
438//
439//      Sort GFilenames, GFilenames, GLabels, GDateTime,  GIntent, GPurpose, G_ID, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,GRot,GTemp,GField,GMCR,GPos,gNumGuides
440
441        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
442       
443        String list = WaveList("*",",","")
444        String cmd
445       
446        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
447       
448        sprintf cmd, "Sort Filenames, %s", list
449//      Print cmd                       // For debugging
450       
451        Execute cmd
452       
453        SetDataFolder root:
454        return(0)
455End
456
457//function to create the CAT/VSTable to display the header information
458//this table is just like any other table
459Function V_BuildTableWindow()
460
461        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
462       
463        String list = WaveList("*",",","")
464        String cmd
465       
466        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
467       
468        sprintf cmd, "Edit %s", list
469//      Print cmd                       // For debugging
470       
471        Execute cmd
472
473        String name="CatVSANSTable"
474        DoWindow/C $name
475       
476        SetDataFolder root:
477       
478//      Wave/T Filenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
479//      Wave/T Labels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
480//      Wave/T DateAndTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
481////    Wave SDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
482//      Wave Lambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
483//      Wave CntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
484//      Wave TotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
485//      Wave CntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
486//      Wave Transmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
487//      Wave Thickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
488////    Wave XCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
489////    Wave YCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
490//
491//      Wave/T NumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
492//      Wave NumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
493//      Wave RotAngle =  $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
494//      Wave Temperature = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
495//      Wave Field= $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
496//      Wave MCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"              //added Mar 2008
497//      Wave Pos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
498//      Wave/T Intent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
499//      Wave/T Purpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
500//      Wave Group_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
501//
502//// original order, magnetic at the end
503////    Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR as "Data File Catalog"
504//// with numGuides
505////    Edit Filenames, Labels, DateAndTime, SDD, Lambda, numGuides, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field, MCR, Pos as "Data File Catalog"
506
507//      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"
508
509
510        return(0)
511End
512
513//reads header information and puts it in the appropriate waves for display in the table.
514//fname is the full path for opening (and reading) information from the file
515//which alreay was found to exist. sname is the file;vers to be written out,
516//avoiding the need to re-extract it from fname.
517Function V_GetHeaderInfoToWave(fname,sname)
518        String fname,sname
519       
520
521        Variable lastPoint,ctime,detcnt,cntrate
522
523        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
524//      Wave/T GSuffix = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Suffix"
525        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
526        Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
527
528        WAVE sdd_f = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_F"
529        WAVE sdd_m = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_M"
530        WAVE sdd_b = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD_B"
531
532        Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
533        Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
534
535        Wave TotCnts_F = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_F"
536        Wave CntRate_F = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_F"
537        Wave TotCnts_M = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_M"
538        Wave CntRate_M = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_M"
539        Wave TotCnts_B = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts_B"
540        Wave CntRate_B = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate_B"
541       
542        Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
543        Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
544//      Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
545//      Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
546        Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
547        Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
548//      Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
549//      Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
550        Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
551        Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
552        Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
553        Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
554        Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
555        Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
556        Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
557        Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
558
559        lastPoint = numpnts(GLambda)
560               
561        //filename
562        InsertPoints lastPoint,1,GFilenames
563        GFilenames[lastPoint]=sname
564       
565//      //read the file alphanumeric suffix
566//      // (DONE) x- this does not exist for VSANS - so is there an equivalent, or delete? ((delete))
567//      InsertPoints lastPoint,1,GSuffix
568//      GSuffix[lastPoint]="unknown"
569
570        //read the counting time (integer)
571        InsertPoints lastPoint,1,GCntTime
572        ctime = V_getCount_time(fname)
573        GCntTime[lastPoint]=ctime
574       
575        //read the file creation date (string)
576        InsertPoints lastPoint,1,GDateTime
577        GDateTime[lastPoint]=V_getDataStartTime(fname)
578
579        // read the sample.label text field (string)
580        InsertPoints lastPoint,1,GLabels
581        GLabels[lastPoint]=V_getSampleDescription(fname)
582       
583               
584        //read the reals
585        //detector count and (derived) count rate
586        detcnt = V_getDet_IntegratedCount(fname,"FL")
587        detcnt += V_getDet_IntegratedCount(fname,"FR")
588        detcnt += V_getDet_IntegratedCount(fname,"FT")
589        detcnt += V_getDet_IntegratedCount(fname,"FB")
590        cntrate = detcnt/ctime
591        InsertPoints lastPoint,1,TotCnts_F
592        TotCnts_F[lastPoint]=detcnt
593        InsertPoints lastPoint,1,CntRate_F
594        CntRate_F[lastPoint]=cntrate
595
596        detcnt = V_getDet_IntegratedCount(fname,"ML")
597        detcnt += V_getDet_IntegratedCount(fname,"MR")
598        detcnt += V_getDet_IntegratedCount(fname,"MT")
599        detcnt += V_getDet_IntegratedCount(fname,"MB")
600        cntrate = detcnt/ctime
601        InsertPoints lastPoint,1,TotCnts_M
602        TotCnts_M[lastPoint]=detcnt
603        InsertPoints lastPoint,1,CntRate_M
604        CntRate_M[lastPoint]=cntrate
605       
606        detcnt = V_getDet_IntegratedCount(fname,"B")
607        cntrate = detcnt/ctime
608        InsertPoints lastPoint,1,TotCnts_B
609        TotCnts_B[lastPoint]=detcnt
610        InsertPoints lastPoint,1,CntRate_B
611        CntRate_B[lastPoint]=cntrate
612               
613               
614        //Attenuators
615        // (DONE) x- this is the "number" of the attenuator
616        InsertPoints lastPoint,1,GNumAttens
617        GNumAttens[lastPoint]=V_getAtten_number(fname)
618       
619        //Transmission
620        InsertPoints lastPoint,1,GTransmission
621        GTransmission[lastPoint]=V_getSampleTransmission(fname)
622       
623        //Thickness
624        InsertPoints lastPoint,1,GThickness
625        GThickness[lastPoint]=V_getSampleThickness(fname)
626
627//      // TODO --  the x and y center have different meaning, since there are multiple panels
628//      // TODO -- remove the hard-wiring
629//      String detStr = "FL"
630//      //XCenter of beam on detector
631//      InsertPoints lastPoint,1,GXCenter
632//      GXCenter[lastPoint]=V_getDet_beam_center_x(fname,detStr)
633//     
634//      // TODO --  the x and y center have different meaning, since there are multiple panels
635//      //YCenter
636//      InsertPoints lastPoint,1,GYCenter
637//      GYCenter[lastPoint]=V_getDet_beam_center_y(fname,detStr)
638
639//       there are multiple distances to report
640//      //SDD
641        InsertPoints lastPoint,1,sdd_f
642        sdd_f[lastPoint]=V_getDet_ActualDistance(fname,"FL")
643
644        InsertPoints lastPoint,1,sdd_m
645        sdd_m[lastPoint]=V_getDet_ActualDistance(fname,"ML")
646       
647        InsertPoints lastPoint,1,sdd_b
648        sdd_b[lastPoint]=V_getDet_ActualDistance(fname,"B")
649               
650        //wavelength
651        InsertPoints lastPoint,1,GLambda
652        GLambda[lastPoint]=V_getWavelength(fname)
653       
654        //Rotation Angle
655        InsertPoints lastPoint,1,GRot
656        GRot[lastPoint]=V_getSampleRotationAngle(fname)
657       
658        //Sample Temperature
659        // this reads sample:temperature which is the average temperature reading (may be affected by noise)
660        InsertPoints lastPoint,1,GTemp
661        GTemp[lastPoint]=V_getSampleTemperature(fname)
662
663        // TODO -- this is not yet implemented
664        //Sample Field
665        InsertPoints lastPoint,1,GField
666        GField[lastPoint]=-999
667               
668        // Monitor Count Rate
669        InsertPoints lastPoint,1,GMCR
670        GMCR[lastPoint]  = V_getBeamMonNormData(fname)/ctime            //total monitor count / total count time
671
672
673// number of guides and sample position, only for NCNR (a string now)
674        InsertPoints lastPoint,1,GNumGuides
675        GNumGuides[lastPoint]  = V_getNumberOfGuides(fname)
676
677// TODO -- maybe this is better to convert to a text wave?     
678        //Sample Position (== number position in 10CB)
679        InsertPoints lastPoint,1,GPos
680        GPos[lastPoint] = str2num(V_getSamplePosition(fname))
681
682// Intent (text)
683        InsertPoints lastPoint,1,GIntent
684        GIntent[lastPoint] = V_getReduction_intent(fname)
685
686// Purpose (text)
687        InsertPoints lastPoint,1,GPurpose
688        GPurpose[lastPoint] = V_getReduction_purpose(fname)
689               
690// group_id (sample)
691        InsertPoints lastPoint,1,G_ID
692        G_ID[lastPoint] = V_getSample_groupID(fname)
693
694        return(0)
695End
696
697
698
699// just to call the function to generate the panel
700Proc V_Catalog_Sort()
701        V_BuildCatSortPanel()
702End
703
704// [davidm] create CAT Sort-Panel
705function V_BuildCatSortPanel()
706
707        // check if CatVSANSTable exists
708        DoWindow CatVSANSTable
709        if (V_flag==0)
710                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
711                return 0
712        endif
713       
714        // bring CatSortPanel to front
715        DoWindow/F CatSortPanel
716        if (V_flag != 0)
717                return 0
718        endif
719       
720        print "Creating CAT Sort-Panel..."
721               
722        //PauseUpdate
723        NewPanel /W=(600,360,790,730)/K=1 as "CAT - Sort Panel"
724        DoWindow/C CatSortPanel
725        ModifyPanel fixedSize=1, cbRGB = (42919, 53970, 60909)
726       
727        Button SortFilenamesButton,             pos={25, 8},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Filenames"
728        Button SortLabelsButton,                        pos={25,38},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Labels"
729        Button SortDateAndTimeButton,   pos={25,68},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Date and Time"
730        Button SortIntentButton,                        pos={25,98},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Intent"
731        Button SortPurposeButton,               pos={25,128},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Purpose"
732        Button SortIDButton,                    pos={25,158},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Group ID"
733        Button SortLambdaButton,                        pos={25,188},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Lambda"
734        Button SortCountTimButton,              pos={25,218},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Time"
735        Button SortSDDFButton,          pos={25,248},   size={140,24},proc=V_CatVSANSTable_SortProc,title="SDD F"
736        Button SortCountRateFButton,            pos={25,278},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Rate F"
737        Button SortMonitorCountsButton, pos={25,308},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Monitor Counts"
738        Button SortTransmissionButton,  pos={25,338},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Transmission"
739
740end
741
742Proc V_CatVSANSTable_SortProc(ctrlName) : ButtonControl // added by [davidm]
743        String ctrlName
744       
745        // check if CatVSANSTable exists
746        DoWindow CatVSANSTable
747        if (V_flag==0)
748                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
749                return
750        endif
751               
752        // have to use function
753        V_CatVSANSTable_SortFunction(ctrlName)
754       
755end
756
757function V_CatVSANSTable_SortFunction(ctrlName) // added by [davidm]
758        String ctrlName
759
760// still need to declare these to access notRaw files and to get count of length
761        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
762        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
763
764//      Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
765////    Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
766//      Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
767//      Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
768//      Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
769//      Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
770//      Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
771//      Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
772////    Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
773////    Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
774//      Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
775//      Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
776////    Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
777////    Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
778//      Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
779//      Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
780//      Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
781//      Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
782//      Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
783//      Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
784//      Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
785//      Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
786
787       
788        // take out the "not-RAW-Files"
789        Variable fileCount = numpnts(GFilenames)
790        Variable rawCount = numpnts(GLabels)
791        Variable notRAWcount = fileCount - rawCount
792       
793        if (notRAWcount > 0)
794                Make/T/O/N=(notRAWcount) notRAWlist
795                notRAWlist[0, notRAWcount-1] = GFilenames[p+rawCount]
796                DeletePoints rawCount, notRAWcount, GFilenames
797        endif
798
799
800// get the list
801        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
802       
803        String list = WaveList("*",",",""),sortKey=""
804        String cmd
805       
806        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
807       
808// set the sortKey string       
809        strswitch (ctrlName)
810       
811                case "SortFilenamesButton":
812//                      Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
813//                      Sort GFilenames,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
814                        sortKey = "Filenames"
815                        break
816                       
817                case "SortLabelsButton":
818//                      Sort GLabels, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
819//                      Sort GLabels,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
820                        sortKey = "Labels"
821                        break
822                       
823                case "SortDateAndTimeButton":
824//                      Sort GDateTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
825//                      Sort GDateTime,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
826                        sortKey = "DateAndTime"
827
828                        break
829                       
830                case "SortIntentButton":
831//                      Sort GIntent,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
832                        sortKey = "Intent"
833
834                        break
835                       
836                case "SortIDButton":
837//                      Sort G_ID,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
838                        sortKey = "Group_ID"
839
840                        break
841                       
842                case "SortLambdaButton":
843//                      Sort GLambda, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
844//                      Sort GLambda,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
845                        sortKey = "Lambda"
846
847                        break
848                       
849                case "SortCountTimButton":
850//                      Sort GCntTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
851//                      Sort GCntTime,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
852                        sortKey = "CntTime"
853
854                        break
855                       
856                case "SortSDDFButton":
857//                      Sort GTotCnts, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
858//                      Sort GTotCnts,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
859                        sortKey = "SDD_F"
860
861                        break
862                       
863                case "SortCountRateFButton":
864//                      Sort GCntRate, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
865//                      Sort GCntRate,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
866                        sortKey = "CntRate_F"
867
868                        break
869                       
870                case "SortMonitorCountsButton":
871                        sortKey = "MCR"
872
873                        break
874                       
875                case "SortTransmissionButton":
876//                      Sort GTransmission, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
877//                      Sort GTransmission,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
878                        sortKey = "Transmission"
879
880                        break
881                       
882                case "SortPurposeButton":
883//                      Sort GThickness, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
884//                      Sort GPurpose,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
885                        sortKey = "Purpose"
886
887                        break
888       
889        endswitch
890       
891        //do the sort
892//      sprintf cmd, "Sort %s, %s", sortKey,list
893// use braces and second key to keep anything with the same first "key" value in numerical run number order
894        sprintf cmd, "Sort {%s,Filenames} %s", sortKey,list
895//      Print cmd                       // For debugging
896       
897        Execute cmd
898       
899       
900        // insert the "not-RAW-Files" again
901        if (notRAWcount > 0)
902                InsertPoints rawCount, notRAWcount, GFilenames
903                GFilenames[rawCount, fileCount-1] = notRAWlist[p-rawCount]
904        endif
905       
906        SetDataFolder root:
907
908end
909
Note: See TracBrowser for help on using the repository browser.