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

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

proper handling of setback, intent, and purpose. New value of setback is included, and proper definition of how purpose and intent are defined within NICE and the GUI are partly completed now. Searches still need to be updated.

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