1 | #pragma TextEncoding = "MacRoman" // For details execute DisplayHelpTopic "The TextEncoding Pragma" |
---|
2 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
3 | |
---|
4 | |
---|
5 | // |
---|
6 | // Operation does no scaling, only the basic (default) trim of the ends, concatenate, sort, and save |
---|
7 | // -- if data has been converted to WORK and the solid angle correction was done, then the data |
---|
8 | // is per unit solid angle, and matches up - at least the simulated data does... |
---|
9 | // It should match up in real VSANS data since the flux conditions are identical for |
---|
10 | // all panels, only the geometry is different. |
---|
11 | // |
---|
12 | // |
---|
13 | // V_DataPlotting.ipf is where the I(q) panel is drawn and the binning is set |
---|
14 | // |
---|
15 | // see the VCALC BinAllMiddlePanels() for an example of this |
---|
16 | // see the binning routines in VC_DetectorBinning_Utils.ipf for the details |
---|
17 | // |
---|
18 | |
---|
19 | // TODO |
---|
20 | // |
---|
21 | // -- verify the binning for slit mode. Looks correct, but verify |
---|
22 | // -- DOCUMENT |
---|
23 | // |
---|
24 | // x- detector "B" is currently skipped since the calibration waves are not faked |
---|
25 | // when the raw data is loaded. Then the qxqyqz waves are not generated. |
---|
26 | // |
---|
27 | // x- REDO the logic here. It's a mess, and will get the calculation wrong |
---|
28 | // |
---|
29 | // x- figure out the binning type (where is it set for VSANS?) |
---|
30 | // x- don't know, so currently VSANS binning type is HARD-WIRED |
---|
31 | // x- figure out when this needs to be called to (force) re-calculate I vs Q |
---|
32 | // |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | // |
---|
37 | // NOTE |
---|
38 | // this is the master conversion function |
---|
39 | // ***Use no others |
---|
40 | // *** When other bin types are developed, DO NOT reassign these numbers. |
---|
41 | // instead, skip the old numbers and assign new ones. |
---|
42 | // old modes can be removed from the string constant ksBinTypeStr (above), but the |
---|
43 | // mode numbers are what many different binning, plotting, and reduction functions are |
---|
44 | // switching on. In the future, it may be necessary to change the key (everywhere) to a string |
---|
45 | // switch, but for now, stick with the numbers. |
---|
46 | Function V_BinTypeStr2Num(binStr) |
---|
47 | String binStr |
---|
48 | |
---|
49 | Variable binType |
---|
50 | strswitch(binStr) // string switch |
---|
51 | case "One": |
---|
52 | binType = 1 |
---|
53 | break // exit from switch |
---|
54 | case "Two": |
---|
55 | binType = 2 |
---|
56 | break // exit from switch |
---|
57 | case "Four": |
---|
58 | binType = 3 |
---|
59 | break // exit from switch |
---|
60 | case "Slit Mode": |
---|
61 | binType = 4 |
---|
62 | break // exit from switch |
---|
63 | |
---|
64 | default: // optional default expression executed |
---|
65 | binType = 0 |
---|
66 | Abort "Binning mode not found"// when no case matches |
---|
67 | endswitch |
---|
68 | return(binType) |
---|
69 | end |
---|
70 | |
---|
71 | // |
---|
72 | // TODO -- binType == 4 (slit mode) should never end up here |
---|
73 | // -- new logic in calling routines to dispatch to proper routine |
---|
74 | // -- AND need to write the routine for binning_SlitMode |
---|
75 | // |
---|
76 | Function V_QBinAllPanels_Circular(folderStr,binType) |
---|
77 | String folderStr |
---|
78 | Variable binType |
---|
79 | |
---|
80 | // do the back, middle, and front separately |
---|
81 | |
---|
82 | // figure out the binning type (where is it set?) |
---|
83 | Variable ii,delQ |
---|
84 | String detStr |
---|
85 | |
---|
86 | // binType = V_GetBinningPopMode() |
---|
87 | |
---|
88 | //// TODO: |
---|
89 | // |
---|
90 | // Back detector is handled spearately since there is nothing to combine |
---|
91 | // |
---|
92 | delQ = SetDeltaQ(folderStr,"B") |
---|
93 | |
---|
94 | // dispatch based on binning type |
---|
95 | if(binType == 1 || binType == 2 || binType == 3) |
---|
96 | VC_fDoBinning_QxQy2D(folderStr, "B") //normal binning, nothing to combine |
---|
97 | endif |
---|
98 | |
---|
99 | // TODO -- this is only a temporary fix for slit mode |
---|
100 | if(binType == 4) |
---|
101 | /// this is for a tall, narrow slit mode |
---|
102 | VC_fBinDetector_byRows(folderStr,"B") |
---|
103 | endif |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | // these are the binning types where detectors are not combined |
---|
108 | // other combined binning is below the loop |
---|
109 | for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) |
---|
110 | detStr = StringFromList(ii, ksDetectorListNoB, ";") |
---|
111 | |
---|
112 | // set delta Q for binning |
---|
113 | delQ = SetDeltaQ(folderStr,detStr) |
---|
114 | |
---|
115 | // dispatch based on binning type |
---|
116 | if(binType==1) |
---|
117 | VC_fDoBinning_QxQy2D(folderStr,detStr) |
---|
118 | endif |
---|
119 | |
---|
120 | // TODO -- this is only a temporary fix for slit mode |
---|
121 | if(binType == 4) |
---|
122 | /// this is for a tall, narrow slit mode |
---|
123 | VC_fBinDetector_byRows(folderStr,detStr) |
---|
124 | endif |
---|
125 | |
---|
126 | endfor |
---|
127 | |
---|
128 | // bin in pairs |
---|
129 | if(binType == 2) |
---|
130 | VC_fDoBinning_QxQy2D(folderStr,"MLR") |
---|
131 | VC_fDoBinning_QxQy2D(folderStr,"MTB") |
---|
132 | VC_fDoBinning_QxQy2D(folderStr,"FLR") |
---|
133 | VC_fDoBinning_QxQy2D(folderStr,"FTB") |
---|
134 | endif |
---|
135 | |
---|
136 | // bin everything on front or middle together |
---|
137 | if(binType == 3) |
---|
138 | VC_fDoBinning_QxQy2D(folderStr,"MLRTB") |
---|
139 | VC_fDoBinning_QxQy2D(folderStr,"FLRTB") |
---|
140 | endif |
---|
141 | |
---|
142 | return(0) |
---|
143 | End |
---|
144 | |
---|
145 | // concatenates and sorts the 1D data in "type" WORK folder |
---|
146 | // uses the current display if type=="" |
---|
147 | // |
---|
148 | Function V_ConcatenateForSave(pathStr,type,tagStr,binType) |
---|
149 | String pathStr,type,tagStr |
---|
150 | Variable binType |
---|
151 | |
---|
152 | // get the current display type, if null string passed in |
---|
153 | SVAR curtype = root:Packages:NIST:VSANS:Globals:gCurDispType |
---|
154 | |
---|
155 | if(strlen(type)==0) |
---|
156 | type = curType |
---|
157 | endif |
---|
158 | |
---|
159 | // trim the data if needed |
---|
160 | // remove the q=0 point from the back detector, if it's there |
---|
161 | // does not need to know binType |
---|
162 | V_RemoveQ0_B(type) |
---|
163 | |
---|
164 | // concatenate the data sets |
---|
165 | // TODO x- figure out which binning was used (this is done in V_1DConcatenate()) |
---|
166 | // clear the old tmp waves first, if they still exist |
---|
167 | // SetDataFolder $("root:Packages:NIST:VSANS:"+type) |
---|
168 | SetDataFolder $(pathStr+type) |
---|
169 | Killwaves/Z tmp_q,tmp_i,tmp_s,tmp_sq,tmp_qb,tmp_fs |
---|
170 | setDataFolder root: |
---|
171 | V_1DConcatenate(pathStr,type,tagStr,binType) |
---|
172 | |
---|
173 | // sort the data set |
---|
174 | V_TmpSort1D(pathStr,type) |
---|
175 | |
---|
176 | return(0) |
---|
177 | End |
---|
178 | |
---|
179 | // |
---|
180 | // this is only called from the button on the data panel (**not anymore**) |
---|
181 | // so the type is the currently displayed type, and the binning is from the panel |
---|
182 | // |
---|
183 | Function V_SimpleSave1DData(pathStr,type,tagStr,saveName) |
---|
184 | String pathStr,type,tagStr,saveName |
---|
185 | |
---|
186 | // |
---|
187 | // get the current display type, if null string passed in |
---|
188 | SVAR curtype = root:Packages:NIST:VSANS:Globals:gCurDispType |
---|
189 | Variable binType = V_GetBinningPopMode() |
---|
190 | |
---|
191 | V_ConcatenateForSave(pathStr,curType,tagStr,binType) |
---|
192 | |
---|
193 | // write out the data set to a file |
---|
194 | if(strlen(saveName)==0) |
---|
195 | Execute "V_GetNameForSave()" |
---|
196 | SVAR newName = root:saveName |
---|
197 | saveName = newName |
---|
198 | endif |
---|
199 | |
---|
200 | V_Write1DData(pathStr,curtype,saveName) |
---|
201 | |
---|
202 | End |
---|
203 | |
---|
204 | |
---|
205 | Proc V_GetNameForSave(str) |
---|
206 | String str |
---|
207 | String/G root:saveName=str |
---|
208 | End |
---|
209 | |
---|
210 | |
---|
211 | // blindly assumes that there is only one zero at the top of the wave |
---|
212 | // could be more sophisticated in the future... |
---|
213 | Function V_RemoveQ0_B(type) |
---|
214 | String type |
---|
215 | |
---|
216 | SetDataFolder $("root:Packages:NIST:VSANS:"+type) |
---|
217 | |
---|
218 | WAVE/Z qBin = qBin_qxqy_B |
---|
219 | WAVE/Z iBin = iBin_qxqy_B |
---|
220 | WAVE/Z eBin = eBin_qxqy_B |
---|
221 | WAVE/Z nBin = nBin_qxqy_B |
---|
222 | WAVE/Z iBin2 = iBin2_qxqy_B |
---|
223 | |
---|
224 | // resolution waves |
---|
225 | Wave/Z sigQ = sigmaQ_qxqy_B |
---|
226 | Wave/Z qBar = qBar_qxqy_B |
---|
227 | Wave/Z fSubS = fSubS_qxqy_B |
---|
228 | |
---|
229 | if(qBin[0] == 0) |
---|
230 | DeletePoints 0, 1, qBin,iBin,eBin,nBin,iBin2,sigQ,qBar,fSubS |
---|
231 | endif |
---|
232 | |
---|
233 | SetDataFolder root: |
---|
234 | return(0) |
---|
235 | end |
---|
236 | |
---|
237 | |
---|
238 | // concatentate data in folderStr |
---|
239 | // |
---|
240 | // TODO: |
---|
241 | // -- !!! Resolution waves are currently skipped - these must be added |
---|
242 | // |
---|
243 | // x- this currently ignores the binning type (one, two, etc. ) |
---|
244 | // x- change the Concatenate call to use the waveList, to eliminate the need to declare all of the waves |
---|
245 | // -- this currently assumes that all of the waves exist |
---|
246 | // -- need robust error checking for wave existence |
---|
247 | // -- wave names are hard-wired and their name and location may be different in the future |
---|
248 | // x- if different averaging options were chosen (bin type of 2, 4 etc) then |
---|
249 | // although waves may exist, they may not be the right ones to use. There |
---|
250 | // will be a somewhat complex selection process |
---|
251 | // x- detector B is currently skipped |
---|
252 | // |
---|
253 | // this seems like a lot of extra work to do something so simple...but it's better than a loop |
---|
254 | // |
---|
255 | // root:Packages:NIST:VSANS:RAW:iBin_qxqy_FB |
---|
256 | // |
---|
257 | // binType = 1 = one |
---|
258 | // binType = 2 = two |
---|
259 | // binType = 3 = four |
---|
260 | // binType = 4 = Slit Mode |
---|
261 | // |
---|
262 | // if binType is passed in as -9999, get the binning mode from the popup |
---|
263 | // otherwise the value is assumed good (from a protocol) |
---|
264 | // |
---|
265 | // pathStr must have the trailing colon |
---|
266 | // tagStr is normally null, but is "_trim" for data to be trimmed |
---|
267 | // |
---|
268 | Function V_1DConcatenate(pathStr,folderStr,tagStr,binType) |
---|
269 | String pathStr,folderStr,tagStr |
---|
270 | Variable binType |
---|
271 | |
---|
272 | if(binType==-9999) |
---|
273 | binType = V_GetBinningPopMode() |
---|
274 | endif |
---|
275 | |
---|
276 | // SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) |
---|
277 | SetDataFolder $(pathStr+folderStr) |
---|
278 | |
---|
279 | //kill these waves before starting, or the new concatenation will be added to the old |
---|
280 | KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_qb,tmp_sq,tmp_fs |
---|
281 | |
---|
282 | NVAR gIgnoreDetB = root:Packages:NIST:VSANS:Globals:gIgnoreDetB |
---|
283 | |
---|
284 | String waveListStr="" |
---|
285 | if(binType == 1) |
---|
286 | // q-values |
---|
287 | waveListStr="" |
---|
288 | if(!gIgnoreDetB) |
---|
289 | waveListStr = "qBin_qxqy_B" + tagStr + ";" |
---|
290 | endif |
---|
291 | waveListStr += "qBin_qxqy_MB" + tagStr + ";" |
---|
292 | waveListStr += "qBin_qxqy_MT" + tagStr + ";" |
---|
293 | waveListStr += "qBin_qxqy_ML" + tagStr + ";" |
---|
294 | waveListStr += "qBin_qxqy_MR" + tagStr + ";" |
---|
295 | waveListStr += "qBin_qxqy_FB" + tagStr + ";" |
---|
296 | waveListStr += "qBin_qxqy_FT" + tagStr + ";" |
---|
297 | waveListStr += "qBin_qxqy_FL" + tagStr + ";" |
---|
298 | waveListStr += "qBin_qxqy_FR" + tagStr + ";" |
---|
299 | |
---|
300 | Concatenate/NP/O waveListStr, tmp_q |
---|
301 | |
---|
302 | //intensity |
---|
303 | waveListStr="" |
---|
304 | if(!gIgnoreDetB) |
---|
305 | waveListStr = "iBin_qxqy_B" + tagStr + ";" |
---|
306 | endif |
---|
307 | waveListStr += "iBin_qxqy_MB" + tagStr + ";" |
---|
308 | waveListStr += "iBin_qxqy_MT" + tagStr + ";" |
---|
309 | waveListStr += "iBin_qxqy_ML" + tagStr + ";" |
---|
310 | waveListStr += "iBin_qxqy_MR" + tagStr + ";" |
---|
311 | waveListStr += "iBin_qxqy_FB" + tagStr + ";" |
---|
312 | waveListStr += "iBin_qxqy_FT" + tagStr + ";" |
---|
313 | waveListStr += "iBin_qxqy_FL" + tagStr + ";" |
---|
314 | waveListStr += "iBin_qxqy_FR" + tagStr + ";" |
---|
315 | // waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" |
---|
316 | // waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" |
---|
317 | |
---|
318 | Concatenate/NP/O waveListStr, tmp_i |
---|
319 | |
---|
320 | //error |
---|
321 | waveListStr="" |
---|
322 | if(!gIgnoreDetB) |
---|
323 | waveListStr = "eBin_qxqy_B" + tagStr + ";" |
---|
324 | endif |
---|
325 | waveListStr += "eBin_qxqy_MB" + tagStr + ";" |
---|
326 | waveListStr += "eBin_qxqy_MT" + tagStr + ";" |
---|
327 | waveListStr += "eBin_qxqy_ML" + tagStr + ";" |
---|
328 | waveListStr += "eBin_qxqy_MR" + tagStr + ";" |
---|
329 | waveListStr += "eBin_qxqy_FB" + tagStr + ";" |
---|
330 | waveListStr += "eBin_qxqy_FT" + tagStr + ";" |
---|
331 | waveListStr += "eBin_qxqy_FL" + tagStr + ";" |
---|
332 | waveListStr += "eBin_qxqy_FR" + tagStr + ";" |
---|
333 | // waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" |
---|
334 | // waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" |
---|
335 | |
---|
336 | Concatenate/NP/O waveListStr, tmp_s |
---|
337 | |
---|
338 | //sigma Q |
---|
339 | waveListStr="" |
---|
340 | if(!gIgnoreDetB) |
---|
341 | waveListStr = "sigmaQ_qxqy_B" + tagStr + ";" |
---|
342 | endif |
---|
343 | waveListStr += "sigmaQ_qxqy_MB" + tagStr + ";" |
---|
344 | waveListStr += "sigmaQ_qxqy_MT" + tagStr + ";" |
---|
345 | waveListStr += "sigmaQ_qxqy_ML" + tagStr + ";" |
---|
346 | waveListStr += "sigmaQ_qxqy_MR" + tagStr + ";" |
---|
347 | waveListStr += "sigmaQ_qxqy_FB" + tagStr + ";" |
---|
348 | waveListStr += "sigmaQ_qxqy_FT" + tagStr + ";" |
---|
349 | waveListStr += "sigmaQ_qxqy_FL" + tagStr + ";" |
---|
350 | waveListStr += "sigmaQ_qxqy_FR" + tagStr + ";" |
---|
351 | // waveListStr = "sigmaQ_qxqy_B;sigmaQ_qxqy_MB;sigmaQ_qxqy_MT;sigmaQ_qxqy_ML;sigmaQ_qxqy_MR;" |
---|
352 | // waveListStr += "sigmaQ_qxqy_FB;sigmaQ_qxqy_FT;sigmaQ_qxqy_FL;sigmaQ_qxqy_FR;" |
---|
353 | |
---|
354 | Concatenate/NP/O waveListStr, tmp_sq |
---|
355 | |
---|
356 | //Q bar |
---|
357 | waveListStr="" |
---|
358 | if(!gIgnoreDetB) |
---|
359 | waveListStr = "qBar_qxqy_B" + tagStr + ";" |
---|
360 | endif |
---|
361 | waveListStr += "qBar_qxqy_MB" + tagStr + ";" |
---|
362 | waveListStr += "qBar_qxqy_MT" + tagStr + ";" |
---|
363 | waveListStr += "qBar_qxqy_ML" + tagStr + ";" |
---|
364 | waveListStr += "qBar_qxqy_MR" + tagStr + ";" |
---|
365 | waveListStr += "qBar_qxqy_FB" + tagStr + ";" |
---|
366 | waveListStr += "qBar_qxqy_FT" + tagStr + ";" |
---|
367 | waveListStr += "qBar_qxqy_FL" + tagStr + ";" |
---|
368 | waveListStr += "qBar_qxqy_FR" + tagStr + ";" |
---|
369 | // waveListStr = "qBar_qxqy_B;qBar_qxqy_MB;qBar_qxqy_MT;qBar_qxqy_ML;qBar_qxqy_MR;" |
---|
370 | // waveListStr += "qBar_qxqy_FB;qBar_qxqy_FT;qBar_qxqy_FL;qBar_qxqy_FR;" |
---|
371 | |
---|
372 | Concatenate/NP/O waveListStr, tmp_qb |
---|
373 | |
---|
374 | //shadow fs |
---|
375 | waveListStr="" |
---|
376 | if(!gIgnoreDetB) |
---|
377 | waveListStr = "fSubS_qxqy_B" + tagStr + ";" |
---|
378 | endif |
---|
379 | waveListStr += "fSubS_qxqy_MB" + tagStr + ";" |
---|
380 | waveListStr += "fSubS_qxqy_MT" + tagStr + ";" |
---|
381 | waveListStr += "fSubS_qxqy_ML" + tagStr + ";" |
---|
382 | waveListStr += "fSubS_qxqy_MR" + tagStr + ";" |
---|
383 | waveListStr += "fSubS_qxqy_FB" + tagStr + ";" |
---|
384 | waveListStr += "fSubS_qxqy_FT" + tagStr + ";" |
---|
385 | waveListStr += "fSubS_qxqy_FL" + tagStr + ";" |
---|
386 | waveListStr += "fSubS_qxqy_FR" + tagStr + ";" |
---|
387 | // waveListStr = "fSubS_qxqy_B;fSubS_qxqy_MB;fSubS_qxqy_MT;fSubS_qxqy_ML;fSubS_qxqy_MR;" |
---|
388 | // waveListStr += "fSubS_qxqy_FB;fSubS_qxqy_FT;fSubS_qxqy_FL;fSubS_qxqy_FR;" |
---|
389 | |
---|
390 | Concatenate/NP/O waveListStr, tmp_fs |
---|
391 | |
---|
392 | endif |
---|
393 | |
---|
394 | if(binType == 2) |
---|
395 | // q-values |
---|
396 | waveListStr="" |
---|
397 | if(!gIgnoreDetB) |
---|
398 | waveListStr = "qBin_qxqy_B" + tagStr + ";" |
---|
399 | endif |
---|
400 | waveListStr += "qBin_qxqy_MTB" + tagStr + ";" |
---|
401 | waveListStr += "qBin_qxqy_MLR" + tagStr + ";" |
---|
402 | waveListStr += "qBin_qxqy_FTB" + tagStr + ";" |
---|
403 | waveListStr += "qBin_qxqy_FLR" + tagStr + ";" |
---|
404 | |
---|
405 | // waveListStr = "qBin_qxqy_B;qBin_qxqy_MTB;qBin_qxqy_MLR;" |
---|
406 | // waveListStr += "qBin_qxqy_FTB;qBin_qxqy_FLR;" |
---|
407 | |
---|
408 | Concatenate/NP/O waveListStr, tmp_q |
---|
409 | |
---|
410 | //intensity |
---|
411 | waveListStr="" |
---|
412 | if(!gIgnoreDetB) |
---|
413 | waveListStr = "iBin_qxqy_B" + tagStr + ";" |
---|
414 | endif |
---|
415 | waveListStr += "iBin_qxqy_MTB" + tagStr + ";" |
---|
416 | waveListStr += "iBin_qxqy_MLR" + tagStr + ";" |
---|
417 | waveListStr += "iBin_qxqy_FTB" + tagStr + ";" |
---|
418 | waveListStr += "iBin_qxqy_FLR" + tagStr + ";" |
---|
419 | |
---|
420 | // waveListStr = "iBin_qxqy_B;iBin_qxqy_MTB;iBin_qxqy_MLR;" |
---|
421 | // waveListStr += "iBin_qxqy_FTB;iBin_qxqy_FLR;" |
---|
422 | |
---|
423 | Concatenate/NP/O waveListStr, tmp_i |
---|
424 | |
---|
425 | //error |
---|
426 | waveListStr="" |
---|
427 | if(!gIgnoreDetB) |
---|
428 | waveListStr = "eBin_qxqy_B" + tagStr + ";" |
---|
429 | endif |
---|
430 | waveListStr += "eBin_qxqy_MTB" + tagStr + ";" |
---|
431 | waveListStr += "eBin_qxqy_MLR" + tagStr + ";" |
---|
432 | waveListStr += "eBin_qxqy_FTB" + tagStr + ";" |
---|
433 | waveListStr += "eBin_qxqy_FLR" + tagStr + ";" |
---|
434 | |
---|
435 | // waveListStr = "eBin_qxqy_B;eBin_qxqy_MTB;eBin_qxqy_MLR;" |
---|
436 | // waveListStr += "eBin_qxqy_FTB;eBin_qxqy_FLR;" |
---|
437 | |
---|
438 | Concatenate/NP/O waveListStr, tmp_s |
---|
439 | |
---|
440 | // sigma Q |
---|
441 | waveListStr="" |
---|
442 | if(!gIgnoreDetB) |
---|
443 | waveListStr = "sigmaQ_qxqy_B" + tagStr + ";" |
---|
444 | endif |
---|
445 | waveListStr += "sigmaQ_qxqy_MTB" + tagStr + ";" |
---|
446 | waveListStr += "sigmaQ_qxqy_MLR" + tagStr + ";" |
---|
447 | waveListStr += "sigmaQ_qxqy_FTB" + tagStr + ";" |
---|
448 | waveListStr += "sigmaQ_qxqy_FLR" + tagStr + ";" |
---|
449 | |
---|
450 | // waveListStr = "sigmaQ_qxqy_B;sigmaQ_qxqy_MTB;sigmaQ_qxqy_MLR;" |
---|
451 | // waveListStr += "sigmaQ_qxqy_FTB;sigmaQ_qxqy_FLR;" |
---|
452 | |
---|
453 | Concatenate/NP/O waveListStr, tmp_sq |
---|
454 | |
---|
455 | // Q bar |
---|
456 | waveListStr="" |
---|
457 | if(!gIgnoreDetB) |
---|
458 | waveListStr = "qBar_qxqy_B" + tagStr + ";" |
---|
459 | endif |
---|
460 | waveListStr += "qBar_qxqy_MTB" + tagStr + ";" |
---|
461 | waveListStr += "qBar_qxqy_MLR" + tagStr + ";" |
---|
462 | waveListStr += "qBar_qxqy_FTB" + tagStr + ";" |
---|
463 | waveListStr += "qBar_qxqy_FLR" + tagStr + ";" |
---|
464 | |
---|
465 | // waveListStr = "qBar_qxqy_B;qBar_qxqy_MTB;qBar_qxqy_MLR;" |
---|
466 | // waveListStr += "qBar_qxqy_FTB;qBar_qxqy_FLR;" |
---|
467 | |
---|
468 | Concatenate/NP/O waveListStr, tmp_qb |
---|
469 | |
---|
470 | // shadow fs |
---|
471 | waveListStr="" |
---|
472 | if(!gIgnoreDetB) |
---|
473 | waveListStr = "fSubS_qxqy_B" + tagStr + ";" |
---|
474 | endif |
---|
475 | waveListStr += "fSubS_qxqy_MTB" + tagStr + ";" |
---|
476 | waveListStr += "fSubS_qxqy_MLR" + tagStr + ";" |
---|
477 | waveListStr += "fSubS_qxqy_FTB" + tagStr + ";" |
---|
478 | waveListStr += "fSubS_qxqy_FLR" + tagStr + ";" |
---|
479 | |
---|
480 | // waveListStr = "fSubS_qxqy_B;fSubS_qxqy_MTB;fSubS_qxqy_MLR;" |
---|
481 | // waveListStr += "fSubS_qxqy_FTB;fSubS_qxqy_FLR;" |
---|
482 | |
---|
483 | Concatenate/NP/O waveListStr, tmp_fs |
---|
484 | |
---|
485 | endif |
---|
486 | |
---|
487 | if(binType == 3) |
---|
488 | // q-values |
---|
489 | waveListStr="" |
---|
490 | if(!gIgnoreDetB) |
---|
491 | waveListStr = "qBin_qxqy_B" + tagStr + ";" |
---|
492 | endif |
---|
493 | waveListStr += "qBin_qxqy_MLRTB" + tagStr + ";" |
---|
494 | waveListStr += "qBin_qxqy_FLRTB" + tagStr + ";" |
---|
495 | |
---|
496 | // waveListStr = "qBin_qxqy_B;qBin_qxqy_MLRTB;qBin_qxqy_FLRTB;" |
---|
497 | |
---|
498 | Concatenate/NP/O waveListStr, tmp_q |
---|
499 | |
---|
500 | //intensity |
---|
501 | waveListStr="" |
---|
502 | if(!gIgnoreDetB) |
---|
503 | waveListStr = "iBin_qxqy_B" + tagStr + ";" |
---|
504 | endif |
---|
505 | waveListStr += "iBin_qxqy_MLRTB" + tagStr + ";" |
---|
506 | waveListStr += "iBin_qxqy_FLRTB" + tagStr + ";" |
---|
507 | |
---|
508 | // waveListStr = "iBin_qxqy_B;iBin_qxqy_MLRTB;iBin_qxqy_FLRTB;" |
---|
509 | |
---|
510 | Concatenate/NP/O waveListStr, tmp_i |
---|
511 | |
---|
512 | //error |
---|
513 | waveListStr="" |
---|
514 | if(!gIgnoreDetB) |
---|
515 | waveListStr = "eBin_qxqy_B" + tagStr + ";" |
---|
516 | endif |
---|
517 | waveListStr += "eBin_qxqy_MLRTB" + tagStr + ";" |
---|
518 | waveListStr += "eBin_qxqy_FLRTB" + tagStr + ";" |
---|
519 | |
---|
520 | // waveListStr = "eBin_qxqy_B;eBin_qxqy_MLRTB;eBin_qxqy_FLRTB;" |
---|
521 | |
---|
522 | Concatenate/NP/O waveListStr, tmp_s |
---|
523 | |
---|
524 | // sigma Q |
---|
525 | waveListStr="" |
---|
526 | if(!gIgnoreDetB) |
---|
527 | waveListStr = "sigmaQ_qxqy_B" + tagStr + ";" |
---|
528 | endif |
---|
529 | waveListStr += "sigmaQ_qxqy_MLRTB" + tagStr + ";" |
---|
530 | waveListStr += "sigmaQ_qxqy_FLRTB" + tagStr + ";" |
---|
531 | |
---|
532 | // waveListStr = "sigmaQ_qxqy_B;sigmaQ_qxqy_MLRTB;sigmaQ_qxqy_FLRTB;" |
---|
533 | |
---|
534 | Concatenate/NP/O waveListStr, tmp_sq |
---|
535 | |
---|
536 | // Q bar |
---|
537 | waveListStr="" |
---|
538 | if(!gIgnoreDetB) |
---|
539 | waveListStr = "qBar_qxqy_B" + tagStr + ";" |
---|
540 | endif |
---|
541 | waveListStr += "qBar_qxqy_MLRTB" + tagStr + ";" |
---|
542 | waveListStr += "qBar_qxqy_FLRTB" + tagStr + ";" |
---|
543 | |
---|
544 | // waveListStr = "qBar_qxqy_B;qBar_qxqy_MLRTB;qBar_qxqy_FLRTB;" |
---|
545 | |
---|
546 | Concatenate/NP/O waveListStr, tmp_qb |
---|
547 | |
---|
548 | // shadow fs |
---|
549 | waveListStr="" |
---|
550 | if(!gIgnoreDetB) |
---|
551 | waveListStr = "fSubS_qxqy_B" + tagStr + ";" |
---|
552 | endif |
---|
553 | waveListStr += "fSubS_qxqy_MLRTB" + tagStr + ";" |
---|
554 | waveListStr += "fSubS_qxqy_FLRTB" + tagStr + ";" |
---|
555 | |
---|
556 | // waveListStr = "fSubS_qxqy_B;fSubS_qxqy_MLRTB;fSubS_qxqy_FLRTB;" |
---|
557 | |
---|
558 | Concatenate/NP/O waveListStr, tmp_fs |
---|
559 | endif |
---|
560 | |
---|
561 | // TODO - This is the identical set of waves as for the case of binType = 1. |
---|
562 | // they have the same names, but are averaged differently since it's slit mode. |
---|
563 | // I have separated this, since in practice the TB panels are probably best to ignore |
---|
564 | // and NOT include in the averaging since the Qy range is so limited. |
---|
565 | if(binType == 4) |
---|
566 | // q-values |
---|
567 | waveListStr="" |
---|
568 | if(!gIgnoreDetB) |
---|
569 | waveListStr = "qBin_qxqy_B" + tagStr + ";" |
---|
570 | endif |
---|
571 | // waveListStr += "qBin_qxqy_MB" + tagStr + ";" |
---|
572 | // waveListStr += "qBin_qxqy_MT" + tagStr + ";" |
---|
573 | waveListStr += "qBin_qxqy_ML" + tagStr + ";" |
---|
574 | waveListStr += "qBin_qxqy_MR" + tagStr + ";" |
---|
575 | // waveListStr += "qBin_qxqy_FB" + tagStr + ";" |
---|
576 | // waveListStr += "qBin_qxqy_FT" + tagStr + ";" |
---|
577 | waveListStr += "qBin_qxqy_FL" + tagStr + ";" |
---|
578 | waveListStr += "qBin_qxqy_FR" + tagStr + ";" |
---|
579 | // waveListStr = "qBin_qxqy_B;qBin_qxqy_MB;qBin_qxqy_MT;qBin_qxqy_ML;qBin_qxqy_MR;" |
---|
580 | // waveListStr += "qBin_qxqy_FB;qBin_qxqy_FT;qBin_qxqy_FL;qBin_qxqy_FR;" |
---|
581 | |
---|
582 | Concatenate/NP/O waveListStr, tmp_q |
---|
583 | |
---|
584 | //intensity |
---|
585 | waveListStr="" |
---|
586 | if(!gIgnoreDetB) |
---|
587 | waveListStr = "iBin_qxqy_B" + tagStr + ";" |
---|
588 | endif |
---|
589 | // waveListStr += "iBin_qxqy_MB" + tagStr + ";" |
---|
590 | // waveListStr += "iBin_qxqy_MT" + tagStr + ";" |
---|
591 | waveListStr += "iBin_qxqy_ML" + tagStr + ";" |
---|
592 | waveListStr += "iBin_qxqy_MR" + tagStr + ";" |
---|
593 | // waveListStr += "iBin_qxqy_FB" + tagStr + ";" |
---|
594 | // waveListStr += "iBin_qxqy_FT" + tagStr + ";" |
---|
595 | waveListStr += "iBin_qxqy_FL" + tagStr + ";" |
---|
596 | waveListStr += "iBin_qxqy_FR" + tagStr + ";" |
---|
597 | // waveListStr = "iBin_qxqy_B;iBin_qxqy_MB;iBin_qxqy_MT;iBin_qxqy_ML;iBin_qxqy_MR;" |
---|
598 | // waveListStr += "iBin_qxqy_FB;iBin_qxqy_FT;iBin_qxqy_FL;iBin_qxqy_FR;" |
---|
599 | |
---|
600 | Concatenate/NP/O waveListStr, tmp_i |
---|
601 | |
---|
602 | //error |
---|
603 | waveListStr="" |
---|
604 | if(!gIgnoreDetB) |
---|
605 | waveListStr = "eBin_qxqy_B" + tagStr + ";" |
---|
606 | endif |
---|
607 | // waveListStr += "eBin_qxqy_MB" + tagStr + ";" |
---|
608 | // waveListStr += "eBin_qxqy_MT" + tagStr + ";" |
---|
609 | waveListStr += "eBin_qxqy_ML" + tagStr + ";" |
---|
610 | waveListStr += "eBin_qxqy_MR" + tagStr + ";" |
---|
611 | // waveListStr += "eBin_qxqy_FB" + tagStr + ";" |
---|
612 | // waveListStr += "eBin_qxqy_FT" + tagStr + ";" |
---|
613 | waveListStr += "eBin_qxqy_FL" + tagStr + ";" |
---|
614 | waveListStr += "eBin_qxqy_FR" + tagStr + ";" |
---|
615 | // waveListStr = "eBin_qxqy_B;eBin_qxqy_MB;eBin_qxqy_MT;eBin_qxqy_ML;eBin_qxqy_MR;" |
---|
616 | // waveListStr += "eBin_qxqy_FB;eBin_qxqy_FT;eBin_qxqy_FL;eBin_qxqy_FR;" |
---|
617 | |
---|
618 | Concatenate/NP/O waveListStr, tmp_s |
---|
619 | |
---|
620 | //sigma Q |
---|
621 | waveListStr="" |
---|
622 | if(!gIgnoreDetB) |
---|
623 | waveListStr = "sigmaQ_qxqy_B" + tagStr + ";" |
---|
624 | endif |
---|
625 | // waveListStr += "sigmaQ_qxqy_MB" + tagStr + ";" |
---|
626 | // waveListStr += "sigmaQ_qxqy_MT" + tagStr + ";" |
---|
627 | waveListStr += "sigmaQ_qxqy_ML" + tagStr + ";" |
---|
628 | waveListStr += "sigmaQ_qxqy_MR" + tagStr + ";" |
---|
629 | // waveListStr += "sigmaQ_qxqy_FB" + tagStr + ";" |
---|
630 | // waveListStr += "sigmaQ_qxqy_FT" + tagStr + ";" |
---|
631 | waveListStr += "sigmaQ_qxqy_FL" + tagStr + ";" |
---|
632 | waveListStr += "sigmaQ_qxqy_FR" + tagStr + ";" |
---|
633 | // waveListStr = "sigmaQ_qxqy_B;sigmaQ_qxqy_MB;sigmaQ_qxqy_MT;sigmaQ_qxqy_ML;sigmaQ_qxqy_MR;" |
---|
634 | // waveListStr += "sigmaQ_qxqy_FB;sigmaQ_qxqy_FT;sigmaQ_qxqy_FL;sigmaQ_qxqy_FR;" |
---|
635 | |
---|
636 | Concatenate/NP/O waveListStr, tmp_sq |
---|
637 | |
---|
638 | //Q bar |
---|
639 | waveListStr="" |
---|
640 | if(!gIgnoreDetB) |
---|
641 | waveListStr = "qBar_qxqy_B" + tagStr + ";" |
---|
642 | endif |
---|
643 | // waveListStr += "qBar_qxqy_MB" + tagStr + ";" |
---|
644 | // waveListStr += "qBar_qxqy_MT" + tagStr + ";" |
---|
645 | waveListStr += "qBar_qxqy_ML" + tagStr + ";" |
---|
646 | waveListStr += "qBar_qxqy_MR" + tagStr + ";" |
---|
647 | // waveListStr += "qBar_qxqy_FB" + tagStr + ";" |
---|
648 | // waveListStr += "qBar_qxqy_FT" + tagStr + ";" |
---|
649 | waveListStr += "qBar_qxqy_FL" + tagStr + ";" |
---|
650 | waveListStr += "qBar_qxqy_FR" + tagStr + ";" |
---|
651 | // waveListStr = "qBar_qxqy_B;qBar_qxqy_MB;qBar_qxqy_MT;qBar_qxqy_ML;qBar_qxqy_MR;" |
---|
652 | // waveListStr += "qBar_qxqy_FB;qBar_qxqy_FT;qBar_qxqy_FL;qBar_qxqy_FR;" |
---|
653 | |
---|
654 | Concatenate/NP/O waveListStr, tmp_qb |
---|
655 | |
---|
656 | //shadow fs |
---|
657 | waveListStr="" |
---|
658 | if(!gIgnoreDetB) |
---|
659 | waveListStr = "fSubS_qxqy_B" + tagStr + ";" |
---|
660 | endif |
---|
661 | // waveListStr += "fSubS_qxqy_MB" + tagStr + ";" |
---|
662 | // waveListStr += "fSubS_qxqy_MT" + tagStr + ";" |
---|
663 | waveListStr += "fSubS_qxqy_ML" + tagStr + ";" |
---|
664 | waveListStr += "fSubS_qxqy_MR" + tagStr + ";" |
---|
665 | // waveListStr += "fSubS_qxqy_FB" + tagStr + ";" |
---|
666 | // waveListStr += "fSubS_qxqy_FT" + tagStr + ";" |
---|
667 | waveListStr += "fSubS_qxqy_FL" + tagStr + ";" |
---|
668 | waveListStr += "fSubS_qxqy_FR" + tagStr + ";" |
---|
669 | // waveListStr = "fSubS_qxqy_B;fSubS_qxqy_MB;fSubS_qxqy_MT;fSubS_qxqy_ML;fSubS_qxqy_MR;" |
---|
670 | // waveListStr += "fSubS_qxqy_FB;fSubS_qxqy_FT;fSubS_qxqy_FL;fSubS_qxqy_FR;" |
---|
671 | |
---|
672 | Concatenate/NP/O waveListStr, tmp_fs |
---|
673 | |
---|
674 | endif |
---|
675 | |
---|
676 | // Can't kill here, since they are still needed to sort and write out! |
---|
677 | // KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_res0,tmp_res1,tmp_res2,tmp_res3 |
---|
678 | |
---|
679 | SetDataFolder root: |
---|
680 | |
---|
681 | return(0) |
---|
682 | End |
---|
683 | |
---|
684 | // TODO: |
---|
685 | // -- resolution waves are ignored, since they don't exist (yet) |
---|
686 | // -- only a sort is done, no rescaling of data sets |
---|
687 | // (it's too late now anyways, since the data was concatenated) |
---|
688 | // |
---|
689 | // see Auto_Sort() in the SANS Automation ipf for the rest of the details of |
---|
690 | // how to combine the resolution waves (they also need to be concatenated, which is currently not done) |
---|
691 | // |
---|
692 | Function V_TmpSort1D(pathStr,folderStr) |
---|
693 | String pathStr,folderStr |
---|
694 | |
---|
695 | SetDataFolder $(pathStr+folderStr) |
---|
696 | |
---|
697 | Wave qw = tmp_q |
---|
698 | Wave iw = tmp_i |
---|
699 | Wave sw = tmp_s |
---|
700 | Wave sq = tmp_sq |
---|
701 | Wave qb = tmp_qb |
---|
702 | Wave fs = tmp_fs |
---|
703 | |
---|
704 | |
---|
705 | Sort qw, qw,iw,sw,sq,qb,fs |
---|
706 | |
---|
707 | |
---|
708 | SetDataFolder root: |
---|
709 | return(0) |
---|
710 | End |
---|
711 | |
---|
712 | |
---|
713 | // TODO |
---|
714 | // (appears to be unused, in favor of the version that uses the global strings) |
---|
715 | // needs: |
---|
716 | // -- trim the beamstop out (based on shadow?) |
---|
717 | // -- trim out zero q from the file (bad actor in analysis functions) |
---|
718 | // -- trim num from the highQ end or lowQ end? |
---|
719 | // -- splits the res wave into individual waves in anticipation of concatenation |
---|
720 | // -- or -- deal with the res wave after? |
---|
721 | // |
---|
722 | // -- make a copy of the waves? |
---|
723 | // -- then, what is the concatenate function looking for?? |
---|
724 | // |
---|
725 | Function V_Trim1DData(dataFolder,binType,nBeg,nEnd) |
---|
726 | String dataFolder |
---|
727 | Variable binType,nBeg,nEnd |
---|
728 | |
---|
729 | Variable npt,ii |
---|
730 | SetDataFolder $("root:Packages:NIST:VSANS:"+dataFolder) |
---|
731 | |
---|
732 | Printf "%d points removed from beginning, %d points from the end (of each set) before concatenating\r",nbeg,nend |
---|
733 | |
---|
734 | // for each binType block: |
---|
735 | // declare the waves |
---|
736 | // make a copy of the waves?? |
---|
737 | // //Break out resolution wave into separate waves |
---|
738 | // delete the beginning points from everything |
---|
739 | // trim off the last nEnd points from everything |
---|
740 | // DeletePoints num-nEnd,nEnd, qw,iw,sw |
---|
741 | // // delete all points where the shadow is < 0.98 |
---|
742 | ////Put resolution contents back??? |
---|
743 | |
---|
744 | if(binType == 1) |
---|
745 | Wave/Z q_fb = qBin_qxqy_FB |
---|
746 | Wave/Z q_ft = qBin_qxqy_FT |
---|
747 | Wave/Z q_fl = qBin_qxqy_FL |
---|
748 | Wave/Z q_fr = qBin_qxqy_FR |
---|
749 | Wave/Z q_mb = qBin_qxqy_MB |
---|
750 | Wave/Z q_mt = qBin_qxqy_MT |
---|
751 | Wave/Z q_ml = qBin_qxqy_ML |
---|
752 | Wave/Z q_mr = qBin_qxqy_MR |
---|
753 | Wave/Z q_b = qBin_qxqy_B |
---|
754 | |
---|
755 | Wave/Z i_fb = iBin_qxqy_FB |
---|
756 | Wave/Z i_ft = iBin_qxqy_FT |
---|
757 | Wave/Z i_fl = iBin_qxqy_FL |
---|
758 | Wave/Z i_fr = iBin_qxqy_FR |
---|
759 | Wave/Z i_mb = iBin_qxqy_MB |
---|
760 | Wave/Z i_mt = iBin_qxqy_MT |
---|
761 | Wave/Z i_ml = iBin_qxqy_ML |
---|
762 | Wave/Z i_mr = iBin_qxqy_MR |
---|
763 | Wave/Z i_b = iBin_qxqy_B |
---|
764 | |
---|
765 | Wave/Z s_fb = eBin_qxqy_FB |
---|
766 | Wave/Z s_ft = eBin_qxqy_FT |
---|
767 | Wave/Z s_fl = eBin_qxqy_FL |
---|
768 | Wave/Z s_fr = eBin_qxqy_FR |
---|
769 | Wave/Z s_mb = eBin_qxqy_MB |
---|
770 | Wave/Z s_mt = eBin_qxqy_MT |
---|
771 | Wave/Z s_ml = eBin_qxqy_ML |
---|
772 | Wave/Z s_mr = eBin_qxqy_MR |
---|
773 | Wave/Z s_b = eBin_qxqy_B |
---|
774 | |
---|
775 | |
---|
776 | |
---|
777 | DeletePoints 0,nBeg, q_fb,q_ft,q_fl,q_fr,q_mb,q_mt,q_ml,q_mr,q_b |
---|
778 | DeletePoints 0,nBeg, i_fb,i_ft,i_fl,i_fr,i_mb,i_mt,i_ml,i_mr,i_b |
---|
779 | DeletePoints 0,nBeg, s_fb,s_ft,s_fl,s_fr,s_mb,s_mt,s_ml,s_mr,s_b |
---|
780 | //since each set may have a different number of points |
---|
781 | npt = numpnts(q_fb) |
---|
782 | DeletePoints npt-nEnd,nEnd, q_fb,i_fb,s_fb |
---|
783 | |
---|
784 | npt = numpnts(q_ft) |
---|
785 | DeletePoints npt-nEnd,nEnd, q_ft,i_ft,s_ft |
---|
786 | |
---|
787 | npt = numpnts(q_fl) |
---|
788 | DeletePoints npt-nEnd,nEnd, q_fl,i_fl,s_fl |
---|
789 | |
---|
790 | npt = numpnts(q_fr) |
---|
791 | DeletePoints npt-nEnd,nEnd, q_fr,i_fr,s_fr |
---|
792 | |
---|
793 | npt = numpnts(q_mb) |
---|
794 | DeletePoints npt-nEnd,nEnd, q_mb,i_mb,s_mb |
---|
795 | |
---|
796 | npt = numpnts(q_mt) |
---|
797 | DeletePoints npt-nEnd,nEnd, q_mt,i_mt,s_mt |
---|
798 | |
---|
799 | npt = numpnts(q_ml) |
---|
800 | DeletePoints npt-nEnd,nEnd, q_ml,i_ml,s_ml |
---|
801 | |
---|
802 | npt = numpnts(q_mr) |
---|
803 | DeletePoints npt-nEnd,nEnd, q_mr,i_mr,s_mr |
---|
804 | |
---|
805 | npt = numpnts(q_b) |
---|
806 | DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b |
---|
807 | |
---|
808 | endif |
---|
809 | |
---|
810 | if(binType == 2) |
---|
811 | Wave/Z q_ftb = qBin_qxqy_FTB |
---|
812 | Wave/Z q_flr = qBin_qxqy_FLR |
---|
813 | Wave/Z q_mtb = qBin_qxqy_MTB |
---|
814 | Wave/Z q_mlr = qBin_qxqy_MLR |
---|
815 | Wave/Z q_b = qBin_qxqy_B |
---|
816 | |
---|
817 | Wave/Z i_ftb = iBin_qxqy_FTB |
---|
818 | Wave/Z i_flr = iBin_qxqy_FLR |
---|
819 | Wave/Z i_mtb = iBin_qxqy_MTB |
---|
820 | Wave/Z i_mlr = iBin_qxqy_MLR |
---|
821 | Wave/Z i_b = iBin_qxqy_B |
---|
822 | |
---|
823 | Wave/Z s_ftb = eBin_qxqy_FTB |
---|
824 | Wave/Z s_flr = eBin_qxqy_FLR |
---|
825 | Wave/Z s_mtb = eBin_qxqy_MTB |
---|
826 | Wave/Z s_mlr = eBin_qxqy_MLR |
---|
827 | Wave/Z s_b = eBin_qxqy_B |
---|
828 | |
---|
829 | |
---|
830 | DeletePoints 0,nBeg, q_ftb,q_flr,q_mtb,q_mlr,q_b |
---|
831 | DeletePoints 0,nBeg, i_ftb,i_flr,i_mtb,i_mlr,i_b |
---|
832 | DeletePoints 0,nBeg, s_ftb,s_flr,s_mtb,s_mlr,s_b |
---|
833 | //since each set may have a different number of points |
---|
834 | npt = numpnts(q_ftb) |
---|
835 | DeletePoints npt-nEnd,nEnd, q_ftb,i_ftb,s_ftb |
---|
836 | |
---|
837 | npt = numpnts(q_flr) |
---|
838 | DeletePoints npt-nEnd,nEnd, q_flr,i_flr,s_flr |
---|
839 | |
---|
840 | npt = numpnts(q_mtb) |
---|
841 | DeletePoints npt-nEnd,nEnd, q_mtb,i_mtb,s_mtb |
---|
842 | |
---|
843 | npt = numpnts(q_mlr) |
---|
844 | DeletePoints npt-nEnd,nEnd, q_mlr,i_mlr,s_mlr |
---|
845 | |
---|
846 | npt = numpnts(q_b) |
---|
847 | DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b |
---|
848 | |
---|
849 | |
---|
850 | endif |
---|
851 | |
---|
852 | if(binType == 3) |
---|
853 | Wave/Z q_flrtb = qBin_qxqy_FLRTB |
---|
854 | Wave/Z q_mlrtb = qBin_qxqy_MLRTB |
---|
855 | Wave/Z q_b = qBin_qxqy_B |
---|
856 | |
---|
857 | Wave/Z i_flrtb = iBin_qxqy_FLRTB |
---|
858 | Wave/Z i_mlrtb = iBin_qxqy_MLRTB |
---|
859 | Wave/Z i_b = iBin_qxqy_B |
---|
860 | |
---|
861 | Wave/Z s_flrtb = eBin_qxqy_FLRTB |
---|
862 | Wave/Z s_mlrtb = eBin_qxqy_MLRTB |
---|
863 | Wave/Z s_b = eBin_qxqy_B |
---|
864 | |
---|
865 | DeletePoints 0,nBeg, q_flrtb,q_mlrtb,q_b |
---|
866 | DeletePoints 0,nBeg, i_flrtb,i_mlrtb,i_b |
---|
867 | DeletePoints 0,nBeg, s_flrtb,s_mlrtb,s_b |
---|
868 | //since each set may have a different number of points |
---|
869 | npt = numpnts(q_flrtb) |
---|
870 | DeletePoints npt-nEnd,nEnd, q_flrtb,i_flrtb,s_flrtb |
---|
871 | |
---|
872 | npt = numpnts(q_mlrtb) |
---|
873 | DeletePoints npt-nEnd,nEnd, q_mlrtb,i_mlrtb,s_mlrtb |
---|
874 | |
---|
875 | npt = numpnts(q_b) |
---|
876 | DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b |
---|
877 | |
---|
878 | endif |
---|
879 | |
---|
880 | // TODO - This is the identical set of waves as for the case of binType = 1. |
---|
881 | // they have the same names, but are averaged differently since it's slit mode. |
---|
882 | // I have separated this, since in practice the TB panels are probably best to ignore |
---|
883 | // and NOT include in the averaging since the Qy range is so limited. |
---|
884 | if(binType == 4) |
---|
885 | Wave/Z q_fb = qBin_qxqy_FB |
---|
886 | Wave/Z q_ft = qBin_qxqy_FT |
---|
887 | Wave/Z q_fl = qBin_qxqy_FL |
---|
888 | Wave/Z q_fr = qBin_qxqy_FR |
---|
889 | Wave/Z q_mb = qBin_qxqy_MB |
---|
890 | Wave/Z q_mt = qBin_qxqy_MT |
---|
891 | Wave/Z q_ml = qBin_qxqy_ML |
---|
892 | Wave/Z q_mr = qBin_qxqy_MR |
---|
893 | Wave/Z q_b = qBin_qxqy_B |
---|
894 | |
---|
895 | Wave/Z i_fb = iBin_qxqy_FB |
---|
896 | Wave/Z i_ft = iBin_qxqy_FT |
---|
897 | Wave/Z i_fl = iBin_qxqy_FL |
---|
898 | Wave/Z i_fr = iBin_qxqy_FR |
---|
899 | Wave/Z i_mb = iBin_qxqy_MB |
---|
900 | Wave/Z i_mt = iBin_qxqy_MT |
---|
901 | Wave/Z i_ml = iBin_qxqy_ML |
---|
902 | Wave/Z i_mr = iBin_qxqy_MR |
---|
903 | Wave/Z i_b = iBin_qxqy_B |
---|
904 | |
---|
905 | Wave/Z s_fb = eBin_qxqy_FB |
---|
906 | Wave/Z s_ft = eBin_qxqy_FT |
---|
907 | Wave/Z s_fl = eBin_qxqy_FL |
---|
908 | Wave/Z s_fr = eBin_qxqy_FR |
---|
909 | Wave/Z s_mb = eBin_qxqy_MB |
---|
910 | Wave/Z s_mt = eBin_qxqy_MT |
---|
911 | Wave/Z s_ml = eBin_qxqy_ML |
---|
912 | Wave/Z s_mr = eBin_qxqy_MR |
---|
913 | Wave/Z s_b = eBin_qxqy_B |
---|
914 | |
---|
915 | DeletePoints 0,nBeg, q_fb,q_ft,q_fl,q_fr,q_mb,q_mt,q_ml,q_mr,q_b |
---|
916 | DeletePoints 0,nBeg, i_fb,i_ft,i_fl,i_fr,i_mb,i_mt,i_ml,i_mr,i_b |
---|
917 | DeletePoints 0,nBeg, s_fb,s_ft,s_fl,s_fr,s_mb,s_mt,s_ml,s_mr,s_b |
---|
918 | //since each set may have a different number of points |
---|
919 | npt = numpnts(q_fb) |
---|
920 | DeletePoints npt-nEnd,nEnd, q_fb,i_fb,s_fb |
---|
921 | |
---|
922 | npt = numpnts(q_ft) |
---|
923 | DeletePoints npt-nEnd,nEnd, q_ft,i_ft,s_ft |
---|
924 | |
---|
925 | npt = numpnts(q_fl) |
---|
926 | DeletePoints npt-nEnd,nEnd, q_fl,i_fl,s_fl |
---|
927 | |
---|
928 | npt = numpnts(q_fr) |
---|
929 | DeletePoints npt-nEnd,nEnd, q_fr,i_fr,s_fr |
---|
930 | |
---|
931 | npt = numpnts(q_mb) |
---|
932 | DeletePoints npt-nEnd,nEnd, q_mb,i_mb,s_mb |
---|
933 | |
---|
934 | npt = numpnts(q_mt) |
---|
935 | DeletePoints npt-nEnd,nEnd, q_mt,i_mt,s_mt |
---|
936 | |
---|
937 | npt = numpnts(q_ml) |
---|
938 | DeletePoints npt-nEnd,nEnd, q_ml,i_ml,s_ml |
---|
939 | |
---|
940 | npt = numpnts(q_mr) |
---|
941 | DeletePoints npt-nEnd,nEnd, q_mr,i_mr,s_mr |
---|
942 | |
---|
943 | npt = numpnts(q_b) |
---|
944 | DeletePoints npt-nEnd,nEnd, q_b,i_b,s_b |
---|
945 | |
---|
946 | endif |
---|
947 | |
---|
948 | SetDataFolder root: |
---|
949 | return(0) |
---|
950 | end |
---|
951 | |
---|
952 | |
---|
953 | |
---|
954 | / |
---|
955 | Proc V_Load_Data_ITX() |
---|
956 | V_Load_itx("","",0,0) |
---|
957 | end |
---|
958 | |
---|
959 | // TODO |
---|
960 | // -- fill in |
---|
961 | // -- link somewhere? |
---|
962 | // |
---|
963 | // a function to load in the individual I(q) sets which were written out to a single |
---|
964 | // file, in itx format. |
---|
965 | // |
---|
966 | // The data, like other 1D data sets, is to be loaded to its own folder under root |
---|
967 | // |
---|
968 | // Then, the data sets can be plotted as VSANS data sets, depending on which data extensions are present. |
---|
969 | // (and color coded) |
---|
970 | // (and used for setting the trimming) |
---|
971 | // (and...) |
---|
972 | // |
---|
973 | // |
---|
974 | // see A_LoadOneDDataToName(fileStr,outStr,doPlot,forceOverwrite) |
---|
975 | // |
---|
976 | Function V_Load_itx(fileStr,outStr,doPlot,forceOverwrite) |
---|
977 | String fileStr, outstr |
---|
978 | Variable doPlot,forceOverwrite |
---|
979 | |
---|
980 | SetDataFolder root: //build sub-folders for each data set under root |
---|
981 | |
---|
982 | // if no fileStr passed in, display dialog now |
---|
983 | if (cmpStr(fileStr,"") == 0) |
---|
984 | fileStr = DoOpenFileDialog("Select a data file to load") |
---|
985 | if (cmpstr(fileStr,"") == 0) |
---|
986 | String/G root:Packages:NIST:gLastFileName = "" |
---|
987 | return(0) //get out if no file selected |
---|
988 | endif |
---|
989 | endif |
---|
990 | |
---|
991 | //Load the waves, using default waveX names |
---|
992 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
993 | LoadWave/O/T fileStr |
---|
994 | // LoadWave/G/D/A/Q fileStr |
---|
995 | String fileNamePath = S_Path+S_fileName |
---|
996 | // String basestr = ParseFilePath(3,ParseFilePath(5,fileNamePath,":",0,0),":",0,0) |
---|
997 | |
---|
998 | String basestr |
---|
999 | if (!cmpstr(outstr, "")) //Outstr = "", cmpstr returns 0 |
---|
1000 | // enforce a short enough name here to keep Igor objects < 31 chars |
---|
1001 | baseStr = ShortFileNameString(CleanupName(S_fileName,0)) |
---|
1002 | baseStr = CleanupName(baseStr,0) //in case the user added odd characters |
---|
1003 | //baseStr = CleanupName(S_fileName,0) |
---|
1004 | else |
---|
1005 | baseStr = outstr //for output, hopefully correct length as passed in |
---|
1006 | endif |
---|
1007 | |
---|
1008 | // print "basestr :"+basestr |
---|
1009 | String fileName = ParseFilePath(0,ParseFilePath(5,filestr,":",0,0),":",1,0) |
---|
1010 | // print "filename :"+filename |
---|
1011 | |
---|
1012 | Variable ii,num=ItemsinList(S_waveNames) |
---|
1013 | |
---|
1014 | if(DataFolderExists("root:"+baseStr)) |
---|
1015 | if (!forceOverwrite) |
---|
1016 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
1017 | if(V_flag==2) //user selected No, don't load the data |
---|
1018 | SetDataFolder root: |
---|
1019 | for(ii=0;ii<num;ii+=1) |
---|
1020 | KillWaves $(StringFromList(ii, S_waveNames)) // kill the waves that were loaded |
---|
1021 | endfor |
---|
1022 | if(DataFolderExists("root:Packages:NIST")) |
---|
1023 | String/G root:Packages:NIST:gLastFileName = filename |
---|
1024 | endif |
---|
1025 | return(0) //quits the macro |
---|
1026 | endif |
---|
1027 | endif |
---|
1028 | SetDataFolder $("root:"+baseStr) |
---|
1029 | else |
---|
1030 | NewDataFolder/S $("root:"+baseStr) |
---|
1031 | endif |
---|
1032 | |
---|
1033 | // ////overwrite the existing data, if it exists |
---|
1034 | |
---|
1035 | // a semicolon-delimited list of wave names loaded |
---|
1036 | //S_waveNames |
---|
1037 | for(ii=0;ii<num;ii+=1) |
---|
1038 | Duplicate/O $("root:"+StringFromList(ii, S_waveNames)), $(StringFromList(ii, S_waveNames)) |
---|
1039 | endfor |
---|
1040 | |
---|
1041 | |
---|
1042 | // clean up |
---|
1043 | SetDataFolder root: |
---|
1044 | |
---|
1045 | for(ii=0;ii<num;ii+=1) |
---|
1046 | KillWaves $(StringFromList(ii, S_waveNames)) // kill the waves that were loaded |
---|
1047 | endfor |
---|
1048 | // Duplicate/O $("root:"+n0), $w0 |
---|
1049 | // Duplicate/O $("root:"+n1), $w1 |
---|
1050 | // Duplicate/O $("root:"+n2), $w2 |
---|
1051 | |
---|
1052 | // no resolution matrix to make |
---|
1053 | |
---|
1054 | |
---|
1055 | return(0) |
---|
1056 | End |
---|
1057 | |
---|
1058 | |
---|
1059 | // given strings of the number of points to remove, loop over the detectors |
---|
1060 | // |
---|
1061 | // TODO |
---|
1062 | // -- currently uses global strings or default strings |
---|
1063 | // -- if proper strings (non-null) are passed in, they are used, otherwise global, then default |
---|
1064 | Function V_Trim1DDataStr(folderStr,binType,nBegStr,nEndStr) |
---|
1065 | String folderStr |
---|
1066 | Variable binType |
---|
1067 | String nBegStr,nEndStr |
---|
1068 | |
---|
1069 | String detListStr |
---|
1070 | if(binType == 1) |
---|
1071 | detListStr = ksBinType1 |
---|
1072 | endif |
---|
1073 | if(binType == 2) |
---|
1074 | detListStr = ksBinType2 |
---|
1075 | endif |
---|
1076 | if(binType == 3) |
---|
1077 | detListStr = ksBinType3 |
---|
1078 | endif |
---|
1079 | if(binType == 4) |
---|
1080 | detListStr = ksBinType4 |
---|
1081 | endif |
---|
1082 | if(strlen(detListStr)==0) |
---|
1083 | return(0) |
---|
1084 | endif |
---|
1085 | |
---|
1086 | |
---|
1087 | //use global, then default values if null string passed in |
---|
1088 | if(strlen(nBegStr)==0) |
---|
1089 | SVAR/Z gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
1090 | SVAR/Z gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
1091 | |
---|
1092 | if(!SVAR_exists(gBegPtsStr) || !SVAR_exists(gEndPtsStr) || strlen(gBegPtsStr)==0 || strlen(gEndPtsStr)==0) |
---|
1093 | nBegStr = ksBinTrimBegDefault |
---|
1094 | nEndStr = ksBinTrimEndDefault |
---|
1095 | else |
---|
1096 | nBegStr = gBegPtsStr |
---|
1097 | nEndStr = gEndPtsStr |
---|
1098 | endif |
---|
1099 | endif |
---|
1100 | |
---|
1101 | Variable num, ii,nBeg,nEnd |
---|
1102 | String item,detstr |
---|
1103 | |
---|
1104 | num = ItemsInList(detListStr) |
---|
1105 | for(ii=0;ii<num;ii+=1) |
---|
1106 | detStr = StringFromList(ii, detListStr) |
---|
1107 | nBeg = NumberByKey(detStr, nBegStr,"=",";") |
---|
1108 | nEnd = NumberByKey(detStr, nEndStr,"=",";") |
---|
1109 | V_TrimOneSet(folderStr,detStr,nBeg,nEnd) |
---|
1110 | endfor |
---|
1111 | |
---|
1112 | return(0) |
---|
1113 | End |
---|
1114 | |
---|
1115 | // TODO |
---|
1116 | // x- make this resolution-aware |
---|
1117 | // |
---|
1118 | Function V_TrimOneSet(folderStr,detStr,nBeg,nEnd) |
---|
1119 | String folderStr,detStr |
---|
1120 | Variable nBeg,nEnd |
---|
1121 | |
---|
1122 | SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) |
---|
1123 | |
---|
1124 | Printf "%d points removed from beginning, %d points from the end of %s \r",nbeg,nend,detStr |
---|
1125 | |
---|
1126 | // TODO |
---|
1127 | // for each binType block: |
---|
1128 | // --declare the waves |
---|
1129 | // --make a copy of the waves?? |
---|
1130 | // //--Break out resolution wave into separate waves |
---|
1131 | // --delete the beginning points from everything |
---|
1132 | // --trim off the last nEnd points from everything |
---|
1133 | // --DeletePoints num-nEnd,nEnd, qw,iw,sw |
---|
1134 | // // --delete all points where the shadow is < 0.98 |
---|
1135 | ////--Put resolution contents back??? |
---|
1136 | |
---|
1137 | Wave/Z qw = $("qBin_qxqy_"+detStr) |
---|
1138 | Wave/Z iw = $("iBin_qxqy_"+detStr) |
---|
1139 | Wave/Z ew = $("eBin_qxqy_"+detStr) |
---|
1140 | // resolution waves |
---|
1141 | Wave/Z sigQ = $("sigmaQ_qxqy_"+detStr) |
---|
1142 | Wave/Z qBar = $("qBar_qxqy_"+detStr) |
---|
1143 | Wave/Z fSubS = $("fSubS_qxqy_"+detStr) |
---|
1144 | |
---|
1145 | DeletePoints 0,nBeg, qw,iw,ew,sigQ,qBar,fSubS |
---|
1146 | |
---|
1147 | Variable npt |
---|
1148 | npt = numpnts(qw) |
---|
1149 | DeletePoints npt-nEnd,nEnd, qw,iw,ew,sigQ,qBar,fSubS |
---|
1150 | |
---|
1151 | return(0) |
---|
1152 | End |
---|
1153 | |
---|
1154 | |
---|
1155 | // |
---|
1156 | // returns 1 if the val is non-negative, other value |
---|
1157 | // indicates that the resoution data is USANS data. |
---|
1158 | // |
---|
1159 | // TODO: |
---|
1160 | // -- this DUPLICATES a same-named SANS procedure, so there could be a clash at some point |
---|
1161 | // -- bigger issue - I'll need a better way to identify and load the different resolution |
---|
1162 | // conditions with VSANS |
---|
1163 | // |
---|
1164 | // |
---|
1165 | Function isSANSResolution(val) |
---|
1166 | Variable val |
---|
1167 | |
---|
1168 | if(val >= 0) |
---|
1169 | return(1) |
---|
1170 | else |
---|
1171 | return(0) |
---|
1172 | endif |
---|
1173 | End |
---|
1174 | |
---|
1175 | |
---|