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