예제 #1
0
def SmhrConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{SmhrOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.SmhrOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{SmhrOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{SmhrOptions}
    @type args: C{list}
    """

    # Call the configuration setter for RefOptions
    hlr_ref_options.RefConfiguration(parser, configure, options, args)

    # Set the beam divergence calculation flag
    if hlr_utils.cli_provide_override(configure, "beamdiv_corr",
                                      "--beamdiv-corr"):
        configure.beamdiv_corr = options.beamdiv_corr

    # Set the detector spatial resolution
    if hlr_utils.cli_provide_override(configure, "det_spat_res",
                                      "--det-spat-res"):
        if options.det_spat_res is None:
            configure.det_spat_res = options.det_spat_res
        else:
            # Set this to half its values for the acceptance polygon
            # and convert units to meters
            configure.det_spat_res = 0.5 * options.det_spat_res * 1.0e-3

    # Set the center pixel for the beam divergence calculation
    if hlr_utils.cli_provide_override(configure, "center_pix", "--center-pix"):
        configure.center_pix = options.center_pix

    # Set the number of bins to clean from a cut spectra
    if hlr_utils.cli_provide_override(configure, "num_bins_clean",
                                      "--num-bins-clean"):
        configure.num_bins_clean = options.num_bins_clean
예제 #2
0
    )
    parser.set_defaults(acc_down_time="0.0,0.0,seconds")

    parser.add_option("", "--timing", action="store_true", dest="timing", help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for SansOptions
    hlr_utils.SansConfiguration(parser, configure, options, args)

    # Set the accelerator down time
    if hlr_utils.cli_provide_override(configure, "acc_down_time", "--acc-down-time"):
        configure.acc_down_time = hlr_utils.DrParameterFromString(options.acc_down_time, True)

    if configure.lambda_bins is None:
        parser.error("Please specify the final wavelength axis!")

    # Set timer object if timing option is used
    if options.timing:
        import sns_timing

        timer = sns_timing.DiffTime()
    else:
        timer = None

    # Run the program
    run(configure, timer)
예제 #3
0
    parser.set_defaults(wb_norm=False)
    
    parser.add_option("", "--timing", action="store_true", dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for DgsOptions
    hlr_utils.DgsConfiguration(parser, configure, options, args)

    # Set the high threshold value
    if hlr_utils.cli_provide_override(configure, "hi_threshold",
                                      "--hi-threshold"):
        configure.hi_threshold = options.hi_threshold
        
    # Set the low threshold value
    if hlr_utils.cli_provide_override(configure, "lo_threshold",
                                      "--lo-threshold"):
        configure.lo_threshold = options.lo_threshold

    # Set the white-beam normalization option
    if hlr_utils.cli_provide_override(configure, "wb_norm", "--wb-norm"):
        configure.wb_norm = options.wb_norm
        
    # Set timer object if timing option is used
    if options.timing:
        import sns_timing
        timer = sns_timing.DiffTime()
예제 #4
0
def DgsConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{DgsOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.DgsOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{DgsOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{DgsOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_options.InstConfiguration(parser, configure, options, args, inst="DGS")

    # Set the upstream monitor path
    if hlr_utils.cli_provide_override(configure, "usmon_path", "--usmon-path"):
        configure.usmon_path = hlr_utils.NxPath(options.usmon_path)

    # Set the downstream monitor path
    if hlr_utils.cli_provide_override(configure, "dsmon_path", "--dsmon-path"):
        configure.dsmon_path = hlr_utils.NxPath(options.dsmon_path)        

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file,
                                                       one_file=True)

    # Set the minimum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_min",
                                      "--tof-cut-min"):
        configure.tof_cut_min = options.tof_cut_min

    # Set the maximum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_max",
                                      "--tof-cut-max"):
        configure.tof_cut_max = options.tof_cut_max        

    # Set a time-independent background subtraction constant
    if hlr_utils.cli_provide_override(configure, "tib_const", "--tib-const"):
        configure.tib_const = hlr_utils.DrParameterFromString(\
            options.tib_const, True)

    # Set the TOF range for the time-independent background determination
    if hlr_utils.cli_provide_override(configure, "tib_range", "--tib-range"):
        configure.tib_range = options.tib_range

    # Stop is both TIB methods are used
    if configure.tib_const is not None and configure.tib_range is not None:
        parser.error("Please use either --tib-const or --tib-range")

    # Set the chopper phase corrections for sample data
    if hlr_utils.cli_provide_override(configure, "cwp_data", "--cwp-data"):
        if options.cwp_data is not None:
            configure.cwp_data = [float(x) \
                                  for x in options.cwp_data.split(',')]
            if len(configure.data) != len(configure.cwp_data):
                parser.error("Need the same number of chopper phase "\
                             +"corrections as sample data runs!")
        else:
            configure.cwp_data = options.cwp_data

    # Set the chopper phase corrections for empty can data
    if hlr_utils.cli_provide_override(configure, "cwp_ecan", "--cwp-ecan"):
        if options.cwp_ecan is not None:
            configure.cwp_ecan = [float(x) \
                                  for x in options.cwp_ecan.split(',')]
            if len(configure.ecan) != len(configure.cwp_ecan):
                parser.error("Need the same number of chopper phase "\
                             +"corrections as empty can data runs!")
        else:
            configure.cwp_ecan = options.cwp_ecan


    # Set the chopper phase corrections for black can data
    if hlr_utils.cli_provide_override(configure, "cwp_bcan", "--cwp-bcan"):
        if options.cwp_bcan is not None:
            configure.cwp_bcan = [float(x) \
                                  for x in options.cwp_bcan.split(',')]
            if len(configure.bcan) != len(configure.cwp_bcan):
                parser.error("Need the same number of chopper phase "\
                             +"corrections as black can data runs!")
        else:
            configure.cwp_bcan = options.cwp_bcan

    # Set the initial energy
    if hlr_utils.cli_provide_override(configure, "initial_energy",
                                      "--initial-energy"):
        configure.initial_energy = hlr_utils.DrParameterFromString(\
            options.initial_energy, True)

    # Set the time-zero offset
    if hlr_utils.cli_provide_override(configure, "time_zero_offset",
                                      "--time-zero-offset"):    
        configure.time_zero_offset = hlr_utils.DrParameterFromString(\
            options.time_zero_offset, True)

    # Set no_mon_norm flag
    if hlr_utils.cli_provide_override(configure, "no_mon_norm",
                                      "--no-mon-norm"):
        configure.no_mon_norm = options.no_mon_norm

    # Set proton charge normalization flag
    if hlr_utils.cli_provide_override(configure, "pc_norm",
                                      "--pc-norm"):
        configure.pc_norm = options.pc_norm        

    # Set the proton charge scaling parameter
    if hlr_utils.cli_provide_override(configure, "scale_pc", "--scale-pc"):
        configure.scale_pc = options.scale_pc

    # Set the TOF range for the monitor integration
    if hlr_utils.cli_provide_override(configure, "mon_int_range",
                                      "--mon-int-range"):
        configure.mon_int_range = options.mon_int_range

    # Set the detector efficiency. This can be a tuple (one number for all
    # pixels) or a file containing numbers for all pixels.
    if hlr_utils.cli_provide_override(configure, "det_eff", "--det-eff"):
        try:
            configure.det_eff = hlr_utils.DrParameterFromString(\
                options.det_eff, True)
        except RuntimeError:
            configure.det_eff = hlr_utils.determine_files(options.det_eff,
                                                          one_file=True)
            
    # Set the transmission coefficient for the sample data background
    if hlr_utils.cli_provide_override(configure, "data_trans_coeff",
                                      "--data-trans-coeff"):
        configure.data_trans_coeff = hlr_utils.DrParameterFromString(\
            options.data_trans_coeff, True)

    # Set the transmission coefficient for the normalization background
    if hlr_utils.cli_provide_override(configure, "norm_trans_coeff",
                                      "--norm-trans-coeff"):
        configure.norm_trans_coeff = hlr_utils.DrParameterFromString(\
            options.norm_trans_coeff, True)        

    # Set the wavelength range for the vanadium normalization integration
    if hlr_utils.cli_provide_override(configure, "norm_int_range",
                                      "--norm-int-range"):
        configure.norm_int_range = options.norm_int_range

    # Set the wavelength bins
    if hlr_utils.cli_provide_override(configure, "lambda_bins",
                                      "--lambda-bins"):
        configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)

    # Set the ability to dump the combined calibrated TOF information
    if hlr_utils.cli_provide_override(configure, "dump_ctof_comb",
                                      "--dump-ctof-comb"):
        configure.dump_ctof_comb = options.dump_ctof_comb

    # Set the ability to dump the combined final wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave_comb",
                                      "--dump-wave-comb"):
        configure.dump_wave_comb = options.dump_wave_comb

    # Set the ability to dump the time-independent background information
    if hlr_utils.cli_provide_override(configure, "dump_tib", "--dump-tib"):
        configure.dump_tib = options.dump_tib
예제 #5
0
    parser.set_defaults(dump_ecell_rtof=False)
    
    parser.add_option("", "--timing", action="store_true", dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()
    
    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for RefRedOptions
    hlr_utils.RefConfiguration(parser, configure, options, args)

    # Setup the empty cell file list
    if hlr_utils.cli_provide_override(configure, "ecell", "--ecell"):
        configure.ecell = hlr_utils.determine_files(options.ecell,
                                                    configure.inst,
                                                    configure.facility)

    # If empty cell subtraction is desired, turn off standard background
    # subtraction
    if configure.ecell is not None:
        configure.no_bkg = True
        
    # Setup the substrate transmission coefficients
    if hlr_utils.cli_provide_override(configure, "subtrans_coeff",
                                      "--subtrans-coeff"):
        configure.subtrans_coeff = options.subtrans_coeff

    # Setup the substrate diameter parameter
예제 #6
0
    )
    parser.set_defaults(dump_ecell_rtof=False)

    parser.add_option("", "--timing", action="store_true", dest="timing", help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for RefRedOptions
    hlr_utils.RefConfiguration(parser, configure, options, args)

    # Setup the empty cell file list
    if hlr_utils.cli_provide_override(configure, "ecell", "--ecell"):
        configure.ecell = hlr_utils.determine_files(options.ecell, configure.inst, configure.facility)

    # If empty cell subtraction is desired, turn off standard background
    # subtraction
    if configure.ecell is not None:
        configure.no_bkg = True

    # Setup the substrate transmission coefficients
    if hlr_utils.cli_provide_override(configure, "subtrans_coeff", "--subtrans-coeff"):
        configure.subtrans_coeff = options.subtrans_coeff

    # Setup the substrate diameter parameter
    if hlr_utils.cli_provide_override(configure, "substrate_diam", "--substrate-diam"):
        configure.substrate_diam = options.substrate_diam
예제 #7
0
    parser.set_defaults(dump_sxl=False)    

    parser.add_option("-w", "--width", action="store_true", dest="width",
                      help="Flag to divide the TOF histogram by the bin width")
    parser.set_defaults(width=False)

    (options, args) = parser.parse_args()

    # set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for InstOptions
    hlr_utils.InstConfiguration(parser, configure, options, args)

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file,
                                                       one_file=True)

    # set the starting ids
    if hlr_utils.cli_provide_override(configure, "starting_ids",
                                      "--starting-ids"):
        if options.starting_ids is not None:
            configure.starting_ids = hlr_utils.create_id_pairs(\
            options.starting_ids,\
            options.data_paths)
        else:
            configure.starting_ids = options.starting_ids

    # set the ending ids
    if hlr_utils.cli_provide_override(configure, "ending_ids", "--ending-ids"):
예제 #8
0
                      "--timing",
                      action="store_true",
                      dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for SansOptions
    hlr_utils.SansConfiguration(parser, configure, options, args)

    # Set the background file list
    if hlr_utils.cli_provide_override(configure, "back", "--back"):
        configure.back = hlr_utils.determine_files(options.back,
                                                   configure.inst,
                                                   configure.facility)

    if configure.lambda_bins is None:
        parser.error("Please specify the final wavelength axis!")

    # Turn off monitor and detector efficiencies if transmission background is
    # present
    if configure.back is not None:
        if configure.mon_effc:
            configure.mon_effc = False
        if configure.det_effc:
            configure.det_effc = False
예제 #9
0
def BasicConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{BasicOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.BasicOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{BasicOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{BasicOptions}
    @type args: C{list}
    """

    # Set from a configuration file first
    if options.config is not None:
        import xml.dom.minidom
        conf_doc = xml.dom.minidom.parse(options.config)
        configure = hlr_utils.ConfigFromXml(conf_doc, configure)

    # Now override options provided on command-line

    # Set the verbosity, if present on command-line
    if not configure.verbose:
        configure.verbose = options.verbose 
    else: 
        # Got the verbosity from the config file, but check CLI 
        if hlr_utils.cli_checker("-v", "-q"): 
            # Override option 
            configure.verbose = options.verbose 
        else: 
            # No flags present, do nothing
            pass 

    # Define instrument short name first as stuff below depends on it
    if hlr_utils.cli_provide_override(configure, "inst", "--inst"):
        configure.inst = options.inst

    # Define facility short name as stuff below depends on it
    if hlr_utils.cli_provide_override(configure, "facility", "--facility"):
        configure.facility = options.facility        

    # Define proposal as stuff below depends on it.
    if hlr_utils.cli_provide_override(configure, "proposal", "--proposal"):
        configure.proposal = options.proposal
        
    # Get the datafile name and check it
    if options.data is not None:
        configure.data = hlr_utils.determine_files(options.data,
                                                   configure.inst,
                                                   configure.facility,
                                                   configure.proposal,
                                                   stop_on_none=True)
    elif len(args) > 0:
        configure.data = hlr_utils.determine_files(args, configure.inst,
                                                   configure.facility,
                                                   configure.proposal,
                                                   stop_on_none=True)
    elif configure.data:
        # We have data from the config file, so everything is OK.
        pass
    else:
        parser.error("Did not specify a datafile")

    import os
    # Deal with file or directory from output option
    if options.output:
        filepath = hlr_utils.fix_filename(options.output)
        if os.path.exists(filepath):
            if os.path.isdir(filepath):
                outfile = os.path.basename(configure.data[0])
                path = os.path.join(filepath, outfile)
                configure.output = hlr_utils.ext_replace(path, "nxs", "txt")
                configure.path_replacement = filepath
                configure.ext_replacement = "txt"

            elif os.path.isfile(filepath):
                configure.output = filepath
                configure.path_replacement = os.path.dirname(filepath)
                configure.ext_replacement = filepath.split('.')[-1]

            else:
                parser.error("Cannot handle %s in output option" % filepath)
        else:
            # Assume that this is a file and hope that the directory exists
            directory = os.path.dirname(filepath)
            if directory != "":
                if not os.path.exists(directory):
                    raise RuntimeError("The directory %s must exist!" \
                                       % directory)
                else:
                    pass
            else:
                directory = None
            configure.output = filepath
            configure.path_replacement = directory
            configure.ext_replacement = filepath.split('.')[-1]

    elif configure.output:
        # We have an output file, so no need to do anything else
        try:
            configure.path_replacement
        except AttributeError:
            configure.path_replacement = None
    # Create the output file name if there isn't one supplied
    else:
        outfile = os.path.basename(configure.data[0])
        path = os.path.join(os.getcwd(), outfile)
        configure.output = hlr_utils.ext_replace(path, "nxs", "txt")
        configure.path_replacement = None
        configure.ext_replacement = "txt"

    if configure.verbose and options.output:
        print "Using %s as output file" % configure.output
예제 #10
0
def DgsRedConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{DgsRedOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.DgsRedOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{DgsRedOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{DgsRedOptions}
    @type args: C{list}
    """

    # Call the configuration setter for DgsOptions
    hlr_dgs_options.DgsConfiguration(parser, configure, options, args)

    # Set the mask file
    if hlr_utils.cli_provide_override(configure, "mask_file", "--mask-file"):
        configure.mask_file = hlr_utils.determine_files(options.mask_file)

    # Set the corner geometry information file
    if hlr_utils.cli_provide_override(configure, "corner_geom",
                                      "--corner-geom"):
        configure.corner_geom = options.corner_geom

    if configure.corner_geom is None:
        parser.error("You must provide a corner geometry file via the "\
                     +"corner-geom option!")

    # Set the lambda ratio flag
    if hlr_utils.cli_provide_override(configure, "lambda_ratio",
                                      "--lambda-ratio"):
        configure.lambda_ratio = options.lambda_ratio

    # Set the flag for making the phonon density of states representation
    if hlr_utils.cli_provide_override(configure, "pdos_Q", "--pdos-Q"):
        configure.pdos_Q = options.pdos_Q

    # Set the Debye-Waller constant for the phonon DOS representation
    if hlr_utils.cli_provide_override(configure, "debye_waller",
                                      "--debye-waller"):
        configure.debye_waller = hlr_utils.DrParameterFromString(\
            options.debye_waller)
    else:
        configure.debye_waller = options.debye_waller

    # Set the energy transfer bins
    if hlr_utils.cli_provide_override(configure, "E_bins", "--energy-bins"):
        configure.E_bins = hlr_utils.AxisFromString(options.E_bins)

    if configure.E_bins is None:
        parser.error("You must provide energy transfer binning via the "\
                     +"energy-bins option")        

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    if configure.Q_bins is None:
        parser.error("You must provide momentum transfer binning via the "\
                     +"mom-trans-bins option")

    # Set the ability to write SPE and PHX files instead of S(Q, E) dist
    if hlr_utils.cli_provide_override(configure, "make_spe", "--make_spe"):
        configure.make_spe = options.make_spe

    # Set the ability to create the Q vector meshes for each energy slice
    if hlr_utils.cli_provide_override(configure, "qmesh", "--qmesh", "-m"):
        configure.qmesh = options.qmesh
        
    # Set the ability to write out fixed grid mesh files
    if hlr_utils.cli_provide_override(configure, "fixed", "--fixed", "-x"):
        configure.fixed = options.fixed        

    # Set the ability to turn off zero suppression for single crystal data
    if hlr_utils.cli_provide_override(configure, "no_zero_supp",
                                      "--no-zero-supp"):
        configure.no_zero_supp = options.no_zero_supp

    # Set the ability to dump the combined energy transfer information
    if hlr_utils.cli_provide_override(configure, "dump_et_comb",
                                      "--dump-et-comb"):
        configure.dump_et_comb = options.dump_et_comb        

    if hlr_utils.cli_provide_override(configure, "split", "--split"):
        configure.split = options.split
예제 #11
0
    parser.remove_option("--ncos-polar-bins")
    # This one is handled by the loop
    parser.remove_option("--ldb-const")
    # Block the rescaling as this causes havoc with the looping
    parser.remove_option("--rescale-final")

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for AmrOptions
    hlr_utils.AmrConfiguration(parser, configure, options, args)

    # Set the positive and negative energy transfer axis integration ranges
    if hlr_utils.cli_provide_override(configure, "et_int_range",
                                      "--et-int-range"):
        configure.et_int_range = hlr_utils.AxisFromString(options.et_int_range)

    configure.et_pos_range = (configure.et_int_range.getMinimum(),
                              configure.et_int_range.getMaximum())
    configure.et_neg_range = (-1.0 * configure.et_int_range.getMaximum(),
                              -1.0 * configure.et_int_range.getMinimum())

    # Capture final energy binning
    configure.final_E_bins = configure.E_bins

    # Reset energy transfer axis to [-E_t_max, E_t_max]
    configure.E_bins = hlr_utils.Axis(
        -1.0 * configure.et_int_range.getMaximum(),
        configure.et_int_range.getMaximum(), configure.et_int_range.getDelta())
예제 #12
0
    )
    parser.set_defaults(wb_norm=False)

    parser.add_option("", "--timing", action="store_true", dest="timing", help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for DgsOptions
    hlr_utils.DgsConfiguration(parser, configure, options, args)

    # Set the high threshold value
    if hlr_utils.cli_provide_override(configure, "hi_threshold", "--hi-threshold"):
        configure.hi_threshold = options.hi_threshold

    # Set the low threshold value
    if hlr_utils.cli_provide_override(configure, "lo_threshold", "--lo-threshold"):
        configure.lo_threshold = options.lo_threshold

    # Set the white-beam normalization option
    if hlr_utils.cli_provide_override(configure, "wb_norm", "--wb-norm"):
        configure.wb_norm = options.wb_norm

    # Set timer object if timing option is used
    if options.timing:
        import sns_timing

        timer = sns_timing.DiffTime()
예제 #13
0
def DgsConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{DgsOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.DgsOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{DgsOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{DgsOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_options.InstConfiguration(parser, configure, options, args, inst="DGS")

    # Set the upstream monitor path
    if hlr_utils.cli_provide_override(configure, "usmon_path", "--usmon-path"):
        configure.usmon_path = hlr_utils.NxPath(options.usmon_path)

    # Set the downstream monitor path
    if hlr_utils.cli_provide_override(configure, "dsmon_path", "--dsmon-path"):
        configure.dsmon_path = hlr_utils.NxPath(options.dsmon_path)

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file, one_file=True)

    # Set the minimum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_min", "--tof-cut-min"):
        configure.tof_cut_min = options.tof_cut_min

    # Set the maximum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_max", "--tof-cut-max"):
        configure.tof_cut_max = options.tof_cut_max

    # Set a time-independent background subtraction constant
    if hlr_utils.cli_provide_override(configure, "tib_const", "--tib-const"):
        configure.tib_const = hlr_utils.DrParameterFromString(options.tib_const, True)

    # Set the TOF range for the time-independent background determination
    if hlr_utils.cli_provide_override(configure, "tib_range", "--tib-range"):
        configure.tib_range = options.tib_range

    # Stop is both TIB methods are used
    if configure.tib_const is not None and configure.tib_range is not None:
        parser.error("Please use either --tib-const or --tib-range")

    # Set the chopper phase corrections for sample data
    if hlr_utils.cli_provide_override(configure, "cwp_data", "--cwp-data"):
        if options.cwp_data is not None:
            configure.cwp_data = [float(x) for x in options.cwp_data.split(",")]
            if len(configure.data) != len(configure.cwp_data):
                parser.error("Need the same number of chopper phase " + "corrections as sample data runs!")
        else:
            configure.cwp_data = options.cwp_data

    # Set the chopper phase corrections for empty can data
    if hlr_utils.cli_provide_override(configure, "cwp_ecan", "--cwp-ecan"):
        if options.cwp_ecan is not None:
            configure.cwp_ecan = [float(x) for x in options.cwp_ecan.split(",")]
            if len(configure.ecan) != len(configure.cwp_ecan):
                parser.error("Need the same number of chopper phase " + "corrections as empty can data runs!")
        else:
            configure.cwp_ecan = options.cwp_ecan

    # Set the chopper phase corrections for black can data
    if hlr_utils.cli_provide_override(configure, "cwp_bcan", "--cwp-bcan"):
        if options.cwp_bcan is not None:
            configure.cwp_bcan = [float(x) for x in options.cwp_bcan.split(",")]
            if len(configure.bcan) != len(configure.cwp_bcan):
                parser.error("Need the same number of chopper phase " + "corrections as black can data runs!")
        else:
            configure.cwp_bcan = options.cwp_bcan

    # Set the initial energy
    if hlr_utils.cli_provide_override(configure, "initial_energy", "--initial-energy"):
        configure.initial_energy = hlr_utils.DrParameterFromString(options.initial_energy, True)

    # Set the time-zero offset
    if hlr_utils.cli_provide_override(configure, "time_zero_offset", "--time-zero-offset"):
        configure.time_zero_offset = hlr_utils.DrParameterFromString(options.time_zero_offset, True)

    # Set no_mon_norm flag
    if hlr_utils.cli_provide_override(configure, "no_mon_norm", "--no-mon-norm"):
        configure.no_mon_norm = options.no_mon_norm

    # Set proton charge normalization flag
    if hlr_utils.cli_provide_override(configure, "pc_norm", "--pc-norm"):
        configure.pc_norm = options.pc_norm

    # Set the proton charge scaling parameter
    if hlr_utils.cli_provide_override(configure, "scale_pc", "--scale-pc"):
        configure.scale_pc = options.scale_pc

    # Set the TOF range for the monitor integration
    if hlr_utils.cli_provide_override(configure, "mon_int_range", "--mon-int-range"):
        configure.mon_int_range = options.mon_int_range

    # Set the detector efficiency. This can be a tuple (one number for all
    # pixels) or a file containing numbers for all pixels.
    if hlr_utils.cli_provide_override(configure, "det_eff", "--det-eff"):
        try:
            configure.det_eff = hlr_utils.DrParameterFromString(options.det_eff, True)
        except RuntimeError:
            configure.det_eff = hlr_utils.determine_files(options.det_eff, one_file=True)

    # Set the transmission coefficient for the sample data background
    if hlr_utils.cli_provide_override(configure, "data_trans_coeff", "--data-trans-coeff"):
        configure.data_trans_coeff = hlr_utils.DrParameterFromString(options.data_trans_coeff, True)

    # Set the transmission coefficient for the normalization background
    if hlr_utils.cli_provide_override(configure, "norm_trans_coeff", "--norm-trans-coeff"):
        configure.norm_trans_coeff = hlr_utils.DrParameterFromString(options.norm_trans_coeff, True)

    # Set the wavelength range for the vanadium normalization integration
    if hlr_utils.cli_provide_override(configure, "norm_int_range", "--norm-int-range"):
        configure.norm_int_range = options.norm_int_range

    # Set the wavelength bins
    if hlr_utils.cli_provide_override(configure, "lambda_bins", "--lambda-bins"):
        configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)

    # Set the ability to dump the combined calibrated TOF information
    if hlr_utils.cli_provide_override(configure, "dump_ctof_comb", "--dump-ctof-comb"):
        configure.dump_ctof_comb = options.dump_ctof_comb

    # Set the ability to dump the combined final wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave_comb", "--dump-wave-comb"):
        configure.dump_wave_comb = options.dump_wave_comb

    # Set the ability to dump the time-independent background information
    if hlr_utils.cli_provide_override(configure, "dump_tib", "--dump-tib"):
        configure.dump_tib = options.dump_tib
예제 #14
0
def AmrConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{AmrOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.AmrOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{AmrOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{AmrOptions}
    @type args: C{list}
    """

    # Call the configuration setter for IgsOptions
    hlr_igs_options.IgsConfiguration(parser, configure, options, args)
 
    # Set the monitor efficiency (tuple)
    if hlr_utils.cli_provide_override(configure, "mon_eff", "--mon-eff"): 
        configure.mon_eff = hlr_utils.DrParameterFromString(options.mon_eff,
                                                            True)

    # Set the detector efficiency. This can be a tuple (one number for all
    # pixels) or a file containing numbers for all pixels.
    if hlr_utils.cli_provide_override(configure, "det_eff", "--det-eff"):
        try:
            configure.det_eff = hlr_utils.DrParameterFromString(\
                options.det_eff, True)
        except ValueError:
            configure.det_eff = hlr_utils.determine_files(options.det_eff,
                                                          one_file=True)
    # Set the energy transfer bins
    if hlr_utils.cli_provide_override(configure, "E_bins", "--energy-bins"):
        configure.E_bins = hlr_utils.AxisFromString(options.E_bins)

    if configure.E_bins is None:
        parser.error("You must provide energy transfer binning via the "\
                     +"energy-bins option")        

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    # Set the negative cosine polar angle bins
    if hlr_utils.cli_provide_override(configure, "ncospol_bins",
                                      "--ncos-polar-bins"):
        configure.ncospol_bins = hlr_utils.AxisFromString(options.ncospol_bins)

    # Make sure only momentum transfer or negative cosine polar binning is set
    if (configure.Q_bins is not None and \
        configure.ncospol_bins is not None) or \
        (configure.Q_bins is None and configure.ncospol_bins is None):
        parser.error("Please specify either --mom-trans-bins or "\
                     +"--ncos-polar-bins")

    # Set the final data rescaling constant
    if hlr_utils.cli_provide_override(configure, "rescale_final",
                                      "--rescale-final"):
        try:
            configure.rescale_final = float(options.rescale_final)
        except TypeError:
            configure.rescale_final = options.rescale_final

    # Set the scaling of the S(Q,E) distribution by the solid angle
    # distribution
    if hlr_utils.cli_provide_override(configure, "scale_sqe", "--scale-sqe"):
        configure.scale_sqe = options.scale_sqe

    # Set the lambda-dependent background constant for data
    if hlr_utils.cli_provide_override(configure, "ldb_const", "--ldb-const"):
        configure.ldb_const = hlr_utils.DrParameterFromString(\
                    options.ldb_const, True)

    # Set the TOF least background channel
    if hlr_utils.cli_provide_override(configure, "tof_least_bkg",
                                      "--tof-least-bkg"):
        configure.tof_least_bkg = hlr_utils.DrParameterFromString(\
                    options.tof_least_bkg, True)

    # Set the Chopper frequency
    if hlr_utils.cli_provide_override(configure, "chopper_freq",
                                      "--chopper-freq"):
        configure.chopper_freq = hlr_utils.DrParameterFromString(\
                    options.chopper_freq, True)

    # Set the wavelength center for the Chopper
    if hlr_utils.cli_provide_override(configure, "chopper_lambda_cent",
                                      "--chopper-lambda-cent"):
        configure.chopper_lambda_cent = hlr_utils.DrParameterFromString(\
                    options.chopper_lambda_cent, True)

    # Set the ability to dump the energy transfer information
    if hlr_utils.cli_provide_override(configure, "dump_dslin",
                                      "--dump-dslin"):
        configure.dump_dslin = options.dump_dslin

    # Set the ability to dump the wavelength information after vanadium norm
    if hlr_utils.cli_provide_override(configure, "dump_norm", "--dump-norm"):
        configure.dump_norm = options.dump_norm
        
    # Set the ability to dump the energy transfer information
    if hlr_utils.cli_provide_override(configure, "dump_energy",
                                      "--dump-energy"):
        configure.dump_energy = options.dump_energy
    
    # Set the ability to dump the initial energy information
    if hlr_utils.cli_provide_override(configure, "dump_initial_energy",
                                      "--dump-initial-energy"):    
        configure.dump_initial_energy = options.dump_initial_energy

    # Set the ability to dump the pixel contribution information
    if hlr_utils.cli_provide_override(configure, "dump_pix_contrib",
                                      "--dump-pix-contrib"):
        configure.dump_pix_contrib = options.dump_pix_contrib

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_dslin = True
            configure.dump_norm = True
            configure.dump_energy = True
            configure.dump_initial_energy = True

    if hlr_utils.cli_provide_override(configure, "split", "--split"):
        configure.split = options.split
예제 #15
0
    parser.set_defaults(dump_twod=False)

    parser.add_option("", "--timing", action="store_true", dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for RefOptions
    hlr_utils.RefConfiguration(parser, configure, options, args)

    # Set the lambda perpendicular (lambda_T)
    if hlr_utils.cli_provide_override(configure, "lambdap_bins",
                                      "--lambdap-bins"):
        configure.lambdap_bins = hlr_utils.AxisFromString(options.lambdap_bins)

    # Set mon_norm flag
    if hlr_utils.cli_provide_override(configure, "mon_norm", "--mon-norm"):
        configure.mon_norm = options.mon_norm

    # Set the monitor path
    if hlr_utils.cli_provide_override(configure, "mon_path", "--mon-path"):
        configure.mon_path = hlr_utils.NxPath(options.mon_path)

    # Set the override angle for calculating lambda_T
    if hlr_utils.cli_provide_override(configure, "omega", "--omega"):
        configure.omega = hlr_utils.DrParameterFromString(options.omega, True)

    # Set the ability to dump the R(pid, lambda_T) information
예제 #16
0
                      "--timing",
                      action="store_true",
                      dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for RefOptions
    hlr_utils.RefConfiguration(parser, configure, options, args)

    # Set the lambda perpendicular (lambda_T)
    if hlr_utils.cli_provide_override(configure, "lambdap_bins",
                                      "--lambdap-bins"):
        configure.lambdap_bins = hlr_utils.AxisFromString(options.lambdap_bins)

    # Set mon_norm flag
    if hlr_utils.cli_provide_override(configure, "mon_norm", "--mon-norm"):
        configure.mon_norm = options.mon_norm

    # Set the monitor path
    if hlr_utils.cli_provide_override(configure, "mon_path", "--mon-path"):
        configure.mon_path = hlr_utils.NxPath(options.mon_path)

    # Set the override angle for calculating lambda_T
    if hlr_utils.cli_provide_override(configure, "omega", "--omega"):
        configure.omega = hlr_utils.DrParameterFromString(options.omega, True)

    # Set the ability to dump the R(pid, lambda_T) information
예제 #17
0
def InstConfiguration(parser, configure, options, args, **kwargs):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{InstOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.InstOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{InstOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{InstOptions}
    @type args: C{list}

    @param kwargs: A list of keyword arguments that the function accepts:

    @keyword inst: The classification type name of the instrument. Current
                   names are I{DGS}, I{IGS}, I{PD}, I{REF}, I{SAS}, I{SCD}.
    @type inst: C{string}
    """
    
    # Check for keywords
    try:
        instrument = kwargs["inst"]
    except KeyError:
        instrument = ""

    # Call the configuration setter for BasicOptions
    BasicConfiguration(parser, configure, options, args)

    # Set the instrument geometry file
    if hlr_utils.cli_provide_override(configure, "inst_geom", "--inst-geom"):
        configure.inst_geom = hlr_utils.determine_files(options.inst_geom,
                                                        one_file=True)

    # Set the data paths
    if hlr_utils.cli_provide_override(configure, "data_paths", "--data-paths"):
        configure.data_paths = hlr_utils.NxPath(options.data_paths)

    # Set the normalization file list
    if hlr_utils.cli_provide_override(configure, "norm", "--norm"):
        configure.norm = hlr_utils.determine_files(options.norm,
                                                   configure.inst,
                                                   configure.facility,
                                                   configure.proposal)

    if instrument == "IGS":
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "ecan", "--ecan"):
            configure.ecan = hlr_utils.determine_files(options.ecan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        # Set the background file list
        if hlr_utils.cli_provide_override(configure, "back", "--back"):
            configure.back = hlr_utils.determine_files(options.back,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the direct scattering background file list
        if hlr_utils.cli_provide_override(configure, "dsback", "--dsback"):
            configure.dsback = hlr_utils.determine_files(options.dsback,
                                                         configure.inst,
                                                         configure.facility,
                                                         configure.proposal)
    elif instrument == "SAS":
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "ecan", "--ecan"):
            configure.ecan = hlr_utils.determine_files(options.ecan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "solv", "--solv"):
            configure.solv = hlr_utils.determine_files(options.solv,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "open", "--open"):
            configure.open = hlr_utils.determine_files(options.open,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "dkcur", "--dkcur"):
            configure.dkcur = hlr_utils.determine_files(options.dkcur,
                                                        configure.inst,
                                                        configure.facility,
                                                        configure.proposal)

    elif instrument == "DGS":
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "ecan", "--ecan"):
            configure.ecan = hlr_utils.determine_files(options.ecan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the black can file list
        if hlr_utils.cli_provide_override(configure, "bcan", "--bcan"):
            configure.bcan = hlr_utils.determine_files(options.bcan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "dkcur", "--dkcur"):
            configure.dkcur = hlr_utils.determine_files(options.dkcur,
                                                        configure.inst,
                                                        configure.facility,
                                                        configure.proposal)
            
    else:
        pass
예제 #18
0
def RefConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{RefOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.RefOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{RefOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{RefOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_options.InstConfiguration(parser, configure, options, args, inst="REF")

    # Set the data instrument geometry file
    if hlr_utils.cli_provide_override(configure, "data_inst_geom",
                                      "--data-inst-geom"):
        configure.data_inst_geom = hlr_utils.determine_files(\
            options.data_inst_geom,
            one_file=True)

    # Set the normalization instrument geometry file
    if hlr_utils.cli_provide_override(configure, "norm_inst_geom",
                                      "--norm-inst-geom"):
        configure.norm_inst_geom = hlr_utils.determine_files(\
            options.norm_inst_geom,
            one_file=True)

    # Set the normalization data paths
    if hlr_utils.cli_provide_override(configure, "norm_data_paths",
                                      "--norm-data-paths"):
        try:
            configure.norm_data_paths = hlr_utils.NxPath(\
                options.norm_data_paths)
        except AttributeError:
            configure.norm_data_paths = options.norm_data_paths

    # Get the data path for the sample data ROI file
    if hlr_utils.cli_provide_override(configure, "data_roi_file",
                                      "--data-roi-file"):
        configure.data_roi_file = hlr_utils.determine_files(\
                     options.data_roi_file,
                     one_file=True)

    # Get the data path for the normalization data ROI file
    if hlr_utils.cli_provide_override(configure, "norm_roi_file",
                                      "--norm-roi-file"):
        if options.norm_roi_file is not None:
            configure.norm_roi_file = hlr_utils.determine_files(\
                     options.norm_roi_file,
                     one_file=True)
        else:
            configure.norm_roi_file = configure.data_roi_file

    # Get the data path for the sample data background ROI file
    if hlr_utils.cli_provide_override(configure, "dbkg_roi_file",
                                      "--dbkg-roi-file"):
        configure.dbkg_roi_file = hlr_utils.determine_files(\
                     options.dbkg_roi_file,
                     one_file=True)

    # Get the data path for the normalization background ROI file
    if hlr_utils.cli_provide_override(configure, "nbkg_roi_file",
                                      "--nbkg-roi-file"):
        if options.nbkg_roi_file is not None:
            configure.nbkg_roi_file = hlr_utils.determine_files(\
                     options.nbkg_roi_file,
                     one_file=True)
        else:
            configure.nbkg_roi_file = configure.dbkg_roi_file

    # Get the polar angle offset
    if hlr_utils.cli_provide_override(configure, "angle_offset",
                                      "--angle-offset"):
        configure.angle_offset = hlr_utils.DrParameterFromString(\
            options.angle_offset, True)

    # Set the ability to turn off background estimation and subtraction
    if hlr_utils.cli_provide_override(configure, "no_bkg", "--no-bkg"):
        configure.no_bkg = options.no_bkg

    # Set the ability to turn off normalization background estimation
    # and subtraction
    if hlr_utils.cli_provide_override(configure, "no_norm_bkg",
                                      "--no-norm-bkg"):
        configure.no_norm_bkg = options.no_norm_bkg

    # Set the minimum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_min",
                                      "--tof-cut-min"):
        configure.tof_cut_min = options.tof_cut_min

    # Set the maximum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_max",
                                      "--tof-cut-max"):
        configure.tof_cut_max = options.tof_cut_max

    # Set the TOF bins to zero out from the data and normalization spectra
    if hlr_utils.cli_provide_override(configure, "tof_cuts", "--tof-cuts"):
        if options.tof_cuts is not None:
            configure.tof_cuts = options.tof_cuts.split(',')
        else:
            configure.tof_cuts = options.tof_cuts

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    # Set the no bad data filter flag
    if hlr_utils.cli_provide_override(configure, "no_filter", "--no-filter"):
        configure.no_filter = options.no_filter

    # Set the store delta t over t flag
    if hlr_utils.cli_provide_override(configure, "store_dtot", "--store-dtot"):
        configure.store_dtot = options.store_dtot

    # Set the pixel ID range values for peak exclusion from sample data
    if hlr_utils.cli_provide_override(configure, "data_peak_excl",
                                      "--data-peak-excl"):
        configure.data_peak_excl = options.data_peak_excl

    # Set the pixel ID range values for peak exclusion from normalization data
    if hlr_utils.cli_provide_override(configure, "norm_peak_excl",
                                      "--norm-peak-excl"):
        configure.norm_peak_excl = options.norm_peak_excl

    # Set the integration direction
    if hlr_utils.cli_provide_override(configure, "int_dir", "--int-dir"):
        configure.int_dir = options.int_dir

    # Get the scattering (polar) angle for axis TOF to Q conversion
    if hlr_utils.cli_provide_override(configure, "scatt_angle",
                                      "--scatt-angle"):
        configure.scatt_angle = hlr_utils.DrParameterFromString(\
            options.scatt_angle, True)

    # Set the ability to dump the combined specular TOF information
    if hlr_utils.cli_provide_override(configure, "dump_specular",
                                      "--dump-specular"):
        configure.dump_specular = options.dump_specular

    # Set the ability to dump the combined background TOF information
    if hlr_utils.cli_provide_override(configure, "dump_bkg", "--dump-bkg"):
        configure.dump_bkg = options.dump_bkg

    # Set the ability to dump the combined subtracted TOF information
    if hlr_utils.cli_provide_override(configure, "dump_sub", "--dump-sub"):
        configure.dump_sub = options.dump_sub

    # Set the ability to dump the R(TOF) information
    if hlr_utils.cli_provide_override(configure, "dump_rtof", "--dump-rtof"):
        configure.dump_rtof = options.dump_rtof

    # Set the ability to dump the combined R(TOF) information
    if hlr_utils.cli_provide_override(configure, "dump_rtof_comb",
                                      "--dump-rtof-comb"):
        configure.dump_rtof_comb = options.dump_rtof_comb

    # Set the ability to dump the R(Q) information
    if hlr_utils.cli_provide_override(configure, "dump_rq", "--dump-rq"):
        configure.dump_rq = options.dump_rq

    # Set the ability to dump the R(Q) after rebinning information
    if hlr_utils.cli_provide_override(configure, "dump_rqr", "--dump-rqr"):
        configure.dump_rqr = options.dump_rqr

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_specular = True
            configure.dump_bkg = True
            configure.dump_sub = True
            configure.dump_rtof = True
            configure.dump_rtof_comb = True
            configure.dump_rq = True
            configure.dump_rqr = True
예제 #19
0
def BasicConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{BasicOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.BasicOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{BasicOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{BasicOptions}
    @type args: C{list}
    """

    # Set from a configuration file first
    if options.config is not None:
        import xml.dom.minidom
        conf_doc = xml.dom.minidom.parse(options.config)
        configure = hlr_utils.ConfigFromXml(conf_doc, configure)

    # Now override options provided on command-line

    # Set the verbosity, if present on command-line
    if not configure.verbose:
        configure.verbose = options.verbose
    else:
        # Got the verbosity from the config file, but check CLI
        if hlr_utils.cli_checker("-v", "-q"):
            # Override option
            configure.verbose = options.verbose
        else:
            # No flags present, do nothing
            pass

    # Define instrument short name first as stuff below depends on it
    if hlr_utils.cli_provide_override(configure, "inst", "--inst"):
        configure.inst = options.inst

    # Define facility short name as stuff below depends on it
    if hlr_utils.cli_provide_override(configure, "facility", "--facility"):
        configure.facility = options.facility

    # Define proposal as stuff below depends on it.
    if hlr_utils.cli_provide_override(configure, "proposal", "--proposal"):
        configure.proposal = options.proposal

    # Get the datafile name and check it
    if options.data is not None:
        configure.data = hlr_utils.determine_files(options.data,
                                                   configure.inst,
                                                   configure.facility,
                                                   configure.proposal,
                                                   stop_on_none=True)
    elif len(args) > 0:
        configure.data = hlr_utils.determine_files(args,
                                                   configure.inst,
                                                   configure.facility,
                                                   configure.proposal,
                                                   stop_on_none=True)
    elif configure.data:
        # We have data from the config file, so everything is OK.
        pass
    else:
        parser.error("Did not specify a datafile")

    import os
    # Deal with file or directory from output option
    if options.output:
        filepath = hlr_utils.fix_filename(options.output)
        if os.path.exists(filepath):
            if os.path.isdir(filepath):
                outfile = os.path.basename(configure.data[0])
                path = os.path.join(filepath, outfile)
                configure.output = hlr_utils.ext_replace(path, "nxs", "txt")
                configure.path_replacement = filepath
                configure.ext_replacement = "txt"

            elif os.path.isfile(filepath):
                configure.output = filepath
                configure.path_replacement = os.path.dirname(filepath)
                configure.ext_replacement = filepath.split('.')[-1]

            else:
                parser.error("Cannot handle %s in output option" % filepath)
        else:
            # Assume that this is a file and hope that the directory exists
            directory = os.path.dirname(filepath)
            if directory != "":
                if not os.path.exists(directory):
                    raise RuntimeError("The directory %s must exist!" \
                                       % directory)
                else:
                    pass
            else:
                directory = None
            configure.output = filepath
            configure.path_replacement = directory
            configure.ext_replacement = filepath.split('.')[-1]

    elif configure.output:
        # We have an output file, so no need to do anything else
        try:
            configure.path_replacement
        except AttributeError:
            configure.path_replacement = None
    # Create the output file name if there isn't one supplied
    else:
        outfile = os.path.basename(configure.data[0])
        path = os.path.join(os.getcwd(), outfile)
        configure.output = hlr_utils.ext_replace(path, "nxs", "txt")
        configure.path_replacement = None
        configure.ext_replacement = "txt"

    if configure.verbose and options.output:
        print "Using %s as output file" % configure.output
예제 #20
0
                      "--timing",
                      action="store_true",
                      dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for SansOptions
    hlr_utils.SansConfiguration(parser, configure, options, args)

    # Set the accelerator down time
    if hlr_utils.cli_provide_override(configure, "acc_down_time",
                                      "--acc-down-time"):
        configure.acc_down_time = hlr_utils.DrParameterFromString(\
            options.acc_down_time, True)

    if configure.lambda_bins is None:
        parser.error("Please specify the final wavelength axis!")

    # Set timer object if timing option is used
    if options.timing:
        import sns_timing
        timer = sns_timing.DiffTime()
    else:
        timer = None

    # Run the program
    run(configure, timer)
예제 #21
0
def InstConfiguration(parser, configure, options, args, **kwargs):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{InstOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.InstOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{InstOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{InstOptions}
    @type args: C{list}

    @param kwargs: A list of keyword arguments that the function accepts:

    @keyword inst: The classification type name of the instrument. Current
                   names are I{DGS}, I{IGS}, I{PD}, I{REF}, I{SAS}, I{SCD}.
    @type inst: C{string}
    """

    # Check for keywords
    try:
        instrument = kwargs["inst"]
    except KeyError:
        instrument = ""

    # Call the configuration setter for BasicOptions
    BasicConfiguration(parser, configure, options, args)

    # Set the instrument geometry file
    if hlr_utils.cli_provide_override(configure, "inst_geom", "--inst-geom"):
        configure.inst_geom = hlr_utils.determine_files(options.inst_geom,
                                                        one_file=True)

    # Set the data paths
    if hlr_utils.cli_provide_override(configure, "data_paths", "--data-paths"):
        configure.data_paths = hlr_utils.NxPath(options.data_paths)

    # Set the normalization file list
    if hlr_utils.cli_provide_override(configure, "norm", "--norm"):
        configure.norm = hlr_utils.determine_files(options.norm,
                                                   configure.inst,
                                                   configure.facility,
                                                   configure.proposal)

    if instrument == "IGS":
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "ecan", "--ecan"):
            configure.ecan = hlr_utils.determine_files(options.ecan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        # Set the background file list
        if hlr_utils.cli_provide_override(configure, "back", "--back"):
            configure.back = hlr_utils.determine_files(options.back,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the direct scattering background file list
        if hlr_utils.cli_provide_override(configure, "dsback", "--dsback"):
            configure.dsback = hlr_utils.determine_files(
                options.dsback, configure.inst, configure.facility,
                configure.proposal)
    elif instrument == "SAS":
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "ecan", "--ecan"):
            configure.ecan = hlr_utils.determine_files(options.ecan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "solv", "--solv"):
            configure.solv = hlr_utils.determine_files(options.solv,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "open", "--open"):
            configure.open = hlr_utils.determine_files(options.open,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "dkcur", "--dkcur"):
            configure.dkcur = hlr_utils.determine_files(
                options.dkcur, configure.inst, configure.facility,
                configure.proposal)

    elif instrument == "DGS":
        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "ecan", "--ecan"):
            configure.ecan = hlr_utils.determine_files(options.ecan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the black can file list
        if hlr_utils.cli_provide_override(configure, "bcan", "--bcan"):
            configure.bcan = hlr_utils.determine_files(options.bcan,
                                                       configure.inst,
                                                       configure.facility,
                                                       configure.proposal)

        # Set the empty can file list
        if hlr_utils.cli_provide_override(configure, "dkcur", "--dkcur"):
            configure.dkcur = hlr_utils.determine_files(
                options.dkcur, configure.inst, configure.facility,
                configure.proposal)

    else:
        pass
예제 #22
0
                      +"data.")
    
    parser.add_option("", "--timing", action="store_true", dest="timing",
                      help="Flag to turn on timing of code")
    parser.set_defaults(timing=False)
    
    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for SansOptions
    hlr_utils.SansConfiguration(parser, configure, options, args)

    # Set the background file list
    if hlr_utils.cli_provide_override(configure, "back", "--back"):
        configure.back = hlr_utils.determine_files(options.back,
                                                   configure.inst,
                                                   configure.facility)

    if configure.lambda_bins is None:
        parser.error("Please specify the final wavelength axis!")

    # Turn off monitor and detector efficiencies if transmission background is
    # present
    if configure.back is not None:
        if configure.mon_effc:
            configure.mon_effc = False
        if configure.det_effc:
            configure.det_effc = False
예제 #23
0
    parser.remove_option("--ncos-polar-bins")
    # This one is handled by the loop
    parser.remove_option("--ldb-const")
    # Block the rescaling as this causes havoc with the looping
    parser.remove_option("--rescale-final")

    (options, args) = parser.parse_args()

    # Set up the configuration
    configure = hlr_utils.Configure()

    # Call the configuration setter for AmrOptions
    hlr_utils.AmrConfiguration(parser, configure, options, args)

    # Set the positive and negative energy transfer axis integration ranges
    if hlr_utils.cli_provide_override(configure, "et_int_range",
                                      "--et-int-range"):
        configure.et_int_range = hlr_utils.AxisFromString(options.et_int_range)

    configure.et_pos_range = (configure.et_int_range.getMinimum(),
                              configure.et_int_range.getMaximum())
    configure.et_neg_range = (-1.0*configure.et_int_range.getMaximum(),
                              -1.0*configure.et_int_range.getMinimum())

    # Capture final energy binning
    configure.final_E_bins = configure.E_bins

    # Reset energy transfer axis to [-E_t_max, E_t_max]
    configure.E_bins = hlr_utils.Axis(-1.0*configure.et_int_range.getMaximum(),
                                      configure.et_int_range.getMaximum(),
                                      configure.et_int_range.getDelta())
예제 #24
0
def SansConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{SansOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.SansOptions}

    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}

    @param options: The parsed options from C{SansOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{SansOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_utils.InstConfiguration(parser, configure, options, args, inst="SAS")

    # Set the beam monitor path
    if hlr_utils.cli_provide_override(configure, "bmon_path", "--bmon-path"):
        configure.bmon_path = hlr_utils.NxPath(options.bmon_path)

    # Set the transmission monitor path
    if hlr_utils.cli_provide_override(configure, "tmon_path", "--tmon-path"):
        configure.tmon_path = hlr_utils.NxPath(options.tmon_path)

    # Set the sample data Transmission spectrum file
    if hlr_utils.cli_provide_override(configure, "data_trans", "--data-trans"):
        configure.data_trans = hlr_utils.determine_files(options.data_trans,
                                                         one_file=True)

    # Set the solvent only Transmission spectrum file
    if hlr_utils.cli_provide_override(configure, "solv_trans", "--solv-trans"):
        configure.solv_trans = hlr_utils.determine_files(options.solv_trans,
                                                         one_file=True)

    # Set the empty can Transmission spectrum file
    if hlr_utils.cli_provide_override(configure, "ecan_trans", "--ecan-trans"):
        configure.ecan_trans = hlr_utils.determine_files(options.ecan_trans,
                                                         one_file=True)

    # Set the beam monitor override file
    if hlr_utils.cli_provide_override(configure, "beammon_over",
                                      "--beammon-over"):
        configure.beammon_over = hlr_utils.determine_files(\
            options.beammon_over,
            configure.inst,
            configure.facility,
            configure.proposal,
            stop_on_none=True)

    # Set no_bmon_norm flag
    if hlr_utils.cli_provide_override(configure, "no_bmon_norm",
                                      "--no-bmon-norm"):
        configure.no_bmon_norm = options.no_bmon_norm

    # Set mon_effc flag
    if hlr_utils.cli_provide_override(configure, "mon_effc", "--mon-effc"):
        configure.mon_effc = options.mon_effc

    # Set the monitor efficiency constant
    if hlr_utils.cli_provide_override(configure, "mon_eff_const",
                                      "--mon-eff-const"):
        configure.mon_eff_const = hlr_utils.DrParameterFromString(\
            options.mon_eff_const, True)

    # Set det_effc flag
    if hlr_utils.cli_provide_override(configure, "det_effc", "--det-effc"):
        configure.det_effc = options.det_effc

    # Set the detector efficiency scaling constant
    if hlr_utils.cli_provide_override(configure, "det_eff_scale_const",
                                      "--det-eff-scale-const"):
        configure.det_eff_scale_const = hlr_utils.DrParameterFromString(\
            options.det_eff_scale_const, True)

    # Set the detector efficiency attenuation constant
    if hlr_utils.cli_provide_override(configure, "det_eff_atten_const",
                                      "--det-eff-atten-const"):
        configure.det_eff_atten_const = hlr_utils.DrParameterFromString(\
            options.det_eff_atten_const, True)

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file,
                                                       one_file=True)

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    # Set the theta bins
    if hlr_utils.cli_provide_override(configure, "theta_bins", "--theta-bins"):
        configure.theta_bins = hlr_utils.AxisFromString(options.theta_bins)

    # Set the radius bins
    if hlr_utils.cli_provide_override(configure, "r_bins", "--r-bins"):
        configure.r_bins = hlr_utils.AxisFromString(options.r_bins)

    # Set the time-zero offset for the detector
    if hlr_utils.cli_provide_override(configure, "time_zero_offset_det",
                                      "--time-zero-offset-det"):
        configure.time_zero_offset_det = hlr_utils.DrParameterFromString(\
            options.time_zero_offset_det, True)

    # Set the time-zero offset for the monitor
    if hlr_utils.cli_provide_override(configure, "time_zero_offset_mon",
                                      "--time-zero-offset-mon"):
        configure.time_zero_offset_mon = hlr_utils.DrParameterFromString(\
            options.time_zero_offset_mon, True)

    # Set the lambda bins for use with dump-bmnorm-wave
    if hlr_utils.cli_provide_override(configure, "lambda_bins",
                                      "--lambda-bins"):
        configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)

    # Set the low-side lambda cut for cutting wavelength spectra
    if hlr_utils.cli_provide_override(configure, "lambda_low_cut",
                                      "--lambda-low-cut"):
        try:
            configure.lambda_low_cut = float(options.lambda_low_cut)
        except TypeError:
            configure.lambda_low_cut = options.lambda_low_cut

    # Set the high-side lambda cut for cutting wavelength spectra
    if hlr_utils.cli_provide_override(configure, "lambda_high_cut",
                                      "--lambda-high-cut"):
        try:
            configure.lambda_high_cut = float(options.lambda_high_cut)
        except TypeError:
            configure.lambda_high_cut = options.lambda_high_cut

    # Set the coefficients for the wavelength dependent background correction
    if hlr_utils.cli_provide_override(configure, "bkg_coeff", "--bkg-coeff"):
        try:
            configure.bkg_coeff = options.bkg_coeff.split(',')
        except AttributeError:
            configure.bkg_coeff = options.bkg_coeff

    # Set the accelerator down time for sample data
    if hlr_utils.cli_provide_override(configure, "data_acc_down_time",
                                      "--data-acc-down-time"):
        configure.data_acc_down_time = hlr_utils.DrParameterFromString(\
            options.data_acc_down_time, True)

    # Set the accelerator down time for sample data
    if hlr_utils.cli_provide_override(configure, "solv_acc_down_time",
                                      "--solv-acc-down-time"):
        configure.solv_acc_down_time = hlr_utils.DrParameterFromString(\
            options.solv_acc_down_time, True)

    # Set the accelerator down time for sample ecan
    if hlr_utils.cli_provide_override(configure, "ecan_acc_down_time",
                                      "--ecan-acc-down-time"):
        configure.ecan_acc_down_time = hlr_utils.DrParameterFromString(\
            options.ecan_acc_down_time, True)

    # Set the accelerator down time for sample data
    if hlr_utils.cli_provide_override(configure, "open_acc_down_time",
                                      "--open-acc-down-time"):
        configure.open_acc_down_time = hlr_utils.DrParameterFromString(\
            options.open_acc_down_time, True)

    # Set the axis dependent background scaling constant
    if hlr_utils.cli_provide_override(configure, "bkg_scale", "--bkg-scale"):
        try:
            configure.bkg_scale = float(options.bkg_scale)
        except TypeError:
            configure.bkg_scale = options.bkg_scale

    # Set the final data rescaling constant
    if hlr_utils.cli_provide_override(configure, "rescale_final",
                                      "--rescale-final"):
        try:
            configure.rescale_final = float(options.rescale_final)
        except TypeError:
            configure.rescale_final = options.rescale_final

    # Set the ability to dump the detector pixel wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave", "--dump-wave"):
        configure.dump_wave = options.dump_wave

    # Set the ability to dump the beam monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_bmon_wave",
                                      "--dump-bmon-wave"):
        configure.dump_bmon_wave = options.dump_bmon_wave

    # Set the ability to dump the efficiency corrected beam monitor wavelength
    # information
    if hlr_utils.cli_provide_override(configure, "dump_bmon_effc",
                                      "--dump-bmon-effc"):
        configure.dump_bmon_effc = options.dump_bmon_effc

    # Set the ability to dump the rebinned beam monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_bmon_rebin",
                                      "--dump-bmon-rebin"):
        configure.dump_bmon_rebin = options.dump_bmon_rebin

    # Set the ability to dump the wavelength information after beam monitor
    # normalization
    if hlr_utils.cli_provide_override(configure, "dump_wave_bmnorm",
                                      "--dump-wave-bmnorm"):
        configure.dump_wave_bmnorm = options.dump_wave_bmnorm

    # Set the ability to dump the fractional counts and fractional area
    # separately after rebinning in Q
    if hlr_utils.cli_provide_override(configure, "dump_frac_rebin",
                                      "--dump-frac-rebin"):
        configure.dump_frac_rebin = options.dump_frac_rebin

    # Set the ability to dump a TOF vs radius distribution
    if hlr_utils.cli_provide_override(configure, "dump_tof_r", "--dump-tof-r"):
        configure.dump_tof_r = options.dump_tof_r

    # Set the ability to dump a TOF vs polar angle distribution
    if hlr_utils.cli_provide_override(configure, "dump_tof_theta",
                                      "--dump-tof-theta"):
        configure.dump_tof_theta = options.dump_tof_theta

    # Set the ability to dump a wavelength vs radius distribution
    if hlr_utils.cli_provide_override(configure, "dump_wave_r",
                                      "--dump-wave-r"):
        configure.dump_wave_r = options.dump_wave_r

    # Set the ability to dump a wavelength vs polar angle distribution
    if hlr_utils.cli_provide_override(configure, "dump_wave_theta",
                                      "--dump-wave-theta"):
        configure.dump_wave_theta = options.dump_wave_theta

    # Set the ability to dump a momentum transfer vs radius distribution
    if hlr_utils.cli_provide_override(configure, "dump_Q_r", "--dump-Q-r"):
        configure.dump_Q_r = options.dump_Q_r

    # Set the ability to dump a momentum transfer vs polar angle distribution
    if hlr_utils.cli_provide_override(configure, "dump_Q_theta",
                                      "--dump-Q-theta"):
        configure.dump_Q_theta = options.dump_Q_theta

    if hlr_utils.cli_provide_override(configure, "dump_2d", "--dump-2d"):
        if options.dump_2d:
            configure.dump_tof_r = True
            configure.dump_tof_theta = True
            configure.dump_wave_r = True
            configure.dump_wave_theta = True
            configure.dump_Q_r = True
            configure.dump_Q_theta = True

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_wave = True
            configure.dump_bmon_wave = True
            configure.dump_bmon_effc = True
            configure.dump_bmon_rebin = True
            configure.dump_wave_bmnorm = True
            configure.dump_frac_rebin = True
            configure.dump_tof_r = True
            configure.dump_tof_theta = True
            configure.dump_wave_r = True
            configure.dump_wave_theta = True
            configure.dump_Q_r = True
            configure.dump_Q_theta = True

    # Do some cross-checks
    if configure.dump_tof_r or configure.dump_wave_r or configure.dump_Q_r:
        if configure.r_bins is None:
            parser.error("Must specify --r-bins option when using 2D "\
                         +"distribution options --dump-tof-r, "\
                         +"--dump-wave-r or --dump-Q-r.")

    if configure.dump_tof_theta or configure.dump_wave_theta or \
           configure.dump_Q_theta:
        if configure.theta_bins is None:
            parser.error("Must specify --theta-bins option when using 2D "\
                         +"distribution options --dump-tof-theta, "\
                         +"--dump-wave-theta or --dump-Q-theta.")
예제 #25
0
def DgsRedConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{DgsRedOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.DgsRedOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{DgsRedOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{DgsRedOptions}
    @type args: C{list}
    """

    # Call the configuration setter for DgsOptions
    hlr_dgs_options.DgsConfiguration(parser, configure, options, args)

    # Set the mask file
    if hlr_utils.cli_provide_override(configure, "mask_file", "--mask-file"):
        configure.mask_file = hlr_utils.determine_files(options.mask_file)

    # Set the corner geometry information file
    if hlr_utils.cli_provide_override(configure, "corner_geom",
                                      "--corner-geom"):
        configure.corner_geom = options.corner_geom

    if configure.corner_geom is None:
        parser.error("You must provide a corner geometry file via the "\
                     +"corner-geom option!")

    # Set the lambda ratio flag
    if hlr_utils.cli_provide_override(configure, "lambda_ratio",
                                      "--lambda-ratio"):
        configure.lambda_ratio = options.lambda_ratio

    # Set the flag for making the phonon density of states representation
    if hlr_utils.cli_provide_override(configure, "pdos_Q", "--pdos-Q"):
        configure.pdos_Q = options.pdos_Q

    # Set the Debye-Waller constant for the phonon DOS representation
    if hlr_utils.cli_provide_override(configure, "debye_waller",
                                      "--debye-waller"):
        configure.debye_waller = hlr_utils.DrParameterFromString(\
            options.debye_waller)
    else:
        configure.debye_waller = options.debye_waller

    # Set the energy transfer bins
    if hlr_utils.cli_provide_override(configure, "E_bins", "--energy-bins"):
        configure.E_bins = hlr_utils.AxisFromString(options.E_bins)

    if configure.E_bins is None:
        parser.error("You must provide energy transfer binning via the "\
                     +"energy-bins option")

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    if configure.Q_bins is None:
        parser.error("You must provide momentum transfer binning via the "\
                     +"mom-trans-bins option")

    # Set the ability to write SPE and PHX files instead of S(Q, E) dist
    if hlr_utils.cli_provide_override(configure, "make_spe", "--make_spe"):
        configure.make_spe = options.make_spe

    # Set the ability to create the Q vector meshes for each energy slice
    if hlr_utils.cli_provide_override(configure, "qmesh", "--qmesh", "-m"):
        configure.qmesh = options.qmesh

    # Set the ability to write out fixed grid mesh files
    if hlr_utils.cli_provide_override(configure, "fixed", "--fixed", "-x"):
        configure.fixed = options.fixed

    # Set the ability to turn off zero suppression for single crystal data
    if hlr_utils.cli_provide_override(configure, "no_zero_supp",
                                      "--no-zero-supp"):
        configure.no_zero_supp = options.no_zero_supp

    # Set the ability to dump the combined energy transfer information
    if hlr_utils.cli_provide_override(configure, "dump_et_comb",
                                      "--dump-et-comb"):
        configure.dump_et_comb = options.dump_et_comb

    if hlr_utils.cli_provide_override(configure, "split", "--split"):
        configure.split = options.split
예제 #26
0
def IgsConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{IgsOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.IgsOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{IgsOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{IgsOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_options.InstConfiguration(parser, configure, options, args, inst="IGS")

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file,
                                                       one_file=True)

    # Set the monitor path
    if hlr_utils.cli_provide_override(configure, "mon_path", "--mon-path"):
        configure.mon_path = hlr_utils.NxPath(options.mon_path)

    # Set the dead time
    if hlr_utils.cli_provide_override(configure, "dead_time", "--dead-time"):
        configure.dead_time = hlr_utils.DrParameterFromString(\
            options.dead_time)

    # Set the minimum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_min",
                                      "--tof-cut-min"):
        configure.tof_cut_min = options.tof_cut_min

    # Set the maximum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_max",
                                      "--tof-cut-max"):
        configure.tof_cut_max = options.tof_cut_max        

    # Set the time-independent background TOFs
    if hlr_utils.cli_provide_override(configure, "tib_tofs", "--tib-tofs"):
        if options.tib_tofs is not None:
            configure.tib_tofs = options.tib_tofs.split(',')
        else:
            configure.tib_tofs = options.tib_tofs

    # Set the time-independent background constant for data
    if hlr_utils.cli_provide_override(configure, "tib_data_const",
                                      "--tib-data-const"):
        configure.tib_data_const = hlr_utils.DrParameterFromString(\
                    options.tib_data_const, True)

    # Set the time-independent background constant for ecan
    if hlr_utils.cli_provide_override(configure, "tib_ecan_const",
                                      "--tib-ecan-const"):
        configure.tib_ecan_const = hlr_utils.DrParameterFromString(\
                    options.tib_ecan_const, True)

    # Set the time-independent background constant for back
    if hlr_utils.cli_provide_override(configure, "tib_back_const",
                                      "--tib-back-const"):    
        configure.tib_back_const = hlr_utils.DrParameterFromString(\
                    options.tib_back_const, True)

    # Set the time-independent background constant for norm
    if hlr_utils.cli_provide_override(configure, "tib_norm_const",
                                      "--tib-norm-const"):    
        configure.tib_norm_const = hlr_utils.DrParameterFromString(\
                    options.tib_norm_const, True)

    # Set the time-independent background constant for dsback
    if hlr_utils.cli_provide_override(configure, "tib_dsback_const",
                                      "--tib-dsback-const"):    
        configure.tib_dsback_const = hlr_utils.DrParameterFromString(\
                    options.tib_dsback_const, True)

    # Set the normalization start wavelength
    if hlr_utils.cli_provide_override(configure, "norm_start", "--norm_start"):
        configure.norm_start = float(options.norm_start)

    # Set the normalization end wavelength 
    if hlr_utils.cli_provide_override(configure, "norm_end", "--norm_end"):
        configure.norm_end = float(options.norm_end)

    # Set no_mon_norm flag
    if hlr_utils.cli_provide_override(configure, "no_mon_norm",
                                      "--no-mon-norm"):
        configure.no_mon_norm = options.no_mon_norm

    # Set no_mon_effc flag
    if hlr_utils.cli_provide_override(configure, "no_mon_effc",
                                      "--no-mon-effc"):
        configure.no_mon_effc = options.no_mon_effc

    # Set the final wavelength
    if hlr_utils.cli_provide_override(configure, "wavelength_final",
                                      "--wavelength-final"):    
        configure.wavelength_final = hlr_utils.DrParameterFromString(\
            options.wavelength_final, True)

    # Set the time-zero offset
    if hlr_utils.cli_provide_override(configure, "time_zero_offset",
                                      "--time-zero-offset"):    
        configure.time_zero_offset = hlr_utils.DrParameterFromString(\
            options.time_zero_offset, True)

    # Set the time-zero slope
    if hlr_utils.cli_provide_override(configure, "time_zero_slope",
                                      "--time-zero-slope"):    
        configure.time_zero_slope = hlr_utils.DrParameterFromString(\
            options.time_zero_slope, True)

    # Set the lambda bins for use with dump-mnorm-wave
    if hlr_utils.cli_provide_override(configure, "lambda_bins",
                                      "--lambda-bins"):    
        configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)

    # Set the ability to dump the time-independent background information
    if hlr_utils.cli_provide_override(configure, "dump_tib", "--dump-tib"): 
        configure.dump_tib = options.dump_tib

    # Set the ability to dump the wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave", "--dump-wave"):
        configure.dump_wave = options.dump_wave

    # Set the ability to dump the monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_mon_wave",
                                      "--dump-mon-wave"):
        configure.dump_mon_wave = options.dump_mon_wave    

    # Set the ability to dump the rebinned monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_mon_rebin",
                                      "--dump-mon-rebin"):
        configure.dump_mon_rebin = options.dump_mon_rebin

    # Set the ability to dump the efficiency corrected monitor wavelength
    # information
    if hlr_utils.cli_provide_override(configure, "dump_mon_effc",
                                      "--dump-mon-effc"):
        configure.dump_mon_effc = options.dump_mon_effc

    # Set the ability to dump the wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave_mnorm",
                                      "--dump-wave-mnorm"):
        configure.dump_wave_mnorm = options.dump_wave_mnorm

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_tib = True
            configure.dump_wave = True
            configure.dump_mon_wave = True
            configure.dump_mon_wave = True
            configure.dump_mon_effc = True
            configure.dump_mon_diml = True
            configure.dump_mon_rebin = True
            configure.dump_wave_mnorm = True        

    # Set the filter option
    if hlr_utils.cli_provide_override(configure, "filter", "--filter",
                                      "--no-filter"):    
        configure.filter = options.filter

    # Set MC option
    if hlr_utils.cli_provide_override(configure, "mc", "--mc"):
        configure.mc = options.mc

    # Set the early background subtraction option
    if hlr_utils.cli_provide_override(configure, "hwfix", "--hwfix"):
        configure.hwfix = options.hwfix        
    
    # Set the constant for scaling the background spectra: sample 
    if hlr_utils.cli_provide_override(configure, "scale_bs", "--scale-bs"):
        configure.scale_bs = hlr_utils.DrParameterFromString(options.scale_bs,
                                                             True)

    # Set the constant for scaling the background spectra: normalization
    if hlr_utils.cli_provide_override(configure, "scale_bn", "--scale-bn"):
        configure.scale_bn = hlr_utils.DrParameterFromString(options.scale_bn,
                                                             True)

    # Set the constant for scaling the background spectra: empty container
    # for sample 
    if hlr_utils.cli_provide_override(configure, "scale_bcs", "--scale-bcs"):
        configure.scale_bcs = hlr_utils.DrParameterFromString(\
            options.scale_bcs, True)

    # Set the constant for scaling the background spectra: empty container
    # for normalization
    if hlr_utils.cli_provide_override(configure, "scale_bcn", "--scale-bcn"):
        configure.scale_bcn = hlr_utils.DrParameterFromString(\
            options.scale_bcn, True)

    # Set the constant for scaling the empty container spectra: sample 
    if hlr_utils.cli_provide_override(configure, "scale_cs", "--scale-cs"):
        configure.scale_cs = hlr_utils.DrParameterFromString(options.scale_cs,
                                                             True)

    # Set the constant for scaling the empty container spectra: normalization
    if hlr_utils.cli_provide_override(configure, "scale_cn", "--scale-cn"):
        configure.scale_cn = hlr_utils.DrParameterFromString(options.scale_cn,
                                                             True)

    # Set the elastic peak range in TOF
    if hlr_utils.cli_provide_override(configure, "tof_elastic",
                                      "--tof-elastic"):
        if options.tof_elastic is not None:
            configure.tof_elastic = options.tof_elastic.split(',')
        else:
            configure.tof_elastic = options.tof_elastic
예제 #27
0
def RefConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{RefOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.RefOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{RefOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{RefOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_options.InstConfiguration(parser, configure, options, args, inst="REF")

    # Set the data instrument geometry file
    if hlr_utils.cli_provide_override(configure, "data_inst_geom",
                                      "--data-inst-geom"):
        configure.data_inst_geom = hlr_utils.determine_files(\
            options.data_inst_geom,
            one_file=True)

    # Set the normalization instrument geometry file
    if hlr_utils.cli_provide_override(configure, "norm_inst_geom",
                                      "--norm-inst-geom"):
        configure.norm_inst_geom = hlr_utils.determine_files(\
            options.norm_inst_geom,
            one_file=True)        

    # Set the normalization data paths
    if hlr_utils.cli_provide_override(configure, "norm_data_paths",
                                      "--norm-data-paths"):
        try:
            configure.norm_data_paths = hlr_utils.NxPath(\
                options.norm_data_paths)
        except AttributeError:
            configure.norm_data_paths = options.norm_data_paths

    # Get the data path for the sample data ROI file
    if hlr_utils.cli_provide_override(configure, "data_roi_file",
                                      "--data-roi-file"):
        configure.data_roi_file = hlr_utils.determine_files(\
                     options.data_roi_file,
                     one_file=True)
    
    # Get the data path for the normalization data ROI file
    if hlr_utils.cli_provide_override(configure, "norm_roi_file",
                                      "--norm-roi-file"):
        if options.norm_roi_file is not None:
            configure.norm_roi_file = hlr_utils.determine_files(\
                     options.norm_roi_file,
                     one_file=True)
        else:
            configure.norm_roi_file = configure.data_roi_file

    # Get the data path for the sample data background ROI file
    if hlr_utils.cli_provide_override(configure, "dbkg_roi_file",
                                      "--dbkg-roi-file"):
        configure.dbkg_roi_file = hlr_utils.determine_files(\
                     options.dbkg_roi_file,
                     one_file=True)
    
    # Get the data path for the normalization background ROI file
    if hlr_utils.cli_provide_override(configure, "nbkg_roi_file",
                                      "--nbkg-roi-file"):
        if options.nbkg_roi_file is not None:
            configure.nbkg_roi_file = hlr_utils.determine_files(\
                     options.nbkg_roi_file,
                     one_file=True)
        else:
            configure.nbkg_roi_file = configure.dbkg_roi_file            
    
    # Get the polar angle offset
    if hlr_utils.cli_provide_override(configure, "angle_offset",
                                      "--angle-offset"):
        configure.angle_offset = hlr_utils.DrParameterFromString(\
            options.angle_offset, True)

    # Set the ability to turn off background estimation and subtraction
    if hlr_utils.cli_provide_override(configure, "no_bkg", "--no-bkg"):    
        configure.no_bkg = options.no_bkg

    # Set the ability to turn off normalization background estimation
    # and subtraction
    if hlr_utils.cli_provide_override(configure, "no_norm_bkg",
                                      "--no-norm-bkg"):    
        configure.no_norm_bkg = options.no_norm_bkg

    # Set the minimum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_min",
                                      "--tof-cut-min"):
        configure.tof_cut_min = options.tof_cut_min

    # Set the maximum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_max",
                                      "--tof-cut-max"):
        configure.tof_cut_max = options.tof_cut_max        

    # Set the TOF bins to zero out from the data and normalization spectra
    if hlr_utils.cli_provide_override(configure, "tof_cuts", "--tof-cuts"):
        if options.tof_cuts is not None:
            configure.tof_cuts = options.tof_cuts.split(',')
        else:
            configure.tof_cuts = options.tof_cuts

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    # Set the no bad data filter flag
    if hlr_utils.cli_provide_override(configure, "no_filter", "--no-filter"):
        configure.no_filter = options.no_filter

    # Set the store delta t over t flag
    if hlr_utils.cli_provide_override(configure, "store_dtot", "--store-dtot"):
        configure.store_dtot = options.store_dtot        

    # Set the pixel ID range values for peak exclusion from sample data
    if hlr_utils.cli_provide_override(configure, "data_peak_excl",
                                      "--data-peak-excl"):
        configure.data_peak_excl = options.data_peak_excl

    # Set the pixel ID range values for peak exclusion from normalization data
    if hlr_utils.cli_provide_override(configure, "norm_peak_excl",
                                      "--norm-peak-excl"):
        configure.norm_peak_excl = options.norm_peak_excl        

    # Set the integration direction
    if hlr_utils.cli_provide_override(configure, "int_dir", "--int-dir"):
        configure.int_dir = options.int_dir

    # Get the scattering (polar) angle for axis TOF to Q conversion
    if hlr_utils.cli_provide_override(configure, "scatt_angle",
                                      "--scatt-angle"):
        configure.scatt_angle = hlr_utils.DrParameterFromString(\
            options.scatt_angle, True)

    # Set the ability to dump the combined specular TOF information
    if hlr_utils.cli_provide_override(configure, "dump_specular",
                                      "--dump-specular"): 
        configure.dump_specular = options.dump_specular

    # Set the ability to dump the combined background TOF information
    if hlr_utils.cli_provide_override(configure, "dump_bkg", "--dump-bkg"):
        configure.dump_bkg = options.dump_bkg

    # Set the ability to dump the combined subtracted TOF information
    if hlr_utils.cli_provide_override(configure, "dump_sub", "--dump-sub"):    
        configure.dump_sub = options.dump_sub

    # Set the ability to dump the R(TOF) information
    if hlr_utils.cli_provide_override(configure, "dump_rtof", "--dump-rtof"): 
        configure.dump_rtof = options.dump_rtof

    # Set the ability to dump the combined R(TOF) information
    if hlr_utils.cli_provide_override(configure, "dump_rtof_comb",
                                      "--dump-rtof-comb"): 
        configure.dump_rtof_comb = options.dump_rtof_comb        

    # Set the ability to dump the R(Q) information
    if hlr_utils.cli_provide_override(configure, "dump_rq", "--dump-rq"): 
        configure.dump_rq = options.dump_rq

    # Set the ability to dump the R(Q) after rebinning information
    if hlr_utils.cli_provide_override(configure, "dump_rqr", "--dump-rqr"): 
        configure.dump_rqr = options.dump_rqr        

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_specular = True
            configure.dump_bkg = True
            configure.dump_sub = True
            configure.dump_rtof = True
            configure.dump_rtof_comb = True
            configure.dump_rq = True
            configure.dump_rqr = True
예제 #28
0
def SansConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{SansOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.SansOptions}

    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}

    @param options: The parsed options from C{SansOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{SansOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_utils.InstConfiguration(parser, configure, options, args, inst="SAS")

    # Set the beam monitor path
    if hlr_utils.cli_provide_override(configure, "bmon_path", "--bmon-path"):
        configure.bmon_path = hlr_utils.NxPath(options.bmon_path)

    # Set the transmission monitor path
    if hlr_utils.cli_provide_override(configure, "tmon_path", "--tmon-path"):
        configure.tmon_path = hlr_utils.NxPath(options.tmon_path)        

    # Set the sample data Transmission spectrum file
    if hlr_utils.cli_provide_override(configure, "data_trans", "--data-trans"):
        configure.data_trans = hlr_utils.determine_files(options.data_trans,
                                                         one_file=True)

    # Set the solvent only Transmission spectrum file
    if hlr_utils.cli_provide_override(configure, "solv_trans", "--solv-trans"):
        configure.solv_trans = hlr_utils.determine_files(options.solv_trans,
                                                         one_file=True)

    # Set the empty can Transmission spectrum file
    if hlr_utils.cli_provide_override(configure, "ecan_trans", "--ecan-trans"):
        configure.ecan_trans = hlr_utils.determine_files(options.ecan_trans,
                                                         one_file=True)   

    # Set the beam monitor override file
    if hlr_utils.cli_provide_override(configure, "beammon_over",
                                      "--beammon-over"):
        configure.beammon_over = hlr_utils.determine_files(\
            options.beammon_over,
            configure.inst,
            configure.facility,
            configure.proposal,
            stop_on_none=True)

    # Set no_bmon_norm flag
    if hlr_utils.cli_provide_override(configure, "no_bmon_norm",
                                      "--no-bmon-norm"):
        configure.no_bmon_norm = options.no_bmon_norm
    
    # Set mon_effc flag
    if hlr_utils.cli_provide_override(configure, "mon_effc", "--mon-effc"):
        configure.mon_effc = options.mon_effc

    # Set the monitor efficiency constant
    if hlr_utils.cli_provide_override(configure, "mon_eff_const",
                                      "--mon-eff-const"):
        configure.mon_eff_const = hlr_utils.DrParameterFromString(\
            options.mon_eff_const, True)

    # Set det_effc flag
    if hlr_utils.cli_provide_override(configure, "det_effc", "--det-effc"):
        configure.det_effc = options.det_effc

    # Set the detector efficiency scaling constant
    if hlr_utils.cli_provide_override(configure, "det_eff_scale_const",
                                      "--det-eff-scale-const"):
        configure.det_eff_scale_const = hlr_utils.DrParameterFromString(\
            options.det_eff_scale_const, True)

    # Set the detector efficiency attenuation constant
    if hlr_utils.cli_provide_override(configure, "det_eff_atten_const",
                                      "--det-eff-atten-const"):
        configure.det_eff_atten_const = hlr_utils.DrParameterFromString(\
            options.det_eff_atten_const, True)        

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file,
                                                       one_file=True)

    # Set the momentum transfer bins
    if hlr_utils.cli_provide_override(configure, "Q_bins", "--mom-trans-bins"):
        configure.Q_bins = hlr_utils.AxisFromString(options.Q_bins)

    # Set the theta bins
    if hlr_utils.cli_provide_override(configure, "theta_bins", "--theta-bins"):
        configure.theta_bins = hlr_utils.AxisFromString(options.theta_bins)   

    # Set the radius bins
    if hlr_utils.cli_provide_override(configure, "r_bins", "--r-bins"):
        configure.r_bins = hlr_utils.AxisFromString(options.r_bins)   

    # Set the time-zero offset for the detector
    if hlr_utils.cli_provide_override(configure, "time_zero_offset_det",
                                      "--time-zero-offset-det"):    
        configure.time_zero_offset_det = hlr_utils.DrParameterFromString(\
            options.time_zero_offset_det, True)

    # Set the time-zero offset for the monitor
    if hlr_utils.cli_provide_override(configure, "time_zero_offset_mon",
                                      "--time-zero-offset-mon"):    
        configure.time_zero_offset_mon = hlr_utils.DrParameterFromString(\
            options.time_zero_offset_mon, True)        

    # Set the lambda bins for use with dump-bmnorm-wave
    if hlr_utils.cli_provide_override(configure, "lambda_bins",
                                      "--lambda-bins"):    
        configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)

    # Set the low-side lambda cut for cutting wavelength spectra
    if hlr_utils.cli_provide_override(configure, "lambda_low_cut",
                                      "--lambda-low-cut"):
        try:
            configure.lambda_low_cut = float(options.lambda_low_cut)
        except TypeError:
            configure.lambda_low_cut = options.lambda_low_cut

    # Set the high-side lambda cut for cutting wavelength spectra
    if hlr_utils.cli_provide_override(configure, "lambda_high_cut",
                                      "--lambda-high-cut"):
        try:
            configure.lambda_high_cut = float(options.lambda_high_cut)
        except TypeError:
            configure.lambda_high_cut = options.lambda_high_cut            

    # Set the coefficients for the wavelength dependent background correction
    if hlr_utils.cli_provide_override(configure, "bkg_coeff", "--bkg-coeff"):
        try:
            configure.bkg_coeff = options.bkg_coeff.split(',')
        except AttributeError:
            configure.bkg_coeff = options.bkg_coeff

    # Set the accelerator down time for sample data
    if hlr_utils.cli_provide_override(configure, "data_acc_down_time",
                                      "--data-acc-down-time"):
        configure.data_acc_down_time = hlr_utils.DrParameterFromString(\
            options.data_acc_down_time, True)

    # Set the accelerator down time for sample data
    if hlr_utils.cli_provide_override(configure, "solv_acc_down_time",
                                      "--solv-acc-down-time"):
        configure.solv_acc_down_time = hlr_utils.DrParameterFromString(\
            options.solv_acc_down_time, True)

    # Set the accelerator down time for sample ecan
    if hlr_utils.cli_provide_override(configure, "ecan_acc_down_time",
                                      "--ecan-acc-down-time"):
        configure.ecan_acc_down_time = hlr_utils.DrParameterFromString(\
            options.ecan_acc_down_time, True)

    # Set the accelerator down time for sample data
    if hlr_utils.cli_provide_override(configure, "open_acc_down_time",
                                      "--open-acc-down-time"):
        configure.open_acc_down_time = hlr_utils.DrParameterFromString(\
            options.open_acc_down_time, True)        

    # Set the axis dependent background scaling constant
    if hlr_utils.cli_provide_override(configure, "bkg_scale", "--bkg-scale"):
        try:
            configure.bkg_scale = float(options.bkg_scale)
        except TypeError:
            configure.bkg_scale = options.bkg_scale

    # Set the final data rescaling constant
    if hlr_utils.cli_provide_override(configure, "rescale_final",
                                      "--rescale-final"):
        try:
            configure.rescale_final = float(options.rescale_final)
        except TypeError:
            configure.rescale_final = options.rescale_final
        
    # Set the ability to dump the detector pixel wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave", "--dump-wave"):
        configure.dump_wave = options.dump_wave

    # Set the ability to dump the beam monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_bmon_wave",
                                      "--dump-bmon-wave"):
        configure.dump_bmon_wave = options.dump_bmon_wave    

    # Set the ability to dump the efficiency corrected beam monitor wavelength
    # information
    if hlr_utils.cli_provide_override(configure, "dump_bmon_effc",
                                      "--dump-bmon-effc"):
        configure.dump_bmon_effc = options.dump_bmon_effc

    # Set the ability to dump the rebinned beam monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_bmon_rebin",
                                      "--dump-bmon-rebin"):
        configure.dump_bmon_rebin = options.dump_bmon_rebin

    # Set the ability to dump the wavelength information after beam monitor
    # normalization
    if hlr_utils.cli_provide_override(configure, "dump_wave_bmnorm",
                                      "--dump-wave-bmnorm"):
        configure.dump_wave_bmnorm = options.dump_wave_bmnorm

    # Set the ability to dump the fractional counts and fractional area
    # separately after rebinning in Q
    if hlr_utils.cli_provide_override(configure, "dump_frac_rebin",
                                      "--dump-frac-rebin"):
        configure.dump_frac_rebin = options.dump_frac_rebin

    # Set the ability to dump a TOF vs radius distribution
    if hlr_utils.cli_provide_override(configure, "dump_tof_r", "--dump-tof-r"):
        configure.dump_tof_r = options.dump_tof_r

    # Set the ability to dump a TOF vs polar angle distribution
    if hlr_utils.cli_provide_override(configure, "dump_tof_theta",
                                      "--dump-tof-theta"):
        configure.dump_tof_theta = options.dump_tof_theta

    # Set the ability to dump a wavelength vs radius distribution
    if hlr_utils.cli_provide_override(configure, "dump_wave_r",
                                      "--dump-wave-r"):
        configure.dump_wave_r = options.dump_wave_r        

    # Set the ability to dump a wavelength vs polar angle distribution
    if hlr_utils.cli_provide_override(configure, "dump_wave_theta",
                                      "--dump-wave-theta"):
        configure.dump_wave_theta = options.dump_wave_theta

    # Set the ability to dump a momentum transfer vs radius distribution
    if hlr_utils.cli_provide_override(configure, "dump_Q_r",
                                      "--dump-Q-r"):
        configure.dump_Q_r = options.dump_Q_r        

    # Set the ability to dump a momentum transfer vs polar angle distribution
    if hlr_utils.cli_provide_override(configure, "dump_Q_theta",
                                      "--dump-Q-theta"):
        configure.dump_Q_theta = options.dump_Q_theta        

    if hlr_utils.cli_provide_override(configure, "dump_2d", "--dump-2d"):
        if options.dump_2d:
            configure.dump_tof_r = True
            configure.dump_tof_theta = True
            configure.dump_wave_r = True
            configure.dump_wave_theta = True
            configure.dump_Q_r = True
            configure.dump_Q_theta = True

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_wave = True
            configure.dump_bmon_wave = True
            configure.dump_bmon_effc = True
            configure.dump_bmon_rebin = True
            configure.dump_wave_bmnorm = True
            configure.dump_frac_rebin = True
            configure.dump_tof_r = True
            configure.dump_tof_theta = True
            configure.dump_wave_r = True
            configure.dump_wave_theta = True
            configure.dump_Q_r = True
            configure.dump_Q_theta = True

    # Do some cross-checks
    if configure.dump_tof_r or configure.dump_wave_r or configure.dump_Q_r:
        if configure.r_bins is None:
            parser.error("Must specify --r-bins option when using 2D "\
                         +"distribution options --dump-tof-r, "\
                         +"--dump-wave-r or --dump-Q-r.")

    if configure.dump_tof_theta or configure.dump_wave_theta or \
           configure.dump_Q_theta:
        if configure.theta_bins is None:
            parser.error("Must specify --theta-bins option when using 2D "\
                         +"distribution options --dump-tof-theta, "\
                         +"--dump-wave-theta or --dump-Q-theta.")            
예제 #29
0
def IgsConfiguration(parser, configure, options, args):
    """
    This function sets the incoming C{Configure} object with all the options
    that have been specified via the C{IgsOptions} object.

    @param parser: The parser object
    @type parser: L{hlr_utils.IgsOptions}
    
    @param configure: The configuration object
    @type configure: L{hlr_utils.Configure}
    
    @param options: The parsed options from C{IgsOptions}
    @type options: C{Option}

    @param args: The parsed arguments from C{IgsOptions}
    @type args: C{list}
    """

    # Call the configuration setter for InstOptions
    hlr_options.InstConfiguration(parser, configure, options, args, inst="IGS")

    # Set the ROI file
    if hlr_utils.cli_provide_override(configure, "roi_file", "--roi-file"):
        configure.roi_file = hlr_utils.determine_files(options.roi_file,
                                                       one_file=True)

    # Set the monitor path
    if hlr_utils.cli_provide_override(configure, "mon_path", "--mon-path"):
        configure.mon_path = hlr_utils.NxPath(options.mon_path)

    # Set the dead time
    if hlr_utils.cli_provide_override(configure, "dead_time", "--dead-time"):
        configure.dead_time = hlr_utils.DrParameterFromString(\
            options.dead_time)

    # Set the minimum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_min",
                                      "--tof-cut-min"):
        configure.tof_cut_min = options.tof_cut_min

    # Set the maximum TOF channel for spectrum cutting
    if hlr_utils.cli_provide_override(configure, "tof_cut_max",
                                      "--tof-cut-max"):
        configure.tof_cut_max = options.tof_cut_max

    # Set the time-independent background TOFs
    if hlr_utils.cli_provide_override(configure, "tib_tofs", "--tib-tofs"):
        if options.tib_tofs is not None:
            configure.tib_tofs = options.tib_tofs.split(',')
        else:
            configure.tib_tofs = options.tib_tofs

    # Set the time-independent background constant for data
    if hlr_utils.cli_provide_override(configure, "tib_data_const",
                                      "--tib-data-const"):
        configure.tib_data_const = hlr_utils.DrParameterFromString(\
                    options.tib_data_const, True)

    # Set the time-independent background constant for ecan
    if hlr_utils.cli_provide_override(configure, "tib_ecan_const",
                                      "--tib-ecan-const"):
        configure.tib_ecan_const = hlr_utils.DrParameterFromString(\
                    options.tib_ecan_const, True)

    # Set the time-independent background constant for back
    if hlr_utils.cli_provide_override(configure, "tib_back_const",
                                      "--tib-back-const"):
        configure.tib_back_const = hlr_utils.DrParameterFromString(\
                    options.tib_back_const, True)

    # Set the time-independent background constant for norm
    if hlr_utils.cli_provide_override(configure, "tib_norm_const",
                                      "--tib-norm-const"):
        configure.tib_norm_const = hlr_utils.DrParameterFromString(\
                    options.tib_norm_const, True)

    # Set the time-independent background constant for dsback
    if hlr_utils.cli_provide_override(configure, "tib_dsback_const",
                                      "--tib-dsback-const"):
        configure.tib_dsback_const = hlr_utils.DrParameterFromString(\
                    options.tib_dsback_const, True)

    # Set the normalization start wavelength
    if hlr_utils.cli_provide_override(configure, "norm_start", "--norm_start"):
        configure.norm_start = float(options.norm_start)

    # Set the normalization end wavelength
    if hlr_utils.cli_provide_override(configure, "norm_end", "--norm_end"):
        configure.norm_end = float(options.norm_end)

    # Set no_mon_norm flag
    if hlr_utils.cli_provide_override(configure, "no_mon_norm",
                                      "--no-mon-norm"):
        configure.no_mon_norm = options.no_mon_norm

    # Set no_mon_effc flag
    if hlr_utils.cli_provide_override(configure, "no_mon_effc",
                                      "--no-mon-effc"):
        configure.no_mon_effc = options.no_mon_effc

    # Set the final wavelength
    if hlr_utils.cli_provide_override(configure, "wavelength_final",
                                      "--wavelength-final"):
        configure.wavelength_final = hlr_utils.DrParameterFromString(\
            options.wavelength_final, True)

    # Set the time-zero offset
    if hlr_utils.cli_provide_override(configure, "time_zero_offset",
                                      "--time-zero-offset"):
        configure.time_zero_offset = hlr_utils.DrParameterFromString(\
            options.time_zero_offset, True)

    # Set the time-zero slope
    if hlr_utils.cli_provide_override(configure, "time_zero_slope",
                                      "--time-zero-slope"):
        configure.time_zero_slope = hlr_utils.DrParameterFromString(\
            options.time_zero_slope, True)

    # Set the lambda bins for use with dump-mnorm-wave
    if hlr_utils.cli_provide_override(configure, "lambda_bins",
                                      "--lambda-bins"):
        configure.lambda_bins = hlr_utils.AxisFromString(options.lambda_bins)

    # Set the ability to dump the time-independent background information
    if hlr_utils.cli_provide_override(configure, "dump_tib", "--dump-tib"):
        configure.dump_tib = options.dump_tib

    # Set the ability to dump the wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave", "--dump-wave"):
        configure.dump_wave = options.dump_wave

    # Set the ability to dump the monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_mon_wave",
                                      "--dump-mon-wave"):
        configure.dump_mon_wave = options.dump_mon_wave

    # Set the ability to dump the rebinned monitor wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_mon_rebin",
                                      "--dump-mon-rebin"):
        configure.dump_mon_rebin = options.dump_mon_rebin

    # Set the ability to dump the efficiency corrected monitor wavelength
    # information
    if hlr_utils.cli_provide_override(configure, "dump_mon_effc",
                                      "--dump-mon-effc"):
        configure.dump_mon_effc = options.dump_mon_effc

    # Set the ability to dump the wavelength information
    if hlr_utils.cli_provide_override(configure, "dump_wave_mnorm",
                                      "--dump-wave-mnorm"):
        configure.dump_wave_mnorm = options.dump_wave_mnorm

    if hlr_utils.cli_provide_override(configure, "dump_all", "--dump-all"):
        if options.dump_all:
            configure.dump_tib = True
            configure.dump_wave = True
            configure.dump_mon_wave = True
            configure.dump_mon_wave = True
            configure.dump_mon_effc = True
            configure.dump_mon_diml = True
            configure.dump_mon_rebin = True
            configure.dump_wave_mnorm = True

    # Set the filter option
    if hlr_utils.cli_provide_override(configure, "filter", "--filter",
                                      "--no-filter"):
        configure.filter = options.filter

    # Set MC option
    if hlr_utils.cli_provide_override(configure, "mc", "--mc"):
        configure.mc = options.mc

    # Set the early background subtraction option
    if hlr_utils.cli_provide_override(configure, "hwfix", "--hwfix"):
        configure.hwfix = options.hwfix

    # Set the constant for scaling the background spectra: sample
    if hlr_utils.cli_provide_override(configure, "scale_bs", "--scale-bs"):
        configure.scale_bs = hlr_utils.DrParameterFromString(
            options.scale_bs, True)

    # Set the constant for scaling the background spectra: normalization
    if hlr_utils.cli_provide_override(configure, "scale_bn", "--scale-bn"):
        configure.scale_bn = hlr_utils.DrParameterFromString(
            options.scale_bn, True)

    # Set the constant for scaling the background spectra: empty container
    # for sample
    if hlr_utils.cli_provide_override(configure, "scale_bcs", "--scale-bcs"):
        configure.scale_bcs = hlr_utils.DrParameterFromString(\
            options.scale_bcs, True)

    # Set the constant for scaling the background spectra: empty container
    # for normalization
    if hlr_utils.cli_provide_override(configure, "scale_bcn", "--scale-bcn"):
        configure.scale_bcn = hlr_utils.DrParameterFromString(\
            options.scale_bcn, True)

    # Set the constant for scaling the empty container spectra: sample
    if hlr_utils.cli_provide_override(configure, "scale_cs", "--scale-cs"):
        configure.scale_cs = hlr_utils.DrParameterFromString(
            options.scale_cs, True)

    # Set the constant for scaling the empty container spectra: normalization
    if hlr_utils.cli_provide_override(configure, "scale_cn", "--scale-cn"):
        configure.scale_cn = hlr_utils.DrParameterFromString(
            options.scale_cn, True)

    # Set the elastic peak range in TOF
    if hlr_utils.cli_provide_override(configure, "tof_elastic",
                                      "--tof-elastic"):
        if options.tof_elastic is not None:
            configure.tof_elastic = options.tof_elastic.split(',')
        else:
            configure.tof_elastic = options.tof_elastic