source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Combine_1D.ipf @ 1242

Last change on this file since 1242 was 1242, checked in by srkline, 3 years ago

updating the IgorVersion? pragma to v7.0 for all files to be consistent.

File size: 19.6 KB
RevLine 
[1030]1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
[1242]3#pragma IgorVersion = 7.00
[1030]4
5
6
[1038]7
8//
9// TODO:
[1039]10// x- make  the data folder list for the popup
11// x- make the data folder popup do the work of plotting
[1038]12//
[1039]13// x- (done by invoking the panel)
14//   x-make a button to show the default table, and set up dependencies to link to the graph display
15//
[1038]16// -- have an "active" data set to trim, or make duplicates for all of the data sets
17//
18// -- button to convert the points to strings that can be used and written to data files?
[1039]19// -- is this really necessary? if the save button is clicked, the strings are automatically generated
20//  -- but what if it's not? What if I do something else to send the strings to a protocol? or to a file?
[1038]21//
[1039]22// -- find a better way to be sure that the dependency does not generate errors if it is not
23//   properly killed
24//
25// -- help file
26//
27// x- larger panel
28//
29// x- error checking if the binType and the data present don't match. (test for failure)
30// -- do I really need the binType popup? How else would I know what data sets to plot/remove?
31//
32// x- table is continually duplicated
[1038]33// -- AutoPosition the windows next to each other
[1039]34// x- (different)(not ugly) color for the control bar so it's distinguishable from the regular data plot
35// x- "Done" button that kills the root:ToTrim folder (may need to kill the dependency first)
[1038]36//
[1042]37Proc V_CombineDataGraph()
[1038]38
[1039]39// this is the "initialization" step
40        NewDataFolder/O root:ToTrim
41       
[1038]42        DoWindow/F V_1D_Combine
[1039]43
44        Variable num,ii
45        String detStr
46               
[1038]47        if(V_flag==0)
48
[1039]49                Display /W=(277,526,879,1069)/N=V_1D_Combine /K=2
50
[1038]51                ControlBar 70
52                ModifyGraph cbRGB=(44000,44000,44000)
53               
[1074]54//              Button button2,pos={15,5},size={70,20},proc=V_Load_ITX_button,title="Load Data"
55//              Button button2,help={"Load an ITX file"}
[1039]56               
[1074]57//              PopupMenu popup1,pos={125,5},size={90,20},title="Data Folder"
58//              PopupMenu popup1,help={"data folder"}
59//              PopupMenu popup1,value= GetAList(4),proc=V_DataFolderPlotPop
[1038]60               
[1074]61                PopupMenu popup0,pos={15,5},size={70,20},title="Bin Type"
[1038]62                PopupMenu popup0,help={"binning type"}
[1074]63                PopupMenu popup0,value= ksBinTypeStr,proc=V_DataBinTypePlotPop
[1038]64
[1039]65                Button button3,pos={544.00,5},size={30.00,20.00},title="?"
[1209]66                Button button3,proc=V_ShowCombine1DHelp,help={"help file for combining 1D data"}
[1039]67
[1038]68                CheckBox check0,pos={18.00,36.00},size={57.00,16.00},proc=V_Plot1D_LogCheckProc,title="Log Axes"
69                CheckBox check0,value= 1
70
[1039]71                Button AllQ,pos={100,36},size={70,20},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q"
[1038]72                Button AllQ,help={"Show the full q-range of the dataset"}
73
[1148]74                Button button1,pos={225,36},size={140,20},proc=V_TrimWaves2StringButton,title="Save Trim Points"
[1039]75                Button button1,help={"Convert the waves to global strings"}
[1038]76               
[1074]77//              Button button4,pos={388,36},size={90.00,20.00},title="Trim & Save"
78//              Button button4,help={"combine and save 1D data"},proc=V_SaveTrimmed_Button
[1038]79               
[1039]80                Button button0,pos={524,36},size={70,20},proc=V_DoneCombine1D_ButtonProc,title="Done"
81                Button button0,help={"Close the panel and kill the temporary folder"}
82                               
83                Legend/C/N=text0/J/X=72.00/Y=60.00
[1038]84
[1039]85        endif   
86       
87
88        //trust that the table is present? No, but don't overwrite the data in the waves
89        // unless any one of the three doesn't exist
90       
91        SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols
92
93        if(exists("PanelNameW") == 0 || exists("Beg_pts") == 0 || exists("End_pts") == 0)
94                Make/O/T/N=(ItemsInList(ksPanelBinTypeList)) PanelNameW
95                Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) Beg_pts
96                Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) End_pts
97       
98                num = ItemsInList(ksPanelBinTypeList)
99                ii=0
100                do
101                        detStr = StringFromList(ii, ksPanelBinTypeList)
102                        Beg_pts[ii]  = NumberByKey(detStr, ksBinTrimBegDefault,"=",";")
103                        End_pts[ii] = NumberByKey(detStr, ksBinTrimEndDefault,"=",";")
104                        PanelNameW[ii] = detStr
105                        ii += 1
106                while(ii<num)
[1038]107               
[1039]108        endif
109        // now make sure that the table is present
110        DoWindow/F V_TrimPointsTable
[1038]111
[1039]112        if(V_flag==0)
113                Edit/K=0/N=V_TrimPointsTable PanelNameW,Beg_pts,End_pts         
[1038]114        endif
[1039]115       
[1080]116        // last, set up the dependency (but don't set it up twice!)
117        if(exists("root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate") == 0)
118                Make/O/D/N=1 root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate
119                root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate := V_TrimTestUpdate(Beg_pts, End_pts)
120        else
121                string dependencyStr = GetFormula(root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate)
122                if(strlen(dependencyStr)==0)
123                        root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate := V_TrimTestUpdate(Beg_pts, End_pts)
124                endif
125        endif
[1039]126       
127        SetDataFolder root:
[1038]128               
129End
130
[1039]131
[1209]132Function V_ShowCombine1DHelp(ctrlName) : ButtonControl
133        String ctrlName
134        DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Documentation[Combine 1D Files]"
135        if(V_flag !=0)
136                DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found"
137        endif
138        return(0)
139End
140
[1039]141// function that is a simple dependency, and updates the trimmed waves
142// that are displayed
143//
144// does not actually modify the real data, makes a copy, and is only a visual
145//
146//
147Function V_TrimTestUpdate(Beg_pts, End_pts)
[1038]148        Wave Beg_pts,End_pts
149       
150        // trim the data displayed
151        // do this by setting the iBin values to NaN, so it won't display
152        // won't hurt to set twice...
153       
[1039]154        Wave/T panelStr = root:Packages:NIST:VSANS:Globals:Protocols:PanelNameW
155        Wave begW = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
156        Wave endW = root:Packages:NIST:VSANS:Globals:Protocols:End_pts
157
158        // in case the dependency is still active, and the folder was killed
159        if(DataFolderExists("root:ToTrim") == 0)
160                return(0)
161        endif
[1038]162       
[1039]163//      SetDataFolder root:ToTrim
[1074]164//      ControlInfo/W=V_1D_Combine popup1
165//      String dataFldrStr = S_Value
[1099]166        NVAR gIgnoreBackDet = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
[1074]167        SVAR curDispType = root:Packages:NIST:VSANS:Globals:gCurDispType
168        String dataFldrStr = "root:Packages:NIST:VSANS:"+curDispType
169       
[1039]170        Variable num,ii,p1,p2
[1038]171        String str,detStr
172        num=numpnts(panelStr)
173       
174        for(ii=0;ii<num;ii+=1)
175                detStr = panelStr[ii]
[1099]176                if(gIgnoreBackDet && cmpstr(detStr,"B") == 0)
177                        // do nothing
178                else
179                        Wave/Z iw = $("root:ToTrim:iBin_qxqy_"+detStr+"_trim")
180                        Wave/Z iw_orig = $(dataFldrStr+":iBin_qxqy_"+detStr)
181        //              Wave/Z iw = $("iBin_qxqy_"+detStr)
182        //              Wave/Z ew = $("eBin_qxqy_"+detStr)
183                        if(WaveExists(iw) && WaveExists(iw_orig))
[1038]184                               
[1099]185        //                      DeletePoints 0,nBeg, qw,iw,ew
186                                // start fresh
187                                iw = iw_orig
188                                Variable npt
189                                npt = numpnts(iw)
190                                                       
191                                p1 = begW[ii]
192                                if(p1 > 0 && p1 < npt-1)
193                                        iw[0,p1-1] = NaN
194                                endif
195                               
196        //                      DeletePoints npt-nEnd,nEnd, qw,iw,ew
197                                p2 = EndW[ii]
198                               
199                                if(p2 > 0 && p2 < npt-1)
200                                        iw[npt-p2,npt-1] = NaN
201                                endif                   
202                        endif
[1038]203                endif
204        endfor
205       
206        SetDataFolder root:
207
208        return(0)
209End
210
[1050]211//
[1039]212// x- verify that the proper waves exist for the binning type
213//
214// x- the logic here is wrong. if the ToTrim folder is empty (As on startup)
215//  then the waves are always missing - and the function returns an error - every time
216//
[1074]217// now works with the "current" data that is displayed, rather than relying on
218// a lot of user input regarding the details of the saved data
[1039]219//
[1074]220Function V_DataBinTypePlotPop(ctrlName,popNum,popStr) : PopupMenuControl
221        String ctrlName
222        Variable popNum // which item is currently selected (1-based)
223        String popStr           // contents of current popup item as string
224
225
226        String str,winStr="V_1D_Combine"
227        Variable binType,num,ii,err
228
229        binType = V_BinTypeStr2Num(popStr)
230       
231       
232        //  x- need to update this to make sure that the data waves are present before plotting. This
233        //    currently looks in the ToTrim folder, but the binning could be wrong in the data folder
234        //    and will be an error...
235       
236        //dataType now needs to be the full path to the folder
237        // Plot the "real" data. data copy to trim will be plotted later
238        //
239        SVAR dispType = root:Packages:NIST:VSANS:Globals:gCurDispType
[1097]240        String collimationStr="pinhole"         //TODO: where do I get this information from ? does it matter here?
[1074]241
242// dispatch based on the string, not on the number of selection in the pop string
[1097]243        V_QBinAllPanels_Circular(dispType,binType,collimationStr)
[1074]244
245        String workTypeStr
246        workTypeStr = "root:Packages:NIST:VSANS:"+dispType
247       
248
249//      dataType = "root:"+popStr
250//     
251//      //remove EVERYTHING from the graph, no matter what
252        String type,list,item
253//      list = TraceNameList(winStr,";",1)
254//      for(ii=0;ii<ItemsInList(list);ii+=1)
255//              item = StringFromList(ii, list, ";")
256////            CheckDisplayed/W=$winStr $(item)
257////            if(V_flag==1)
258//                      RemoveFromGraph/Z/W=$winStr $(item)
259////            endif
260//      endfor 
261//     
262       
263        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,binType,winStr
264
265        Execute ("V_Back_IQ_Graph"+str)
266        Execute ("V_Middle_IQ_Graph"+str)
267        Execute ("V_Front_IQ_Graph"+str)
268
269        ModifyGraph marker=8,opaque=1,msize=3           //make the traces open white circles
270
271
272        NewDataFolder/O root:ToTrim
273       
274        //remove all of the "toTrim" data from the graph, if it's there
275        SetDataFolder root:ToTrim
276        for(ii=0;ii<ItemsInList(ksPanelBinTypeList);ii+=1)
277                type = StringFromList(ii, ksPanelBinTypeList, ";")
278                CheckDisplayed/W=$winStr $("iBin_qxqy_"+type+"_trim")
279                if(V_flag==1)
280                        RemoveFromGraph/W=$winStr $("iBin_qxqy_"+type+"_trim")
281                endif
282        endfor 
283        SetDataFolder root:
284
285
286        //then kill the data folder, so it can be duplicated
287       
288//
289//      // duplicate all of the data into the new folder
290        SetDataFolder $workTypeStr
291        list = WaveList("*",";","")             //must be in the correct data folder
292        SetDataFolder root:
293//      Print list     
294        num = ItemsInList(list)
295        for(ii=0;ii<num;ii+=1)
296                str = StringFromList(ii,list)
297                Duplicate/O $(workTypeStr+":"+str), $("root:ToTrim:"+str+"_trim")
298        endfor
299       
300//      // be sure that the data is present in the ToTrim folder before trying to plot
301//      err = V_TrimWavesExist(binType)
302//      if(err)
303//              DoAlert 0,"wrong bin type selected"
304//              return(0)
305//      endif
306       
307       
308        // plot the linked data
309        sprintf str,"(\"%s\",%d,\"%s\")","root:ToTrim",binType,winStr
310
311        Execute ("V_Back_IQ_Graph_trim"+str)
312        Execute ("V_Middle_IQ_Graph_trim"+str)
313        Execute ("V_Front_IQ_Graph_trim"+str)
314        // and link the data to the table with a dependency?
315//      done in the panel macro?
316       
317        // last, force the dependency to update so that the trimmed points are shown
318        Wave w = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
319        w[0] += 1
320        w[0] -= 1
321       
322       
323        return(0)       
324End
325
326
327
328//
329// x- verify that the proper waves exist for the binning type
330//
331// x- the logic here is wrong. if the ToTrim folder is empty (As on startup)
332//  then the waves are always missing - and the function returns an error - every time
333//
334// currently unused, in favor of using the current data rather than saved itx data
335//
[1038]336Function V_DataFolderPlotPop(ctrlName,popNum,popStr) : PopupMenuControl
337        String ctrlName
338        Variable popNum // which item is currently selected (1-based)
339        String popStr           // contents of current popup item as string
340
341
342        String str,winStr="V_1D_Combine",dataType
343        Variable binType,num,ii
344        ControlInfo popup0
345        binType = V_BinTypeStr2Num(S_Value)
346       
[1039]347       
[1050]348        //  x- need to update this to make sure that the data waves are present before plotting. This
[1039]349        //    currently looks in the ToTrim folder, but the binning could be wrong in the data folder
350        //    and will be an error...
351       
352        // be sure that the data is present in the ToTrim folder before trying to plot
353        Variable err = V_itxWavesExist(popStr,binType)
354        if(err)
355                DoAlert 0,"wrong bin type selected"
356                return(0)
357        endif
358       
359       
[1038]360        //dataType now needs to be the full path to the folder
[1039]361        // Plot the "real" data. data copy to trim will be plotted later
362        //
[1038]363        dataType = "root:"+popStr
364       
[1039]365        //remove EVERYTHING from the graph, no matter what
366        String type,list,item
367        list = TraceNameList(winStr,";",1)
368        for(ii=0;ii<ItemsInList(list);ii+=1)
369                item = StringFromList(ii, list, ";")
370//              CheckDisplayed/W=$winStr $(item)
371//              if(V_flag==1)
372                        RemoveFromGraph/Z/W=$winStr $(item)
373//              endif
374        endfor 
375       
376       
[1038]377        sprintf str,"(\"%s\",%d,\"%s\")",dataType,binType,winStr
378
379        Execute ("V_Back_IQ_Graph"+str)
380        Execute ("V_Middle_IQ_Graph"+str)
381        Execute ("V_Front_IQ_Graph"+str)
382
383        ModifyGraph marker=8,opaque=1,msize=3           //make the traces open white circles
384
385
386        NewDataFolder/O root:ToTrim
387       
388        //remove all of the "toTrim" data from the graph, if it's there
389        SetDataFolder root:ToTrim
390        for(ii=0;ii<ItemsInList(ksPanelBinTypeList);ii+=1)
391                type = StringFromList(ii, ksPanelBinTypeList, ";")
392                CheckDisplayed/W=$winStr $("iBin_qxqy_"+type+"_trim")
393                if(V_flag==1)
394                        RemoveFromGraph/W=$winStr $("iBin_qxqy_"+type+"_trim")
395                endif
[1039]396        endfor 
[1038]397        SetDataFolder root:
398
[1039]399
[1038]400        //then kill the data folder, so it can be duplicated
401       
402//
[1039]403//      // duplicate all of the data into the new folder
[1038]404        SetDataFolder $dataType
[1039]405        list = WaveList("*",";","")             //must be in the correct data folder
[1038]406        SetDataFolder root:
407//      Print list     
408        num = ItemsInList(list)
409        for(ii=0;ii<num;ii+=1)
410                str = StringFromList(ii,list)
411                Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim")
412        endfor
[1039]413       
414        // be sure that the data is present in the ToTrim folder before trying to plot
415        err = V_TrimWavesExist(binType)
416        if(err)
417                DoAlert 0,"wrong bin type selected"
418                return(0)
419        endif
420       
421       
[1038]422        // plot the linked data
423        sprintf str,"(\"%s\",%d,\"%s\")","root:ToTrim",binType,winStr
424
425        Execute ("V_Back_IQ_Graph_trim"+str)
426        Execute ("V_Middle_IQ_Graph_trim"+str)
427        Execute ("V_Front_IQ_Graph_trim"+str)
[1039]428        // and link the data to the table with a dependency?
429//      done in the panel macro?
[1038]430       
[1039]431        // last, force the dependency to update so that the trimmed points are shown
432        Wave w = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
433        w[0] += 1
434        w[0] -= 1
[1038]435       
[1039]436       
[1038]437        return(0)       
438End
439
[1074]440
441
[1039]442// kill the dependency,
443// kill the panel, then the associated ToTrim folder
444// do not kill the beg/end waves
[1030]445//
[1039]446Function V_DoneCombine1D_ButtonProc(ctrlName) : ButtonControl
447        String ctrlName
[1030]448       
[1039]449        Wave trimUpdate = root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate
450        trimUpdate = 1          //kills the dependency
451        DoWindow/K V_1D_Combine
[1030]452       
[1039]453        KillDataFolder/Z root:ToTrim
[1030]454       
[1039]455        return(0)
[1030]456End
457
[1039]458// TODO
459// -- verify that this works for all binning cases
460// -- see V_Trim1DDataStr to see if they can be combined
[1030]461//
[1039]462Function V_SaveTrimmed_Button(ctrlName) : ButtonControl
[1030]463        String ctrlName
464       
[1039]465        String detListStr,dataType,str
466        Variable bintype,num,ii
[1030]467
[1039]468        ControlInfo popup0
469        binType = V_BinTypeStr2Num(S_Value)
[1030]470       
471       
[1039]472        if(binType == 1)
473                detListStr = ksBinType1
[1030]474        endif
[1039]475        if(binType == 2)
476                detListStr = ksBinType2
[1030]477        endif
[1039]478        if(binType == 3)
479                detListStr = ksBinType3
[1030]480        endif
[1039]481        if(binType == 4)
482                detListStr = ksBinType4
[1030]483        endif
[1039]484        if(strlen(detListStr)==0)
[1079]485                DoAlert 0,"error in V_SaveTrimmed_Button"
[1039]486                return(0)
487        endif
[1030]488
[1039]489// set the global strings
490        V_TrimWaves2String()            //in case the button wasn't clicked
491        SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr
492        SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr
[1030]493
[1039]494// get a fresh copy of the data
495// duplicate all of the data into the new folder
496        ControlInfo popup1
497        dataType = "root:"+S_Value
[1030]498
[1039]499        SetDataFolder $dataType
500        String list = WaveList("*",";","")              //must be in the correct data folder
501        SetDataFolder root:
502//      Print list     
503        num = ItemsInList(list)
504        for(ii=0;ii<num;ii+=1)
505                str = StringFromList(ii,list)
506                Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim")
507        endfor
[1030]508
[1039]509       
510// trim each data set
511        Variable nBeg,nEnd,npt
512        String detstr
513       
514        SetDataFolder root:ToTrim
515        num = ItemsInList(detListStr)
516        for(ii=0;ii<num;ii+=1)
517                detStr = StringFromList(ii, detListStr)
518                nBeg = NumberByKey(detStr, gBegPtsStr,"=",";")
519                nEnd = NumberByKey(detStr, gEndPtsStr,"=",";")
[1030]520               
[1039]521//              V_TrimOneSet(folderStr,detStr,nBeg,nEnd)
522                Wave/Z qw = $("qBin_qxqy_"+detStr+"_trim")
523                Wave/Z iw = $("iBin_qxqy_"+detStr+"_trim")
524                Wave/Z ew = $("eBin_qxqy_"+detStr+"_trim")
[1030]525
[1039]526                DeletePoints 0,nBeg, qw,iw,ew
[1030]527
[1039]528                npt = numpnts(qw)
529                DeletePoints npt-nEnd,nEnd, qw,iw,ew
530//             
531        endfor
[1030]532
533
[1039]534// remove Q=0 from "B" if it's present
535        SetDataFolder root:ToTrim
536        WAVE/Z qBin = qBin_qxqy_B_trim
537        WAVE/Z iBin = iBin_qxqy_B_trim
538        WAVE/Z eBin = eBin_qxqy_B_trim
539//      WAVE/Z nBin = nBin_qxqy_B_trim
540//      WAVE/Z iBin2 = iBin2_qxqy_B_trim
[1030]541
[1039]542        if(qBin[0] == 0)
543                DeletePoints 0, 1, qBin,iBin,eBin//,nBin,iBin2
544        endif
[1030]545
[1039]546       
547// concatenate
548        V_1DConcatenate("root:","ToTrim","_trim",binType)
[1031]549
[1039]550// sort the waves - concatenation creates tmp_q, tmp_i, tmp_s
551// so this call will work (doesn't need the "_trim" tag)
552        V_TmpSort1D("root:","ToTrim")
[1031]553
[1039]554// write out the data to disk
[1031]555
[1039]556        Execute "V_GetNameForSave()"
557        SVAR newName = root:saveName
558        String saveName = newName
[1031]559
[1039]560        //will write out the tmp_q, tmp_i, tmp_s waves
561        V_Write1DData("root:","ToTrim",saveName)                //don't pass the full path, just the name
[1031]562
563       
[1039]564// put a fresh copy of the data back into the folder since the data was actually trimmed
565// duplicate all of the data into the new folder
566        ControlInfo popup1
567        dataType = "root:"+S_Value
[1031]568
[1039]569        SetDataFolder $dataType
570        list = WaveList("*",";","")             //must be in the correct data folder
571        SetDataFolder root:
572//      Print list     
573        num = ItemsInList(list)
574        for(ii=0;ii<num;ii+=1)
575                str = StringFromList(ii,list)
576                Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim")
577        endfor
[1031]578
579
[1039]580        SetDataFolder root:
[1031]581       
582        return(0)
583End
584
[1030]585
586
587//
[1039]588// dialog to select and load an itx format data file
[1030]589//
[1039]590Function V_Load_ITX_Button(ctrlName) : ButtonControl
[1030]591        String ctrlName
592       
[1039]593        Execute "V_Load_Data_ITX()"
[1030]594       
595        return(0)
596End
597
598
[1039]599// TODO
600// -- document
601Function V_TrimWaves2StringButton(ctrlName) : ButtonControl
[1030]602        String ctrlName
603       
[1039]604        V_TrimWaves2String()
[1031]605
[1030]606        return(0)
[1039]607End
[1030]608
[1039]609// for each of the binning types, be sure that the corresponding waves in the
610// root:ToTrim folder actually do exist.
611// return 0 for OK, 1 if error
612Function V_TrimWavesExist(binType)
613        Variable binType
[1030]614       
[1039]615        String binStr="",str
616        Variable num,ii
[1030]617       
[1039]618        if(binType == 1)
619                binStr = ksBinType1
620        endif
621        if(binType == 2)
622                binStr = ksBinType2
623        endif
624        if(binType == 3)
625                binStr = ksBinType3
626        endif
627        if(binType == 4)
628                binStr = ksBinType4
629        endif
[1030]630       
[1039]631        num = ItemsInList(binStr)
632        for(ii=0;ii<num;ii+=1)
633                str = StringFromList(ii,binStr)
634                if(exists("root:ToTrim:iBin_qxqy_"+Str+"_trim") == 0)           // not in use = error
635                        return(1)
[1030]636                endif
[1039]637        endfor
[1030]638       
[1039]639        return(0)               //everything checked out OK, no error
[1030]640
[1039]641end
[1030]642
[1039]643// for each of the binning types, be sure that the corresponding waves in the
644// root:ToTrim folder actually do exist.
645// return 0 for OK, 1 if error
646Function V_itxWavesExist(folderStr,binType)
647        String folderStr
648        Variable binType
[1030]649       
[1039]650        String binStr="",str
651        Variable num,ii
[1030]652       
[1039]653        if(binType == 1)
654                binStr = ksBinType1
[1030]655        endif
[1039]656        if(binType == 2)
657                binStr = ksBinType2
658        endif
659        if(binType == 3)
660                binStr = ksBinType3
661        endif
662        if(binType == 4)
663                binStr = ksBinType4
664        endif
[1030]665       
[1039]666        num = ItemsInList(binStr)
667        for(ii=0;ii<num;ii+=1)
668                str = StringFromList(ii,binStr)
669                if(exists("root:"+folderStr+":iBin_qxqy_"+Str) == 0)            // not in use = error
670                        return(1)
671                endif
[1030]672        endfor
[1039]673       
674        return(0)               //everything checked out OK, no error
[1030]675
[1039]676end
[1030]677
678
[1039]679
[1031]680//
[1039]681// take the waves, and convert to strings that can be added to the protocol
682//
[1050]683//
[1039]684// x- get the variables out of root:, and move it to Protocols
[1050]685// x- get the waves out of root:, and move it to Protocols
[1039]686// x- be sure that the variables are initialized (done in main initialization
[1050]687// x- link this to the panel?
[1039]688//
689Function V_TrimWaves2String()
[1030]690
[1031]691
[1039]692        SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr
693        SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr
[1031]694
[1039]695        Wave/T PanelNameW = root:Packages:NIST:VSANS:Globals:Protocols:PanelNameW
696        Wave Beg_pts = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
697        Wave End_pts = root:Packages:NIST:VSANS:Globals:Protocols:End_pts
698       
699// ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;"
700// ksBinTrimBegDefault = "B=5;FT=6;FB=6;FL=6;FR=6;MT=6;MB=6;ML=6;MR=6;FTB=7;FLR=7;MTB=7;MLR=7;FLRTB=8;MLRTB=8;"
701// ksBinTrimEndDefault
[1031]702
[1039]703        // wipe out the "old" global strings
704        gBegPtsStr = ksBinTrimBegDefault
705        gEndPtsStr = ksBinTrimEndDefault
[1031]706
[1039]707        Variable num, ii,nBeg,nEnd
708        String item,panelStr
[1031]709       
[1039]710        num = numpnts(PanelNameW)
711        for(ii=0;ii<num;ii+=1)
712                panelStr = PanelNameW[ii]
713                gBegPtsStr = ReplaceNumberByKey(panelStr, gBegPtsStr, Beg_pts[ii],"=",";")
714                gEndPtsStr = ReplaceNumberByKey(panelStr, gEndPtsStr, End_pts[ii],"=",";")
[1031]715        endfor
716
717        return(0)
718End
719
720
Note: See TracBrowser for help on using the repository browser.