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

Last change on this file since 1034 was 1034, checked in by srkline, 5 years ago

re-wrote raw data reader for significant speed boost (mostly by skipping the read of DAS_logs)

added centroid calculation to the Marquee

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