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

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

woking on routines to correctly reduce data colloected with slit apertures. trying to get the data to absolute scale, with proper errro bars and resolution information.

Still not there yet.

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