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

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

many additions.

Moved unused igor/nexus testing files to Vx_ prefix since they're garbage. Pulled out the useful bits for mask and div R/W and moved those to theire appropriate procedures.

Testing the simple correction of data, only tested basic subtraction. All of it still needs to be verified since I don't have any real header numbers and units yet.

Adjusted the columns on the file catalog to be more appropriate, and added a hook to allow loading of raw data files directly from the table and a popup contextual menu. May add more functionality to it later.

Corrected how the 1D data is plotted so that it correctly uses the binning type. I(q) save now also uses the binning as specified.

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