source: sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf @ 1175

Last change on this file since 1175 was 1175, checked in by krzywon, 3 years ago

Lay ground work for writing VSANS reduced data in the NXcanSAS format.

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