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

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

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

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