1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=5.0 |
---|
3 | #pragma IgorVersion=4.0 |
---|
4 | |
---|
5 | //************************* |
---|
6 | // Vers. 1.2 092101 |
---|
7 | // |
---|
8 | // - procedures for (easier) caluclation of transmissions along with |
---|
9 | // simultaneous patching of the calculated transmission in designated |
---|
10 | // raw sans files. |
---|
11 | // - transmission and empty beam files are linked to the dataset by their "Annn" suffix |
---|
12 | // only (and their residence in the same data folder) |
---|
13 | // - unused (analysis) integer values are used to store these run numbers in the sample |
---|
14 | // file headers so that transmissions can be automatically calculated, once the xy box is set |
---|
15 | // in the empty beam file. |
---|
16 | // |
---|
17 | //*************************** |
---|
18 | |
---|
19 | //main entry procedure for displaying the Trans input panel |
---|
20 | //also initializes the globals as needed |
---|
21 | // |
---|
22 | Proc CalcTrans() |
---|
23 | |
---|
24 | DoWindow/F Trans_Panel |
---|
25 | If(V_flag == 0) |
---|
26 | InitializeTransPanel() |
---|
27 | //draw panel |
---|
28 | Trans_Panel() |
---|
29 | AutoPositionWindow/M=1/R=Main_Panel Trans_Panel |
---|
30 | Endif |
---|
31 | End |
---|
32 | |
---|
33 | // The BuildFileTables routine will build two tables: one containing the |
---|
34 | // data from the headers of transmission files in the folder and one |
---|
35 | // containing the header data from all other SANS data files. They will |
---|
36 | // each have the first column empty for, in the case of transmission files, |
---|
37 | // the empty beam file and, in the case of scattering files, the scattering |
---|
38 | // run file name. |
---|
39 | Proc BuildFileTables() |
---|
40 | |
---|
41 | Variable err |
---|
42 | PathInfo catPathName |
---|
43 | if(v_flag==0) |
---|
44 | err = PickPath()//sets the local path to the data (catPathName) |
---|
45 | if(err) |
---|
46 | Abort "no path to data was selected, no catalog can be made - use PickPath button" |
---|
47 | Endif |
---|
48 | Endif |
---|
49 | |
---|
50 | DoWindow/F TransFileTable |
---|
51 | |
---|
52 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
53 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
54 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
55 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
56 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Labels" |
---|
57 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_SDD" |
---|
58 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_Lambda" |
---|
59 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
60 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
61 | If(V_Flag==0) |
---|
62 | BuildTransTableWindow() |
---|
63 | ModifyTable width(:myGlobals:TransHeaderInfo:T_SDD)=40 |
---|
64 | ModifyTable width(:myGlobals:TransHeaderInfo:T_Lambda)=40 |
---|
65 | ModifyTable rgb(:myGlobals:TransHeaderInfo:T_Filenames)=(0,0,65535) |
---|
66 | ModifyTable width(:myGlobals:TransHeaderInfo:T_Transmission)=60 |
---|
67 | ModifyTable width(:myGlobals:TransHeaderInfo:T_Whole)=60 |
---|
68 | |
---|
69 | ModifyTable width(Point)=0 |
---|
70 | //ModifyTable width(:myGlobals:TransHeaderInfo:T_Transmission)=40 |
---|
71 | Endif |
---|
72 | |
---|
73 | DoWindow/F ScatterFileTable |
---|
74 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
75 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
76 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
77 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
78 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Labels" |
---|
79 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_SDD" |
---|
80 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_Lambda" |
---|
81 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
82 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_Whole" |
---|
83 | If(V_Flag==0) |
---|
84 | BuildScatTableWindow() |
---|
85 | ModifyTable width(:myGlobals:TransHeaderInfo:S_SDD)=40 |
---|
86 | ModifyTable width(:myGlobals:TransHeaderInfo:S_Lambda)=40 |
---|
87 | ModifyTable width(:myGlobals:TransHeaderInfo:S_Transmission)=60 |
---|
88 | ModifyTable rgb(:myGlobals:TransHeaderInfo:S_Filenames)=(0,0,65535) |
---|
89 | |
---|
90 | ModifyTable width(Point)=0 |
---|
91 | Endif |
---|
92 | |
---|
93 | String temp="" |
---|
94 | |
---|
95 | //get a list of all files in the folder, some will be junk version numbers that don't exist |
---|
96 | String list,partialName,tempName |
---|
97 | list = IndexedFile(catPathName,-1,"????") //get all files in folder |
---|
98 | Variable numitems,ii,ok |
---|
99 | |
---|
100 | //remove version numbers from semicolon-delimited list |
---|
101 | list = RemoveVersNumsFromList(list) |
---|
102 | |
---|
103 | numitems = ItemsInList(list,";") |
---|
104 | |
---|
105 | //loop through all of the files in the list, reading CAT/SHORT information if the file is RAW SANS |
---|
106 | //***version numbers have been removed*** |
---|
107 | String str,fullName |
---|
108 | Variable lastPoint |
---|
109 | ii=0 |
---|
110 | |
---|
111 | do |
---|
112 | //get current item in the list |
---|
113 | partialName = StringFromList(ii, list, ";") |
---|
114 | //get a valid file based on this partialName and catPathName |
---|
115 | tempName = FindValidFilename(partialName) |
---|
116 | If(cmpstr(tempName,"")==0) //a null string was returned |
---|
117 | //write to notebook that file was not found |
---|
118 | //if string is not a number, report the error |
---|
119 | if(str2num(partialName) == NaN) |
---|
120 | str = "this file was not found: "+partialName+"\r\r" |
---|
121 | //Notebook CatWin,font="Times",fsize=12,text=str |
---|
122 | Endif |
---|
123 | else |
---|
124 | //prepend path to tempName for read routine |
---|
125 | PathInfo catPathName |
---|
126 | FullName = S_path + tempName |
---|
127 | //make sure the file is really a RAW data file |
---|
128 | ok = CheckIfRawData(fullName) |
---|
129 | if (ok) |
---|
130 | GetTransHeaderInfoToWave(fullName,tempName) |
---|
131 | Endif |
---|
132 | Endif |
---|
133 | ii+=1 |
---|
134 | while(ii<numitems) |
---|
135 | //Now sort them all based on the suffix data |
---|
136 | SortTransByDate() |
---|
137 | //Now fill in the filenames of the ones that have already had EMP or TRANS |
---|
138 | //files associated with them. |
---|
139 | GetFilenamesFromSuffices() |
---|
140 | |
---|
141 | //position the windows nicely |
---|
142 | AutoPositionWindow/M=1/R=TransFileTable ScatterFileTable |
---|
143 | DoWindow/F Trans_Panel |
---|
144 | End |
---|
145 | |
---|
146 | //actually creates the table of transmission files |
---|
147 | // - the waves must exist |
---|
148 | // |
---|
149 | Function BuildTransTableWindow() |
---|
150 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
151 | Wave/T T_Filenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
152 | Wave/T T_Suffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
153 | Wave/T T_Labels = $"root:myGlobals:TransHeaderInfo:T_Labels" |
---|
154 | Wave T_SDD = $"root:myGlobals:TransHeaderInfo:T_SDD" |
---|
155 | Wave T_Lambda = $"root:myGlobals:TransHeaderInfo:T_Lambda" |
---|
156 | Wave T_Transmission = $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
157 | Wave T_Whole= $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
158 | |
---|
159 | Edit/K=1/W=(30,30,500,250) T_EMP_Filenames, T_Filenames, T_Labels, T_SDD, T_Lambda, T_Transmission, T_Whole as "TransmissionFiles" |
---|
160 | String name="TransFileTable" |
---|
161 | DoWindow/C $name |
---|
162 | |
---|
163 | End |
---|
164 | |
---|
165 | //actually creates the table of scattering files |
---|
166 | // - the waves must exist |
---|
167 | // |
---|
168 | Function BuildScatTableWindow() |
---|
169 | Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
170 | Wave/T S_Filenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
171 | Wave/T S_Suffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
172 | Wave/T S_Labels = $"root:myGlobals:TransHeaderInfo:S_Labels" |
---|
173 | Wave S_SDD = $"root:myGlobals:TransHeaderInfo:S_SDD" |
---|
174 | Wave S_Lambda = $"root:myGlobals:TransHeaderInfo:S_Lambda" |
---|
175 | Wave S_Transmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
176 | |
---|
177 | Edit/K=1/W=(50,50,520,270) S_TRANS_Filenames, S_Filenames, S_Labels, S_SDD, S_Lambda, S_Transmission as "ScatteringFiles" |
---|
178 | String name="ScatterFileTable" |
---|
179 | DoWindow/C $name |
---|
180 | |
---|
181 | End |
---|
182 | |
---|
183 | //sorts each of the tables by date - does this by using the suffix "Annn" |
---|
184 | // which is automatically supplied by the VAX (and can't be changed) |
---|
185 | // - only problem may be "Z999" -> "A001" rollover |
---|
186 | // |
---|
187 | Function SortTransByDate() |
---|
188 | Wave/T T_GEMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
189 | Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
190 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
191 | Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
192 | Wave/T T_GLabels = $"root:myGlobals:TransHeaderInfo:T_Labels" |
---|
193 | Wave T_GSDD = $"root:myGlobals:TransHeaderInfo:T_SDD" |
---|
194 | Wave T_GLambda = $"root:myGlobals:TransHeaderInfo:T_Lambda" |
---|
195 | Wave T_GTransmission = $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
196 | Wave T_Whole= $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
197 | |
---|
198 | Wave/T S_GTRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
199 | Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
200 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
201 | Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
202 | Wave/T S_GLabels = $"root:myGlobals:TransHeaderInfo:S_Labels" |
---|
203 | Wave S_GSDD = $"root:myGlobals:TransHeaderInfo:S_SDD" |
---|
204 | Wave S_GLambda = $"root:myGlobals:TransHeaderInfo:S_Lambda" |
---|
205 | Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
206 | Wave S_Whole= $"root:myGlobals:TransHeaderInfo:S_Whole" |
---|
207 | |
---|
208 | Sort T_GSuffix, T_GEMP_Filenames, T_GSuffix, T_GSuffices, T_GFilenames, T_GLabels, T_GSDD, T_GLambda, T_GTransmission, T_Whole |
---|
209 | Sort S_GSuffix, S_GTRANS_Filenames, S_GSuffix, S_GSuffices, S_GFilenames, S_GLabels, S_GSDD, S_GLambda, S_GTransmission, S_Whole |
---|
210 | |
---|
211 | End |
---|
212 | |
---|
213 | // sorts files alphabetically byt the sample label |
---|
214 | // - consistent and descriptive sample labels really pay off here |
---|
215 | // |
---|
216 | Function SortTransByLabel() |
---|
217 | Wave/T T_GEMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
218 | Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
219 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
220 | Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
221 | Wave/T T_GLabels = $"root:myGlobals:TransHeaderInfo:T_Labels" |
---|
222 | Wave T_GSDD = $"root:myGlobals:TransHeaderInfo:T_SDD" |
---|
223 | Wave T_GLambda = $"root:myGlobals:TransHeaderInfo:T_Lambda" |
---|
224 | Wave T_GTransmission = $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
225 | Wave T_Whole= $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
226 | |
---|
227 | Wave/T S_GTRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
228 | Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
229 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
230 | Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
231 | Wave/T S_GLabels = $"root:myGlobals:TransHeaderInfo:S_Labels" |
---|
232 | Wave S_GSDD = $"root:myGlobals:TransHeaderInfo:S_SDD" |
---|
233 | Wave S_GLambda = $"root:myGlobals:TransHeaderInfo:S_Lambda" |
---|
234 | Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
235 | Wave S_Whole= $"root:myGlobals:TransHeaderInfo:S_Whole" |
---|
236 | |
---|
237 | Sort T_GLabels, T_GEMP_Filenames, T_GSuffix, T_GSuffices, T_GFilenames, T_GLabels, T_GSDD, T_GLambda, T_GTransmission, T_Whole |
---|
238 | Sort S_GLabels, S_GTRANS_Filenames, S_GSuffix, S_GSuffices, S_GFilenames, S_GLabels, S_GSDD, S_GLambda, S_GTransmission, S_Whole |
---|
239 | |
---|
240 | End |
---|
241 | |
---|
242 | //reads the file and assigns header information to the proper table |
---|
243 | // |
---|
244 | //fname - is the full path:name of the datafile (used by Open) |
---|
245 | //sname - is the name only, used as the filename field |
---|
246 | // |
---|
247 | // takes care of all necessary open/close of file |
---|
248 | // |
---|
249 | Function GetTransHeaderInfoToWave(fname,sname) |
---|
250 | String fname,sname |
---|
251 | |
---|
252 | Variable isTrans, xTol= -5 |
---|
253 | |
---|
254 | String textstr,temp,labelStr,date_time,suffix,assoc |
---|
255 | Variable ctime,lambda,sdd,detcnt,cntrate,refNum,trans,thick,xcenter,ycenter,numatten |
---|
256 | Variable lastPoint, beamstop, Whole |
---|
257 | |
---|
258 | isTrans = CheckIfBeamstopOut(fname, xTol) |
---|
259 | // decalre the correct set of waves |
---|
260 | // S_Whole is only a place holder so the waves are of equal length |
---|
261 | if (isTrans) |
---|
262 | Wave/T GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
263 | Wave/T G_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
264 | Wave/T GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
265 | Wave/T GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
266 | Wave/T GLabels = $"root:myGlobals:TransHeaderInfo:T_Labels" |
---|
267 | Wave GSDD = $"root:myGlobals:TransHeaderInfo:T_SDD" |
---|
268 | Wave GLambda = $"root:myGlobals:TransHeaderInfo:T_Lambda" |
---|
269 | Wave GTransmission = $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
270 | Wave GWhole = $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
271 | Else |
---|
272 | Wave/T GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
273 | Wave/T G_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
274 | Wave/T GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
275 | Wave/T GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
276 | Wave/T GLabels = $"root:myGlobals:TransHeaderInfo:S_Labels" |
---|
277 | Wave GSDD = $"root:myGlobals:TransHeaderInfo:S_SDD" |
---|
278 | Wave GLambda = $"root:myGlobals:TransHeaderInfo:S_Lambda" |
---|
279 | Wave GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
280 | Wave GWhole = $"root:myGlobals:TransHeaderInfo:S_Whole" |
---|
281 | Endif |
---|
282 | |
---|
283 | lastPoint = numpnts(GLambda) |
---|
284 | |
---|
285 | Open/R refNum as fname |
---|
286 | |
---|
287 | InsertPoints lastPoint,1,G_TRANS_Filenames |
---|
288 | G_TRANS_Filenames[lastPoint]="" |
---|
289 | |
---|
290 | InsertPoints lastPoint,1,GFilenames |
---|
291 | GFilenames[lastPoint]=sname |
---|
292 | |
---|
293 | //read the file suffix |
---|
294 | FSetPos refNum,19 |
---|
295 | FReadLine/N=4 refNum,suffix |
---|
296 | //print suffix |
---|
297 | InsertPoints lastPoint,1,GSuffix |
---|
298 | GSuffix[lastPoint]=suffix |
---|
299 | |
---|
300 | //read any suffix that this file is associated with |
---|
301 | //FSetPos refNum,91 //wrong position |
---|
302 | FSetPos refNum,404 |
---|
303 | FReadLine/N=4 refNum,assoc |
---|
304 | //print isTrans, assoc |
---|
305 | InsertPoints lastPoint,1,GSuffices |
---|
306 | GSuffices[lastPoint]=assoc |
---|
307 | |
---|
308 | // read the sample.label text field |
---|
309 | FSetPos refNum,98 //will start reading at byte 99 |
---|
310 | FReadLine/N=60 refNum,labelStr |
---|
311 | InsertPoints lastPoint,1,GLabels |
---|
312 | GLabels[lastPoint]=labelStr |
---|
313 | |
---|
314 | Close refNum |
---|
315 | |
---|
316 | //read the reals with GBLoadWave |
---|
317 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
318 | String strToExecute |
---|
319 | |
---|
320 | //Transmission |
---|
321 | strToExecute = GBLoadStr + "/S=158/U=1" + "\"" + fname + "\"" |
---|
322 | Execute strToExecute |
---|
323 | Wave w=$"tempGBWave0" |
---|
324 | trans = w[0] |
---|
325 | InsertPoints lastPoint,1,GTransmission |
---|
326 | GTransmission[lastPoint]=trans |
---|
327 | |
---|
328 | //Whole Transmission |
---|
329 | strToExecute = GBLoadStr + "/S=392/U=1" + "\"" + fname + "\"" |
---|
330 | Execute strToExecute |
---|
331 | Wave w=$"tempGBWave0" |
---|
332 | Whole = w[0] |
---|
333 | InsertPoints lastPoint,1,GWhole |
---|
334 | GWhole[lastPoint]=Whole |
---|
335 | |
---|
336 | //SDD |
---|
337 | strToExecute = GBLoadStr + "/S=260/U=1" + "\"" + fname + "\"" |
---|
338 | Execute strToExecute |
---|
339 | sdd = w[0] |
---|
340 | InsertPoints lastPoint,1,GSDD |
---|
341 | GSDD[lastPoint]=sdd |
---|
342 | |
---|
343 | //wavelength |
---|
344 | strToExecute = GBLoadStr + "/S=292/U=1" + "\"" + fname + "\"" |
---|
345 | Execute strToExecute |
---|
346 | lambda = w[0] |
---|
347 | InsertPoints lastPoint,1,GLambda |
---|
348 | GLambda[lastPoint]=lambda |
---|
349 | |
---|
350 | // InsertPoints lastPoint,1,GWhole |
---|
351 | // GWhole[lastPoint]=1 |
---|
352 | |
---|
353 | KillWaves/Z w |
---|
354 | |
---|
355 | End |
---|
356 | |
---|
357 | //fills in the file relations that have already been set |
---|
358 | // |
---|
359 | // |
---|
360 | Function GetFilenamesFromSuffices() |
---|
361 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
362 | Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
363 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
364 | Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
365 | |
---|
366 | Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
367 | Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
368 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
369 | Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
370 | |
---|
371 | Variable num_s_files, num_t_files, ii, jj |
---|
372 | num_t_files = numpnts(T_GFilenames) |
---|
373 | num_s_files = numpnts(S_GFilenames) |
---|
374 | //print num_t_files, num_s_files |
---|
375 | |
---|
376 | // Get transmission file relations |
---|
377 | ii= 0 |
---|
378 | do |
---|
379 | if (cmpstr(T_GSuffices[ii],"")!=0) |
---|
380 | jj=0 |
---|
381 | do |
---|
382 | if (cmpstr(T_GSuffices[ii],T_GSuffix[jj])==0) |
---|
383 | T_EMP_Filenames[ii]=T_GFilenames[jj] |
---|
384 | endif |
---|
385 | jj+=1 |
---|
386 | while(jj<num_t_files) |
---|
387 | endif |
---|
388 | ii+=1 |
---|
389 | while(ii<num_t_files) |
---|
390 | |
---|
391 | // Get scattering file relations |
---|
392 | ii= 0 |
---|
393 | do |
---|
394 | if (cmpstr(S_GSuffices[ii],"")!=0) |
---|
395 | jj=0 |
---|
396 | do |
---|
397 | if (cmpstr(S_GSuffices[ii],T_GSuffix[jj])==0) |
---|
398 | S_TRANS_Filenames[ii]=T_GFilenames[jj] |
---|
399 | endif |
---|
400 | jj+=1 |
---|
401 | while(jj<num_t_files) |
---|
402 | endif |
---|
403 | ii+=1 |
---|
404 | while(ii<num_s_files) |
---|
405 | End |
---|
406 | |
---|
407 | // gets the selected transmission filename, and puts its name as the |
---|
408 | //empty beam reference file |
---|
409 | // lists the xy box coordinates as read from the file header (zeros if not yet assigned) |
---|
410 | // |
---|
411 | Function PickEMPTransButton(ctrlName) : ButtonControl |
---|
412 | String ctrlName |
---|
413 | |
---|
414 | Variable TransFileTableExists |
---|
415 | TransFileTableExists = WinType("TransFileTable") |
---|
416 | //??BUG?? V_flag returns 1 even if no selection? |
---|
417 | //check manually for null selection |
---|
418 | //Print "local v_flag = ",num2str(V_flag) |
---|
419 | Wave/T LocFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
420 | if (TransFileTableExists != 0) |
---|
421 | String/G root:myGlobals:TransHeaderInfo:gEMP = "" |
---|
422 | GetSelection table,TransFileTable,7 |
---|
423 | //Print S_Selection |
---|
424 | if(strsearch(S_selection,"T_Filenames",0) == 0) |
---|
425 | //selection OK, add to list |
---|
426 | Duplicate/O/R=[V_startRow,V_endRow] LocFilenames, filenames |
---|
427 | Wave/T selectedFiles = $"filenames" |
---|
428 | |
---|
429 | SVAR temp = root:myGlobals:TransHeaderInfo:gEMP |
---|
430 | // |
---|
431 | temp = temp+selectedFiles[0] //take just the first file |
---|
432 | UpdateBoxCoordinates() |
---|
433 | Else |
---|
434 | DoWindow/F TransFileTable |
---|
435 | DoAlert 0,"Invalid selection from the Transmision file table. You must select a file from the T_Filenames column" |
---|
436 | Endif |
---|
437 | else |
---|
438 | //no selection |
---|
439 | DoAlert 0,"No file selected from Transmission file table or no Transmission file table available" |
---|
440 | Endif |
---|
441 | End |
---|
442 | |
---|
443 | //initialize data folder and globals for the Trans panel as needed |
---|
444 | //since this operation is somewhat tangled with the Patch Panel, keep all of the |
---|
445 | //globals in the Patch subfolder (make sure both panels are simultaneously initialized) |
---|
446 | //do not create a separate Trans folder |
---|
447 | // |
---|
448 | Proc InitializeTransPanel() |
---|
449 | //create the global variables needed to run the Trans Panel |
---|
450 | //all are kept in root:myGlobals:TransHeaderInfo |
---|
451 | If( ! (DataFolderExists("root:myGlobals:TransHeaderInfo")) ) |
---|
452 | //create the data folder and the clobals for BOTH the Patch and Trans Panels |
---|
453 | NewDataFolder/O root:myGlobals:TransHeaderInfo |
---|
454 | CreateTransGlobals() |
---|
455 | Endif |
---|
456 | End |
---|
457 | |
---|
458 | |
---|
459 | // |
---|
460 | Proc CreateTransGlobals() |
---|
461 | |
---|
462 | PathInfo catPathName |
---|
463 | If(V_flag==1) |
---|
464 | String dum = S_path |
---|
465 | String/G root:myGlobals:TransHeaderInfo:gCatPathStr = dum |
---|
466 | else |
---|
467 | String/G root:myGlobals:TransHeaderInfo:gCatPathStr = "no path selected" |
---|
468 | endif |
---|
469 | |
---|
470 | String/G root:myGlobals:TransHeaderInfo:gEMP = "no file selected" |
---|
471 | String/G root:myGlobals:TransHeaderInfo:gBox = "" |
---|
472 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
473 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
474 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
475 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
476 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:T_Labels" |
---|
477 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_SDD" |
---|
478 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_Lambda" |
---|
479 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
480 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
481 | |
---|
482 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
483 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
484 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
485 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
486 | Make/O/T/N=0 $"root:myGlobals:TransHeaderInfo:S_Labels" |
---|
487 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_SDD" |
---|
488 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_Lambda" |
---|
489 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
490 | Make/O/D/N=0 $"root:myGlobals:TransHeaderInfo:S_Whole" |
---|
491 | End |
---|
492 | |
---|
493 | |
---|
494 | //function that writes out (to the header of a raw binary SANS file) |
---|
495 | //characters representing the empty beam file and the sample transmission file |
---|
496 | //the 4-character file suffix is written, rather than the run numbers |
---|
497 | //from this, the trans files can be located, and the |
---|
498 | //sample file contains all the information needed to calculate its transmission |
---|
499 | // |
---|
500 | //uses first 4 bytes of params.reserve (character field) starting at byte 404 |
---|
501 | //(previous version (AM) used run.reserve field @ byte 91, which was not empty, and not at the start of the field!) |
---|
502 | // |
---|
503 | Function AssignSelTransFilesToData(startRow,endRow) |
---|
504 | Variable startRow,endRow |
---|
505 | |
---|
506 | // GetSelection table,ScatterFileTable,1 |
---|
507 | |
---|
508 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
509 | Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
510 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
511 | Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
512 | |
---|
513 | Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
514 | Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
515 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
516 | Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
517 | |
---|
518 | Variable num_s_files, num_t_files, ii, jj |
---|
519 | Variable refnum |
---|
520 | num_t_files = numpnts(T_GFilenames) |
---|
521 | String suffix = "" |
---|
522 | PathInfo catPathName |
---|
523 | String pathname = S_path |
---|
524 | String filename |
---|
525 | |
---|
526 | // Write suffix of empty beam file into transmission files |
---|
527 | ii= 0 |
---|
528 | do |
---|
529 | if (cmpstr(T_EMP_Filenames[ii],"")!=0) |
---|
530 | jj=0 |
---|
531 | do |
---|
532 | if (cmpstr(T_EMP_Filenames[ii],T_GFilenames[jj])==0) |
---|
533 | suffix=T_GSuffix[jj] |
---|
534 | filename = pathname + T_GFilenames[ii] |
---|
535 | Open/A/T="????TEXT" refnum as filename |
---|
536 | //FSetPos refnum,91 //wrong position |
---|
537 | FSetPos refnum,404 |
---|
538 | FBinWrite refnum, suffix |
---|
539 | FStatus refnum |
---|
540 | FSetPos refnum,V_logEOF |
---|
541 | Close refnum |
---|
542 | endif |
---|
543 | jj+=1 |
---|
544 | while(jj<num_t_files) |
---|
545 | endif |
---|
546 | ii+=1 |
---|
547 | while(ii<num_t_files) |
---|
548 | |
---|
549 | // Write suffix of transmission files into scattering files |
---|
550 | ii= startRow |
---|
551 | do |
---|
552 | if (cmpstr(S_TRANS_Filenames[ii],"")!=0) |
---|
553 | jj=0 |
---|
554 | do |
---|
555 | if (cmpstr(S_TRANS_Filenames[ii],T_GFilenames[jj])==0) |
---|
556 | suffix=T_GSuffix[jj] |
---|
557 | filename = pathname + S_GFilenames[ii] |
---|
558 | Open/A/T="????TEXT" refnum as filename |
---|
559 | //FSetPos refnum,91 //wrong position |
---|
560 | FSetPos refnum,404 |
---|
561 | FBinWrite refnum, suffix |
---|
562 | FStatus refnum |
---|
563 | FSetPos refnum,V_logEOF |
---|
564 | Close refnum |
---|
565 | endif |
---|
566 | jj+=1 |
---|
567 | while(jj<num_t_files) |
---|
568 | endif |
---|
569 | ii+=1 |
---|
570 | while(ii<=endRow) |
---|
571 | return(0) |
---|
572 | End |
---|
573 | |
---|
574 | // Allows to calculate transmissions without need of a scattering file. Used with the Calculate Total Trans button. |
---|
575 | |
---|
576 | Function AssignTotalTransFilesToData(startRow,endRow) |
---|
577 | Variable startRow,endRow |
---|
578 | |
---|
579 | // GetSelection table,ScatterFileTable,1 |
---|
580 | |
---|
581 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
582 | Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
583 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
584 | Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
585 | |
---|
586 | Variable num_t_files, ii, jj |
---|
587 | Variable refnum |
---|
588 | num_t_files = numpnts(T_GFilenames) |
---|
589 | String suffix = "" |
---|
590 | PathInfo catPathName |
---|
591 | String pathname = S_path |
---|
592 | String filename |
---|
593 | |
---|
594 | // Write suffix of empty beam file into transmission files |
---|
595 | ii= 0 |
---|
596 | do |
---|
597 | if (cmpstr(T_EMP_Filenames[ii],"")!=0) |
---|
598 | jj=0 |
---|
599 | do |
---|
600 | if (cmpstr(T_EMP_Filenames[ii],T_GFilenames[jj])==0) |
---|
601 | suffix=T_GSuffix[jj] |
---|
602 | filename = pathname + T_GFilenames[ii] |
---|
603 | Open/A/T="????TEXT" refnum as filename |
---|
604 | //FSetPos refnum,91 //wrong position |
---|
605 | FSetPos refnum,404 |
---|
606 | FBinWrite refnum, suffix |
---|
607 | FStatus refnum |
---|
608 | FSetPos refnum,V_logEOF |
---|
609 | Close refnum |
---|
610 | endif |
---|
611 | jj+=1 |
---|
612 | while(jj<num_t_files) |
---|
613 | endif |
---|
614 | ii+=1 |
---|
615 | while(ii<num_t_files) |
---|
616 | |
---|
617 | return(0) |
---|
618 | End |
---|
619 | |
---|
620 | |
---|
621 | //function that clears the selected assignments of sample trans -> sample scattering |
---|
622 | //also writes a trans=1 value back to the sample file |
---|
623 | // |
---|
624 | Function fClearSelectedAssignments(startRow,endRow) |
---|
625 | Variable startRow,endRow |
---|
626 | |
---|
627 | // GetSelection table,ScatterFileTable,1 |
---|
628 | |
---|
629 | Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
630 | Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
631 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
632 | Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
633 | Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
634 | |
---|
635 | Variable num_s_files, num_t_files, ii, jj |
---|
636 | Variable refnum |
---|
637 | num_t_files = numpnts(T_GFilenames) |
---|
638 | String suffix = " " //4 blank spaces |
---|
639 | PathInfo catPathName |
---|
640 | String pathname = S_path |
---|
641 | String filename |
---|
642 | |
---|
643 | // don't do anything with the trans file -> empty beam file correspondence |
---|
644 | |
---|
645 | // // Write suffix of empty beam file into transmission files |
---|
646 | // ii= 0 |
---|
647 | // do |
---|
648 | // if (cmpstr(T_EMP_Filenames[ii],"")!=0) |
---|
649 | // jj=0 |
---|
650 | // do |
---|
651 | // if (cmpstr(T_EMP_Filenames[ii],T_GFilenames[jj])==0) |
---|
652 | // suffix=T_GSuffix[jj] |
---|
653 | // filename = pathname + T_GFilenames[ii] |
---|
654 | // Open/A/T="????TEXT" refnum as filename |
---|
655 | // //FSetPos refnum,91 //wrong position |
---|
656 | // FSetPos refnum,404 |
---|
657 | // FBinWrite refnum, suffix |
---|
658 | // FStatus refnum |
---|
659 | // FSetPos refnum,V_logEOF |
---|
660 | // Close refnum |
---|
661 | // endif |
---|
662 | // jj+=1 |
---|
663 | // while(jj<num_t_files) |
---|
664 | // endif |
---|
665 | // ii+=1 |
---|
666 | // while(ii<num_t_files) |
---|
667 | |
---|
668 | // Write null suffix of transmission files into scattering files |
---|
669 | ii= startRow |
---|
670 | do |
---|
671 | filename = pathname + S_GFilenames[ii] |
---|
672 | Open/A/T="????TEXT" refnum as filename |
---|
673 | //FSetPos refnum,91 //wrong position |
---|
674 | FSetPos refnum,404 |
---|
675 | FBinWrite refnum, suffix |
---|
676 | FStatus refnum |
---|
677 | FSetPos refnum,V_logEOF |
---|
678 | Close refnum |
---|
679 | |
---|
680 | //write a trans==1 to the file header of the raw data (open/close done in function) |
---|
681 | ReWriteReal(filename,1,158) //transmission start byte is 158 |
---|
682 | |
---|
683 | //then update the table that is displayed |
---|
684 | S_TRANS_Filenames[ii] = "" |
---|
685 | S_GTransmission[ii] = 1 |
---|
686 | |
---|
687 | ii+=1 |
---|
688 | while(ii<=endRow) |
---|
689 | return(0) |
---|
690 | End |
---|
691 | |
---|
692 | |
---|
693 | // assigns both the empty file to the trans file |
---|
694 | // and the trans file to the scattering file |
---|
695 | // - writes out 4 characters to the file headers @ byte 404 |
---|
696 | // |
---|
697 | // assignments are only permanently made when the transmissions |
---|
698 | // are actually calculated |
---|
699 | // |
---|
700 | // NOT USED - AssignSelTransFilestoData(first,last) has been generalized to take a range |
---|
701 | // 3/31/04 SRK |
---|
702 | //Function AssignTransFilesToData() |
---|
703 | // |
---|
704 | // Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
705 | // Wave/T T_GSuffices = $"root:myGlobals:TransHeaderInfo:T_Suffices" |
---|
706 | // Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
707 | // Wave/T T_GSuffix = $"root:myGlobals:TransHeaderInfo:T_Suffix" |
---|
708 | // |
---|
709 | // Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
710 | // Wave/T S_GSuffices = $"root:myGlobals:TransHeaderInfo:S_Suffices" |
---|
711 | // Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
712 | // Wave/T S_GSuffix = $"root:myGlobals:TransHeaderInfo:S_Suffix" |
---|
713 | // |
---|
714 | // Variable num_s_files, num_t_files, ii, jj |
---|
715 | // Variable refnum |
---|
716 | // num_t_files = numpnts(T_GFilenames) |
---|
717 | // num_s_files = numpnts(S_GFilenames) |
---|
718 | // String suffix = "" |
---|
719 | // PathInfo catPathName |
---|
720 | // String pathname = S_path |
---|
721 | // String filename |
---|
722 | // |
---|
723 | // // Write suffix of empty beam file into transmission files |
---|
724 | // ii= 0 |
---|
725 | // do |
---|
726 | // if (cmpstr(T_EMP_Filenames[ii],"")!=0) |
---|
727 | // jj=0 |
---|
728 | // do |
---|
729 | // if (cmpstr(T_EMP_Filenames[ii],T_GFilenames[jj])==0) |
---|
730 | // suffix=T_GSuffix[jj] |
---|
731 | // filename = pathname + T_GFilenames[ii] |
---|
732 | // Open/A/T="????TEXT" refnum as filename |
---|
733 | // //FSetPos refnum,91 //wrong position |
---|
734 | // FSetPos refnum,404 |
---|
735 | // FBinWrite refnum, suffix |
---|
736 | // FStatus refnum |
---|
737 | // FSetPos refnum,V_logEOF |
---|
738 | // Close refnum |
---|
739 | // endif |
---|
740 | // jj+=1 |
---|
741 | // while(jj<num_t_files) |
---|
742 | // endif |
---|
743 | // ii+=1 |
---|
744 | // while(ii<num_t_files) |
---|
745 | // |
---|
746 | // // Write suffix of transmission files into scattering files |
---|
747 | // ii= 0 |
---|
748 | // do |
---|
749 | // if (cmpstr(S_TRANS_Filenames[ii],"")!=0) |
---|
750 | // jj=0 |
---|
751 | // do |
---|
752 | // if (cmpstr(S_TRANS_Filenames[ii],T_GFilenames[jj])==0) |
---|
753 | // suffix=T_GSuffix[jj] |
---|
754 | // filename = pathname + S_GFilenames[ii] |
---|
755 | // Open/A/T="????TEXT" refnum as filename |
---|
756 | // //FSetPos refnum,91 //wrong position |
---|
757 | // FSetPos refnum,404 |
---|
758 | // FBinWrite refnum, suffix |
---|
759 | // FStatus refnum |
---|
760 | // FSetPos refnum,V_logEOF |
---|
761 | // Close refnum |
---|
762 | // endif |
---|
763 | // jj+=1 |
---|
764 | // while(jj<num_t_files) |
---|
765 | // endif |
---|
766 | // ii+=1 |
---|
767 | // while(ii<num_s_files) |
---|
768 | // |
---|
769 | // return(0) |
---|
770 | //End |
---|
771 | |
---|
772 | |
---|
773 | |
---|
774 | // NOT USED --- CalcSelTransFromHeader(first,last) has been generalized to accept a selection |
---|
775 | // and modified to account for different attenuation factors. 3/31/04 SRK |
---|
776 | // |
---|
777 | //Function CalcTransFromHeader() |
---|
778 | // String filename |
---|
779 | // Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
780 | // Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
781 | // |
---|
782 | // Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
783 | // Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
784 | // Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
785 | // |
---|
786 | // Variable num_s_files, num_t_files, ii, jj |
---|
787 | // Variable refnum, transCts, emptyCts |
---|
788 | // num_t_files = numpnts(T_GFilenames) |
---|
789 | // num_s_files = numpnts(S_GFilenames) |
---|
790 | // String suffix = "" |
---|
791 | // PathInfo catPathName |
---|
792 | // String pathname = S_path |
---|
793 | // String textStr="",abortStr="" |
---|
794 | // String emptyFile, transFile |
---|
795 | // |
---|
796 | // ii= 0 |
---|
797 | // do |
---|
798 | // if (cmpstr(S_TRANS_Filenames[ii],"")!=0) |
---|
799 | // jj=0 |
---|
800 | // do |
---|
801 | // if (cmpstr(S_TRANS_Filenames[ii],T_GFilenames[jj])==0) |
---|
802 | // //Look for an empty beam for the transmission then |
---|
803 | // if (cmpstr(T_EMP_Filenames[jj],"")!=0)//Do the transmission calculation |
---|
804 | // textStr = "" |
---|
805 | // filename=pathname+S_GFilenames[ii] |
---|
806 | // emptyFile = pathname+T_EMP_Filenames[jj] |
---|
807 | // transFile = pathname+T_GFilenames[jj] |
---|
808 | // ////////// |
---|
809 | // // check the empty beam file for previously selected coordinates |
---|
810 | // //if they exist, set the xy string , save the normalized counts somewhere |
---|
811 | // //the value was written to an unused r*4 header analysis.factor (@b494) |
---|
812 | // Variable x1,x2,y1,y2,err |
---|
813 | // Open/R refnum as emptyFile |
---|
814 | // FSetPos refnum,478 |
---|
815 | // FBinRead/F=3/B=3 refnum, x1 |
---|
816 | // FBinRead/F=3/B=3 refnum, x2 |
---|
817 | // FBinRead/F=3/B=3 refnum, y1 |
---|
818 | // FBinRead/F=3/B=3 refnum, y2 |
---|
819 | // Close refnum |
---|
820 | // //read the real count value |
---|
821 | // String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
822 | // String strToExecute |
---|
823 | // strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" |
---|
824 | // Execute strToExecute |
---|
825 | // Wave w=$"tempGBWave0" |
---|
826 | // Variable/G root:myGlobals:Patch:gTransCts = w[0] |
---|
827 | // emptyCts = w[0] |
---|
828 | // |
---|
829 | // // |
---|
830 | // if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction |
---|
831 | // //no region selected |
---|
832 | // //prompt user to select box w/marquee |
---|
833 | // DoWindow/F TransFileTable |
---|
834 | // Abort "Use \"Set BCENT File\", then \"SetXYBox\" to select XY range in empty beam file "+T_EMP_Filenames[jj] |
---|
835 | // //from here the Marquee menu selection must handle the task of setting the box |
---|
836 | // //and updating the information in the file header |
---|
837 | // Endif |
---|
838 | // |
---|
839 | // //read in trans file to add to SAM |
---|
840 | // ReadHeaderAndData(transFile) |
---|
841 | // //adds to SAM |
---|
842 | // err = Raw_to_work("SAM") |
---|
843 | // //sum region in SAM |
---|
844 | // transCts = SumCountsInBox(x1,x2,y1,y2,"SAM") |
---|
845 | // |
---|
846 | // //calculate trans based on empty beam value |
---|
847 | // Variable trans= transCts/emptyCts |
---|
848 | // |
---|
849 | // //write out counts and transmission |
---|
850 | // textstr += " Trans counts = "+num2str(transCts) + " Trans = "+num2str(trans) |
---|
851 | // Print S_GFilenames[ii], textstr |
---|
852 | // //Print ii,jj |
---|
853 | // //Print "Empty counts = ",emptycts, "Trans counts = "+num2str(transCts) + " Trans = "+num2str(trans) |
---|
854 | // |
---|
855 | // //write the trans to the file header of the raw data (open/close done in function) |
---|
856 | // Variable start = 158 //transmission start byte |
---|
857 | // ReWriteReal(filename,trans,start) |
---|
858 | // |
---|
859 | // //then update the global that is displayed |
---|
860 | // S_GTransmission[ii] = trans |
---|
861 | // |
---|
862 | // else // There is no empty assigned |
---|
863 | // abortStr = "Empty beam file not assigned properly for " + T_GFilenames[jj] |
---|
864 | // Print abortStr |
---|
865 | // //Abort abortStr |
---|
866 | // return(1) |
---|
867 | // endif |
---|
868 | // endif |
---|
869 | // jj+=1 |
---|
870 | // while(jj<num_t_files) |
---|
871 | // else //no transmission file |
---|
872 | // abortStr = "Transmission beam file not assigned properly for " + S_GFilenames[ii] |
---|
873 | // Print abortStr |
---|
874 | // endif |
---|
875 | // ii+=1 |
---|
876 | // while(ii<num_s_files) |
---|
877 | // print "done" |
---|
878 | // return(0) |
---|
879 | //End |
---|
880 | |
---|
881 | |
---|
882 | |
---|
883 | //given a selection of scattering files, calculates the transmission |
---|
884 | //and writes the new transmission to the file header |
---|
885 | // |
---|
886 | //given the full path;name;vers (= filenmame), of a raw binary SANS file, |
---|
887 | //the transmission of the sample is calculated (if possible) from information |
---|
888 | //in the file header. empty beam and sample transmision run numbers are extracted |
---|
889 | //and the files are located from the run number (if possible) |
---|
890 | //from the header of the empty beam file, the XY box coordinates and "empty" |
---|
891 | //counts are determined |
---|
892 | //once all information is located, the transmission is calculated and the |
---|
893 | //transmission field of the sample file is automatically "Patched" |
---|
894 | // - updates the global variable that is displayed in the panel |
---|
895 | //can be run in batch mode, sequentially passing each item from a list of filenames |
---|
896 | //this is the single step of the batch mode |
---|
897 | // |
---|
898 | //in batch mode: execution will proceed through all of the files, reporting |
---|
899 | //results to the history window. If no trans could be successfully calculated |
---|
900 | //(for a blocked beam, for example), then that is displayed as well, and the |
---|
901 | //raw data is not modified |
---|
902 | // |
---|
903 | // now takes the attenuation of the sample trans and empty beam trans into account, (normally this == 1) |
---|
904 | // and rescales the transmission as appropriate |
---|
905 | // 3/31/04 SRK |
---|
906 | // |
---|
907 | Function CalcSelTransFromHeader(startRow,endRow) |
---|
908 | Variable startRow,endRow |
---|
909 | // GetSelection table,ScatterFileTable,1 |
---|
910 | |
---|
911 | String filename |
---|
912 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
913 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
914 | |
---|
915 | Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
916 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
917 | Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
918 | |
---|
919 | Variable num_s_files, num_t_files, ii, jj |
---|
920 | Variable refnum, transCts, emptyCts,attenRatio,lambda,trans |
---|
921 | Variable x1,x2,y1,y2,err,attenEmp,attenSam |
---|
922 | String suffix = "",pathName,textStr,abortStr,emptyFile,transFile,samFileStr |
---|
923 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
924 | String strToExecute |
---|
925 | |
---|
926 | num_t_files = numpnts(T_GFilenames) |
---|
927 | |
---|
928 | PathInfo catPathName |
---|
929 | pathname = S_path |
---|
930 | |
---|
931 | ii= startRow |
---|
932 | do |
---|
933 | if (cmpstr(S_TRANS_Filenames[ii],"")!=0) //if there is a sample trans file assigned |
---|
934 | jj=0 |
---|
935 | do |
---|
936 | if (cmpstr(S_TRANS_Filenames[ii],T_GFilenames[jj])==0) //find it in the trans file table |
---|
937 | if (cmpstr(T_EMP_Filenames[jj],"")!=0) //if empty beam file assigned, proceed with the calculation |
---|
938 | //full path+name to access all 3 files |
---|
939 | filename=pathname+S_GFilenames[ii] |
---|
940 | emptyFile = pathname+T_EMP_Filenames[jj] |
---|
941 | transFile = pathname+T_GFilenames[jj] |
---|
942 | ////////// |
---|
943 | // check the empty beam file for previously selected coordinates |
---|
944 | //if they exist, set the xy string , save the normalized counts somewhere |
---|
945 | //the value was written to an unused r*4 header analysis.factor (@b494) |
---|
946 | Open/R refnum as emptyFile |
---|
947 | FSetPos refnum,478 |
---|
948 | FBinRead/F=3/B=3 refnum, x1 |
---|
949 | FBinRead/F=3/B=3 refnum, x2 |
---|
950 | FBinRead/F=3/B=3 refnum, y1 |
---|
951 | FBinRead/F=3/B=3 refnum, y2 |
---|
952 | Close refnum |
---|
953 | //read the real count value |
---|
954 | strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" |
---|
955 | Execute strToExecute |
---|
956 | Wave w=$"tempGBWave0" |
---|
957 | // Variable/G root:myGlobals:Patch:gTransCts = w[0] |
---|
958 | emptyCts = w[0] |
---|
959 | // read the attenuator number of the empty beam file |
---|
960 | strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + emptyFile + "\"" |
---|
961 | Execute strToExecute |
---|
962 | attenEmp = w[3] |
---|
963 | // |
---|
964 | if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction |
---|
965 | //no region selected -- prompt user to select box w/marquee |
---|
966 | DoWindow/F TransFileTable |
---|
967 | Abort "Use \"Set BCENT File\", then \"SetXYBox\" to select XY range in empty beam file "+T_EMP_Filenames[jj] |
---|
968 | //from here the Marquee menu selection must handle the task of setting the box and updating the information in the file header |
---|
969 | Endif |
---|
970 | |
---|
971 | //read in trans file then add to SAM |
---|
972 | ReadHeaderAndData(transFile) |
---|
973 | //adds to SAM |
---|
974 | err = Raw_to_work("SAM") |
---|
975 | //sum region in SAM |
---|
976 | transCts = SumCountsInBox(x1,x2,y1,y2,"SAM") |
---|
977 | // get the attenuator, lambda, and sample string (to get the instrument) |
---|
978 | WAVE/T samText = $"root:SAM:textRead" |
---|
979 | WAVE samReals = $"root:SAM:realsRead" |
---|
980 | samfileStr = samText[3] |
---|
981 | lambda = samReals[26] |
---|
982 | attenSam = samReals[3] |
---|
983 | //calculate the ratio of attenuation factors - assumes that same instrument used for each, AND same lambda |
---|
984 | AttenRatio = AttenuationFactor(samFileStr,lambda,attenEmp)/AttenuationFactor(samFileStr,lambda,attenSam) |
---|
985 | //calculate trans based on empty beam value and rescale by attenuation ratio |
---|
986 | trans= transCts/emptyCts * AttenRatio |
---|
987 | |
---|
988 | //write out counts and transmission to history window, showing the attenuator ratio, if it is not unity |
---|
989 | If(attenRatio==1) |
---|
990 | Printf "%s\t\tTrans Counts = %g\tTrans = %g\r",S_GFilenames[ii], transCts,trans |
---|
991 | else |
---|
992 | Printf "%s\t\tTrans Counts = %g\tTrans = %g\tAttenuatorRatio = %g\r",S_GFilenames[ii], transCts,trans,attenRatio |
---|
993 | endif |
---|
994 | //write the trans to the file header of the raw data (open/close done in function) |
---|
995 | ReWriteReal(filename,trans,158) //transmission start byte is 158 |
---|
996 | |
---|
997 | //then update the global that is displayed |
---|
998 | S_GTransmission[ii] = trans |
---|
999 | |
---|
1000 | else // There is no empty assigned |
---|
1001 | abortStr = "Empty beam file not assigned properly for " + T_GFilenames[jj] |
---|
1002 | Print abortStr |
---|
1003 | //Abort abortStr |
---|
1004 | return(1) |
---|
1005 | endif |
---|
1006 | endif |
---|
1007 | jj+=1 |
---|
1008 | while(jj<num_t_files) |
---|
1009 | else //no transmission file |
---|
1010 | abortStr = "Transmission beam file not assigned properly for " + S_GFilenames[ii] |
---|
1011 | Print abortStr |
---|
1012 | endif |
---|
1013 | ii+=1 |
---|
1014 | while(ii<=endRow) |
---|
1015 | print "done" |
---|
1016 | return(0) |
---|
1017 | End |
---|
1018 | |
---|
1019 | // |
---|
1020 | // For the calculation of the Transmission using only the Trans Files screen |
---|
1021 | // Uses only the information on the transmissionFiles screen to calculate |
---|
1022 | // a "box" Transmission for comparison with the Whole Transmission |
---|
1023 | // updated 5/11/2006 by Bryan Greenwald |
---|
1024 | Function CalcTotalTrans(startRow,endRow) |
---|
1025 | Variable startRow,endRow |
---|
1026 | // GetSelection table,ScatterFileTable,1 |
---|
1027 | |
---|
1028 | String filename |
---|
1029 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
1030 | |
---|
1031 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
1032 | Wave T_GTransmission = $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
1033 | |
---|
1034 | // Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
1035 | // Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
1036 | // Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
1037 | Wave GWhole= $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
1038 | |
---|
1039 | Variable num_t_files, ii, jj |
---|
1040 | Variable refnum, transCts, emptyCts,attenRatio,lambda,trans |
---|
1041 | Variable x1,x2,y1,y2,err,attenEmp,attenSam |
---|
1042 | String suffix = "",pathName,textStr,abortStr,emptyFile,transFile,samFileStr |
---|
1043 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
1044 | String strToExecute |
---|
1045 | |
---|
1046 | num_t_files = numpnts(T_GFilenames) |
---|
1047 | |
---|
1048 | PathInfo catPathName |
---|
1049 | pathname = S_path |
---|
1050 | |
---|
1051 | ii= startRow |
---|
1052 | do |
---|
1053 | if (cmpstr(T_Emp_Filenames[ii],"")!=0) //if there is a sample trans file assigned |
---|
1054 | jj=0 |
---|
1055 | do |
---|
1056 | if (cmpstr(T_Emp_Filenames[ii],T_GFilenames[jj])==0) //find it in the trans file table |
---|
1057 | if (cmpstr(T_EMP_Filenames[ii],"")!=0) //if empty beam file assigned, proceed with the calculation |
---|
1058 | //full path+name to access all 3 files |
---|
1059 | filename=pathname+T_GFilenames[ii] |
---|
1060 | emptyFile = pathname+T_EMP_Filenames[ii] |
---|
1061 | transFile = pathname+T_GFilenames[ii] |
---|
1062 | ////////// |
---|
1063 | // check the empty beam file for previously selected coordinates |
---|
1064 | //if they exist, set the xy string , save the normalized counts somewhere |
---|
1065 | //the value was written to an unused r*4 header analysis.factor (@b494) |
---|
1066 | Open/R refnum as emptyFile |
---|
1067 | FSetPos refnum,478 |
---|
1068 | FBinRead/F=3/B=3 refnum, x1 |
---|
1069 | FBinRead/F=3/B=3 refnum, x2 |
---|
1070 | FBinRead/F=3/B=3 refnum, y1 |
---|
1071 | FBinRead/F=3/B=3 refnum, y2 |
---|
1072 | Close refnum |
---|
1073 | //read the real count value |
---|
1074 | strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" |
---|
1075 | Execute strToExecute |
---|
1076 | Wave w=$"tempGBWave0" |
---|
1077 | // Variable/G root:myGlobals:Patch:gTransCts = w[0] |
---|
1078 | emptyCts = w[0] |
---|
1079 | // read the attenuator number of the empty beam file |
---|
1080 | strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + emptyFile + "\"" |
---|
1081 | Execute strToExecute |
---|
1082 | attenEmp = w[3] |
---|
1083 | // |
---|
1084 | if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction |
---|
1085 | //no region selected -- prompt user to select box w/marquee |
---|
1086 | DoWindow/F TransFileTable |
---|
1087 | Abort "Use \"Set BCENT File\", then \"SetXYBox\" to select XY range in empty beam file "+T_EMP_Filenames[jj] |
---|
1088 | //from here the Marquee menu selection must handle the task of setting the box and updating the information in the file header |
---|
1089 | Endif |
---|
1090 | |
---|
1091 | //read in trans file then add to SAM |
---|
1092 | ReadHeaderAndData(transFile) |
---|
1093 | //adds to SAM |
---|
1094 | err = Raw_to_work("SAM") |
---|
1095 | //sum region in SAM |
---|
1096 | transCts = SumCountsInBox(x1,x2,y1,y2,"SAM") |
---|
1097 | // get the attenuator, lambda, and sample string (to get the instrument) |
---|
1098 | WAVE/T samText = $"root:SAM:textRead" |
---|
1099 | WAVE samReals = $"root:SAM:realsRead" |
---|
1100 | samfileStr = samText[3] |
---|
1101 | lambda = samReals[26] |
---|
1102 | attenSam = samReals[3] |
---|
1103 | //calculate the ratio of attenuation factors - assumes that same instrument used for each, AND same lambda |
---|
1104 | AttenRatio = AttenuationFactor(samFileStr,lambda,attenEmp)/AttenuationFactor(samFileStr,lambda,attenSam) |
---|
1105 | //calculate trans based on empty beam value and rescale by attenuation ratio |
---|
1106 | trans= transCts/emptyCts * AttenRatio |
---|
1107 | |
---|
1108 | //write out counts and transmission to history window, showing the attenuator ratio, if it is not unity |
---|
1109 | If(attenRatio==1) |
---|
1110 | //Printf "%s\t\tTrans Counts = %g\t Actual Trans = %g\r",T_GFilenames[ii], transCts,trans |
---|
1111 | Printf "%s\t\tBox Counts = %g\t Trans = %g\r",T_GFilenames[ii], transCts,trans |
---|
1112 | else |
---|
1113 | //Printf "%s\t\tTrans Counts = %g\t Trans = %g\tAttenuatorRatio = %g\r",T_GFilenames[ii], transCts,trans,attenRatio |
---|
1114 | Printf "%s\t\tBox Counts = %g\t Trans = %g\t AttenuatorRatio = %g\r",T_GFilenames[ii], transCts,trans,attenRatio |
---|
1115 | endif |
---|
1116 | //write the trans to the file header of the raw data (open/close done in function) |
---|
1117 | ReWriteReal(filename,trans,158) //transmission start byte is 158 |
---|
1118 | |
---|
1119 | //then update the global that is displayed |
---|
1120 | T_GTransmission[ii] = trans |
---|
1121 | |
---|
1122 | else // There is no empty assigned |
---|
1123 | abortStr = "Empty beam file not assigned properly for " + T_GFilenames[jj] |
---|
1124 | Print abortStr |
---|
1125 | //Abort abortStr |
---|
1126 | return(1) |
---|
1127 | endif |
---|
1128 | endif |
---|
1129 | jj+=1 |
---|
1130 | while(jj<num_t_files) |
---|
1131 | else //no transmission file |
---|
1132 | abortStr = "Transmission beam file not assigned properly for " + T_GFilenames[ii] |
---|
1133 | Print abortStr |
---|
1134 | endif |
---|
1135 | ii+=1 |
---|
1136 | while(ii<=endRow) |
---|
1137 | //print "done" |
---|
1138 | return(0) |
---|
1139 | End |
---|
1140 | |
---|
1141 | // |
---|
1142 | // For the calculation of the Transmission using only the whole detector |
---|
1143 | // Used to compute the transmission for the TransmissionFiles table using |
---|
1144 | // the entire computer. For comparison with the "box" trans |
---|
1145 | // updated: 5/11/2006 bo Bryan Greenwald |
---|
1146 | Function CalcWholeTrans(startRow,endRow) |
---|
1147 | Variable startRow,endRow |
---|
1148 | // GetSelection table,ScatterFileTable,1 |
---|
1149 | |
---|
1150 | String filename |
---|
1151 | Wave/T T_EMP_Filenames = $"root:myGlobals:TransHeaderInfo:T_EMP_Filenames" |
---|
1152 | |
---|
1153 | Wave/T T_GFilenames = $"root:myGlobals:TransHeaderInfo:T_Filenames" |
---|
1154 | Wave T_GTransmission = $"root:myGlobals:TransHeaderInfo:T_Transmission" |
---|
1155 | |
---|
1156 | // Wave/T S_TRANS_Filenames = $"root:myGlobals:TransHeaderInfo:S_TRANS_Filenames" |
---|
1157 | // Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
1158 | // Wave S_GTransmission = $"root:myGlobals:TransHeaderInfo:S_Transmission" |
---|
1159 | Wave GWhole= $"root:myGlobals:TransHeaderInfo:T_Whole" |
---|
1160 | |
---|
1161 | Variable num_t_files, ii, jj |
---|
1162 | Variable refnum, transCts, emptyCts,attenRatio,lambda,trans |
---|
1163 | Variable x1,x2,y1,y2,err,attenEmp,attenSam |
---|
1164 | String suffix = "",pathName,textStr,abortStr,emptyFile,transFile,samFileStr |
---|
1165 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
1166 | String strToExecute |
---|
1167 | |
---|
1168 | num_t_files = numpnts(T_GFilenames) |
---|
1169 | |
---|
1170 | PathInfo catPathName |
---|
1171 | pathname = S_path |
---|
1172 | |
---|
1173 | ii= startRow |
---|
1174 | do |
---|
1175 | if (cmpstr(T_Emp_Filenames[ii],"")!=0) //if there is a sample trans file assigned |
---|
1176 | jj=0 |
---|
1177 | do |
---|
1178 | if (cmpstr(T_Emp_Filenames[ii],T_GFilenames[jj])==0) //find it in the trans file table |
---|
1179 | if (cmpstr(T_EMP_Filenames[ii],"")!=0) //if empty beam file assigned, proceed with the calculation |
---|
1180 | //full path+name to access all 3 files |
---|
1181 | filename=pathname+T_GFilenames[ii] |
---|
1182 | emptyFile = pathname+T_EMP_Filenames[ii] |
---|
1183 | transFile = pathname+T_GFilenames[ii] |
---|
1184 | ////////// |
---|
1185 | // check the empty beam file for previously selected coordinates |
---|
1186 | //if they exist, set the xy string , save the normalized counts somewhere |
---|
1187 | //the value was written to an unused r*4 header analysis.factor (@b494) |
---|
1188 | Open/R refnum as emptyFile |
---|
1189 | FSetPos refnum,478 |
---|
1190 | FBinRead/F=3/B=3 refnum, x1 |
---|
1191 | FBinRead/F=3/B=3 refnum, x2 |
---|
1192 | FBinRead/F=3/B=3 refnum, y1 |
---|
1193 | FBinRead/F=3/B=3 refnum, y2 |
---|
1194 | Close refnum |
---|
1195 | //read the real count value |
---|
1196 | strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + emptyFile + "\"" |
---|
1197 | Execute strToExecute |
---|
1198 | Wave w=$"tempGBWave0" |
---|
1199 | // Variable/G root:myGlobals:Patch:gTransCts = w[0] |
---|
1200 | emptyCts = w[0] |
---|
1201 | // read the attenuator number of the empty beam file |
---|
1202 | strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + emptyFile + "\"" |
---|
1203 | Execute strToExecute |
---|
1204 | attenEmp = w[3] |
---|
1205 | // |
---|
1206 | if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction |
---|
1207 | //no region selected -- prompt user to select box w/marquee |
---|
1208 | DoWindow/F TransFileTable |
---|
1209 | Abort "Use \"Set BCENT File\", then \"SetXYBox\" to select XY range in empty beam file "+T_EMP_Filenames[jj] |
---|
1210 | //from here the Marquee menu selection must handle the task of setting the box and updating the information in the file header |
---|
1211 | Endif |
---|
1212 | |
---|
1213 | //read in trans file then add to SAM |
---|
1214 | ReadHeaderAndData(transFile) |
---|
1215 | //adds to SAM |
---|
1216 | err = Raw_to_work("SAM") |
---|
1217 | //sum region in SAM |
---|
1218 | transCts = SumTotalCounts("SAM") |
---|
1219 | // get the attenuator, lambda, and sample string (to get the instrument) |
---|
1220 | WAVE/T samText = $"root:SAM:textRead" |
---|
1221 | WAVE samReals = $"root:SAM:realsRead" |
---|
1222 | samfileStr = samText[3] |
---|
1223 | lambda = samReals[26] |
---|
1224 | attenSam = samReals[3] |
---|
1225 | //calculate the ratio of attenuation factors - assumes that same instrument used for each, AND same lambda |
---|
1226 | AttenRatio = AttenuationFactor(samFileStr,lambda,attenEmp)/AttenuationFactor(samFileStr,lambda,attenSam) |
---|
1227 | //calculate trans based on empty beam value and rescale by attenuation ratio |
---|
1228 | trans= transCts/emptyCts * AttenRatio |
---|
1229 | |
---|
1230 | //write out counts and transmission to history window, showing the attenuator ratio, if it is not unity |
---|
1231 | If(attenRatio==1) |
---|
1232 | //Printf "%s\t\tTrans Counts = %g\tTrans using whole detector = %g\t Tbox/Twhole = %g\r",T_GFilenames[ii], transCts,trans,T_GTransmission[ii]/trans |
---|
1233 | Printf "%s\t\tTotal Counts = %g\t Trans using whole detector = %g\t",T_GFilenames[ii], transCts,trans |
---|
1234 | else |
---|
1235 | //Printf "%s\t\tTrans Counts = %g\tTrans = %g\tAttenuatorRatio = %g, Tbox/Twhole = %g\r",T_GFilenames[ii], transCts,trans,attenRatio, T_GTransmission[ii]/trans |
---|
1236 | Printf "%s\t\tTotal Counts = %g\t Trans using whole detector = %g\t AttenuatorRatio = %g",T_GFilenames[ii], transCts,trans,attenRatio |
---|
1237 | endif |
---|
1238 | If(T_GTransmission[ii]/trans > 0.97) |
---|
1239 | printf " Tbox/Twhole = %g\r",T_GTransmission[ii]/trans |
---|
1240 | else |
---|
1241 | printf " !!! Tbox/Twhole is low !!! = %g\r",T_GTransmission[ii]/trans |
---|
1242 | endif |
---|
1243 | //write the trans to the file header of the raw data (open/close done in function) |
---|
1244 | ReWriteReal(filename,trans,392) //WholeTrans start byte is 392 |
---|
1245 | |
---|
1246 | //then update the global that is displayed |
---|
1247 | GWhole[ii] = trans |
---|
1248 | |
---|
1249 | else // There is no empty assigned |
---|
1250 | abortStr = "Empty beam file not assigned properly for " + T_GFilenames[jj] |
---|
1251 | Print abortStr |
---|
1252 | //Abort abortStr |
---|
1253 | return(1) |
---|
1254 | endif |
---|
1255 | endif |
---|
1256 | jj+=1 |
---|
1257 | while(jj<num_t_files) |
---|
1258 | else //no transmission file |
---|
1259 | abortStr = "Transmission beam file not assigned properly for " + T_GFilenames[ii] |
---|
1260 | Print abortStr |
---|
1261 | endif |
---|
1262 | ii+=1 |
---|
1263 | while(ii<=endRow) |
---|
1264 | print "done" |
---|
1265 | return(0) |
---|
1266 | End |
---|
1267 | |
---|
1268 | |
---|
1269 | //window recreation macro for the Trans Panel |
---|
1270 | // |
---|
1271 | Proc Trans_Panel() |
---|
1272 | PauseUpdate; Silent 1 // building window... |
---|
1273 | NewPanel /W=(173,197,540,424)/K=1 as "Calculate Transmissions" |
---|
1274 | DoWindow/C Trans_Panel |
---|
1275 | ModifyPanel cbRGB=(49807,47186,38011) |
---|
1276 | ModifyPanel fixedSize=1 |
---|
1277 | SetDrawLayer UserBack |
---|
1278 | DrawLine 0,56,368,56 |
---|
1279 | DrawLine 0,125,368,125 |
---|
1280 | Button pick_emp,pos={4,65},size={105,20},proc=PickEMPTransButton,title="set BCENT file" |
---|
1281 | Button pick_emp,help={"This button will set the file selected in the Transmission file table to be the empty beam file."} |
---|
1282 | SetVariable empStr,pos={114,67},size={250,17},title="file:" |
---|
1283 | SetVariable empStr,help={"Filename of the empty beam file(s) to be used in the transmission calculation"} |
---|
1284 | SetVariable empStr,fSize=10 |
---|
1285 | SetVariable empStr,limits={-Inf,Inf,0},value= root:myGlobals:TransHeaderInfo:gEMP |
---|
1286 | Button Trn_button_1,pos={5,101},size={90,20},proc=Trn_SetXYBoxButton,title="Set XY Box" |
---|
1287 | Button Trn_button_1,help={"Sets the XY box to sum over"} |
---|
1288 | Button Trn_button_2,pos={174,139},size={110,20},proc=Trn_SortFilesByDate,title="Sort by Date" |
---|
1289 | Button Trn_button_2,help={"Sort the scattering and transmission files by creation date."} |
---|
1290 | Button Trn_button_3,pos={174,169},size={110,20},proc=Trn_SortFilesByLabel,title="Sort by Label" |
---|
1291 | Button Trn_button_3,help={"Sort the scattering and transmission files by label."} |
---|
1292 | Button Trn_button_4,pos={295,139},size={67,20},proc=Trn_ShowHelpProc,title="Help" |
---|
1293 | Button Trn_button_4,help={"Show a help notebook for calculating transmissions."} |
---|
1294 | SetVariable Trn_setvar_1,pos={135,100},size={227,17},title="Box is " |
---|
1295 | SetVariable Trn_setvar_1,help={"Box coordinates to sum over"},fSize=10 |
---|
1296 | SetVariable Trn_setvar_1,limits={-Inf,Inf,0},value= root:myGlobals:TransHeaderInfo:gBox |
---|
1297 | Button Trn_button_0,pos={1,1},size={70,20},proc=Trn_PickPathButton,title="Pick Path" |
---|
1298 | Button Trn_button_0,help={"Select the folder containing the SANS data files"} |
---|
1299 | Button Trn_button_9,pos={335,1},size={25,20},proc=ShowTransHelp,title="?" |
---|
1300 | Button Trn_button_9,help={"Show the help file for calculating sample transmissions"} |
---|
1301 | SetVariable Trn_setvar_0,pos={80,4},size={250,17},title="Path" |
---|
1302 | SetVariable Trn_setvar_0,help={"Currently selected data path"},fSize=10 |
---|
1303 | SetVariable Trn_setvar_0,limits={-Inf,Inf,0},value= root:myGlobals:TransHeaderInfo:gCatPathStr |
---|
1304 | Button Trn_button_5,pos={5,169},size={161,20},proc=Trn_CalcAllFilesButton,title="Calculate All Files" |
---|
1305 | Button Trn_button_5,help={"Calculate transmission and patch headers of ALL files in the Scattering File Table."} |
---|
1306 | Button Trn_button_6,pos={295,198},size={67,20},proc=Trn_PanelDoneButtonProc,title="Done" |
---|
1307 | Button Trn_button_6,help={"Close the panel when done calculating transmissions"} |
---|
1308 | Button Trn_button_7,pos={67,32},size={214,20},proc=Trn_RefreshProc,title="List Files" |
---|
1309 | Button Trn_button_7,help={"Generate or refresh the tables of files."} |
---|
1310 | Button Trn_button_8,pos={5,139},size={161,20},proc=Trn_CalcSelectedFilesButton,title="Calculate Selected Files" |
---|
1311 | Button Trn_button_8,help={"Calculate transmission and patch headers of selected files in the Scattering File Table."} |
---|
1312 | Button Trn_button_10,pos={5,198}, size={161,20},proc=TotalTransButtonProc |
---|
1313 | Button Trn_button_10 title="Calculate Total Trans" |
---|
1314 | Button Trn_button_10 help={"Calculate transmission over the whole detector and patch headers of ALL files in the data folder."} |
---|
1315 | EndMacro |
---|
1316 | |
---|
1317 | |
---|
1318 | Function TotalTransButtonProc(ctrlName) : ButtonControl |
---|
1319 | String ctrlName |
---|
1320 | TotalTrans(ctrlName) |
---|
1321 | End |
---|
1322 | |
---|
1323 | |
---|
1324 | Proc ShowTransHelp(ctrlName) : ButtonControl |
---|
1325 | String ctrlName |
---|
1326 | DisplayHelpTopic/K=1 "SANS Data Reduction Tutorial[Calculate Transmissions]" |
---|
1327 | End |
---|
1328 | |
---|
1329 | |
---|
1330 | //generates the file tables of scattering files and transmission files |
---|
1331 | // |
---|
1332 | // if the tables already exist, they will be updated |
---|
1333 | // |
---|
1334 | Proc Trn_RefreshProc(ctrlName) : ButtonControl |
---|
1335 | String ctrlName |
---|
1336 | BuildFileTables() |
---|
1337 | End |
---|
1338 | |
---|
1339 | //shows a noteboox of help text describing how to calculate transmissions |
---|
1340 | // - better that the user read the igor or pdf file, but it's a victory to get |
---|
1341 | //users to read anything at all |
---|
1342 | // |
---|
1343 | Proc Trn_ShowHelpProc(ctrlName) : ButtonControl |
---|
1344 | String ctrlName |
---|
1345 | DisplayTransHelp() |
---|
1346 | End |
---|
1347 | |
---|
1348 | //sorts the tables by date |
---|
1349 | // |
---|
1350 | Proc Trn_SortFilesByDate(ctrlName) : ButtonControl |
---|
1351 | String ctrlName |
---|
1352 | SortTransByDate() |
---|
1353 | End |
---|
1354 | |
---|
1355 | //sorts the tables alphabetically by the sample label field |
---|
1356 | // |
---|
1357 | Proc Trn_SortFilesByLabel(ctrlName) : ButtonControl |
---|
1358 | String ctrlName |
---|
1359 | SortTransByLabel() |
---|
1360 | End |
---|
1361 | |
---|
1362 | //button action procedure to select the local path to the |
---|
1363 | //folder containing the RAW SANS data files |
---|
1364 | // - once the data folder is selected, all of the popup file menus are |
---|
1365 | //forced to update with fresh file lists |
---|
1366 | // |
---|
1367 | Function Trn_PickPathButton(PathButton) : ButtonControl |
---|
1368 | String PathButton |
---|
1369 | |
---|
1370 | //set the global string to the selected pathname |
---|
1371 | Variable err |
---|
1372 | err = PickPath() |
---|
1373 | if(err) |
---|
1374 | return(1) //some problem with path or user cancelled, get out |
---|
1375 | endif |
---|
1376 | |
---|
1377 | PathInfo/S catPathName |
---|
1378 | String path = S_path |
---|
1379 | if (V_flag == 0) |
---|
1380 | //path does not exist - no folder selected |
---|
1381 | String/G root:myGlobals:TransHeaderInfo:gCatPathStr = "no folder selected" |
---|
1382 | else |
---|
1383 | String/G root:myGlobals:TransHeaderInfo:gCatPathStr = path |
---|
1384 | endif |
---|
1385 | |
---|
1386 | //Update the pathStr variable box |
---|
1387 | ControlUpdate/W=Trans_Panel $"Trn_setvar_0" |
---|
1388 | //Generate tables |
---|
1389 | Execute "BuildFileTables()" |
---|
1390 | |
---|
1391 | End |
---|
1392 | |
---|
1393 | //button action function that asks the user to set the XY box to sum over |
---|
1394 | //for all transmission calculations |
---|
1395 | // |
---|
1396 | // requires the user to set the box coordinates with the marquee popup |
---|
1397 | //that wil properly set the keyword string, and write the values to the empty beam header |
---|
1398 | // |
---|
1399 | Function Trn_SetXYBoxButton(ctrlName) : ButtonControl |
---|
1400 | String ctrlName |
---|
1401 | |
---|
1402 | String msgStr = "Select the Empty Beam File" |
---|
1403 | String filename="" |
---|
1404 | |
---|
1405 | //get the filename from the popup menu |
---|
1406 | //and construct a full path to it |
---|
1407 | SVAR partialName = root:myGlobals:TransHeaderInfo:gEMP |
---|
1408 | print partialName |
---|
1409 | //get a valid file based on this partialName and catPathName |
---|
1410 | String tempName = FindValidFilename(partialName) |
---|
1411 | if(cmpstr(tempName,"")==0) |
---|
1412 | //file not found, get out |
---|
1413 | Abort "Empty beam file not found Trn_SetXYBoxButton(ctrlName)" |
---|
1414 | Endif |
---|
1415 | //name is ok, prepend path to tempName for read routine |
---|
1416 | PathInfo catPathName |
---|
1417 | filename = S_path + tempName |
---|
1418 | |
---|
1419 | //read the file in - check for previous coordinates |
---|
1420 | ReadHeaderAndData(filename) |
---|
1421 | //data is displayed here (go through the normal display steps, so all is created properly |
---|
1422 | String/G root:myGlobals:gDataDisplayType="RAW" |
---|
1423 | fRawWindowHook() |
---|
1424 | |
---|
1425 | // check the empty beam file for previously selected coordinates |
---|
1426 | //if they exist, set the xy string , save the normalized counts somewhere |
---|
1427 | //the value was written to an unused r*4 header analysis.factor (@b494) |
---|
1428 | Variable refnum,x1,x2,y1,y2,err |
---|
1429 | Open/R refnum as filename |
---|
1430 | FSetPos refnum,478 |
---|
1431 | FBinRead/F=3/B=3 refnum, x1 |
---|
1432 | FBinRead/F=3/B=3 refnum, x2 |
---|
1433 | FBinRead/F=3/B=3 refnum, y1 |
---|
1434 | FBinRead/F=3/B=3 refnum, y2 |
---|
1435 | Close refnum |
---|
1436 | //read the real count value |
---|
1437 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
1438 | String strToExecute |
---|
1439 | strToExecute = GBLoadStr + "/S=494/U=1" + "\"" + filename + "\"" |
---|
1440 | Execute strToExecute |
---|
1441 | Wave w=$"tempGBWave0" |
---|
1442 | Variable/G root:myGlobals:gTransCts = w[0] //***NOTE this is NOT in the Trans sub-folder |
---|
1443 | // |
---|
1444 | if( ((x1-x2)==0) || ((y1-y2)==0) ) //zero width marquee in either direction |
---|
1445 | //no region selected |
---|
1446 | |
---|
1447 | //add the empty beam file to work.SAM |
---|
1448 | err = Raw_to_work("SAM") |
---|
1449 | |
---|
1450 | //the calling macro must change the display type |
---|
1451 | String/G root:myGlobals:gDataDisplayType="SAM" //displayed data type is sam |
---|
1452 | |
---|
1453 | //data is displayed here |
---|
1454 | fRawWindowHook() |
---|
1455 | |
---|
1456 | //prompt user to select box w/marquee |
---|
1457 | DoAlert 0,"Select the region to sum with the Marquee" |
---|
1458 | |
---|
1459 | //from here the Marquee menu selection must handle the task of setting the box |
---|
1460 | //and updating the information in the file header |
---|
1461 | else |
---|
1462 | // region already selected, just put up the values from the file header |
---|
1463 | //allow user the option of overriding the current box region |
---|
1464 | msgStr = "X1="+num2str(x1)+";" |
---|
1465 | msgStr += "X2="+num2str(x2)+";" |
---|
1466 | msgStr += "Y1="+num2str(y1)+";" |
---|
1467 | msgStr += "Y2="+num2str(y2)+";" |
---|
1468 | String textStr |
---|
1469 | textStr = "Override current box "+msgStr+" ?" |
---|
1470 | DoAlert 1,textStr |
---|
1471 | If((V_flag)==1) |
---|
1472 | //get new box coordinates, same procedure as above |
---|
1473 | //add the empty beam file to work.SAM |
---|
1474 | err = Raw_to_work("SAM") |
---|
1475 | |
---|
1476 | //the calling macro must change the display type |
---|
1477 | String/G root:myGlobals:gDataDisplayType="SAM" //displayed data type is sam |
---|
1478 | |
---|
1479 | //data is displayed here |
---|
1480 | fRawWindowHook() |
---|
1481 | |
---|
1482 | //prompt user to select box w/marquee |
---|
1483 | DoAlert 0,"Select the region to sum with the Marquee" |
---|
1484 | |
---|
1485 | //from here the Marquee menu selection must handle the task of setting the box |
---|
1486 | //and updating the information in the file header |
---|
1487 | else |
---|
1488 | String/G root:myGlobals:TransHeaderInfo:gBox = msgStr |
---|
1489 | Endif |
---|
1490 | Endif |
---|
1491 | |
---|
1492 | UpdateBoxCoordinates() |
---|
1493 | KillWaves/Z w |
---|
1494 | Return (0) |
---|
1495 | End |
---|
1496 | |
---|
1497 | |
---|
1498 | //button action function that assigns the selected empty beam file (run number only) |
---|
1499 | //and the sample trnansmissionfile (run number only) to the popup list of sample scattering |
---|
1500 | //files (ALL of the list items). Assignment is done by writing the integer run numbers of |
---|
1501 | //trans files to the header of each of the scattering files, in a batchwise processing |
---|
1502 | //of the popup list |
---|
1503 | // |
---|
1504 | //transmission are not calculated here - only the file numbers are set |
---|
1505 | // |
---|
1506 | //*********unused*********** |
---|
1507 | //Function Trn_AssignAllFilesButton(ctrlName) : ButtonControl |
---|
1508 | // String ctrlName |
---|
1509 | // |
---|
1510 | // AssignTransFilesToData() |
---|
1511 | // |
---|
1512 | //End |
---|
1513 | |
---|
1514 | //button action procedure to calculate the transmission of all of the sample files in the |
---|
1515 | //sample popup list, based on the information in EACH sample header and in the empty beam file |
---|
1516 | //the box must be set properly in the empty beam file, AND the empty and trans |
---|
1517 | //run number must also be set properly in EACH scattering file, |
---|
1518 | //If run numbers are not properly assigned, no trans is calculated and the |
---|
1519 | //header is not modified |
---|
1520 | // |
---|
1521 | //The RAW data header of EACH sample file IS modified, with the newly calculated transmission |
---|
1522 | // |
---|
1523 | //not very friendly, but forces users to assign the files before continuing |
---|
1524 | // |
---|
1525 | Function Trn_CalcAllFilesButton(ctrlName) : ButtonControl |
---|
1526 | String ctrlName |
---|
1527 | |
---|
1528 | //calculate the transmission and Patch the header (if possible) |
---|
1529 | Wave/T S_GFilenames = $"root:myGlobals:TransHeaderInfo:S_Filenames" |
---|
1530 | Variable num_s_files = numpnts(S_GFilenames) |
---|
1531 | AssignSelTransFilesToData(0,num_s_files-1) //do all the files (points 0 to n-1, inclusive) |
---|
1532 | CalcSelTransFromHeader(0,num_s_files-1) |
---|
1533 | |
---|
1534 | End |
---|
1535 | |
---|
1536 | //for selected scattering files in the scattering table, |
---|
1537 | // the "Annn" association of trans file is written to the data file, |
---|
1538 | // the the transmission is actually calculated |
---|
1539 | // |
---|
1540 | Function Trn_CalcSelectedFilesButton(ctrlName) : ButtonControl |
---|
1541 | String ctrlName |
---|
1542 | |
---|
1543 | Variable scatterTableExists |
---|
1544 | scatterTableExists = WinType("ScatterFileTable") |
---|
1545 | if (scatterTableExists != 0) |
---|
1546 | GetSelection table,ScatterFileTable,1 |
---|
1547 | if(V_Flag != 0) |
---|
1548 | AssignSelTransFilesToData(V_StartRow,V_EndRow) |
---|
1549 | //calculate the transmission and Patch the header (if possible) |
---|
1550 | CalcSelTransFromHeader(V_StartRow,V_EndRow) |
---|
1551 | Else |
---|
1552 | DoAlert 0,"No selection from Scattering Files table" |
---|
1553 | Endif |
---|
1554 | Else |
---|
1555 | DoAlert 0,"No file selected from Scattering Files table or no Scattering Files table available" |
---|
1556 | Endif |
---|
1557 | End |
---|
1558 | |
---|
1559 | // b BGtoFix -comment to describe the workings of the function |
---|
1560 | // since it's different than calculating the regular transmission |
---|
1561 | // |
---|
1562 | // I am not sure what the difference is inthe function of CalcTotalTrans and CalcWholeTrans ? |
---|
1563 | // do they really do anything different? |
---|
1564 | // |
---|
1565 | Function TotalTrans(ctrlName) : ButtonControl |
---|
1566 | String ctrlName |
---|
1567 | |
---|
1568 | Variable transTableExists |
---|
1569 | transTableExists = WinType("ScatterFileTable") // b BGtoFix -checking for the existence of the wrong table |
---|
1570 | if (transTableExists != 0) |
---|
1571 | GetSelection table,transFileTable,1 |
---|
1572 | if(V_Flag != 0) |
---|
1573 | AssignTotalTransFilesToData(V_StartRow,V_EndRow) |
---|
1574 | //calculate the transmission and Patch the header (if possible) |
---|
1575 | CalcTotalTrans(V_StartRow,V_EndRow) |
---|
1576 | CalcWholeTrans(V_StartRow,V_EndRow) |
---|
1577 | Else |
---|
1578 | DoAlert 0,"No selection from Scattering Files table" // b BGtoFix - really looking for files from the Trans Table... |
---|
1579 | Endif |
---|
1580 | Else |
---|
1581 | DoAlert 0,"No file selected from Scattering Files table or no Scattering Files table available" // b BGtoFix - really looking for files from the Trans Table... |
---|
1582 | Endif |
---|
1583 | End |
---|
1584 | |
---|
1585 | |
---|
1586 | //simple button procedure to close the trans panel |
---|
1587 | // - automatically kills the two tables as well |
---|
1588 | // |
---|
1589 | Function Trn_PanelDoneButtonProc(ctrlName) : ButtonControl |
---|
1590 | String ctrlName |
---|
1591 | |
---|
1592 | // this button will make sure all files are closed |
---|
1593 | //and close the panel |
---|
1594 | |
---|
1595 | Close/A |
---|
1596 | DoWindow/K Trans_Panel |
---|
1597 | DoWindow/K ScatterFileTable |
---|
1598 | DoWindow/K TransFileTable |
---|
1599 | End |
---|
1600 | |
---|
1601 | |
---|
1602 | //function to check the header of a raw data file (full path specified by fname) |
---|
1603 | //checks the field of the x-position of the beamstop during data collection |
---|
1604 | //if the x-position is more negatice (farther to the left) than xTol(input) |
---|
1605 | //the the beamstop is "out" and the file is a transmission run and not a scattering run |
---|
1606 | //xtol typically set at -5 (cm) - trans runs have bs(x) at -10 to -15 cm |
---|
1607 | // function returns 1 if beamstop is out, 0 if beamstop is in |
---|
1608 | // |
---|
1609 | Function CheckIfBeamstopOut(fName,xTol) |
---|
1610 | String fname |
---|
1611 | Variable xTol |
---|
1612 | |
---|
1613 | Variable refnum,xpos |
---|
1614 | //pos = 369, read one real value |
---|
1615 | |
---|
1616 | SetDataFolder root: |
---|
1617 | String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q" |
---|
1618 | String strToExecute="" |
---|
1619 | // 1 R*4 value |
---|
1620 | strToExecute = GBLoadStr + "/S=368/U=1" + "\"" + fname + "\"" |
---|
1621 | Execute strToExecute |
---|
1622 | Wave w=$"root:tempGBWave0" |
---|
1623 | xPos = w[0] |
---|
1624 | KillWaves/Z w |
---|
1625 | //Print "xPos = ",xpos |
---|
1626 | |
---|
1627 | if(xpos<=xTol) |
---|
1628 | //xpos is farther left (more negative) than xtol (currently -5 cm) |
---|
1629 | Return(1) |
---|
1630 | else |
---|
1631 | //some other file |
---|
1632 | Return(0) |
---|
1633 | Endif |
---|
1634 | End |
---|
1635 | |
---|
1636 | //function to update the box coordinates of the file selected as the |
---|
1637 | //empty beam file - takes the file that is currently popped from the list |
---|
1638 | //reads the 4 "analysis" integers that hold the box coordinates |
---|
1639 | //resets the globals string that is displayed with the new values |
---|
1640 | //should be called whenever the "empty" popup is popped, to ensure |
---|
1641 | //that current header information is displayed |
---|
1642 | // |
---|
1643 | Function UpdateBoxCoordinates() |
---|
1644 | |
---|
1645 | //construct a full name, and read in the label from the file |
---|
1646 | //and set the global |
---|
1647 | String textstr="" |
---|
1648 | ControlInfo empStr |
---|
1649 | SVAR item = root:myGlobals:TransHeaderInfo:gEMP |
---|
1650 | String tempName = FindValidFilename(item) |
---|
1651 | if(cmpstr(tempName,"")==0) |
---|
1652 | //file not found, get out |
---|
1653 | Abort "Empty beam file not found UpdateBoxCoordinates(ctrlName)" |
---|
1654 | Endif |
---|
1655 | //name is ok, prepend path to tempName for read routine |
---|
1656 | PathInfo catPathName |
---|
1657 | String filename = S_path + tempName |
---|
1658 | |
---|
1659 | Variable refnum,x1,x2,y1,y2,err |
---|
1660 | Open/R refnum as filename |
---|
1661 | FSetPos refnum,478 |
---|
1662 | FBinRead/F=3/B=3 refnum, x1 |
---|
1663 | FBinRead/F=3/B=3 refnum, x2 |
---|
1664 | FBinRead/F=3/B=3 refnum, y1 |
---|
1665 | FBinRead/F=3/B=3 refnum, y2 |
---|
1666 | Close refnum |
---|
1667 | |
---|
1668 | //and update the global string |
---|
1669 | String msgStr="" |
---|
1670 | msgStr = "X1="+num2str(x1)+";" |
---|
1671 | msgStr += "X2="+num2str(x2)+";" |
---|
1672 | msgStr += "Y1="+num2str(y1)+";" |
---|
1673 | msgStr += "Y2="+num2str(y2)+";" |
---|
1674 | |
---|
1675 | String/G root:myGlobals:TransHeaderInfo:gBox = msgStr |
---|
1676 | |
---|
1677 | ControlUpdate/W=Trans_panel Trn_setvar_1 |
---|
1678 | End |
---|
1679 | |
---|
1680 | //crude procedure to display a notebook of help information for users |
---|
1681 | // |
---|
1682 | Proc DisplayTransHelp() |
---|
1683 | String nb = "Notebook0" |
---|
1684 | NewNotebook/N=$nb/F=1/V=1/W=(342,302,868,674) as "Notebook0:Transmission Help" |
---|
1685 | Notebook $nb defaultTab=36, statusWidth=238, pageMargins={36,72,36,72} |
---|
1686 | Notebook $nb showRuler=1, rulerUnits=1, updating={1, 3600} |
---|
1687 | Notebook $nb newRuler=Normal, justification=0, margins={0,0,468}, spacing={0,0,0}, tabs={}, rulerDefaults={"Geneva",10,0,(0,0,0)} |
---|
1688 | Notebook $nb ruler=Normal; Notebook $nb justification=1, fSize=14, fStyle=1, text="Transmission Help\r" |
---|
1689 | Notebook $nb ruler=Normal, fSize=-1, fStyle=-1, text="\r" |
---|
1690 | Notebook $nb text="This panel allows quick and easy calculation of sample transmission. The neutron transmission of a sampl" |
---|
1691 | Notebook $nb text="e must be calculated and entered into the header of each sample scattering file before proper background" |
---|
1692 | Notebook $nb text=" corrections or absolute scaling can be done.\r" |
---|
1693 | Notebook $nb text="\r" |
---|
1694 | Notebook $nb text="During data collection, you measured an empty beam - that is a measurement with heavy attenuation of th" |
---|
1695 | Notebook $nb text="e neutron beam and the beamstop mover out of line with the direct beam. Then without changing the attenu" |
---|
1696 | Notebook $nb text="ation or replacing the beamstop, you put a sample in the beam, and repeated the measurement (a sample tr" |
---|
1697 | Notebook $nb text="ansmission measurement). The neutron transmission of the sample is simply the ratio of the number of neu" |
---|
1698 | Notebook $nb text="tron counts from the sample transmission measurement normalized by the number of neutron counts from the" |
---|
1699 | Notebook $nb text=" empty beam measurement. In this way, each sample transmission file is \"linked\" to the same empty beam t" |
---|
1700 | Notebook $nb text="ransmission file.\r" |
---|
1701 | Notebook $nb text="\r" |
---|
1702 | Notebook $nb text="This calculated transmission value must be entered into the header of the sample scattering measurement " |
---|
1703 | Notebook $nb text="- that is the measurement of the sample with the beamstop covering the primary (transmitted) beam, and n" |
---|
1704 | Notebook $nb text="o (or few) attenuators in place. In this way, the sample transmission file is \"linked\" to its correspond" |
---|
1705 | Notebook $nb text="ing sample scattering file. This panel allows you to set up the links and calculate the transmission.Tra" |
---|
1706 | Notebook $nb text="nsmisison values are automatically patched to the scattering file headers as they are calculated.\r" |
---|
1707 | Notebook $nb text="\r" |
---|
1708 | Notebook $nb text="To Calculate Transmissions:\r" |
---|
1709 | Notebook $nb text="\r" |
---|
1710 | Notebook $nb text="1) Click \"List Files\" to get two lists (tables) - one of all the sample scattering files in the folder, " |
---|
1711 | Notebook $nb text="and one of the transmission files.\r" |
---|
1712 | Notebook $nb text="\r" |
---|
1713 | Notebook $nb text="2) Select the region of the detector to sum over from the empty beam transmission file. Do theis by clic" |
---|
1714 | Notebook $nb text="king on the filename of the empty beam transmision file (from the TransmissionFiles window, in the blue " |
---|
1715 | Notebook $nb text="\"T_Filenames\" column). Return to the panel, and click the \"set EMP file\" button\", and the filename shoul" |
---|
1716 | Notebook $nb text="d appear in the file box. The \"Box is\" field should have zeros for the x and y coordinates. Click the \"S" |
---|
1717 | Notebook $nb text="et XY Box\" button. The empty beam file will be displayed, and you will be instructed to select the regio" |
---|
1718 | Notebook $nb text="n to sum with the marquee. On the data, click and drag a rectangle that encompasses the primary beam. Mo" |
---|
1719 | Notebook $nb text="ve the cursor inside the selection, to get an \"upside-down hat\" cursor. Click to get a menu, and near th" |
---|
1720 | Notebook $nb text="e bottom, select \"Set XY Box Coords\". The pixel values should be updated to the Transmission panel, and " |
---|
1721 | Notebook $nb text="are written to the empty beam header for future calculations. Note that the marquee selection can also b" |
---|
1722 | Notebook $nb text="e used to measure the beam center, or centroid of any selected region.\r" |
---|
1723 | Notebook $nb text="\r" |
---|
1724 | Notebook $nb text="3) Now you need to \"link\" the ", fStyle=2, text="sample", fStyle=-1, text=" transmission files to the " |
---|
1725 | Notebook $nb fStyle=2, text="empty", fStyle=-1, text=" ", fStyle=2, text="beam", fStyle=-1 |
---|
1726 | Notebook $nb text=" transmission file. Do this in the TransmissionFiles window by selecting the filename (in the blue T_Fil" |
---|
1727 | Notebook $nb text="enames column) and pasing it to the corresponding row(s) in the T_EMP_Filenames column. This links the e" |
---|
1728 | Notebook $nb text="mpty beam transmission with the sample transmission file. Do this for every sample transmission file.\r" |
---|
1729 | Notebook $nb text="\r" |
---|
1730 | Notebook $nb text="4) Now you need to link the sample ", fStyle=2, text="transmission", fStyle=-1 |
---|
1731 | Notebook $nb text=" file to the sample ", fStyle=2, text="scattering", fStyle=-1 |
---|
1732 | Notebook $nb text=" file. Do this by selecting the name of the transmission file (from the blue T_Filenames column) and pas" |
---|
1733 | Notebook $nb text="ting it into the corresponding row of the S_TRANS_Filenames column of the ScatteringFiles window. This l" |
---|
1734 | Notebook $nb text="inks the scattering file to its corresponding sample transmission file. This for all of the sample scatt" |
---|
1735 | Notebook $nb text="ering files.\r" |
---|
1736 | Notebook $nb text="\r" |
---|
1737 | Notebook $nb text="5) Calculate the transmissions (and automatically write the transmission value to the satterng file head" |
---|
1738 | Notebook $nb text="er) by clicking \"Calculate All Files\" from the Transmission Panel. The results will be printed to the co" |
---|
1739 | Notebook $nb text="mmand window at the bottom of the screen. Any improperly assigned files will be listed. For example, blo" |
---|
1740 | Notebook $nb text="cked beam scattering files will return an error, since the transmssion known to be zero, and is not meas" |
---|
1741 | Notebook $nb text="ured (and no files are \"linked\"). Rather than calculating the transmission of all of the files, a range" |
---|
1742 | Notebook $nb text=" of S_Filenames can be selected, then calculated by clicking \"Calculate Selected Files\".\r" |
---|
1743 | Notebook $nb text="\r" |
---|
1744 | Notebook $nb text="By default the lists are sorted by run number (= chronological). In some cases it may be easier to sort " |
---|
1745 | Notebook $nb text="by the sample label to group several of the same sample scattering files collected at different sample-t" |
---|
1746 | Notebook $nb text="o-detector distances. Its utility depends, of course, on how consistent and unique your sample labels ar" |
---|
1747 | Notebook $nb text="e.\r" |
---|
1748 | Notebook $nb text="\r" |
---|
1749 | Notebook $nb text="The \"links\" are stored in the corresponding files, and wil be re-generated when the lists are re-generat" |
---|
1750 | Notebook $nb text="ed. Unassigned links will appear as blank elements in the T_EMP_Filenames or S_TRANS_Filenames columns.\r" |
---|
1751 | Notebook $nb text="\r" |
---|
1752 | Notebook $nb, selection={startOfFile,startOfFile} |
---|
1753 | Notebook $nb text="\r" |
---|
1754 | End |
---|
1755 | |
---|
1756 | //****************** |
---|
1757 | //lookup tables for attenuator transmissions |
---|
1758 | //NG3 and NG7 attenuators are physically different, so the transmissions are slightly different |
---|
1759 | //NG1 - (8m SANS) is not supported |
---|
1760 | |
---|
1761 | Proc MakeNG3AttenTable() |
---|
1762 | |
---|
1763 | NewDataFolder/O root:myGlobals:Attenuators |
---|
1764 | //do explicitly to avoid data folder problems, redundant, but it must work without fail |
---|
1765 | Make/O/N=9 root:myGlobals:Attenuators:ng3att0 |
---|
1766 | Make/O/N=9 root:myGlobals:Attenuators:ng3att1 |
---|
1767 | Make/O/N=9 root:myGlobals:Attenuators:ng3att2 |
---|
1768 | Make/O/N=9 root:myGlobals:Attenuators:ng3att3 |
---|
1769 | Make/O/N=9 root:myGlobals:Attenuators:ng3att4 |
---|
1770 | Make/O/N=9 root:myGlobals:Attenuators:ng3att5 |
---|
1771 | Make/O/N=9 root:myGlobals:Attenuators:ng3att6 |
---|
1772 | Make/O/N=9 root:myGlobals:Attenuators:ng3att7 |
---|
1773 | Make/O/N=9 root:myGlobals:Attenuators:ng3att8 |
---|
1774 | Make/O/N=9 root:myGlobals:Attenuators:ng3att9 |
---|
1775 | Make/O/N=9 root:myGlobals:Attenuators:ng3att10 |
---|
1776 | |
---|
1777 | //each wave has 8 elements, the transmission of att# at the wavelengths |
---|
1778 | //lambda = 5,6,7,8,10,12,14,17 |
---|
1779 | Make/O/N=9 root:myGlobals:Attenuators:ng3lambda={5,6,7,8,10,12,14,17,20} |
---|
1780 | root:myGlobals:Attenuators:ng3att0 = {1, 1, 1, 1, 1, 1, 1, 1,1 } |
---|
1781 | root:myGlobals:Attenuators:ng3att1 = {0.421, 0.394, 0.371, 0.349, 0.316, 0.293, 0.274, 0.245,0.220} |
---|
1782 | root:myGlobals:Attenuators:ng3att2 = {0.187, 0.164, 0.145, 0.130, 0.106, 0.0916, 0.0808, 0.0651,0.0531} |
---|
1783 | root:myGlobals:Attenuators:ng3att3 = {0.0777, 0.0636, 0.0534, 0.0446, 0.0330, 0.0262, 0.0217, 0.0157 ,0.0116} |
---|
1784 | root:myGlobals:Attenuators:ng3att4 = {0.0328, 0.0252, 0.0195, 0.0156, 0.0104, 7.68e-3, 5.98e-3, 3.91e-3,0.00262} |
---|
1785 | root:myGlobals:Attenuators:ng3att5 = {0.0139, 9.94e-3, 7.34e-3, 5.44e-3, 3.29e-3, 2.25e-3, 1.66e-3, 9.95e-4, 6.12e-4} |
---|
1786 | root:myGlobals:Attenuators:ng3att6 = {5.95e-3, 3.97e-3, 2.77e-3, 1.95e-3, 1.06e-3, 6.81e-4, 4.71e-4, 2.59e-4 , 1.45e-4} |
---|
1787 | root:myGlobals:Attenuators:ng3att7 = {1.07e-3, 6.24e-4, 3.90e-4, 2.44e-4, 1.14e-4, 6.55e-5, 4.10e-5, 1.64e-5 , 7.26e-6} |
---|
1788 | root:myGlobals:Attenuators:ng3att8 = {1.90e-4, 9.84e-5, 5.60e-5, 3.25e-5, 1.55e-5, 6.60e-6, 3.42e-6, 1.04e-6 , 3.48e-7} |
---|
1789 | root:myGlobals:Attenuators:ng3att9 = {3.61e-5, 1.74e-5, 9.90e-6, 6.45e-6, 2.35e-6, 6.35e-7, 2.86e-7, 6.61e-8 , 1.73e-8} |
---|
1790 | root:myGlobals:Attenuators:ng3att10 = {7.60e-6, 3.99e-6, 2.96e-6, 2.03e-6, 3.34e-7, 6.11e-8, 2.39e-8, 4.19e-9 , 8.60e-10} |
---|
1791 | |
---|
1792 | End |
---|
1793 | |
---|
1794 | Proc MakeNG7AttenTable() |
---|
1795 | |
---|
1796 | NewDataFolder/O root:myGlobals:Attenuators |
---|
1797 | |
---|
1798 | Make/O/N=9 root:myGlobals:Attenuators:ng7att0 |
---|
1799 | Make/O/N=9 root:myGlobals:Attenuators:ng7att1 |
---|
1800 | Make/O/N=9 root:myGlobals:Attenuators:ng7att2 |
---|
1801 | Make/O/N=9 root:myGlobals:Attenuators:ng7att3 |
---|
1802 | Make/O/N=9 root:myGlobals:Attenuators:ng7att4 |
---|
1803 | Make/O/N=9 root:myGlobals:Attenuators:ng7att5 |
---|
1804 | Make/O/N=9 root:myGlobals:Attenuators:ng7att6 |
---|
1805 | Make/O/N=9 root:myGlobals:Attenuators:ng7att7 |
---|
1806 | Make/O/N=9 root:myGlobals:Attenuators:ng7att8 |
---|
1807 | Make/O/N=9 root:myGlobals:Attenuators:ng7att9 |
---|
1808 | Make/O/N=9 root:myGlobals:Attenuators:ng7att10 |
---|
1809 | |
---|
1810 | //each wave has 8 elements, the transmission of att# at the wavelengths |
---|
1811 | //lambda = 5,6,7,8,10,12,14,17 |
---|
1812 | Make/O/N=9 root:myGlobals:Attenuators:ng7lambda={5,6,7,8,10,12,14,17,20} |
---|
1813 | root:myGlobals:Attenuators:ng7att0 = {1, 1, 1, 1, 1, 1, 1, 1 ,1} |
---|
1814 | root:myGlobals:Attenuators:ng7att1 = {0.418, 0.393, 0.369, 0.347, 0.313, 0.291, 0.271, 0.244, 0.219 } |
---|
1815 | root:myGlobals:Attenuators:ng7att2 = {0.189, 0.167, 0.148, 0.132, 0.109, 0.0945, 0.0830, 0.0681, 0.0560} |
---|
1816 | root:myGlobals:Attenuators:ng7att3 = {0.0784, 0.0651, 0.0541, 0.0456, 0.0340, 0.0273, 0.0223, 0.0164 , 0.0121} |
---|
1817 | root:myGlobals:Attenuators:ng7att4 = {0.0328, 0.0256, 0.0200, 0.0159, 0.0107, 7.98e-3, 6.14e-3, 4.09e-3 , 0.00274} |
---|
1818 | root:myGlobals:Attenuators:ng7att5 = {0.0139, 0.0101, 7.43e-3, 5.58e-3, 3.42e-3, 2.36e-3, 1.70e-3, 1.03e-3 , 6.27e-4} |
---|
1819 | root:myGlobals:Attenuators:ng7att6 = {5.90e-3, 4.07e-3, 2.79e-3, 1.99e-3, 1.11e-3, 7.13e-4, 4.91e-4, 2.59e-4 , 1.42e-4} |
---|
1820 | root:myGlobals:Attenuators:ng7att7 = {1.04e-3, 6.37e-4, 3.85e-4, 2.46e-4, 1.16e-4, 6.86e-5, 4.10e-5, 1.64e-5 ,7.02e-6} |
---|
1821 | root:myGlobals:Attenuators:ng7att8 = {1.90e-4, 1.03e-4, 5.71e-5, 3.44e-5, 1.65e-5, 6.60e-6, 3.42e-6, 1.04e-6 , 3.48e-7} |
---|
1822 | root:myGlobals:Attenuators:ng7att9 = {3.58e-5, 1.87e-5, 1.05e-5, 7.00e-6, 2.35e-6, 6.35e-7, 2.86e-7, 6.61e-8 , 1.73e-8} |
---|
1823 | root:myGlobals:Attenuators:ng7att10 = {7.76e-6, 4.56e-6, 3.25e-6, 2.03e-6, 3.34e-7, 6.11e-8, 2.39e-8, 4.19e-9, 8.60e-10} |
---|
1824 | |
---|
1825 | End |
---|
1826 | |
---|
1827 | //returns the transmission of the attenuator (at NG3) given the attenuator number |
---|
1828 | //which must be an integer(to select the wave) and given the wavelength. |
---|
1829 | //the wavelength may be any value between 5 and 20 (A), and is interpolated |
---|
1830 | //between calibrated wavelengths for a given attenuator |
---|
1831 | Function LookupAttenNG3(lambda,attenNo) |
---|
1832 | Variable lambda, attenNo |
---|
1833 | |
---|
1834 | Variable trans |
---|
1835 | String attStr="root:myGlobals:Attenuators:ng3att"+num2str(trunc(attenNo)) |
---|
1836 | String lamStr = "root:myGlobals:Attenuators:ng3lambda" |
---|
1837 | |
---|
1838 | if(attenNo == 0) |
---|
1839 | return (1) //no attenuation, return trans == 1 |
---|
1840 | endif |
---|
1841 | |
---|
1842 | if( (lambda < 5) || (lambda > 20 ) ) |
---|
1843 | Abort "Wavelength out of calibration range (5,20). You must manually enter the absolute parameters" |
---|
1844 | Endif |
---|
1845 | |
---|
1846 | if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) |
---|
1847 | Execute "MakeNG3AttenTable()" |
---|
1848 | Endif |
---|
1849 | //just in case creating the tables fails.... |
---|
1850 | if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) |
---|
1851 | Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" |
---|
1852 | Endif |
---|
1853 | |
---|
1854 | //lookup the value by interpolating the wavelength |
---|
1855 | //the attenuator must always be an integer |
---|
1856 | Wave att = $attStr |
---|
1857 | Wave lam = $lamstr |
---|
1858 | trans = interp(lambda,lam,att) |
---|
1859 | |
---|
1860 | // Print "trans = ",trans |
---|
1861 | |
---|
1862 | return trans |
---|
1863 | End |
---|
1864 | |
---|
1865 | //returns the transmission of the attenuator (at NG7) given the attenuator number |
---|
1866 | //which must be an integer(to select the wave) and given the wavelength. |
---|
1867 | //the wavelength may be any value between 5 and 20 (A), and is interpolated |
---|
1868 | //between calibrated wavelengths for a given attenuator |
---|
1869 | // |
---|
1870 | // this set of tables is also used for NG5 (NG1) SANS instrument - as the attenuator has yet to be calibrated |
---|
1871 | Function LookupAttenNG7(lambda,attenNo) |
---|
1872 | Variable lambda, attenNo |
---|
1873 | |
---|
1874 | Variable trans |
---|
1875 | String attStr="root:myGlobals:Attenuators:ng7att"+num2str(trunc(attenNo)) |
---|
1876 | String lamStr = "root:myGlobals:Attenuators:ng7lambda" |
---|
1877 | |
---|
1878 | if(attenNo == 0) |
---|
1879 | return (1) //no attenuation, return trans == 1 |
---|
1880 | endif |
---|
1881 | |
---|
1882 | if( (lambda < 5) || (lambda > 20 ) ) |
---|
1883 | Abort "Wavelength out of calibration range (5,20). You must manually enter the absolute parameters" |
---|
1884 | Endif |
---|
1885 | |
---|
1886 | if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) |
---|
1887 | Execute "MakeNG7AttenTable()" |
---|
1888 | Endif |
---|
1889 | //just in case creating the tables fails.... |
---|
1890 | if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) |
---|
1891 | Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" |
---|
1892 | Endif |
---|
1893 | |
---|
1894 | //lookup the value by interpolating the wavelength |
---|
1895 | //the attenuator must always be an integer |
---|
1896 | Wave att = $attStr |
---|
1897 | Wave lam = $lamstr |
---|
1898 | trans = interp(lambda,lam,att) |
---|
1899 | |
---|
1900 | //Print "trans = ",trans |
---|
1901 | |
---|
1902 | return trans |
---|
1903 | |
---|
1904 | End |
---|
1905 | |
---|
1906 | //returns the proper attenuation factor based on the instrument (NG3, NG5, or NG7) |
---|
1907 | //NG5 values are taken from the NG7 tables (there is very little difference in the |
---|
1908 | //values, and NG5 attenuators have not been calibrated (as of 8/01) |
---|
1909 | //filestr as passed is textread[3], the default directory |
---|
1910 | Function AttenuationFactor(fileStr,lam,attenNo) |
---|
1911 | String fileStr |
---|
1912 | Variable lam,attenNo |
---|
1913 | |
---|
1914 | Variable attenFactor=1,loc |
---|
1915 | String instr=fileStr[1,3] //filestr is "[NGnSANSn] " or "[NGnSANSnn]" (11 characters total) |
---|
1916 | |
---|
1917 | strswitch(instr) |
---|
1918 | case "NG3": |
---|
1919 | attenFactor = LookupAttenNG3(lam,attenNo) |
---|
1920 | break |
---|
1921 | case "NG5": |
---|
1922 | //using NG7 lookup Table |
---|
1923 | attenFactor = LookupAttenNG7(lam,attenNo) |
---|
1924 | break |
---|
1925 | case "NG7": |
---|
1926 | attenFactor = LookupAttenNG7(lam,attenNo) |
---|
1927 | break |
---|
1928 | default: |
---|
1929 | //return error? |
---|
1930 | attenFactor=1 |
---|
1931 | endswitch |
---|
1932 | // print "instr, lambda, attenNo,attenFactor = ",instr,lam,attenNo,attenFactor |
---|
1933 | return(attenFactor) |
---|
1934 | End |
---|
1935 | |
---|
1936 | //******************* |
---|
1937 | //************ |
---|
1938 | // A simple panel to allow users of the NG1 SANS instrument to make their |
---|
1939 | // transmission files "look" like a transmission measurement to the data reduction |
---|
1940 | // program. Transmission files are designated by an x-position of the beamstop of |
---|
1941 | // < -5 (cm). this simple procedure sets xpos=-10 for individual files. files |
---|
1942 | // con be "un-converted", which set the xpos=0. |
---|
1943 | // 1/30/01 SRK |
---|
1944 | //************ |
---|
1945 | |
---|
1946 | Proc TransformToTransFile() |
---|
1947 | Variable/G root:myGlobals:gConvTrans=1 |
---|
1948 | DoWindow/F Convert_to_Trans |
---|
1949 | if(V_flag==0) |
---|
1950 | Convert2Trans() |
---|
1951 | endif |
---|
1952 | End |
---|
1953 | |
---|
1954 | //fname must be the full path and name for the file |
---|
1955 | Function ChangeBSXPos(fname,xpos) |
---|
1956 | String fname |
---|
1957 | Variable xpos |
---|
1958 | |
---|
1959 | Variable start |
---|
1960 | //x-position starts after byte 368 |
---|
1961 | //ReWriteReal() takes care of open/close on its own |
---|
1962 | start = 368 //BS x-position |
---|
1963 | ReWriteReal(fname,xpos,start) |
---|
1964 | return(0) |
---|
1965 | End |
---|
1966 | |
---|
1967 | //sets the beamstop position to zero NOT the original position |
---|
1968 | Function UnConvertButtonProc(ctrlName) : ButtonControl |
---|
1969 | String ctrlName |
---|
1970 | |
---|
1971 | //Print "UnConvert" |
---|
1972 | String fullname="" |
---|
1973 | ControlInfo fileNum |
---|
1974 | Variable num = V_Value //run number to find |
---|
1975 | |
---|
1976 | fullname = FindFileFromRunNumber(num) |
---|
1977 | Print fullname |
---|
1978 | //report error or change the file |
---|
1979 | if(cmpstr(fullname,"")==0) |
---|
1980 | Print "Unconvert - file not found" |
---|
1981 | else |
---|
1982 | //Print "Unconvert",fullname |
---|
1983 | ChangeBSXPos(fullName,0) |
---|
1984 | Endif |
---|
1985 | return(0) |
---|
1986 | End |
---|
1987 | |
---|
1988 | //button procedure to do the conversion |
---|
1989 | // writes fake beamstop position to the data file |
---|
1990 | // |
---|
1991 | Function ConvertButtonProc(ctrlName) : ButtonControl |
---|
1992 | String ctrlName |
---|
1993 | |
---|
1994 | String fullname="" |
---|
1995 | ControlInfo fileNum |
---|
1996 | Variable num = V_Value //run number to find |
---|
1997 | |
---|
1998 | fullname = FindFileFromRunNumber(num) |
---|
1999 | print fullname |
---|
2000 | //report error or change the file |
---|
2001 | if(cmpstr(fullname,"")==0) |
---|
2002 | Print "Convert - file not found" |
---|
2003 | else |
---|
2004 | //Print "Convert",fullname |
---|
2005 | ChangeBSXPos(fullName,-10) |
---|
2006 | Endif |
---|
2007 | return(0) |
---|
2008 | End |
---|
2009 | |
---|
2010 | //simple panel recreation macro |
---|
2011 | // |
---|
2012 | Proc Convert2Trans() |
---|
2013 | PauseUpdate; Silent 1 // building window... |
---|
2014 | NewPanel /W=(434,74,671,216) /K=1 |
---|
2015 | DoWindow/C Convert_to_Trans |
---|
2016 | SetDrawLayer UserBack |
---|
2017 | DrawText 18,22,"Convert files to be recognized" |
---|
2018 | DrawText 43,39,"as transmission files" |
---|
2019 | SetVariable fileNum,pos={43,58},size={130,15},title="File Number" |
---|
2020 | SetVariable fileNum,limits={1,Inf,1},value=root:myGlobals:gConvTrans |
---|
2021 | SetVariable fileNum,help={"Sets the run number of the file that is to be converted"} |
---|
2022 | Button ConvButton,pos={73,79},size={80,20},proc=ConvertButtonProc,title="Convert" |
---|
2023 | Button ConvButton,help={"Converts the chosen file to appear as a transmission file"} |
---|
2024 | Button UndoButton,pos={68,105},size={90,20},proc=UnConvertButtonProc,title="Un-Convert" |
---|
2025 | Button UndoButton,help={"Converts the chosen file to appear as a scattering file"} |
---|
2026 | EndMacro |
---|
2027 | |
---|
2028 | |
---|
2029 | ///// |
---|
2030 | // A quick way to fill all the T_EMP_Filenames with the selected empty beam file |
---|
2031 | // Note that you must go back and clear or reassign any files that are special cases |
---|
2032 | // |
---|
2033 | // IMPORTANT - this will overwrite any other file assignments (typically not a problem |
---|
2034 | // if you are using only one wavelength) |
---|
2035 | // |
---|
2036 | ///// |
---|
2037 | Function FillEMPFilenameWSelection() |
---|
2038 | |
---|
2039 | GetSelection table,TransFileTable,3 |
---|
2040 | Variable row=V_startRow //ony need the selected row, we know the column names and location |
---|
2041 | Wave/T fw = root:myGlobals:TransHeaderInfo:T_FileNames //trans files |
---|
2042 | Wave/T ew = root:myGlobals:TransHeaderInfo:T_EMP_FileNames //empty beam reference files |
---|
2043 | |
---|
2044 | ew[] = fw[row] |
---|
2045 | |
---|
2046 | return(0) |
---|
2047 | End |
---|
2048 | |
---|
2049 | //given a selection of the sample files, try to find the corresponding transmission file |
---|
2050 | // |
---|
2051 | Function GuessTransFile(charsToUse,row) |
---|
2052 | Variable charsToUse,row //number of characers to use from the beginning of the label, and the row of the sample file |
---|
2053 | |
---|
2054 | // GetSelection table,ScatterFileTable,3 |
---|
2055 | // Variable row=V_startRow //ony need the selected row, we know the column names and location |
---|
2056 | Wave/T sw = root:myGlobals:TransHeaderInfo:S_Labels //Sample file labels |
---|
2057 | Wave/T tw = root:myGlobals:TransHeaderInfo:T_Labels //trans file labels |
---|
2058 | Wave/T tnam = root:myGlobals:TransHeaderInfo:T_FileNames //trans file names |
---|
2059 | Wave/T snam = root:myGlobals:TransHeaderInfo:S_TRANS_FileNames //Scattering - trans correspondence |
---|
2060 | |
---|
2061 | Variable num,ii,found |
---|
2062 | String samStr = "",testStr="" |
---|
2063 | |
---|
2064 | samStr = (sw[row])[0,charsToUse-1] //string to try and match |
---|
2065 | samStr += "*" |
---|
2066 | // Print samStr |
---|
2067 | num=numpnts(tw) |
---|
2068 | ii=0 |
---|
2069 | do |
---|
2070 | testStr=tw[ii] |
---|
2071 | found = stringmatch(testStr, samStr ) |
---|
2072 | if(found == 1) |
---|
2073 | Print "Match Found at: ",samStr,tnam[ii],tw[ii] |
---|
2074 | snam[row] = tnam[ii] //write the file name into the table |
---|
2075 | return(0) |
---|
2076 | endif |
---|
2077 | ii+=1 |
---|
2078 | while(ii<num) |
---|
2079 | |
---|
2080 | //method 2 |
---|
2081 | // samStr = (sw[row])[0,charsToUse-1] //string to try and match |
---|
2082 | //// Print samStr |
---|
2083 | // num=numpnts(tw) |
---|
2084 | // ii=0 |
---|
2085 | // do |
---|
2086 | // testStr=tw[ii] |
---|
2087 | // found = strsearch(testStr,samStr,0) //start from zero, Need Igor 5 to allow 4th parameter to ignore case |
---|
2088 | // if(found != -1) |
---|
2089 | // Print "Match Found at: ",samStr,tnam[ii],tw[ii] |
---|
2090 | // snam[row] = tnam[ii] //write the file name into the table |
---|
2091 | // return(0) |
---|
2092 | // endif |
---|
2093 | // ii+=1 |
---|
2094 | // while(ii<num) |
---|
2095 | |
---|
2096 | Print "No Match found" |
---|
2097 | return(0) |
---|
2098 | End |
---|
2099 | |
---|
2100 | Function GuessAllTransFiles(numChars) |
---|
2101 | Variable numChars |
---|
2102 | |
---|
2103 | if(WinType("ScatterFileTable") ==0 ) |
---|
2104 | return(1) |
---|
2105 | endif |
---|
2106 | |
---|
2107 | Wave/T sw = root:myGlobals:TransHeaderInfo:S_Labels //Sample file labels |
---|
2108 | Variable ii,num=numpnts(sw) |
---|
2109 | |
---|
2110 | for(ii=0;ii<num;ii+=1) |
---|
2111 | GuessTransFile(numChars,ii) |
---|
2112 | endfor |
---|
2113 | |
---|
2114 | return(0) |
---|
2115 | End |
---|
2116 | |
---|
2117 | Function fGuessSelectedTransFiles(numChars) |
---|
2118 | Variable numChars |
---|
2119 | |
---|
2120 | Variable ii |
---|
2121 | Variable scatterTableExists |
---|
2122 | scatterTableExists = WinType("ScatterFileTable") |
---|
2123 | if (scatterTableExists != 0) |
---|
2124 | GetSelection table,ScatterFileTable,1 |
---|
2125 | for(ii=V_StartRow;ii<=V_EndRow;ii+=1) |
---|
2126 | GuessTransFile(numChars,ii) |
---|
2127 | endfor |
---|
2128 | else |
---|
2129 | Print "Transmission->Scattering File table is not open" |
---|
2130 | endif |
---|
2131 | return(0) |
---|
2132 | End |
---|
2133 | |
---|
2134 | Function ClearSelectedAssignments() |
---|
2135 | |
---|
2136 | Variable ii |
---|
2137 | Variable scatterTableExists |
---|
2138 | scatterTableExists = WinType("ScatterFileTable") |
---|
2139 | if (scatterTableExists != 0) |
---|
2140 | GetSelection table,ScatterFileTable,1 |
---|
2141 | fClearSelectedAssignments(V_startRow,V_endRow) |
---|
2142 | endif |
---|
2143 | return(0) |
---|
2144 | End |
---|