1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=5.0 |
---|
3 | #pragma IgorVersion=4.0 |
---|
4 | |
---|
5 | |
---|
6 | // |
---|
7 | // SRK modified 30 JAN07 to include Rotation angle, Temperature, and B-field in the table (at the end) |
---|
8 | // |
---|
9 | |
---|
10 | //************** |
---|
11 | // Vers 1.2 090401 |
---|
12 | // |
---|
13 | // Procedures for creating the Catalog listings of the SANS datafiles in the folder |
---|
14 | // specified by catPathName. |
---|
15 | // Header information from each of the dataifles is organized in a table for |
---|
16 | // easy identification of each file. CatVSTable is the preferred invocation, |
---|
17 | // although CatVSNotebook and CatNotebook can also be used. |
---|
18 | // Files in the folder that are not RAW SANS data are appended to the end of the listing. |
---|
19 | //************** |
---|
20 | |
---|
21 | //this main procedure does all the work, obtaining the folder path, |
---|
22 | //parsing the filenames in the list and (dispatching) to write out the |
---|
23 | //appropriate information to the notebook window |
---|
24 | Proc BuildCatVeryShortTable() |
---|
25 | |
---|
26 | Variable err |
---|
27 | PathInfo catPathName |
---|
28 | if(v_flag==0) |
---|
29 | err = PickPath() //sets the local path to the data (catPathName) |
---|
30 | if(err) |
---|
31 | Abort "no path to data was selected, no catalog can be made - use PickPath button" |
---|
32 | Endif |
---|
33 | Endif |
---|
34 | |
---|
35 | DoWindow/F CatVSTable |
---|
36 | |
---|
37 | Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:Filenames" |
---|
38 | Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:Suffix" |
---|
39 | Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:Labels" |
---|
40 | Make/O/T/N=0 $"root:myGlobals:CatVSHeaderInfo:DateAndTime" |
---|
41 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:SDD" |
---|
42 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Lambda" |
---|
43 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:CntTime" |
---|
44 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:TotCnts" |
---|
45 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:CntRate" |
---|
46 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Transmission" |
---|
47 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Thickness" |
---|
48 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:XCenter" |
---|
49 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:YCenter" |
---|
50 | //Make/O/B/N=0 $"root:myGlobals:CatVSHeaderInfo:NumGuides" |
---|
51 | Make/O/B/N=0 $"root:myGlobals:CatVSHeaderInfo:NumAttens" |
---|
52 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:RunNumber" |
---|
53 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:IsTrans" |
---|
54 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:RotAngle" |
---|
55 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Temperature" |
---|
56 | Make/O/D/N=0 $"root:myGlobals:CatVSHeaderInfo:Field" |
---|
57 | |
---|
58 | If(V_Flag==0) |
---|
59 | BuildTableWindow() |
---|
60 | ModifyTable width(:myGlobals:CatVSHeaderInfo:SDD)=40 |
---|
61 | ModifyTable width(:myGlobals:CatVSHeaderInfo:Lambda)=40 |
---|
62 | ModifyTable width(:myGlobals:CatVSHeaderInfo:CntTime)=50 |
---|
63 | ModifyTable width(:myGlobals:CatVSHeaderInfo:TotCnts)=60 |
---|
64 | ModifyTable width(:myGlobals:CatVSHeaderInfo:CntRate)=60 |
---|
65 | ModifyTable width(:myGlobals:CatVSHeaderInfo:Transmission)=40 |
---|
66 | ModifyTable width(:myGlobals:CatVSHeaderInfo:Thickness)=40 |
---|
67 | ModifyTable width(:myGlobals:CatVSHeaderInfo:XCenter)=40 |
---|
68 | ModifyTable width(:myGlobals:CatVSHeaderInfo:YCenter)=40 |
---|
69 | ModifyTable width(:myGlobals:CatVSHeaderInfo:NumAttens)=30 |
---|
70 | ModifyTable width(:myGlobals:CatVSHeaderInfo:RotAngle)=50 |
---|
71 | ModifyTable width(:myGlobals:CatVSHeaderInfo:Field)=50 |
---|
72 | |
---|
73 | ModifyTable width(Point)=0 //JUN04, remove point numbers - confuses users since point != run |
---|
74 | Endif |
---|
75 | |
---|
76 | //get a list of all files in the folder, some will be junk version numbers that don't exist |
---|
77 | String list,partialName,tempName,temp="" |
---|
78 | list = IndexedFile(catPathName,-1,"????") //get all files in folder |
---|
79 | Variable numitems,ii,ok |
---|
80 | |
---|
81 | //remove version numbers from semicolon-delimited list |
---|
82 | list = RemoveVersNumsFromList(list) |
---|
83 | numitems = ItemsInList(list,";") |
---|
84 | |
---|
85 | //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS |
---|
86 | //***version numbers have been removed*** |
---|
87 | String str,fullName |
---|
88 | Variable lastPoint |
---|
89 | ii=0 |
---|
90 | |
---|
91 | Make/T/O/N=0 notRAWlist |
---|
92 | do |
---|
93 | //get current item in the list |
---|
94 | partialName = StringFromList(ii, list, ";") |
---|
95 | //get a valid file based on this partialName and catPathName |
---|
96 | tempName = FindValidFilename(partialName) |
---|
97 | If(cmpstr(tempName,"")==0) //a null string was returned |
---|
98 | //write to notebook that file was not found |
---|
99 | //if string is not a number, report the error |
---|
100 | if(str2num(partialName) == NaN) |
---|
101 | str = "this file was not found: "+partialName+"\r\r" |
---|
102 | //Notebook CatWin,font="Times",fsize=12,text=str |
---|
103 | Endif |
---|
104 | else |
---|
105 | //prepend path to tempName for read routine |
---|
106 | PathInfo catPathName |
---|
107 | FullName = S_path + tempName |
---|
108 | //make sure the file is really a RAW data file |
---|
109 | ok = CheckIfRawData(fullName) |
---|
110 | if (!ok) |
---|
111 | //write to notebook that file was not a RAW SANS file |
---|
112 | lastPoint = numpnts(notRAWlist) |
---|
113 | InsertPoints lastPoint,1,notRAWlist |
---|
114 | notRAWlist[lastPoint]=tempname |
---|
115 | else |
---|
116 | //go write the header information to the Notebook |
---|
117 | GetHeaderInfoToWave(fullName,tempName) |
---|
118 | Endif |
---|
119 | Endif |
---|
120 | ii+=1 |
---|
121 | while(ii<numitems) |
---|
122 | //Now sort them all based on the suffix data (orders them as collected) |
---|
123 | SortWaves() |
---|
124 | //Append the files that are not raw files to the list |
---|
125 | AppendNotRAWFiles(notRAWlist) |
---|
126 | KillWaves/Z notRAWlist |
---|
127 | // |
---|
128 | |
---|
129 | End |
---|
130 | |
---|
131 | //appends the list of files that are not RAW SANS data to the filename wave (1st column) |
---|
132 | //for display in the table. Note that the filenames column will now be longer than all other |
---|
133 | //waves in the table |
---|
134 | Function AppendNotRAWFiles(w) |
---|
135 | Wave/T w |
---|
136 | Wave/T Filenames = $"root:myGlobals:CatVSHeaderInfo:Filenames" |
---|
137 | Variable lastPoint |
---|
138 | lastPoint = numpnts(Filenames) |
---|
139 | InsertPoints lastPoint,numpnts(w),Filenames |
---|
140 | Filenames[lastPoint,numpnts(Filenames)-1] = w[p-lastPoint] |
---|
141 | return(0) |
---|
142 | End |
---|
143 | |
---|
144 | //sorts all of the waves of header information using the suffix (A123) |
---|
145 | //the result is that all of the data is in the order that it was collected, |
---|
146 | // regardless of how the prefix or run numbers were changed by the user |
---|
147 | Function SortWaves() |
---|
148 | Wave/T GFilenames = $"root:myGlobals:CatVSHeaderInfo:Filenames" |
---|
149 | Wave/T GSuffix = $"root:myGlobals:CatVSHeaderInfo:Suffix" |
---|
150 | Wave/T GLabels = $"root:myGlobals:CatVSHeaderInfo:Labels" |
---|
151 | Wave/T GDateTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime" |
---|
152 | Wave GSDD = $"root:myGlobals:CatVSHeaderInfo:SDD" |
---|
153 | Wave GLambda = $"root:myGlobals:CatVSHeaderInfo:Lambda" |
---|
154 | Wave GCntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime" |
---|
155 | Wave GTotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts" |
---|
156 | Wave GCntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate" |
---|
157 | Wave GTransmission = $"root:myGlobals:CatVSHeaderInfo:Transmission" |
---|
158 | Wave GThickness = $"root:myGlobals:CatVSHeaderInfo:Thickness" |
---|
159 | Wave GXCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter" |
---|
160 | Wave GYCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter" |
---|
161 | //Wave/B GNumGuides = $"root:myGlobals:CatVSHeaderInfo:NumGuides" |
---|
162 | Wave/B GNumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens" |
---|
163 | Wave GRunNumber = $"root:myGlobals:CatVSHeaderInfo:RunNumber" |
---|
164 | Wave GIsTrans = $"root:myGlobals:CatVSHeaderInfo:IsTrans" |
---|
165 | Wave GRot = $"root:myGlobals:CatVSHeaderInfo:RotAngle" |
---|
166 | Wave GTemp = $"root:myGlobals:CatVSHeaderInfo:Temperature" |
---|
167 | Wave GField = $"root:myGlobals:CatVSHeaderInfo:Field" |
---|
168 | |
---|
169 | Sort GSuffix, GSuffix, GFilenames, GLabels, GDateTime, GSDD, GLambda, GCntTime, GTotCnts, GCntRate, GTransmission, GThickness, GXCenter, GYCenter, GNumAttens,GRunNumber,GIsTrans,GRot,GTemp,GField |
---|
170 | return(0) |
---|
171 | End |
---|
172 | |
---|
173 | //function to create the CAT/VSTable to display the header information |
---|
174 | //this table is just like any other table |
---|
175 | Function BuildTableWindow() |
---|
176 | Wave/T Filenames = $"root:myGlobals:CatVSHeaderInfo:Filenames" |
---|
177 | Wave/T Labels = $"root:myGlobals:CatVSHeaderInfo:Labels" |
---|
178 | Wave/T DateAndTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime" |
---|
179 | Wave SDD = $"root:myGlobals:CatVSHeaderInfo:SDD" |
---|
180 | Wave Lambda = $"root:myGlobals:CatVSHeaderInfo:Lambda" |
---|
181 | Wave CntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime" |
---|
182 | Wave TotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts" |
---|
183 | Wave CntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate" |
---|
184 | Wave Transmission = $"root:myGlobals:CatVSHeaderInfo:Transmission" |
---|
185 | Wave Thickness = $"root:myGlobals:CatVSHeaderInfo:Thickness" |
---|
186 | Wave XCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter" |
---|
187 | Wave YCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter" |
---|
188 | //Wave/B NumGuides = $"root:myGlobals:CatVSHeaderInfo:NumGuides" |
---|
189 | Wave/B NumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens" |
---|
190 | Wave RotAngle = $"root:myGlobals:CatVSHeaderInfo:RotAngle" |
---|
191 | Wave Temperature = $"root:myGlobals:CatVSHeaderInfo:Temperature" |
---|
192 | Wave Field= $"root:myGlobals:CatVSHeaderInfo:Field" |
---|
193 | |
---|
194 | // original order, magnetic at the end |
---|
195 | Edit Filenames, Labels, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens, RotAngle, Temperature, Field as "Data File Catalog" |
---|
196 | // alternate ordering, put the magnetic information first |
---|
197 | // Edit Filenames, Labels, RotAngle, Temperature, Field, DateAndTime, SDD, Lambda, CntTime, TotCnts, CntRate, Transmission, Thickness, XCenter, YCenter, NumAttens as "Data File Catalog" |
---|
198 | String name="CatVSTable" |
---|
199 | DoWindow/C $name |
---|
200 | return(0) |
---|
201 | End |
---|
202 | |
---|
203 | //reads header information and puts it in the appropriate waves for display in the table. |
---|
204 | //fname is the full path for opening (and reading) information from the file |
---|
205 | //which alreay was found to exist. sname is the file;vers to be written out, |
---|
206 | //avoiding the need to re-extract it from fname. |
---|
207 | Function GetHeaderInfoToWave(fname,sname) |
---|
208 | String fname,sname |
---|
209 | |
---|
210 | String textstr,temp,lbl,date_time,suffix |
---|
211 | Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten |
---|
212 | Variable lastPoint, beamstop,dum |
---|
213 | |
---|
214 | Wave/T GFilenames = $"root:myGlobals:CatVSHeaderInfo:Filenames" |
---|
215 | Wave/T GSuffix = $"root:myGlobals:CatVSHeaderInfo:Suffix" |
---|
216 | Wave/T GLabels = $"root:myGlobals:CatVSHeaderInfo:Labels" |
---|
217 | Wave/T GDateTime = $"root:myGlobals:CatVSHeaderInfo:DateAndTime" |
---|
218 | Wave GSDD = $"root:myGlobals:CatVSHeaderInfo:SDD" |
---|
219 | Wave GLambda = $"root:myGlobals:CatVSHeaderInfo:Lambda" |
---|
220 | Wave GCntTime = $"root:myGlobals:CatVSHeaderInfo:CntTime" |
---|
221 | Wave GTotCnts = $"root:myGlobals:CatVSHeaderInfo:TotCnts" |
---|
222 | Wave GCntRate = $"root:myGlobals:CatVSHeaderInfo:CntRate" |
---|
223 | Wave GTransmission = $"root:myGlobals:CatVSHeaderInfo:Transmission" |
---|
224 | Wave GThickness = $"root:myGlobals:CatVSHeaderInfo:Thickness" |
---|
225 | Wave GXCenter = $"root:myGlobals:CatVSHeaderInfo:XCenter" |
---|
226 | Wave GYCenter = $"root:myGlobals:CatVSHeaderInfo:YCenter" |
---|
227 | //Wave/B GNumGuides = $"root:myGlobals:CatVSHeaderInfo:NumGuides" |
---|
228 | Wave/B GNumAttens = $"root:myGlobals:CatVSHeaderInfo:NumAttens" |
---|
229 | Wave GRunNumber = $"root:myGlobals:CatVSHeaderInfo:RunNumber" |
---|
230 | Wave GIsTrans = $"root:myGlobals:CatVSHeaderInfo:IsTrans" |
---|
231 | Wave GRot = $"root:myGlobals:CatVSHeaderInfo:RotAngle" |
---|
232 | Wave GTemp = $"root:myGlobals:CatVSHeaderInfo:Temperature" |
---|
233 | Wave GField = $"root:myGlobals:CatVSHeaderInfo:Field" |
---|
234 | |
---|
235 | lastPoint = numpnts(GLambda) |
---|
236 | |
---|
237 | Open/R refNum as fname |
---|
238 | |
---|
239 | InsertPoints lastPoint,1,GFilenames |
---|
240 | GFilenames[lastPoint]=sname |
---|
241 | |
---|
242 | //read the file creation date |
---|
243 | FSetPos refNum,19 |
---|
244 | FReadLine/N=4 refNum,suffix |
---|
245 | InsertPoints lastPoint,1,GSuffix |
---|
246 | GSuffix[lastPoint]=suffix |
---|
247 | |
---|
248 | //read the counting time (integer) |
---|
249 | FSetPos refNum,31 |
---|
250 | FBinRead/F=3/B=3 refNum, ctime |
---|
251 | InsertPoints lastPoint,1,GCntTime |
---|
252 | GCntTime[lastPoint]=ctime |
---|
253 | |
---|
254 | //read the file creation date |
---|
255 | FSetPos refNum,55 |
---|
256 | FReadLine/N=20 refNum,date_time |
---|
257 | InsertPoints lastPoint,1,GDateTime |
---|
258 | GDateTime[lastPoint]=date_time |
---|
259 | |
---|
260 | // read the sample.label text field |
---|
261 | FSetPos refNum,98 //will start reading at byte 99 |
---|
262 | FReadLine/N=60 refNum,lbl |
---|
263 | InsertPoints lastPoint,1,GLabels |
---|
264 | GLabels[lastPoint]=lbl |
---|
265 | |
---|
266 | Close refNum |
---|
267 | |
---|
268 | //read the reals with GBLoadWave |
---|
269 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
270 | String strToExecute |
---|
271 | |
---|
272 | //detector count |
---|
273 | strToExecute = GBLoadStr + "/S=47/U=1" + "\"" + fname + "\"" |
---|
274 | Execute strToExecute |
---|
275 | Wave w=$"tempGBWave0" |
---|
276 | detcnt = w[0] |
---|
277 | cntrate = detcnt/ctime |
---|
278 | InsertPoints lastPoint,1,GTotCnts |
---|
279 | GTotCnts[lastPoint]=detcnt |
---|
280 | InsertPoints lastPoint,1,GCntRate |
---|
281 | GCntRate[lastPoint]=cntrate |
---|
282 | |
---|
283 | //Attenuators |
---|
284 | strToExecute = GBLoadStr + "/S=51/U=1" + "\"" + fname + "\"" |
---|
285 | Execute strToExecute |
---|
286 | numatten = w[0] |
---|
287 | InsertPoints lastPoint,1,GNumAttens |
---|
288 | GNumAttens[lastPoint]=numatten |
---|
289 | |
---|
290 | //Transmission |
---|
291 | strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\"" |
---|
292 | Execute strToExecute |
---|
293 | trans = w[0] |
---|
294 | InsertPoints lastPoint,1,GTransmission |
---|
295 | GTransmission[lastPoint]=trans |
---|
296 | |
---|
297 | //Thickness |
---|
298 | strToExecute = GBLoadStr + "/S=162/U=1" + "\"" + fname + "\"" |
---|
299 | Execute strToExecute |
---|
300 | thick = w[0] |
---|
301 | InsertPoints lastPoint,1,GThickness |
---|
302 | GThickness[lastPoint]=thick |
---|
303 | |
---|
304 | //XCenter |
---|
305 | strToExecute = GBLoadStr + "/S=252/U=1" + "\"" + fname + "\"" |
---|
306 | Execute strToExecute |
---|
307 | xcenter = w[0] |
---|
308 | InsertPoints lastPoint,1,GXCenter |
---|
309 | GXCenter[lastPoint]=xCenter |
---|
310 | |
---|
311 | //YCenter |
---|
312 | strToExecute = GBLoadStr + "/S=256/U=1" + "\"" + fname + "\"" |
---|
313 | Execute strToExecute |
---|
314 | ycenter = w[0] |
---|
315 | InsertPoints lastPoint,1,GYCenter |
---|
316 | GYCenter[lastPoint]=ycenter |
---|
317 | |
---|
318 | //SDD |
---|
319 | strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\"" |
---|
320 | Execute strToExecute |
---|
321 | sdd = w[0] |
---|
322 | InsertPoints lastPoint,1,GSDD |
---|
323 | GSDD[lastPoint]=sdd |
---|
324 | |
---|
325 | //wavelength |
---|
326 | strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\"" |
---|
327 | Execute strToExecute |
---|
328 | lambda = w[0] |
---|
329 | InsertPoints lastPoint,1,GLambda |
---|
330 | GLambda[lastPoint]=lambda |
---|
331 | |
---|
332 | //Rotation Angle |
---|
333 | strToExecute = GBLoadStr + "/S=170/U=1" + "\"" + fname + "\"" |
---|
334 | Execute strToExecute |
---|
335 | dum = w[0] |
---|
336 | InsertPoints lastPoint,1,GRot |
---|
337 | GRot[lastPoint]=dum |
---|
338 | |
---|
339 | //Sample Temperature |
---|
340 | strToExecute = GBLoadStr + "/S=186/U=1" + "\"" + fname + "\"" |
---|
341 | Execute strToExecute |
---|
342 | dum = w[0] |
---|
343 | InsertPoints lastPoint,1,GTemp |
---|
344 | GTemp[lastPoint]=dum |
---|
345 | |
---|
346 | //Sample Field |
---|
347 | strToExecute = GBLoadStr + "/S=190/U=1" + "\"" + fname + "\"" |
---|
348 | Execute strToExecute |
---|
349 | dum = w[0] |
---|
350 | InsertPoints lastPoint,1,GField |
---|
351 | GField[lastPoint]=dum |
---|
352 | |
---|
353 | //Beamstop position (not reported) |
---|
354 | //strToExecute = GBLoadStr + "/S=368/U=1" + "\"" + fname + "\"" |
---|
355 | |
---|
356 | //the run number (not displayed in the table, but carried along) |
---|
357 | InsertPoints lastPoint,1,GRunNumber |
---|
358 | GRunNumber[lastPoint] = GetRunNumFromFile(sname) |
---|
359 | |
---|
360 | // 0 if the file is a scattering file, 1 (truth) if the file is a transmission file |
---|
361 | InsertPoints lastPoint,1,GIsTrans |
---|
362 | GIsTrans[lastPoint] = CheckIfBeamstopOut(fname, -5) //returns one if beamstop is "out" |
---|
363 | |
---|
364 | KillWaves/Z w |
---|
365 | return(0) |
---|
366 | End |
---|
367 | |
---|
368 | |
---|
369 | //this main procedure does all the work for making the cat notebook, |
---|
370 | // obtaining the folder path, parsing the filenames in the list, |
---|
371 | // and (dispatching) to write out the appropriate information to the notebook window |
---|
372 | Proc BuildCatShortNotebook() |
---|
373 | |
---|
374 | DoWindow/F CatWin |
---|
375 | If(V_Flag ==0) |
---|
376 | String nb = "CatWin" |
---|
377 | NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window" |
---|
378 | Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72} |
---|
379 | Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60} |
---|
380 | Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={} |
---|
381 | Notebook $nb ruler=Normal; Notebook $nb margins={0,0,544} |
---|
382 | Endif |
---|
383 | |
---|
384 | Variable err |
---|
385 | PathInfo catPathName |
---|
386 | if(v_flag==0) |
---|
387 | err = PickPath() //sets the local path to the data (catPathName) |
---|
388 | if(err) |
---|
389 | Abort "no path to data was selected, no catalog can be made - use PickPath button" |
---|
390 | Endif |
---|
391 | Endif |
---|
392 | |
---|
393 | String temp="" |
---|
394 | //clear old window contents, reset the path |
---|
395 | Notebook CatWin,selection={startOfFile,EndOfFile} |
---|
396 | Notebook CatWin,text="\r" |
---|
397 | |
---|
398 | PathInfo catPathName |
---|
399 | temp = "FOLDER: "+S_path+"\r\r" |
---|
400 | Notebook CatWin,font="Times",fsize=12,text = temp |
---|
401 | |
---|
402 | //get a list of all files in the folder, some will be junk version numbers that don't exist |
---|
403 | String list,partialName,tempName |
---|
404 | list = IndexedFile(catPathName,-1,"????") //get all files in folder |
---|
405 | Variable numitems,ii,ok |
---|
406 | |
---|
407 | //remove version numbers from semicolon-delimited list |
---|
408 | list = RemoveVersNumsFromList(list) |
---|
409 | |
---|
410 | numitems = ItemsInList(list,";") |
---|
411 | |
---|
412 | //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS |
---|
413 | //***version numbers have been removed*** |
---|
414 | String str,fullName,notRAWlist |
---|
415 | ii=0 |
---|
416 | notRAWlist = "" |
---|
417 | do |
---|
418 | //get current item in the list |
---|
419 | partialName = StringFromList(ii, list, ";") |
---|
420 | //get a valid file based on this partialName and catPathName |
---|
421 | tempName = FindValidFilename(partialName) |
---|
422 | If(cmpstr(tempName,"")==0) //a null string was returned |
---|
423 | //write to notebook that file was not found |
---|
424 | //if string is not a number, report the error |
---|
425 | if(str2num(partialName) == NaN) |
---|
426 | str = "this file was not found: "+partialName+"\r\r" |
---|
427 | Notebook CatWin,font="Times",fsize=12,text=str |
---|
428 | Endif |
---|
429 | else |
---|
430 | //prepend path to tempName for read routine |
---|
431 | PathInfo catPathName |
---|
432 | FullName = S_path + tempName |
---|
433 | //make sure the file is really a RAW data file |
---|
434 | ok = CheckIfRawData(fullName) |
---|
435 | if (!ok) |
---|
436 | //write to notebook that file was not a RAW SANS file |
---|
437 | notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r" |
---|
438 | //Notebook CatWin,font="Times",fsize=12,text=str |
---|
439 | else |
---|
440 | //go write the header information to the Notebook |
---|
441 | WriteCatToNotebook(fullName,tempName) |
---|
442 | Endif |
---|
443 | Endif |
---|
444 | ii+=1 |
---|
445 | while(ii<numitems) |
---|
446 | Notebook CatWin,font="Times",fsize=12,text=notRAWlist |
---|
447 | End |
---|
448 | |
---|
449 | //writes out the CATalog information to the notebook named CatWin (which must exist) |
---|
450 | //fname is the full path for opening (and reading) information from the file |
---|
451 | //which alreay was found to exist. sname is the file;vers to be written out, |
---|
452 | //avoiding the need to re-extract it from fname. |
---|
453 | Function WriteCatToNotebook(fname,sname) |
---|
454 | String fname,sname |
---|
455 | |
---|
456 | String textstr,temp,lbl,date_time |
---|
457 | Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick |
---|
458 | |
---|
459 | Open/R refNum as fname |
---|
460 | //read the file creation date |
---|
461 | FSetPos refNum,55 |
---|
462 | FReadLine/N=20 refnum,date_time |
---|
463 | |
---|
464 | // read the sample.label text field |
---|
465 | FSetPos refNum,98 //will start reading at byte 99 |
---|
466 | FReadLine/N=60 refNum,lbl |
---|
467 | |
---|
468 | //read the counting time (integer) |
---|
469 | FSetPos refNum,31 |
---|
470 | FBinRead/F=3/B=3 refNum, ctime |
---|
471 | |
---|
472 | Close refNum |
---|
473 | |
---|
474 | //read the reals with GBLoadWave |
---|
475 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
476 | String strToExecute |
---|
477 | |
---|
478 | //detector count |
---|
479 | strToExecute = GBLoadStr + "/S=47/U=1" + "\"" + fname + "\"" |
---|
480 | Execute strToExecute |
---|
481 | Wave w=$"tempGBWave0" |
---|
482 | detcnt = w[0] |
---|
483 | cntrate = detcnt/ctime |
---|
484 | |
---|
485 | //wavelength |
---|
486 | strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\"" |
---|
487 | Execute strToExecute |
---|
488 | lambda = w[0] |
---|
489 | |
---|
490 | //SDD |
---|
491 | strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\"" |
---|
492 | Execute strToExecute |
---|
493 | sdd = w[0] |
---|
494 | |
---|
495 | //Transmission |
---|
496 | strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\"" |
---|
497 | Execute strToExecute |
---|
498 | trans = w[0] |
---|
499 | |
---|
500 | //Thickness |
---|
501 | strToExecute = GBLoadStr + "/S=162/U=1" + "\"" + fname + "\"" |
---|
502 | Execute strToExecute |
---|
503 | thick = w[0] |
---|
504 | |
---|
505 | KillWaves/Z w |
---|
506 | |
---|
507 | temp = "FILE: " |
---|
508 | Notebook CatWin,textRGB=(0,0,0),text=temp |
---|
509 | Notebook CatWin,fstyle=1,text=sname |
---|
510 | temp = "\t\t"+date_time+"\r" |
---|
511 | Notebook CatWin,fstyle=0,text=temp |
---|
512 | temp = "LABEL: "+lbl+"\r" |
---|
513 | Notebook CatWin,text=temp |
---|
514 | temp = "COUNTING TIME: "+num2str(ctime)+" secs \t\tDETECTOR COUNT: "+num2str(detcnt)+"\r" |
---|
515 | Notebook CatWin,text=temp |
---|
516 | temp = "WAVELENGTH: "+num2str(lambda)+" A \tSDD: "+num2str(sdd)+" m \t" |
---|
517 | temp += "DET. CNT. RATE: "+num2str(cntrate)+" cts/sec\r" |
---|
518 | Notebook CatWin,text=temp |
---|
519 | temp = "TRANS: " |
---|
520 | Notebook CatWin,text=temp |
---|
521 | temp = num2str(trans) |
---|
522 | Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp |
---|
523 | temp = "\t\tTHICKNESS: " |
---|
524 | Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp |
---|
525 | temp = num2str(thick) |
---|
526 | Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp |
---|
527 | temp = " cm\r\r" |
---|
528 | Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp |
---|
529 | End |
---|
530 | |
---|
531 | |
---|
532 | //**************** |
---|
533 | // main procedure for CAT/VS Notebook ****** |
---|
534 | //this main procedure does all the work, obtaining the folder path, |
---|
535 | //parsing the filenames in the list and (dispatching) to write out the |
---|
536 | //appropriate information to the notebook window |
---|
537 | Proc BuildCatVeryShortNotebook() |
---|
538 | |
---|
539 | DoWindow/F CatWin |
---|
540 | If(V_Flag ==0) |
---|
541 | String nb = "CatWin" |
---|
542 | NewNotebook/F=1/N=$nb/W=(5.25,40.25,581.25,380.75) as "CATALOG Window" |
---|
543 | Notebook $nb defaultTab=36, statusWidth=238, pageMargins={72,72,72,72} |
---|
544 | Notebook $nb showRuler=1, rulerUnits=1, updating={1, 60} |
---|
545 | Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={} |
---|
546 | Notebook $nb ruler=Normal; Notebook $nb margins={0,0,544} |
---|
547 | Endif |
---|
548 | |
---|
549 | Variable err |
---|
550 | PathInfo catPathName |
---|
551 | if(v_flag==0) |
---|
552 | err = PickPath() //sets the local path to the data (catPathName) |
---|
553 | if(err) |
---|
554 | Abort "no path to data was selected, no catalog can be made - use PickPath button" |
---|
555 | Endif |
---|
556 | Endif |
---|
557 | |
---|
558 | String temp="" |
---|
559 | //clear old window contents, reset the path |
---|
560 | Notebook CatWin,selection={startOfFile,EndOfFile} |
---|
561 | Notebook CatWin,text="\r" |
---|
562 | |
---|
563 | PathInfo catPathName |
---|
564 | temp = "FOLDER: "+S_path+"\r\r" |
---|
565 | Notebook CatWin,font="Times",fsize=12,text = temp |
---|
566 | Notebook CatWin,fstyle=1,text="NAME"+", " |
---|
567 | temp = "Label"+", " |
---|
568 | Notebook CatWin,fstyle=0, text=temp |
---|
569 | temp = "CntTime" |
---|
570 | Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp |
---|
571 | temp = ", TotDetCnts, " |
---|
572 | Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp |
---|
573 | temp = "Lambda" |
---|
574 | Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp |
---|
575 | temp = ", SDD, " |
---|
576 | Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp |
---|
577 | temp = "CountRate" |
---|
578 | Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp |
---|
579 | temp = ", Transmission, " |
---|
580 | Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp |
---|
581 | temp = "Thickness" |
---|
582 | Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp |
---|
583 | temp = ", Xposition" |
---|
584 | Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp |
---|
585 | temp = ", Yposition" |
---|
586 | Notebook CatWin,textRGB=(50000,0,0),fStyle = 0,text=temp |
---|
587 | temp = "\r\r" |
---|
588 | Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp |
---|
589 | |
---|
590 | |
---|
591 | //get a list of all files in the folder, some will be junk version numbers that don't exist |
---|
592 | String list,partialName,tempName |
---|
593 | list = IndexedFile(catPathName,-1,"????") //get all files in folder |
---|
594 | Variable numitems,ii,ok |
---|
595 | |
---|
596 | //remove version numbers from semicolon-delimited list |
---|
597 | list = RemoveVersNumsFromList(list) |
---|
598 | |
---|
599 | numitems = ItemsInList(list,";") |
---|
600 | |
---|
601 | //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS |
---|
602 | //***version numbers have been removed*** |
---|
603 | String str,fullName,notRAWlist |
---|
604 | ii=0 |
---|
605 | |
---|
606 | notRAWlist="" |
---|
607 | do |
---|
608 | //get current item in the list |
---|
609 | partialName = StringFromList(ii, list, ";") |
---|
610 | //get a valid file based on this partialName and catPathName |
---|
611 | tempName = FindValidFilename(partialName) |
---|
612 | If(cmpstr(tempName,"")==0) //a null string was returned |
---|
613 | //write to notebook that file was not found |
---|
614 | //if string is not a number, report the error |
---|
615 | if(str2num(partialName) == NaN) |
---|
616 | str = "this file was not found: "+partialName+"\r\r" |
---|
617 | Notebook CatWin,font="Times",fsize=12,text=str |
---|
618 | Endif |
---|
619 | else |
---|
620 | //prepend path to tempName for read routine |
---|
621 | PathInfo catPathName |
---|
622 | FullName = S_path + tempName |
---|
623 | //make sure the file is really a RAW data file |
---|
624 | ok = CheckIfRawData(fullName) |
---|
625 | if (!ok) |
---|
626 | //write to notebook that file was not a RAW SANS file |
---|
627 | notRAWlist += "This file is not recognized as a RAW SANS data file: "+tempName+"\r" |
---|
628 | //Notebook CatWin,font="Times",fsize=12,text=str |
---|
629 | else |
---|
630 | //go write the header information to the Notebook |
---|
631 | WriteCatVSToNotebook(fullName,tempName) |
---|
632 | Endif |
---|
633 | Endif |
---|
634 | ii+=1 |
---|
635 | while(ii<numitems) |
---|
636 | Notebook CatWin,font="Times",fsize=12,text=notRAWlist |
---|
637 | End |
---|
638 | |
---|
639 | //writes out the CATalog information to the notebook named CatWin (which must exist) |
---|
640 | //fname is the full path for opening (and reading) information from the file |
---|
641 | //which alreay was found to exist. sname is the file;vers to be written out, |
---|
642 | //avoiding the need to re-extract it from fname. |
---|
643 | Function WriteCatVSToNotebook(fname,sname) |
---|
644 | String fname,sname |
---|
645 | |
---|
646 | String textstr,temp,lbl,date_time |
---|
647 | Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten |
---|
648 | |
---|
649 | Open/R refNum as fname |
---|
650 | //read the file creation date |
---|
651 | FSetPos refNum,55 |
---|
652 | FReadLine/N=20 refnum,date_time |
---|
653 | |
---|
654 | // read the sample.label text field |
---|
655 | FSetPos refNum,98 //will start reading at byte 99 |
---|
656 | // Only read the first 10 letters in the run label |
---|
657 | FReadLine/N=15 refNum,lbl |
---|
658 | |
---|
659 | //read the counting time (integer) |
---|
660 | FSetPos refNum,31 |
---|
661 | FBinRead/F=3/B=3 refNum, ctime |
---|
662 | |
---|
663 | Close refNum |
---|
664 | |
---|
665 | //read the reals with GBLoadWave |
---|
666 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
667 | String strToExecute |
---|
668 | |
---|
669 | //detector count |
---|
670 | strToExecute = GBLoadStr + "/S=47/U=1" + "\"" + fname + "\"" |
---|
671 | Execute strToExecute |
---|
672 | Wave w=$"tempGBWave0" |
---|
673 | detcnt = w[0] |
---|
674 | cntrate = detcnt/ctime |
---|
675 | |
---|
676 | //Attenuators |
---|
677 | strToExecute = GBLoadStr + "/S=154/U=1" + "\"" + fname + "\"" |
---|
678 | Execute strToExecute |
---|
679 | numatten = w[0] |
---|
680 | |
---|
681 | //Transmission |
---|
682 | strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\"" |
---|
683 | Execute strToExecute |
---|
684 | trans = w[0] |
---|
685 | |
---|
686 | //Thickness |
---|
687 | strToExecute = GBLoadStr + "/S=162/U=1" + "\"" + fname + "\"" |
---|
688 | Execute strToExecute |
---|
689 | thick = w[0] |
---|
690 | |
---|
691 | //XCenter |
---|
692 | strToExecute = GBLoadStr + "/S=252/U=1" + "\"" + fname + "\"" |
---|
693 | Execute strToExecute |
---|
694 | xCenter = w[0] |
---|
695 | |
---|
696 | //YCenter |
---|
697 | strToExecute = GBLoadStr + "/S=256/U=1" + "\"" + fname + "\"" |
---|
698 | Execute strToExecute |
---|
699 | yCenter = w[0] |
---|
700 | |
---|
701 | //SDD |
---|
702 | strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\"" |
---|
703 | Execute strToExecute |
---|
704 | sdd = w[0] |
---|
705 | |
---|
706 | //wavelength |
---|
707 | strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\"" |
---|
708 | Execute strToExecute |
---|
709 | lambda = w[0] |
---|
710 | |
---|
711 | KillWaves/Z w |
---|
712 | |
---|
713 | temp = "" |
---|
714 | Notebook CatWin,textRGB=(0,0,0),text=temp |
---|
715 | Notebook CatWin,fstyle=1,text=sname+", " |
---|
716 | // temp = ", "+date_time+", " |
---|
717 | // Notebook CatWin,fstyle=0,text=temp |
---|
718 | temp = lbl+", " |
---|
719 | Notebook CatWin,fstyle=0, text=temp |
---|
720 | temp = num2str(ctime) |
---|
721 | Notebook CatWin,fstyle=1,textRGB=(0,0,50000),text=temp |
---|
722 | temp = ", " + num2str(detcnt) + ", " |
---|
723 | Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp |
---|
724 | temp = num2str(lambda) |
---|
725 | Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp |
---|
726 | temp = ", "+num2str(sdd)+", " |
---|
727 | Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp |
---|
728 | temp = num2str(cntrate) |
---|
729 | Notebook CatWin,textRGB=(0,50000,0),fStyle = 1,text=temp |
---|
730 | temp = ", "+num2str(trans)+", " |
---|
731 | Notebook CatWin,fstyle=0,textRGB=(0,0,0),text=temp |
---|
732 | temp = num2str(thick) |
---|
733 | Notebook CatWin,textRGB=(0,0,50000),fStyle = 1,text=temp |
---|
734 | temp = ", "+num2str(xCenter)+", " |
---|
735 | Notebook CatWin,textRGB=(0,0,0),fStyle = 0,text=temp |
---|
736 | temp = num2str(yCenter)+"\r" |
---|
737 | Notebook CatWin,textRGB=(50000,0,0),fStyle = 1,text=temp |
---|
738 | //temp = num2str(numatten)+", " |
---|
739 | //Notebook CatWin,text=temp |
---|
740 | End |
---|
741 | |
---|