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

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

adding downstream window transmission correction -- added function to detector corrections, and added item to preference panel. Transmission value is currently set as a global since the value is not part of the VSANS header. Global value defaults to T=1= no correction.

Other changes are cleanup of TODO items that were already done and tested. inline commnents have been updated.

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