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 | // |
---|
43 | // - the numbers here in the switch can be out of order - it's fine |
---|
44 | // |
---|
45 | // old modes can be removed from the string constant ksBinTypeStr(n) (in V_Initialize.ipf), but the |
---|
46 | // mode numbers are what many different binning, plotting, and reduction functions are |
---|
47 | // switching on. In the future, it may be necessary to change the key (everywhere) to a string |
---|
48 | // switch, but for now, stick with the numbers. |
---|
49 | // |
---|
50 | // Strconstant ksBinTypeStr = "F4-M4-B;F2-M2-B;F1-M1-B;F2-M1-B;F1-M2xTB-B;F2-M2xTB-B;SLIT-F2-M2-B;" |
---|
51 | // |
---|
52 | // |
---|
53 | Function V_BinTypeStr2Num(binStr) |
---|
54 | String binStr |
---|
55 | |
---|
56 | Variable binType |
---|
57 | strswitch(binStr) // string switch |
---|
58 | case "F4-M4-B": |
---|
59 | binType = 1 |
---|
60 | break // exit from switch |
---|
61 | case "F2-M2-B": |
---|
62 | binType = 2 |
---|
63 | break // exit from switch |
---|
64 | case "F1-M1-B": |
---|
65 | binType = 3 |
---|
66 | break // exit from switch |
---|
67 | case "SLIT-F2-M2-B": |
---|
68 | binType = 4 |
---|
69 | break // exit from switch |
---|
70 | |
---|
71 | case "F2-M1-B": |
---|
72 | binType = 5 |
---|
73 | break |
---|
74 | case "F1-M2xTB-B": |
---|
75 | binType = 6 |
---|
76 | break |
---|
77 | case "F2-M2xTB-B": |
---|
78 | binType = 7 |
---|
79 | break |
---|
80 | |
---|
81 | default: // optional default expression executed |
---|
82 | binType = 0 |
---|
83 | Abort "Binning mode not found"// when no case matches |
---|
84 | endswitch |
---|
85 | |
---|
86 | return(binType) |
---|
87 | end |
---|
88 | |
---|
89 | // |
---|
90 | // TODO -- binType == 4 (slit mode) should never end up here |
---|
91 | // -- new logic in calling routines to dispatch to proper routine |
---|
92 | // -- AND need to write the routine for binning_SlitMode |
---|
93 | // |
---|
94 | Function V_QBinAllPanels_Circular(folderStr,binType) |
---|
95 | String folderStr |
---|
96 | Variable binType |
---|
97 | |
---|
98 | // do the back, middle, and front separately |
---|
99 | |
---|
100 | // figure out the binning type (where is it set?) |
---|
101 | Variable ii,delQ |
---|
102 | String detStr |
---|
103 | |
---|
104 | // binType = V_GetBinningPopMode() |
---|
105 | |
---|
106 | // set delta Q for binning (used later inside VC_fDoBinning_QxQy2D) |
---|
107 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
108 | detStr = StringFromList(ii, ksDetectorListAll, ";") |
---|
109 | |
---|
110 | delQ = SetDeltaQ(folderStr,detStr) // this sets (overwrites) the global value for each panel type |
---|
111 | endfor |
---|
112 | |
---|
113 | |
---|
114 | switch(binType) |
---|
115 | case 1: |
---|
116 | VC_fDoBinning_QxQy2D(folderStr,"FL") |
---|
117 | VC_fDoBinning_QxQy2D(folderStr,"FR") |
---|
118 | VC_fDoBinning_QxQy2D(folderStr,"FT") |
---|
119 | VC_fDoBinning_QxQy2D(folderStr,"FB") |
---|
120 | VC_fDoBinning_QxQy2D(folderStr,"ML") |
---|
121 | VC_fDoBinning_QxQy2D(folderStr,"MR") |
---|
122 | VC_fDoBinning_QxQy2D(folderStr,"MT") |
---|
123 | VC_fDoBinning_QxQy2D(folderStr,"MB") |
---|
124 | VC_fDoBinning_QxQy2D(folderStr, "B") |
---|
125 | |
---|
126 | break |
---|
127 | case 2: |
---|
128 | VC_fDoBinning_QxQy2D(folderStr,"FLR") |
---|
129 | VC_fDoBinning_QxQy2D(folderStr,"FTB") |
---|
130 | VC_fDoBinning_QxQy2D(folderStr,"MLR") |
---|
131 | VC_fDoBinning_QxQy2D(folderStr,"MTB") |
---|
132 | VC_fDoBinning_QxQy2D(folderStr, "B") |
---|
133 | |
---|
134 | break |
---|
135 | case 3: |
---|
136 | VC_fDoBinning_QxQy2D(folderStr,"MLRTB") |
---|
137 | VC_fDoBinning_QxQy2D(folderStr,"FLRTB") |
---|
138 | VC_fDoBinning_QxQy2D(folderStr, "B") |
---|
139 | |
---|
140 | break |
---|
141 | case 4: /// this is for a tall, narrow slit mode |
---|
142 | VC_fBinDetector_byRows(folderStr,"FL") |
---|
143 | VC_fBinDetector_byRows(folderStr,"FR") |
---|
144 | VC_fBinDetector_byRows(folderStr,"ML") |
---|
145 | VC_fBinDetector_byRows(folderStr,"MR") |
---|
146 | VC_fBinDetector_byRows(folderStr,"B") |
---|
147 | |
---|
148 | break |
---|
149 | case 5: |
---|
150 | VC_fDoBinning_QxQy2D(folderStr,"FTB") |
---|
151 | VC_fDoBinning_QxQy2D(folderStr,"FLR") |
---|
152 | VC_fDoBinning_QxQy2D(folderStr,"MLRTB") |
---|
153 | VC_fDoBinning_QxQy2D(folderStr, "B") |
---|
154 | |
---|
155 | break |
---|
156 | case 6: |
---|
157 | VC_fDoBinning_QxQy2D(folderStr,"FLRTB") |
---|
158 | VC_fDoBinning_QxQy2D(folderStr,"MLR") |
---|
159 | VC_fDoBinning_QxQy2D(folderStr, "B") |
---|
160 | |
---|
161 | break |
---|
162 | case 7: |
---|
163 | VC_fDoBinning_QxQy2D(folderStr,"FTB") |
---|
164 | VC_fDoBinning_QxQy2D(folderStr,"FLR") |
---|
165 | VC_fDoBinning_QxQy2D(folderStr,"MLR") |
---|
166 | VC_fDoBinning_QxQy2D(folderStr, "B") |
---|
167 | |
---|
168 | break |
---|
169 | |
---|
170 | default: |
---|
171 | Abort "Binning mode not found in V_QBinAllPanels_Circular"// when no case matches |
---|
172 | endswitch |
---|
173 | |
---|
174 | |
---|
175 | return(0) |
---|
176 | End |
---|
177 | |
---|
178 | // concatenates and sorts the 1D data in "type" WORK folder |
---|
179 | // uses the current display if type=="" |
---|
180 | // |
---|
181 | Function V_ConcatenateForSave(pathStr,type,tagStr,binType) |
---|
182 | String pathStr,type,tagStr |
---|
183 | Variable binType |
---|
184 | |
---|
185 | // get the current display type, if null string passed in |
---|
186 | SVAR curtype = root:Packages:NIST:VSANS:Globals:gCurDispType |
---|
187 | |
---|
188 | if(strlen(type)==0) |
---|
189 | type = curType |
---|
190 | endif |
---|
191 | |
---|
192 | // trim the data if needed |
---|
193 | // remove the q=0 point from the back detector, if it's there |
---|
194 | // does not need to know binType |
---|
195 | V_RemoveQ0_B(type) |
---|
196 | |
---|
197 | // concatenate the data sets |
---|
198 | // TODO x- figure out which binning was used (this is done in V_1DConcatenate()) |
---|
199 | // clear the old tmp waves first, if they still exist |
---|
200 | // SetDataFolder $("root:Packages:NIST:VSANS:"+type) |
---|
201 | SetDataFolder $(pathStr+type) |
---|
202 | Killwaves/Z tmp_q,tmp_i,tmp_s,tmp_sq,tmp_qb,tmp_fs |
---|
203 | setDataFolder root: |
---|
204 | V_1DConcatenate(pathStr,type,tagStr,binType) |
---|
205 | |
---|
206 | // sort the data set |
---|
207 | V_TmpSort1D(pathStr,type) |
---|
208 | |
---|
209 | return(0) |
---|
210 | End |
---|
211 | |
---|
212 | // |
---|
213 | // this is only called from the button on the data panel (**not anymore**) |
---|
214 | // so the type is the currently displayed type, and the binning is from the panel |
---|
215 | // |
---|
216 | Function V_SimpleSave1DData(pathStr,type,tagStr,saveName) |
---|
217 | String pathStr,type,tagStr,saveName |
---|
218 | |
---|
219 | // |
---|
220 | // get the current display type, if null string passed in |
---|
221 | SVAR curtype = root:Packages:NIST:VSANS:Globals:gCurDispType |
---|
222 | Variable binType = V_GetBinningPopMode() |
---|
223 | |
---|
224 | V_ConcatenateForSave(pathStr,curType,tagStr,binType) |
---|
225 | |
---|
226 | // write out the data set to a file |
---|
227 | if(strlen(saveName)==0) |
---|
228 | Execute "V_GetNameForSave()" |
---|
229 | SVAR newName = root:saveName |
---|
230 | saveName = newName |
---|
231 | endif |
---|
232 | |
---|
233 | V_Write1DData(pathStr,curtype,saveName) |
---|
234 | |
---|
235 | End |
---|
236 | |
---|
237 | |
---|
238 | Proc V_GetNameForSave(str) |
---|
239 | String str |
---|
240 | String/G root:saveName=str |
---|
241 | End |
---|
242 | |
---|
243 | |
---|
244 | // blindly assumes that there is only one zero at the top of the wave |
---|
245 | // could be more sophisticated in the future... |
---|
246 | Function V_RemoveQ0_B(type) |
---|
247 | String type |
---|
248 | |
---|
249 | SetDataFolder $("root:Packages:NIST:VSANS:"+type) |
---|
250 | |
---|
251 | WAVE/Z qBin = qBin_qxqy_B |
---|
252 | WAVE/Z iBin = iBin_qxqy_B |
---|
253 | WAVE/Z eBin = eBin_qxqy_B |
---|
254 | WAVE/Z nBin = nBin_qxqy_B |
---|
255 | WAVE/Z iBin2 = iBin2_qxqy_B |
---|
256 | |
---|
257 | // resolution waves |
---|
258 | Wave/Z sigQ = sigmaQ_qxqy_B |
---|
259 | Wave/Z qBar = qBar_qxqy_B |
---|
260 | Wave/Z fSubS = fSubS_qxqy_B |
---|
261 | |
---|
262 | if(qBin[0] == 0) |
---|
263 | DeletePoints 0, 1, qBin,iBin,eBin,nBin,iBin2,sigQ,qBar,fSubS |
---|
264 | endif |
---|
265 | |
---|
266 | SetDataFolder root: |
---|
267 | return(0) |
---|
268 | end |
---|
269 | |
---|
270 | |
---|
271 | // concatentate data in folderStr |
---|
272 | // |
---|
273 | // TODO: |
---|
274 | // x- !!! Resolution waves are currently skipped - these must be added |
---|
275 | // |
---|
276 | // x- this currently ignores the binning type (one, two, etc. ) |
---|
277 | // x- change the Concatenate call to use the waveList, to eliminate the need to declare all of the waves |
---|
278 | // -- this currently assumes that all of the waves exist |
---|
279 | // -- need robust error checking for wave existence |
---|
280 | // -- wave names are hard-wired and their name and location may be different in the future |
---|
281 | // x- if different averaging options were chosen (bin type of 2, 4 etc) then |
---|
282 | // although waves may exist, they may not be the right ones to use. There |
---|
283 | // will be a somewhat complex selection process |
---|
284 | // x- detector B is currently skipped |
---|
285 | // |
---|
286 | // this seems like a lot of extra work to do something so simple...but it's better than a loop |
---|
287 | // |
---|
288 | // root:Packages:NIST:VSANS:RAW:iBin_qxqy_FB |
---|
289 | // |
---|
290 | // Now, the extensions needed for each binType are handled in a loop using the strings |
---|
291 | // defined globally for each of the numbered binTypes |
---|
292 | // |
---|
293 | // binType = 1 = one |
---|
294 | // binType = 2 = two |
---|
295 | // binType = 3 = four |
---|
296 | // binType = 4 = Slit Mode |
---|
297 | // binType = 5... |
---|
298 | // |
---|
299 | // if binType is passed in as -9999, get the binning mode from the popup |
---|
300 | // otherwise the value is assumed good (from a protocol) |
---|
301 | // |
---|
302 | // pathStr must have the trailing colon |
---|
303 | // tagStr is normally null, but is "_trim" for data to be trimmed |
---|
304 | // |
---|
305 | Function V_1DConcatenate(pathStr,folderStr,tagStr,binType) |
---|
306 | String pathStr,folderStr,tagStr |
---|
307 | Variable binType |
---|
308 | |
---|
309 | |
---|
310 | if(binType==-9999) |
---|
311 | binType = V_GetBinningPopMode() |
---|
312 | endif |
---|
313 | |
---|
314 | String binTypeString = V_getBinTypeString(binType) |
---|
315 | if(strlen(binTypeString) == 0) |
---|
316 | DoAlert 0,"binTypeString is null in V_1DConcatenate" |
---|
317 | return(0) |
---|
318 | endif |
---|
319 | |
---|
320 | // SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) |
---|
321 | SetDataFolder $(pathStr+folderStr) |
---|
322 | |
---|
323 | //kill these waves before starting, or the new concatenation will be added to the old |
---|
324 | KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_qb,tmp_sq,tmp_fs |
---|
325 | |
---|
326 | String q_waveListStr="" |
---|
327 | String i_waveListStr="" |
---|
328 | String s_waveListStr="" |
---|
329 | String sq_waveListStr="" |
---|
330 | String qb_waveListStr="" |
---|
331 | String fs_waveListStr="" |
---|
332 | |
---|
333 | Variable num,ii |
---|
334 | String item="" |
---|
335 | |
---|
336 | //Generate string lists of the waves to be concatenated based on the |
---|
337 | // binTypeString (a global string constant with the extensions) |
---|
338 | // |
---|
339 | |
---|
340 | NVAR gIgnoreDetB = root:Packages:NIST:VSANS:Globals:gIgnoreDetB |
---|
341 | if(!gIgnoreDetB) |
---|
342 | q_waveListStr = "qBin_qxqy_B" + tagStr + ";" |
---|
343 | i_waveListStr = "iBin_qxqy_B" + tagStr + ";" |
---|
344 | s_waveListStr = "eBin_qxqy_B" + tagStr + ";" |
---|
345 | sq_waveListStr = "sigmaQ_qxqy_B" + tagStr + ";" |
---|
346 | qb_waveListStr = "qBar_qxqy_B" + tagStr + ";" |
---|
347 | fs_waveListStr = "fSubS_qxqy_B" + tagStr + ";" |
---|
348 | endif |
---|
349 | |
---|
350 | num = ItemsInList(binTypeString, ";") |
---|
351 | for(ii=0;ii<num;ii+=1) |
---|
352 | item = StringFromList(ii, binTypeString ,";") |
---|
353 | |
---|
354 | // "B" was handled outside the loop, be sure to skip here |
---|
355 | if(cmpstr(item,"B") != 0) |
---|
356 | q_waveListStr += "qBin_qxqy_" + item + tagStr + ";" |
---|
357 | i_waveListStr += "iBin_qxqy_" + item + tagStr + ";" |
---|
358 | s_waveListStr += "eBin_qxqy_" + item + tagStr + ";" |
---|
359 | sq_waveListStr += "sigmaQ_qxqy_" + item + tagStr + ";" |
---|
360 | qb_waveListStr += "qBar_qxqy_" + item + tagStr + ";" |
---|
361 | fs_waveListStr += "fSubS_qxqy_" + item + tagStr + ";" |
---|
362 | endif |
---|
363 | endfor |
---|
364 | |
---|
365 | // concatenate each of the sets |
---|
366 | |
---|
367 | Concatenate/NP/O q_waveListStr, tmp_q |
---|
368 | |
---|
369 | Concatenate/NP/O i_waveListStr, tmp_i |
---|
370 | |
---|
371 | Concatenate/NP/O s_waveListStr, tmp_s |
---|
372 | |
---|
373 | Concatenate/NP/O sq_waveListStr, tmp_sq |
---|
374 | |
---|
375 | Concatenate/NP/O qb_waveListStr, tmp_qb |
---|
376 | |
---|
377 | Concatenate/NP/O fs_waveListStr, tmp_fs |
---|
378 | |
---|
379 | |
---|
380 | |
---|
381 | // Can't kill here, since they are still needed to sort and write out! |
---|
382 | // KillWaves/Z tmp_q,tmp_i,tmp_s,tmp_res0,tmp_res1,tmp_res2,tmp_res3 |
---|
383 | |
---|
384 | SetDataFolder root: |
---|
385 | |
---|
386 | return(0) |
---|
387 | End |
---|
388 | |
---|
389 | // TODO: |
---|
390 | // -- resolution waves are ignored, since they don't exist (yet) |
---|
391 | // -- only a sort is done, no rescaling of data sets |
---|
392 | // (it's too late now anyways, since the data was concatenated) |
---|
393 | // |
---|
394 | // see Auto_Sort() in the SANS Automation ipf for the rest of the details of |
---|
395 | // how to combine the resolution waves (they also need to be concatenated, which is currently not done) |
---|
396 | // |
---|
397 | Function V_TmpSort1D(pathStr,folderStr) |
---|
398 | String pathStr,folderStr |
---|
399 | |
---|
400 | SetDataFolder $(pathStr+folderStr) |
---|
401 | |
---|
402 | Wave qw = tmp_q |
---|
403 | Wave iw = tmp_i |
---|
404 | Wave sw = tmp_s |
---|
405 | Wave sq = tmp_sq |
---|
406 | Wave qb = tmp_qb |
---|
407 | Wave fs = tmp_fs |
---|
408 | |
---|
409 | |
---|
410 | Sort qw, qw,iw,sw,sq,qb,fs |
---|
411 | |
---|
412 | |
---|
413 | SetDataFolder root: |
---|
414 | return(0) |
---|
415 | End |
---|
416 | |
---|
417 | |
---|
418 | // |
---|
419 | Proc V_Load_Data_ITX() |
---|
420 | V_Load_itx("","",0,0) |
---|
421 | end |
---|
422 | |
---|
423 | // TODO |
---|
424 | // -- fill in |
---|
425 | // -- link somewhere? |
---|
426 | // |
---|
427 | // a function to load in the individual I(q) sets which were written out to a single |
---|
428 | // file, in itx format. |
---|
429 | // |
---|
430 | // The data, like other 1D data sets, is to be loaded to its own folder under root |
---|
431 | // |
---|
432 | // Then, the data sets can be plotted as VSANS data sets, depending on which data extensions are present. |
---|
433 | // (and color coded) |
---|
434 | // (and used for setting the trimming) |
---|
435 | // (and...) |
---|
436 | // |
---|
437 | // |
---|
438 | // see A_LoadOneDDataToName(fileStr,outStr,doPlot,forceOverwrite) |
---|
439 | // |
---|
440 | Function V_Load_itx(fileStr,outStr,doPlot,forceOverwrite) |
---|
441 | String fileStr, outstr |
---|
442 | Variable doPlot,forceOverwrite |
---|
443 | |
---|
444 | SetDataFolder root: //build sub-folders for each data set under root |
---|
445 | |
---|
446 | // if no fileStr passed in, display dialog now |
---|
447 | if (cmpStr(fileStr,"") == 0) |
---|
448 | fileStr = DoOpenFileDialog("Select a data file to load") |
---|
449 | if (cmpstr(fileStr,"") == 0) |
---|
450 | String/G root:Packages:NIST:gLastFileName = "" |
---|
451 | return(0) //get out if no file selected |
---|
452 | endif |
---|
453 | endif |
---|
454 | |
---|
455 | //Load the waves, using default waveX names |
---|
456 | //if no path or file is specified for LoadWave, the default Mac open dialog will appear |
---|
457 | LoadWave/O/T fileStr |
---|
458 | // LoadWave/G/D/A/Q fileStr |
---|
459 | String fileNamePath = S_Path+S_fileName |
---|
460 | // String basestr = ParseFilePath(3,ParseFilePath(5,fileNamePath,":",0,0),":",0,0) |
---|
461 | |
---|
462 | String basestr |
---|
463 | if (!cmpstr(outstr, "")) //Outstr = "", cmpstr returns 0 |
---|
464 | // enforce a short enough name here to keep Igor objects < 31 chars |
---|
465 | baseStr = ShortFileNameString(CleanupName(S_fileName,0)) |
---|
466 | baseStr = CleanupName(baseStr,0) //in case the user added odd characters |
---|
467 | //baseStr = CleanupName(S_fileName,0) |
---|
468 | else |
---|
469 | baseStr = outstr //for output, hopefully correct length as passed in |
---|
470 | endif |
---|
471 | |
---|
472 | // print "basestr :"+basestr |
---|
473 | String fileName = ParseFilePath(0,ParseFilePath(5,filestr,":",0,0),":",1,0) |
---|
474 | // print "filename :"+filename |
---|
475 | |
---|
476 | Variable ii,num=ItemsinList(S_waveNames) |
---|
477 | |
---|
478 | if(DataFolderExists("root:"+baseStr)) |
---|
479 | if (!forceOverwrite) |
---|
480 | DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?" |
---|
481 | if(V_flag==2) //user selected No, don't load the data |
---|
482 | SetDataFolder root: |
---|
483 | for(ii=0;ii<num;ii+=1) |
---|
484 | KillWaves $(StringFromList(ii, S_waveNames)) // kill the waves that were loaded |
---|
485 | endfor |
---|
486 | if(DataFolderExists("root:Packages:NIST")) |
---|
487 | String/G root:Packages:NIST:gLastFileName = filename |
---|
488 | endif |
---|
489 | return(0) //quits the macro |
---|
490 | endif |
---|
491 | endif |
---|
492 | SetDataFolder $("root:"+baseStr) |
---|
493 | else |
---|
494 | NewDataFolder/S $("root:"+baseStr) |
---|
495 | endif |
---|
496 | |
---|
497 | // ////overwrite the existing data, if it exists |
---|
498 | |
---|
499 | // a semicolon-delimited list of wave names loaded |
---|
500 | //S_waveNames |
---|
501 | for(ii=0;ii<num;ii+=1) |
---|
502 | Duplicate/O $("root:"+StringFromList(ii, S_waveNames)), $(StringFromList(ii, S_waveNames)) |
---|
503 | endfor |
---|
504 | |
---|
505 | |
---|
506 | // clean up |
---|
507 | SetDataFolder root: |
---|
508 | |
---|
509 | for(ii=0;ii<num;ii+=1) |
---|
510 | KillWaves $(StringFromList(ii, S_waveNames)) // kill the waves that were loaded |
---|
511 | endfor |
---|
512 | // Duplicate/O $("root:"+n0), $w0 |
---|
513 | // Duplicate/O $("root:"+n1), $w1 |
---|
514 | // Duplicate/O $("root:"+n2), $w2 |
---|
515 | |
---|
516 | // no resolution matrix to make |
---|
517 | |
---|
518 | |
---|
519 | return(0) |
---|
520 | End |
---|
521 | |
---|
522 | |
---|
523 | |
---|
524 | // string function to select the correct string constant |
---|
525 | // that corresponds to the selected binType. This string constant |
---|
526 | // contains the list of extensions to be used for plotting, saving, etc. |
---|
527 | // |
---|
528 | // returns null string if no match |
---|
529 | // |
---|
530 | Function/S V_getBinTypeString(binType) |
---|
531 | Variable binType |
---|
532 | |
---|
533 | String detListStr="" |
---|
534 | if(binType == 1) |
---|
535 | detListStr = ksBinType1 |
---|
536 | endif |
---|
537 | if(binType == 2) |
---|
538 | detListStr = ksBinType2 |
---|
539 | endif |
---|
540 | if(binType == 3) |
---|
541 | detListStr = ksBinType3 |
---|
542 | endif |
---|
543 | if(binType == 4) |
---|
544 | detListStr = ksBinType4 |
---|
545 | endif |
---|
546 | if(binType == 5) |
---|
547 | detListStr = ksBinType5 |
---|
548 | endif |
---|
549 | if(binType == 6) |
---|
550 | detListStr = ksBinType6 |
---|
551 | endif |
---|
552 | if(binType == 7) |
---|
553 | detListStr = ksBinType7 |
---|
554 | endif |
---|
555 | |
---|
556 | |
---|
557 | return(detListStr) |
---|
558 | End |
---|
559 | |
---|
560 | // given strings of the number of points to remove, loop over the detectors |
---|
561 | // |
---|
562 | // TODO |
---|
563 | // -- currently uses global strings or default strings |
---|
564 | // -- if proper strings (non-null) are passed in, they are used, otherwise global, then default |
---|
565 | Function V_Trim1DDataStr(folderStr,binType,nBegStr,nEndStr) |
---|
566 | String folderStr |
---|
567 | Variable binType |
---|
568 | String nBegStr,nEndStr |
---|
569 | |
---|
570 | String detListStr="" |
---|
571 | |
---|
572 | detListStr = V_getBinTypeString(binType) //the list of extensions |
---|
573 | if(strlen(detListStr)==0) |
---|
574 | return(0) |
---|
575 | endif |
---|
576 | |
---|
577 | |
---|
578 | //use global, then default values if null string passed in |
---|
579 | if(strlen(nBegStr)==0) |
---|
580 | SVAR/Z gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr |
---|
581 | SVAR/Z gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr |
---|
582 | |
---|
583 | if(!SVAR_exists(gBegPtsStr) || !SVAR_exists(gEndPtsStr) || strlen(gBegPtsStr)==0 || strlen(gEndPtsStr)==0) |
---|
584 | nBegStr = ksBinTrimBegDefault |
---|
585 | nEndStr = ksBinTrimEndDefault |
---|
586 | else |
---|
587 | nBegStr = gBegPtsStr |
---|
588 | nEndStr = gEndPtsStr |
---|
589 | endif |
---|
590 | endif |
---|
591 | |
---|
592 | Variable num, ii,nBeg,nEnd |
---|
593 | String item,detstr |
---|
594 | |
---|
595 | num = ItemsInList(detListStr) |
---|
596 | for(ii=0;ii<num;ii+=1) |
---|
597 | detStr = StringFromList(ii, detListStr) |
---|
598 | nBeg = NumberByKey(detStr, nBegStr,"=",";") |
---|
599 | nEnd = NumberByKey(detStr, nEndStr,"=",";") |
---|
600 | V_TrimOneSet(folderStr,detStr,nBeg,nEnd) |
---|
601 | endfor |
---|
602 | |
---|
603 | return(0) |
---|
604 | End |
---|
605 | |
---|
606 | // TODO |
---|
607 | // x- make this resolution-aware |
---|
608 | // |
---|
609 | Function V_TrimOneSet(folderStr,detStr,nBeg,nEnd) |
---|
610 | String folderStr,detStr |
---|
611 | Variable nBeg,nEnd |
---|
612 | |
---|
613 | SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) |
---|
614 | |
---|
615 | Printf "%d points removed from beginning, %d points from the end of %s \r",nbeg,nend,detStr |
---|
616 | |
---|
617 | // TODO |
---|
618 | // for each binType block: |
---|
619 | // --declare the waves |
---|
620 | // --make a copy of the waves?? |
---|
621 | // //--Break out resolution wave into separate waves |
---|
622 | // --delete the beginning points from everything |
---|
623 | // --trim off the last nEnd points from everything |
---|
624 | // --DeletePoints num-nEnd,nEnd, qw,iw,sw |
---|
625 | // // --delete all points where the shadow is < 0.98 |
---|
626 | ////--Put resolution contents back??? |
---|
627 | |
---|
628 | Wave/Z qw = $("qBin_qxqy_"+detStr) |
---|
629 | Wave/Z iw = $("iBin_qxqy_"+detStr) |
---|
630 | Wave/Z ew = $("eBin_qxqy_"+detStr) |
---|
631 | // resolution waves |
---|
632 | Wave/Z sigQ = $("sigmaQ_qxqy_"+detStr) |
---|
633 | Wave/Z qBar = $("qBar_qxqy_"+detStr) |
---|
634 | Wave/Z fSubS = $("fSubS_qxqy_"+detStr) |
---|
635 | |
---|
636 | DeletePoints 0,nBeg, qw,iw,ew,sigQ,qBar,fSubS |
---|
637 | |
---|
638 | Variable npt |
---|
639 | npt = numpnts(qw) |
---|
640 | DeletePoints npt-nEnd,nEnd, qw,iw,ew,sigQ,qBar,fSubS |
---|
641 | |
---|
642 | return(0) |
---|
643 | End |
---|
644 | |
---|
645 | |
---|
646 | // |
---|
647 | // returns 1 if the val is non-negative, other value |
---|
648 | // indicates that the resoution data is USANS data. |
---|
649 | // |
---|
650 | // TODO: |
---|
651 | // -- this DUPLICATES a same-named SANS procedure, so there could be a clash at some point |
---|
652 | // -- bigger issue - I'll need a better way to identify and load the different resolution |
---|
653 | // conditions with VSANS |
---|
654 | // |
---|
655 | // |
---|
656 | Function isSANSResolution(val) |
---|
657 | Variable val |
---|
658 | |
---|
659 | if(val >= 0) |
---|
660 | return(1) |
---|
661 | else |
---|
662 | return(0) |
---|
663 | endif |
---|
664 | End |
---|
665 | |
---|
666 | |
---|