source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_IQ_Utilities.ipf @ 1097

Last change on this file since 1097 was 1097, checked in by srkline, 5 years ago

added procedures to compare files to see if they are from the same configuration, same wavelength, etc. so they can be properly chosen for transmission files, scattering files, and properly identified for the different resolution conditions.

Re-worked the logic of dispatching averaging, plotting, and saving in Execute_Protocol. Hopefully this will alow for easier dispatching for future conditions, including getting the correct resolution calculation.

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