1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 from optparse import Option
26 import hlr_options
27 import hlr_utils
28
30 """
31 This class provides options for the DGS class of instruments for use in
32 reducing neutron scattering data with the data reduction drivers.
33 """
34
35 - def __init__(self, usage=None, option_list=None, options_class=None,
36 version=None, conflict_handler='error', description=None,
37 **kwargs):
38 """
39 Constructor for C{DgsOptions}
40
41 @param usage: (OPTIONAL) The correct usage of program in which the
42 option class is used
43 @type usage: C{string}
44
45 @param option_list: (OPTIONAL) A list containing the alternative method
46 of providing options
47 @type option_list: C{list}
48
49 @param options_class: (OPTIONAL) The options class type
50 @type options_class: C{optparse.Option}
51
52 @param version: (OPTIONAL) The program version
53 @type version: C{string}
54
55 @param conflict_handler: (OPTIONAL) How the parser handles conflicts
56 between options.
57 @type conflict_handler: C{string}
58
59 @param description: (OPTIONAL) The program description
60 @type description: C{string}
61
62 @param kwargs: A list of keyword arguments that the function accepts:
63 """
64
65 hlr_options.InstOptions.__init__(self, usage, option_list,
66 Option, version, conflict_handler,
67 description, inst="DGS")
68
69 self.add_option("", "--usmon-path", dest="usmon_path",
70 help="Specify the comma separated list of upstream "\
71 +"monitor path and signal.")
72
73 self.add_option("", "--dsmon-path", dest="dsmon_path",
74 help="Specify the comma separated list of downstream "\
75 +"monitor path and signal.")
76
77 self.add_option("", "--roi-file", dest="roi_file",
78 help="Specify a file that contains a list of pixel "\
79 +"ids to be read from the data")
80
81 self.add_option("", "--tib-const", dest="tib_const",
82 help="Specify the value and err^2 for a "\
83 +"time-independent background subtraction constant.")
84
85 self.add_option("", "--initial-energy", dest="initial_energy",
86 help="Specify the initial energy, err^2 for the "\
87 +"reduction in units of meV")
88
89 self.add_option("", "--time-zero-offset", dest="time_zero_offset",
90 help="Specify the time-zero offset, err^2 in units "\
91 +"of microseconds")
92
93 self.add_option("", "--no-mon-norm", action="store_true",
94 dest="no_mon_norm",
95 help="Flag for turning off monitor normalization")
96
97 self.add_option("", "--pc-norm", action="store_true", dest="pc_norm",
98 help="Flag for performing proton charge "\
99 +"normalization. This will only be done if monitor "\
100 +"normalization is turned off.")
101
102 self.add_option("", "--mon-int-range", dest="mon_int_range",
103 type="float", nargs=2, help="Set the minimum and "\
104 +"maximum values in TOF [microseconds] for the "\
105 +"integration of the monitor.")
106
107 self.add_option("", "--det-eff", dest="det_eff",
108 help="Specify the detector efficiency file or an "\
109 +"efficiency tuple (efficiency,error2)")
110
111 self.add_option("", "--data-trans-coeff", dest="data_trans_coeff",
112 help="Specify the transmission coefficient value and "\
113 +"err^2 for the sample data background.")
114
115 self.add_option("", "--norm-trans-coeff", dest="norm_trans_coeff",
116 help="Specify the transmission coefficient value and "\
117 +"err^2 for the normalization data background.")
118
119 self.add_option("", "--norm-int-range", dest="norm_int_range",
120 type="float", nargs=2, help="Set the minimum and "\
121 +"maximum values in energy transfer [meV] for the "\
122 +"integration of the vanadium (norm) dataset.")
123
124 self.add_option("", "--lambda-bins", dest="lambda_bins",
125 help="Specify the minimum and maximum wavelength "\
126 +"values and the wavelength bin width in Angstroms")
127 self.set_defaults(lambda_bins="0.0,10.0,0.1")
128
129 self.add_option("", "--dump-ctof-comb", action="store_true",
130 dest="dump_ctof_comb",
131 help="Flag to dump the calibrated TOF information "\
132 +"for all pixels combined. Creates a *.ctof file.")
133 self.set_defaults(dump_ctof_comb=False)
134
135 self.add_option("", "--dump-wave-comb", action="store_true",
136 dest="dump_wave_comb",
137 help="Flag to dump the wavelength information for all"\
138 +" pixels combined. Creates a *.fwv file.")
139 self.set_defaults(dump_wave_comb=False)
140
141 self.add_option("", "--dump-norm", action="store_true",
142 dest="dump_norm", help="Flag to dump the wavelength "\
143 +"information after vanadium normalization for all"\
144 +"pixels. Creates a *.norm file.")
145 self.set_defaults(dump_norm=False)
146
147
149 """
150 This function sets the incoming C{Configure} object with all the options
151 that have been specified via the C{DgsOptions} object.
152
153 @param parser: The parser object
154 @type parser: L{hlr_utils.DgsOptions}
155
156 @param configure: The configuration object
157 @type configure: L{hlr_utils.Configure}
158
159 @param options: The parsed options from C{DgsOptions}
160 @type options: C{Option}
161
162 @param args: The parsed arguments from C{DgsOptions}
163 @type args: C{list}
164 """
165
166
167 hlr_options.InstConfiguration(parser, configure, options, args, inst="DGS")
168
169
170 if hlr_utils.cli_provide_override(configure, "usmon_path", "--usmon-path"):
171 configure.usmon_path = hlr_utils.NxPath(options.usmon_path)
172
173
174 if hlr_utils.cli_provide_override(configure, "dsmon_path", "--dsmon-path"):
175 configure.dsmon_path = hlr_utils.NxPath(options.dsmon_path)
176
177
178 if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
179 configure.roi_file = hlr_utils.determine_files(options.roi_file,
180 one_file=True)
181
182
183 if hlr_utils.cli_provide_override(configure, "tib_const", "--tib-const"):
184 configure.tib_const = hlr_utils.DrParameterFromString(\
185 options.tib_const, True)
186
187
188 if hlr_utils.cli_provide_override(configure, "initial_energy",
189 "--initial-energy"):
190 configure.initial_energy = hlr_utils.DrParameterFromString(\
191 options.initial_energy, True)
192
193
194 if hlr_utils.cli_provide_override(configure, "time_zero_offset",
195 "--time-zero-offset"):
196 configure.time_zero_offset = hlr_utils.DrParameterFromString(\
197 options.time_zero_offset, True)
198
199
200 if hlr_utils.cli_provide_override(configure, "no_mon_norm",
201 "--no-mon-norm"):
202 configure.no_mon_norm = options.no_mon_norm
203
204
205 if hlr_utils.cli_provide_override(configure, "pc_norm",
206 "--pc-norm"):
207 configure.pc_norm = options.pc_norm
208
209
210 if hlr_utils.cli_provide_override(configure, "mon_int_range",
211 "--mon-int-range"):
212 configure.mon_int_range = options.mon_int_range
213
214
215
216 if hlr_utils.cli_provide_override(configure, "det_eff", "--det-eff"):
217 try:
218 configure.det_eff = hlr_utils.DrParameterFromString(\
219 options.det_eff, True)
220 except RuntimeError:
221 configure.det_eff = hlr_utils.determine_files(options.det_eff,
222 one_file=True)
223
224
225 if hlr_utils.cli_provide_override(configure, "data_trans_coeff",
226 "--data-trans-coeff"):
227 configure.data_trans_coeff = hlr_utils.DrParameterFromString(\
228 options.data_trans_coeff, True)
229
230
231 if hlr_utils.cli_provide_override(configure, "norm_trans_coeff",
232 "--norm-trans-coeff"):
233 configure.norm_trans_coeff = hlr_utils.DrParameterFromString(\
234 options.norm_trans_coeff, True)
235
236
237 if hlr_utils.cli_provide_override(configure, "norm_int_range",
238 "--norm-int-range"):
239 configure.norm_int_range = options.norm_int_range
240
241
242 if hlr_utils.cli_provide_override(configure, "lambda_bins",
243 "--lambda-bins"):
244 configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)
245
246
247 if hlr_utils.cli_provide_override(configure, "dump_ctof_comb",
248 "--dump-ctof-comb"):
249 configure.dump_ctof_comb = options.dump_ctof_comb
250
251
252 if hlr_utils.cli_provide_override(configure, "dump_wave_comb",
253 "--dump-wave-comb"):
254 configure.dump_wave_comb = options.dump_wave_comb
255
256
257 if hlr_utils.cli_provide_override(configure, "dump_norm", "--dump-norm"):
258 configure.dump_norm = options.dump_norm
259