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

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

lots of changes here:
many little fixes to clean up TODO items and marke them DONE

changed the handling of the panel "gap" to split the gap evenly. Q-calculations have been re-verified with this change.

re-named the list of "bin Type" values, and added a few more choices. Streamlined how the averaging and plotting works with this list so that it can be more easily modified as different combinations of binning are envisioned. This resulted in a lot of excess code being cut out and replaced with cleaner logic. This change has also been verified to work as intended.

Attenuation is now always calculated from the table. The table also by (NEW) definition has values for the white beam (one waelength) and graphite (multiple possible wavelengths) where the wavelengths are artificially scaled (*1000) or *1e6) so that the interpolations can be done internally without the need for multiple attenuator tables.

File size: 13.2 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 )
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
93        // Special global to prevent fake data from "B" detector from being written out
94        val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gIgnoreDetB", 1 )
95        Variable/G root:Packages:NIST:VSANS:Globals:gIgnoreDetB = 1
96               
97        DoAlert 0,"The Back detector will be ignored. Change this in the Preferences Panel"
98       
99// flag to allow adding raw data files with different attenuation (normally not done)   
100//      val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten",0)
101//      Variable/G root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten=val
102       
103       
104        // VSANS ANALYSIS tab
105        /// items for VSANS Analysis
106       
107       
108end
109
110Function V_LogScalePrefCheck(ctrlName,checked) : CheckBoxControl
111        String ctrlName
112        Variable checked
113       
114        NVAR gLog = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
115        glog=checked
116        //print "log pref checked = ",checked
117End
118
119//Function DRKProtocolPref(ctrlName,checked) : CheckBoxControl
120//      String ctrlName
121//      Variable checked
122//     
123//      NVAR gDRK = root:Packages:NIST:VSANS:Globals:gAllowDRK
124//      gDRK = checked
125//      //Print "DRK preference = ",checked
126//End
127
128Function V_UnityTransPref(ctrlName,checked) : CheckBoxControl
129        String ctrlName
130        Variable checked
131       
132        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransCheck
133        gVal = checked
134End
135
136Function V_XMLWritePref(ctrlName,checked) : CheckBoxControl
137        String ctrlName
138        Variable checked
139       
140        NVAR gVal = root:Packages:NIST:VSANS:Globals:gXML_Write
141        gVal = checked
142End
143
144Function V_DoTransCorrPref(ctrlName,checked) : CheckBoxControl
145        String ctrlName
146        Variable checked
147       
148        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor
149        gVal = checked
150End
151
152Function V_DoEfficiencyCorrPref(ctrlName,checked) : CheckBoxControl
153        String ctrlName
154        Variable checked
155       
156        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor
157        gVal = checked
158End
159
160Function V_DoRawAttenAdjPref(ctrlName,checked) : CheckBoxControl
161        String ctrlName
162        Variable checked
163       
164        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten
165        gVal = checked
166End
167
168Function V_DoDIVCorPref(ctrlName,checked) : CheckBoxControl
169        String ctrlName
170        Variable checked
171       
172        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDIVCor
173        gVal = checked
174End
175
176Function V_DoDeadTimeCorPref(ctrlName,checked) : CheckBoxControl
177        String ctrlName
178        Variable checked
179       
180        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor
181        gVal = checked
182End
183
184Function V_DoSolidAngleCorPref(ctrlName,checked) : CheckBoxControl
185        String ctrlName
186        Variable checked
187       
188        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor
189        gVal = checked
190End
191
192Function V_DoNonLinearCorPref(ctrlName,checked) : CheckBoxControl
193        String ctrlName
194        Variable checked
195       
196        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor
197        gVal = checked
198End
199
200Function V_DoTubeShadowCorPref(ctrlName,checked) : CheckBoxControl
201        String ctrlName
202        Variable checked
203       
204        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor
205        gVal = checked
206End
207
208Function V_DoMonitorNormPref(ctrlName,checked) : CheckBoxControl
209        String ctrlName
210        Variable checked
211       
212        NVAR gVal = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization
213        gVal = checked
214End
215
216Function V_IgnoreDetBPref(ctrlName,checked) : CheckBoxControl
217        String ctrlName
218        Variable checked
219       
220        NVAR gVal = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
221        gVal = checked
222End
223
224Function V_PrefDoneButtonProc(ctrlName) : ButtonControl
225        String ctrlName
226       
227        DoWindow/K VSANSPref_Panel
228End
229
230
231Proc VSANSPref_Panel()
232        PauseUpdate; Silent 1           // building window...
233        NewPanel /W=(646,208,1070,468)/K=2 as "VSANS Preference Panel"
234        DoWindow/C VSANSPref_Panel
235        ModifyPanel cbRGB=(47748,57192,54093)
236        SetDrawLayer UserBack
237        ModifyPanel fixedSize=1
238//////
239//on main portion of panel, always visible
240        Button PrefPanelButtonA,pos={354,12},size={50,20},proc=V_PrefDoneButtonProc,title="Done"
241
242        TabControl PrefTab,pos={7,49},size={410,202},tabLabel(0)="General",proc=V_PrefTabProc
243        TabControl PrefTab,tabLabel(1)="VSANS",tabLabel(2)="Analysis"
244        TabControl PrefTab,value=1
245        TabControl PrefTab labelBack=(47748,57192,54093)
246       
247//on tab(0) - General
248        CheckBox PrefCtrl_0a,pos={21,96},size={124,14},proc=V_XMLWritePref,title="Use canSAS XML Output"
249        CheckBox PrefCtrl_0a,help={"Checking this will set the default output format to be canSAS XML rather than NIST 6 column"}
250        CheckBox PrefCtrl_0a,value= root:Packages:NIST:VSANS:Globals:gXML_Write
251
252        CheckBox PrefCtrl_0a,disable=1
253
254
255//on tab(1) - VSANS - initially visible
256        CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=V_LogScalePrefCheck,title="Use Log scaling for 2D data display"
257        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."}
258        CheckBox PrefCtrl_1a,value= root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
259//      CheckBox PrefCtrl_1b,pos={21,120},size={163,14},proc=V_DRKProtocolPref,title="Allow DRK correction in protocols"
260//      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."}
261//      CheckBox PrefCtrl_1b,value= root:Packages:NIST:VSANS:Globals:gAllowDRK
262        CheckBox PrefCtrl_1c,pos={21,140},size={137,14},proc=V_UnityTransPref,title="Check for Transmission = 1"
263        CheckBox PrefCtrl_1c,help={"Checking this will check for SAM or EMP Trans = 1 during data correction"}
264        CheckBox PrefCtrl_1c,value= root:Packages:NIST:VSANS:Globals:gDoTransCheck
265        SetVariable PrefCtrl_1d,pos={21,170},size={200,15},title="Averaging Bin Width (pixels)"
266        SetVariable PrefCtrl_1d,limits={1,100,1},value= root:Packages:NIST:VSANS:Globals:gBinWidth
267        SetVariable PrefCtrl_1e,pos={21,195},size={200,15},title="# Phi Steps (annular avg)"
268        SetVariable PrefCtrl_1e,limits={1,360,1},value= root:Packages:NIST:VSANS:Globals:gNPhiSteps
269       
270        CheckBox PrefCtrl_1f title="Do Transmssion Correction?",size={140,14},value=root:Packages:NIST:VSANS:Globals:gDoTransmissionCor,proc=V_DoTransCorrPref
271        CheckBox PrefCtrl_1f pos={255,80},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent transmssion."}
272        CheckBox PrefCtrl_1g title="Do Efficiency Correction?",size={140,14},proc=V_DoEfficiencyCorrPref
273        CheckBox PrefCtrl_1g value=root:Packages:NIST:VSANS:Globals:gDoDetectorEffCor,pos={255,100},help={"TURN OFF ONLY FOR DEBUGGING. This corrects the data for angle dependent detector efficiency."}
274//      CheckBox PrefCtrl_1h title="Adjust RAW attenuation?",size={140,14},proc=V_DoRawAttenAdjPref
275//      CheckBox PrefCtrl_1h value=root:Packages:NIST:VSANS:Globals:gDoAdjustRAW_Atten,pos={255,140},help={"This is normally not done"}
276
277        CheckBox PrefCtrl_1i title="Do DIV Correction?",size={140,14},proc=V_DoDIVCorPref
278        CheckBox PrefCtrl_1i value=root:Packages:NIST:VSANS:Globals:gDoDIVCor,pos={255,120},help={"TURN OFF ONLY FOR DEBUGGING."}
279        CheckBox PrefCtrl_1j title="Do DeadTime Correction?",size={140,14},proc=V_DoDeadTimeCorPref
280        CheckBox PrefCtrl_1j value=root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor,pos={255,140},help={"TURN OFF ONLY FOR DEBUGGING."} 
281        CheckBox PrefCtrl_1k title="Do Solid Angle Correction?",size={140,14},proc=V_DoSolidAngleCorPref
282        CheckBox PrefCtrl_1k value=root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor,pos={255,160},help={"TURN OFF ONLY FOR DEBUGGING."}
283        CheckBox PrefCtrl_1l title="Do Non-linear Correction?",size={140,14},proc=V_DoNonLinearCorPref
284        CheckBox PrefCtrl_1l value=root:Packages:NIST:VSANS:Globals:gDoNonLinearCor,pos={255,180},help={"TURN OFF ONLY FOR DEBUGGING."}
285        CheckBox PrefCtrl_1m title="Do Tube Shadow Correction?",size={140,14},proc=V_DoTubeShadowCorPref
286        CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor,pos={255,200},help={"TURN OFF ONLY FOR DEBUGGING."}
287//      CheckBox PrefCtrl_1n title="Do Tube Shadow Correction?",size={140,14},proc=V_DoMonitorNormPref
288//      CheckBox PrefCtrl_1n value=root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization,pos={255,220},help={"TURN OFF ONLY FOR DEBUGGING."}
289        CheckBox PrefCtrl_1m title="Ignore Back Detector?",size={140,14},proc=V_IgnoreDetBPref
290        CheckBox PrefCtrl_1m value=root:Packages:NIST:VSANS:Globals:gIgnoreDetB,pos={150,220},help={"Will prevent data from Back detector being written to data files."}               
291       
292//      CheckBox PrefCtrl_1a,disable=1
293//      CheckBox PrefCtrl_1b,disable=1
294//      CheckBox PrefCtrl_1c,disable=1
295//      SetVariable PrefCtrl_1d,disable=1
296//      SetVariable PrefCtrl_1e,disable=1
297//      CheckBox PrefCtrl_1f,disable=1
298//      CheckBox PrefCtrl_1g,disable=1
299//      CheckBox PrefCtrl_1h,disable=1
300
301//on tab(2) - Analysis
302        GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12
303       
304        GroupBox PrefCtrl_2a,disable=1
305
306End
307
308// function to control the drawing of controls in the TabControl on the main panel
309// Naming scheme for the controls MUST be strictly adhered to... else controls will
310// appear in odd places...
311// all controls are named PrefCtrl_NA where N is the tab number and A is the letter denoting
312// the controls position on that particular tab.
313// in this way, they will always be drawn correctly..
314//
315Function V_PrefTabProc(name,tab)
316        String name
317        Variable tab
318       
319//      Print "name,number",name,tab
320        String ctrlList = ControlNameList("",";"),item="",nameStr=""
321        Variable num = ItemsinList(ctrlList,";"),ii,onTab
322        for(ii=0;ii<num;ii+=1)
323                //items all start w/"PrefCtrl_", 9 characters
324                item=StringFromList(ii, ctrlList ,";")
325                nameStr=item[0,8]
326                if(cmpstr(nameStr,"PrefCtrl_")==0)
327                        onTab = str2num(item[9])                        //[9] is a number
328                        ControlInfo $item
329                        switch(abs(V_flag))     
330                                case 1:
331                                        Button $item,disable=(tab!=onTab)
332                                        break
333                                case 2:
334                                        CheckBox $item,disable=(tab!=onTab)
335                                        break
336                                case 5:
337                                        SetVariable $item,disable=(tab!=onTab)
338                                        break
339                                case 10:       
340                                        TitleBox $item,disable=(tab!=onTab)
341                                        break
342                                case 4:
343                                        ValDisplay $item,disable=(tab!=onTab)
344                                        break
345                                case 9:
346                                        GroupBox $item,disable=(tab!=onTab)
347                                        break
348                                // add more items to the switch if different control types are used
349                        endswitch
350                endif
351        endfor
352        return(0)
353End
Note: See TracBrowser for help on using the repository browser.