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

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

many changes to the VCALC procedures to add in the hard/soft shadowing to the calculation, visualization of the shadowed regions, and the actual q-values. Added a separate panel to view the shadowed regions.

simpe fix to the real time routine to allow easy updating of both the raw 2D data and 1-D average

update to the USANS package to handle the new NICE generated data where the data is collected in terms of q-values rather than angle. On startup asks user which style of data they have. Sets a preference that can be un-checked if you have old-style ICP data. (there is nothing in the data file that I can key on).

  • Property svn:executable set to *
File size: 37.3 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//      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        // this reads sample:temperature which is the average temperature reading (may be affected by noise)
644        InsertPoints lastPoint,1,GTemp
645        GTemp[lastPoint]=V_getSampleTemperature(fname)
646
647        // TODO -- this is not yet implemented
648        //Sample Field
649        InsertPoints lastPoint,1,GField
650        GField[lastPoint]=-999
651               
652        // Monitor Count Rate
653        InsertPoints lastPoint,1,GMCR
654        GMCR[lastPoint]  = V_getBeamMonNormData(fname)/ctime            //total monitor count / total count time
655
656
657// number of guides and sample position, only for NCNR (a string now)
658        InsertPoints lastPoint,1,GNumGuides
659        GNumGuides[lastPoint]  = V_getNumberOfGuides(fname)
660
661// TODO -- maybe this is better to convert to a text wave?     
662        //Sample Position (== number position in 10CB)
663        InsertPoints lastPoint,1,GPos
664        GPos[lastPoint] = str2num(V_getSamplePosition(fname))
665
666// Intent (text)
667        InsertPoints lastPoint,1,GIntent
668        GIntent[lastPoint] = V_getReduction_intent(fname)
669
670// Purpose (text)
671        InsertPoints lastPoint,1,GPurpose
672        GPurpose[lastPoint] = V_getReduction_purpose(fname)
673               
674// group_id (sample)
675        InsertPoints lastPoint,1,G_ID
676        G_ID[lastPoint] = V_getSample_groupID(fname)
677
678        return(0)
679End
680
681
682
683// just to call the function to generate the panel
684Proc V_Catalog_Sort()
685        V_BuildCatSortPanel()
686End
687
688// [davidm] create CAT Sort-Panel
689function V_BuildCatSortPanel()
690
691        // check if CatVSANSTable exists
692        DoWindow CatVSANSTable
693        if (V_flag==0)
694                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
695                return 0
696        endif
697       
698        // bring CatSortPanel to front
699        DoWindow/F CatSortPanel
700        if (V_flag != 0)
701                return 0
702        endif
703       
704        print "Creating CAT Sort-Panel..."
705               
706        //PauseUpdate
707        NewPanel /W=(600,360,790,730)/K=1 as "CAT - Sort Panel"
708        DoWindow/C CatSortPanel
709        ModifyPanel fixedSize=1, cbRGB = (42919, 53970, 60909)
710       
711        Button SortFilenamesButton,             pos={25, 8},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Filenames"
712        Button SortLabelsButton,                        pos={25,38},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Labels"
713        Button SortDateAndTimeButton,   pos={25,68},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Date and Time"
714        Button SortIntentButton,                        pos={25,98},            size={140,24},proc=V_CatVSANSTable_SortProc,title="Intent"
715        Button SortPurposeButton,               pos={25,128},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Purpose"
716        Button SortIDButton,                    pos={25,158},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Group ID"
717        Button SortLambdaButton,                        pos={25,188},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Lambda"
718        Button SortCountTimButton,              pos={25,218},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Time"
719        Button SortTotalCountsButton,           pos={25,248},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Total Counts"
720        Button SortCountRateButton,             pos={25,278},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Count Rate"
721        Button SortMonitorCountsButton, pos={25,308},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Monitor Counts"
722        Button SortTransmissionButton,  pos={25,338},   size={140,24},proc=V_CatVSANSTable_SortProc,title="Transmission"
723
724end
725
726Proc V_CatVSANSTable_SortProc(ctrlName) : ButtonControl // added by [davidm]
727        String ctrlName
728       
729        // check if CatVSANSTable exists
730        DoWindow CatVSANSTable
731        if (V_flag==0)
732                DoAlert 0,"There is no File Catalog table. Use the File Catalog button to create one."
733                return
734        endif
735               
736        // have to use function
737        V_CatVSANSTable_SortFunction(ctrlName)
738       
739end
740
741function V_CatVSANSTable_SortFunction(ctrlName) // added by [davidm]
742        String ctrlName
743
744// still need to declare these to access notRaw files and to get count of length
745        Wave/T GFilenames = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames"
746        Wave/T GLabels = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Labels"
747
748//      Wave/T GDateTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:DateAndTime"
749////    Wave GSDD = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:SDD"
750//      Wave GLambda = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Lambda"
751//      Wave GCntTime = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntTime"
752//      Wave GTotCnts = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:TotCnts"
753//      Wave GCntRate = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:CntRate"
754//      Wave GTransmission = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Transmission"
755//      Wave GThickness = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Thickness"
756////    Wave GXCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:XCenter"
757////    Wave GYCenter = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:YCenter"
758//      Wave/T GNumGuides = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:nGuides"
759//      Wave GNumAttens = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:NumAttens"
760////    Wave GRunNumber = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RunNumber"
761////    Wave GIsTrans = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:IsTrans"
762//      Wave GRot = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:RotAngle"
763//      Wave GTemp = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Temperature"
764//      Wave GField = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Field"
765//      Wave GMCR = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:MCR"
766//      Wave GPos = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Pos"
767//      Wave/T GIntent = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent"
768//      Wave/T GPurpose = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose"
769//      Wave G_ID = $"root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID"
770
771       
772        // take out the "not-RAW-Files"
773        Variable fileCount = numpnts(GFilenames)
774        Variable rawCount = numpnts(GLabels)
775        Variable notRAWcount = fileCount - rawCount
776       
777        if (notRAWcount > 0)
778                Make/T/O/N=(notRAWcount) notRAWlist
779                notRAWlist[0, notRAWcount-1] = GFilenames[p+rawCount]
780                DeletePoints rawCount, notRAWcount, GFilenames
781        endif
782
783
784// get the list
785        SetDataFolder root:Packages:NIST:VSANS:CatVSHeaderInfo:
786       
787        String list = WaveList("*",",",""),sortKey=""
788        String cmd
789       
790        list = list[0,strlen(list)-2]           //remove the trailing comma or "invalid column name" error
791       
792// set the sortKey string       
793        strswitch (ctrlName)
794       
795                case "SortFilenamesButton":
796//                      Sort GFilenames, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
797//                      Sort GFilenames,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
798                        sortKey = "Filenames"
799                        break
800                       
801                case "SortLabelsButton":
802//                      Sort GLabels, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
803//                      Sort GLabels,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
804                        sortKey = "Labels"
805                        break
806                       
807                case "SortDateAndTimeButton":
808//                      Sort GDateTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
809//                      Sort GDateTime,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
810                        sortKey = "DateAndTime"
811
812                        break
813                       
814                case "SortIntentButton":
815//                      Sort GIntent,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
816                        sortKey = "Intent"
817
818                        break
819                       
820                case "SortIDButton":
821//                      Sort G_ID,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
822                        sortKey = "Group_ID"
823
824                        break
825                       
826                case "SortLambdaButton":
827//                      Sort GLambda, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
828//                      Sort GLambda,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
829                        sortKey = "Lambda"
830
831                        break
832                       
833                case "SortCountTimButton":
834//                      Sort GCntTime, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
835//                      Sort GCntTime,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
836                        sortKey = "CntTime"
837
838                        break
839                       
840                case "SortTotalCountsButton":
841//                      Sort GTotCnts, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
842//                      Sort GTotCnts,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
843                        sortKey = "TotCnts"
844
845                        break
846                       
847                case "SortCountRateButton":
848//                      Sort GCntRate, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
849//                      Sort GCntRate,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
850                        sortKey = "CntRate"
851
852                        break
853                       
854                case "SortMonitorCountsButton":
855                        sortKey = "MCR"
856
857                        break
858                       
859                case "SortTransmissionButton":
860//                      Sort GTransmission, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
861//                      Sort GTransmission,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
862                        sortKey = "Transmission"
863
864                        break
865                       
866                case "SortPurposeButton":
867//                      Sort GThickness, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens, GRunNumber, GIsTrans, GRot, GTemp, GField, GMCR
868//                      Sort GPurpose,  GPurpose, GFilenames, GLabels, GDateTime,  GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness,   GNumAttens,   GRot, GTemp, GField, GMCR, GIntent, G_ID
869                        sortKey = "Purpose"
870
871                        break
872       
873        endswitch
874       
875        //do the sort
876        sprintf cmd, "Sort %s, %s", sortKey,list
877//      Print cmd                       // For debugging
878       
879        Execute cmd
880       
881       
882        // insert the "not-RAW-Files" again
883        if (notRAWcount > 0)
884                InsertPoints rawCount, notRAWcount, GFilenames
885                GFilenames[rawCount, fileCount-1] = notRAWlist[p-rawCount]
886        endif
887       
888        SetDataFolder root:
889
890end
891
Note: See TracBrowser for help on using the repository browser.