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

Last change on this file since 1025 was 1025, checked in by srkline, 6 years ago

many changes to get the basics of a reduction protocol working

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