Package hlr_utils :: Module hlr_dgs_options
[hide private]
[frames] | no frames]

Source Code for Module hlr_utils.hlr_dgs_options

  1  #                  High-Level Reduction Functions 
  2  #           A part of the SNS Analysis Software Suite. 
  3  # 
  4  #                  Spallation Neutron Source 
  5  #          Oak Ridge National Laboratory, Oak Ridge TN. 
  6  # 
  7  # 
  8  #                             NOTICE 
  9  # 
 10  # For this software and its associated documentation, permission is granted 
 11  # to reproduce, prepare derivative works, and distribute copies to the public 
 12  # for any purpose and without fee. 
 13  # 
 14  # This material was prepared as an account of work sponsored by an agency of 
 15  # the United States Government.  Neither the United States Government nor the 
 16  # United States Department of Energy, nor any of their employees, makes any 
 17  # warranty, express or implied, or assumes any legal liability or 
 18  # responsibility for the accuracy, completeness, or usefulness of any 
 19  # information, apparatus, product, or process disclosed, or represents that 
 20  # its use would not infringe privately owned rights. 
 21  # 
 22   
 23  # $Id: hlr_dgs_options.py 2726 2009-01-12 20:07:30Z 2zr $ 
 24   
 25  from optparse import Option 
 26  import hlr_options 
 27  import hlr_utils 
 28   
29 -class DgsOptions(hlr_options.InstOptions):
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 # parent constructor 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
148 -def DgsConfiguration(parser, configure, options, args):
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 # Call the configuration setter for InstOptions 167 hlr_options.InstConfiguration(parser, configure, options, args, inst="DGS") 168 169 # Set the upstream monitor path 170 if hlr_utils.cli_provide_override(configure, "usmon_path", "--usmon-path"): 171 configure.usmon_path = hlr_utils.NxPath(options.usmon_path) 172 173 # Set the downstream monitor path 174 if hlr_utils.cli_provide_override(configure, "dsmon_path", "--dsmon-path"): 175 configure.dsmon_path = hlr_utils.NxPath(options.dsmon_path) 176 177 # Set the ROI file 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 # Set a time-independent background subtraction constant 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 # Set the initial energy 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 # Set the time-zero offset 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 # Set no_mon_norm flag 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 # Set proton charge normalization flag 205 if hlr_utils.cli_provide_override(configure, "pc_norm", 206 "--pc-norm"): 207 configure.pc_norm = options.pc_norm 208 209 # Set the TOF range for the monitor integration 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 # Set the detector efficiency. This can be a tuple (one number for all 215 # pixels) or a file containing numbers for all pixels. 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 # Set the transmission coefficient for the sample data background 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 # Set the transmission coefficient for the normalization background 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 # Set the wavelength range for the vanadium normalization integration 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 # Set the wavelength bins 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 # Set the ability to dump the combined calibrated TOF information 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 # Set the ability to dump the combined final wavelength information 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 # Set the ability to dump the normalization information 257 if hlr_utils.cli_provide_override(configure, "dump_norm", "--dump-norm"): 258 configure.dump_norm = options.dump_norm
259