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

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

many minor changes after real VSANS data collected.

additional procedures added to allow easy correction of the incorrect header information from NICE.

Most notable addition is the pinhole resolution added to the calculation and the I(q) output. White beam is also treated (incorrectly) as a gaussian distrivution, but the results of smeared fitting look to be quite good.

Trimming and sorting routines are now (pinhole) resolution aware.

File identification routines have been updated to use the proper definitions of "purpose" and "intent". Both fields are now in the catalog, to allow for better sorting.

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