source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf @ 1237

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

corrected the naming of the new preference for tube efficiency+shadowing

removed old prefrence for detector efficiency since it is now combined with shadowing.

File size: 14.5 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4///
5// x- update all to be only VSANS-specific
6// x- update all of the function names to be unique to VSANS so that there are no
7//    name clashes with the "duplicate" version that is in PlotUtils.ipf
8//
9// x- Make this a VSANS-only panel
10// x- eliminate the USANS tab
11// x- be sure the general tab is either unique, or eliminate it
12// x- be sure the Analysis tab is unique, or eliminate it
13//
14//
15// global variables used by VSANS are stored in:
16// root:Packages:NIST:VSANS:Globals
17//
18
19
20///////////////////////////
21Proc Show_VSANSPreferences_Panel()
22
23        DoWindow/F VSANSPref_Panel
24        if(V_flag==0)
25                // only re-initialize if the variables don't exist, so you don't overwrite what users have changed
26                if( exists("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault") != 2 )              //if the global variable does not exist, initialize
27                        Initialize_VSANSPreferences()
28                endif
29                VSANSPref_Panel()
30        Endif
31//      Print "Preferences Panel stub"
32End
33
34
35//  x- there are more detector specific corrections here that need to be added
36//
37// create the globals here if they are not already present
38// each package initialization should call this to repeat the initialization
39// without overwriting what was already set
40Proc Initialize_VSANSPreferences()
41       
42        Variable val
43
44        // GENERAL tab
45        /// General items for everyone
46        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gXML_Write", 0 )
47        Variable/G root:Packages:NIST:VSANS:Globals:gXML_Write = val
48       
49       
50        // VSANS tab
51        ///// items for VSANS reduction
52        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault", 1 )
53        Variable/G root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault=val
54       
55//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gAllowDRK", 0 )
56//      Variable/G root:Packages:NIST:VSANS:Globals:gAllowDRK=val                       //don't show DRK as default
57       
58        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransCheck", 1 )
59        Variable/G root:Packages:NIST:VSANS:Globals:gDoTransCheck=val
60       
61        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gBinWidth", 1.2 )
62        Variable/G root:Packages:NIST:VSANS:Globals:gBinWidth=val
63       
64        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gNPhiSteps", 90 )
65        Variable/G root:Packages:NIST:VSANS:Globals:gNPhiSteps=val
66       
67        // flags to turn detector corrections on/off for testing (you should leave these ON)
68        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor", 1 )
69        Variable/G root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor = 1
70       
71        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTransmissionCor", 1 )
72        Variable/G root:Packages:NIST:VSANS:Globals:gDoTransmissionCor = 1
73
74        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDIVCor", 1 )
75        Variable/G root:Packages:NIST:VSANS:Globals:gDoDIVCor = 1
76       
77        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor", 1 )
78        Variable/G root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor = 1
79
80        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor", 1 )
81        Variable/G root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor = 1
82
83        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoNonLinearCor", 1 )
84        Variable/G root:Packages:NIST:VSANS:Globals:gDoNonLinearCor = 1
85
86        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor", 1 )
87        Variable/G root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor = 1
88       
89        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization", 1 )
90        Variable/G root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization = 1
91
92        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCorPref", 1 )
93        Variable/G root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCorPref = 0
94
95        // Special global to prevent fake data from "B" detector from being written out
96        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gIgnoreDetB", 1 )
97        Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 1
98
99// TODOHIGHRES
100// OCT 2018
101// new global to flag the highRes detector binning to accomodate the change in binning
102//  that was set 10/16/18 (changed from 4x4 bin to 1x1= no binning)
103// set this flag == 1 for 1x1
104// set flag 4 == 4x4
105        Variable/G root:Packages:NIST:VSANS:Globals:gHighResBinning = 4
106                       
107        DoAlert 1,"Are you using the back detector? (This can be changed later in the Preferences Panel)"
108        if(V_flag == 1)
109                // yes
110                Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 0
111//              DoAlert 1,"Are you using 1x1 binning?"
112//              if(V_flag == 1)
113//                      // yes
114//                      Variable/G root:Packages:NIST:VSANS:Globals:gHighResBinning = 1
115//              endif
116        endif
117       
118// flag to allow adding raw data files with different attenuation (normally not done)   
119//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten",0)
120//      Variable/G root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten=val
121       
122       
123        // VSANS ANALYSIS tab
124        /// items for VSANS Analysis
125       
126       
127end
128
129Function V_LogScalePrefCheck(ctrlName,checked) : CheckBoxControl
130        String ctrlName
131        Variable checked
132       
133        NVAR gLog = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
134        glog=checked
135        //print "log pref checked = ",checked
136End
137
138//Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl
139//      String ctrlName
140//      Variable checked
141//     
142//      NVAR gDRK = root:Packages:NIST:VSANS:Globals:gAllowDRK
143//      gDRK = checked
144//      //Print "DRK preference = ",checked
145//End
146
147Function V_UnityTransPref(ctrlName,checked) : CheckBoxControl
148        String ctrlName
149        Variable checked
150       
151        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransCheck
152        gVal = checked
153End
154
155Function V_XMLWritePref(ctrlName,checked) : CheckBoxControl
156        String ctrlName
157        Variable checked
158       
159        NVAR gVal = root:Packages:NIST:VSANS:Globals:gXML_Write
160        gVal = checked
161End
162
163Function V_DoTransCorrPref(ctrlName,checked) : CheckBoxControl
164        String ctrlName
165        Variable checked
166       
167        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor
168        gVal = checked
169End
170
171// this is efficiency + shadowing
172Function V_DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl
173        String ctrlName
174        Variable checked
175       
176        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
177        gVal = checked
178End
179
180Function V_DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl
181        String ctrlName
182        Variable checked
183       
184        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten
185        gVal = checked
186End
187
188Function V_DoDIVCorPref(ctrlName,checked) : CheckBoxControl
189        String ctrlName
190        Variable checked
191       
192        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDIVCor
193        gVal = checked
194End
195
196Function V_DoDeadTimeCorPref(ctrlName,checked) : CheckBoxControl
197        String ctrlName
198        Variable checked
199       
200        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor
201        gVal = checked
202End
203
204Function V_DoSolidAngleCorPref(ctrlName,checked) : CheckBoxControl
205        String ctrlName
206        Variable checked
207       
208        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor
209        gVal = checked
210End
211
212Function V_DoNonLinearCorPref(ctrlName,checked) : CheckBoxControl
213        String ctrlName
214        Variable checked
215       
216        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor
217        gVal = checked
218End
219
220// not needed-- efficiency and shadowing are done together
221//Function V_DoTubeShadowCorPref(ctrlName,checked) : CheckBoxControl
222//      String ctrlName
223//      Variable checked
224//     
225//      NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
226//      gVal = checked
227//End
228
229Function V_DoMonitorNormPref(ctrlName,checked) : CheckBoxControl
230        String ctrlName
231        Variable checked
232       
233        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization
234        gVal = checked
235End
236
237Function V_DoDownstreamWindowCorPref(ctrlName,checked) : CheckBoxControl
238        String ctrlName
239        Variable checked
240       
241        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCorPref
242        gVal = checked
243End
244
245
246Function V_IgnoreDetBPref(ctrlName,checked) : CheckBoxControl
247        String ctrlName
248        Variable checked
249       
250        NVAR gVal = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
251        gVal = checked
252End
253
254Function V_PrefDoneButtonProc(ctrlName) : ButtonControl
255        String ctrlName
256       
257        DoWindow/K VSANSPref_Panel
258End
259
260
261Proc VSANSPref_Panel()
262        PauseUpdate; Silent 1           // building window...
263        NewPanel /W=(646,208,1070,468)/K=2 as "VSANS Preference Panel"
264        DoWindow/C VSANSPref_Panel
265        ModifyPanel cbRGB=(47748,57192,54093)
266        SetDrawLayer UserBack
267        ModifyPanel fixedSize=1
268//////
269//on main portion of panel, always visible
270        Button PrefPanelButtonA,pos={354,12},size={50,20},proc=V_PrefDoneButtonProc,title="Done"
271
272        TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=V_PrefTabProc
273        TabControl PrefTab,tabLabel(1)="VSANS",tabLabel(2)="Analysis"
274        TabControl PrefTab,value=1
275        TabControl PrefTab labelBack=(47748,57192,54093)
276       
277//on tab(0) - General
278        CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=V_XMLWritePref,title="Use canSAS XML Output"
279        CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"}
280        CheckBox PrefCtrl_0a,value= root:Packages:NIST:VSANS:Globals:gXML_Write
281
282        CheckBox PrefCtrl_0a,disable=1
283
284
285//on tab(1) - VSANS - initially visible
286        CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=V_LogScalePrefCheck,title="Use Log scaling for 2D data display"
287        CheckBox PrefCtrl_1a,help={"Checking this will display 2D VSANS data with a logarithmic color scale of neutron counts. If not checked, the color mapping will be linear."}
288        CheckBox PrefCtrl_1a,value= root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
289//      CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=V_DRKProtocolPref,title="Allow DRK correction in protocols"
290//      CheckBox PrefCtrl_1b,help={"Checking this will allow DRK correction to be used in reduction protocols. You will need to re-draw the protocol panel for this change to be visible."}
291//      CheckBox PrefCtrl_1b,value= root:Packages:NIST:VSANS:Globals:gAllowDRK
292        CheckBox PrefCtrl_1c,pos={21,140},size={137,14},proc=V_UnityTransPref,title="Check for Transmission = 1"
293        CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"}
294        CheckBox PrefCtrl_1c,value= root:Packages:NIST:VSANS:Globals:gDoTransCheck
295        SetVariable PrefCtrl_1d,pos={21,170},size={200,15},title="Averaging Bin Width (pixels)"
296        SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:VSANS:Globals:gBinWidth
297        SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)"
298        SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps
299       
300        CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCor,proc=V_DoTransCorrPref
301        CheckBox PrefCtrl_1f pos={255,80},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."}
302        CheckBox PrefCtrl_1g title="Do Tube Efficiency+Shadowing?",size={140,14},proc=V_DoEfficiencyCorrPref
303        CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."}
304//      CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=V_DoRawAttenAdjPref
305//      CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"}
306
307        CheckBox PrefCtrl_1i title="Do DIV Correction?",size={140,14},proc=V_DoDIVCorPref
308        CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING."}
309        CheckBox PrefCtrl_1j title="Do DeadTime Correction?",size={140,14},proc=V_DoDeadTimeCorPref
310        CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255,140},help={"TURN OFF ONLY FOR DEBUGGING."} 
311        CheckBox PrefCtrl_1k title="Do Solid Angle Correction?",size={140,14},proc=V_DoSolidAngleCorPref
312        CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255,160},help={"TURN OFF ONLY FOR DEBUGGING."}
313        CheckBox PrefCtrl_1l title="Do Non-linear Correction?",size={140,14},proc=V_DoNonLinearCorPref,disable=2
314        CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255,180},help={"Non-linear correction can't be turned off"}
315        CheckBox PrefCtrl_1m title="Do Downstream Window Corr?",size={140,14},proc=V_DoDownstreamWindowCorPref
316        CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoDownstreamWindowCorPref,pos={255,200},help={"TURN OFF ONLY FOR DEBUGGING."}
317//      CheckBox PrefCtrl_1n title="Do Monitor Normalization?",size={140,14},proc=V_DoMonitorNormPref
318//      CheckBox PrefCtrl_1n value=root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."}
319        CheckBox PrefCtrl_1o title="Ignore Back Detector?",size={140,14},proc=V_IgnoreDetBPref
320        CheckBox PrefCtrl_1o value=root:Packages:NIST:VSANS:Globals:gIgnoreDetB,pos={150,220},help={"Will prevent data from Back detector being written to data files."}               
321       
322//      CheckBox PrefCtrl_1a,disable=1
323//      CheckBox PrefCtrl_1b,disable=1
324//      CheckBox PrefCtrl_1c,disable=1
325//      SetVariable PrefCtrl_1d,disable=1
326//      SetVariable PrefCtrl_1e,disable=1
327//      CheckBox PrefCtrl_1f,disable=1
328//      CheckBox PrefCtrl_1g,disable=1
329//      CheckBox PrefCtrl_1h,disable=1
330//      CheckBox PrefCtrl_1g,value=0,disable=2          // angle dependent efficiency not done yet
331        CheckBox PrefCtrl_1m,value=0,disable=2          // downstream window transmission no done yet
332
333//on tab(2) - Analysis
334        GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12
335       
336        GroupBox PrefCtrl_2a,disable=1
337
338End
339
340// function to control the drawing of controls in the TabControl on the main panel
341// Naming scheme for the controls MUST be strictly adhered to... else controls will
342// appear in odd places...
343// all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting
344// the controls position on that particular tab.
345// in this way, they will always be drawn correctly..
346//
347Function V_PrefTabProc(name,tab)
348        String name
349        Variable tab
350       
351//      Print "name,number",name,tab
352        String ctrlList = ControlNameList("",";"),item="",nameStr=""
353        Variable num = ItemsinList(ctrlList,";"),ii,onTab
354        for(ii=0;ii<num;ii+=1)
355                //items all start w/"PrefCtrl_", 9 characters
356                item=StringFromList(ii, ctrlList ,";")
357                nameStr=item[0,8]
358                if(cmpstr(nameStr,"PrefCtrl_")==0)
359                        onTab = str2num(item[9])                        //[9] is a number
360                        ControlInfo $item
361                        switch(abs(V_flag))     
362                                case 1:
363                                        Button $item,disable=(tab!=onTab)
364                                        break
365                                case 2:
366                                        CheckBox $item,disable=(tab!=onTab)
367                                        break
368                                case 5:
369                                        SetVariable $item,disable=(tab!=onTab)
370                                        break
371                                case 10:       
372                                        TitleBox $item,disable=(tab!=onTab)
373                                        break
374                                case 4:
375                                        ValDisplay $item,disable=(tab!=onTab)
376                                        break
377                                case 9:
378                                        GroupBox $item,disable=(tab!=onTab)
379                                        break
380                                // add more items to the switch if different control types are used
381                        endswitch
382                endif
383        endfor
384        return(0)
385End
Note: See TracBrowser for help on using the repository browser.