Exemplo n.º 1
0
def fit_pix_values(t_ccd, esec, id=1):
    logger = logging.getLogger("sherpa")
    logger.setLevel(logging.WARN)
    data_id = id
    ui.clean()
    ui.set_method('simplex')
    ui.load_user_model(dark_scale_model, 'model')
    ui.add_user_pars('model', ['scale', 'dark_t_ref'])
    ui.set_model(data_id, 'model')
    ui.load_arrays(
        data_id,
        np.array(t_ccd),
        np.array(esec),
    )
    ui.set_staterror(data_id, 30 * np.ones(len(t_ccd)))
    model.scale.val = 0.588
    model.scale.min = 0.3
    model.scale.max = 1.0
    model.dark_t_ref.val = 500
    ui.freeze(model.scale)
    # If more than 5 degrees in the temperature range,
    # thaw and fit for model.scale.  Else just use/return
    # the fit of dark_t_ref
    if np.max(t_ccd) - np.min(t_ccd) > 2:
        # Fit first for dark_t_ref
        ui.fit(data_id)
        ui.thaw(model.scale)
    ui.fit(data_id)
    return ui.get_fit_results(), ui.get_model(data_id)
Exemplo n.º 2
0
def set_log_level(level):
    """
    Set the global logging level

    :level: log level string like "verbose" or "critical"
    """
    levels = "VERBOSE DEBUG INFO WARNING CRITICAL ERROR".split()
    levels_map = {key.lower(): getattr(pyyaks.logger, key) for key in levels}
    level = levels_map[level]

    logger.setLevel(level)
    for handler in logger.handlers:
        handler.setLevel(level)
def fit_pix_values(t_ccd, esec, id=1):
    logger = logging.getLogger("sherpa")
    logger.setLevel(logging.WARN)
    data_id = id
    ui.clean()
    ui.set_method("simplex")
    ui.load_user_model(dark_scale_model, "model")
    ui.add_user_pars("model", ["scale", "dark_t_ref"])
    ui.set_model(data_id, "model")
    ui.load_arrays(data_id, np.array(t_ccd), np.array(esec), 0.1 * np.ones(len(t_ccd)))
    model.scale.val = 0.70
    model.dark_t_ref.val = 500
    ui.freeze(model.scale)
    # If more than 5 degrees in the temperature range,
    # thaw and fit for model.scale.  Else just use/return
    # the fit of dark_t_ref
    ui.fit(data_id)
    ui.thaw(model.scale)
    ui.fit(data_id)
    return ui.get_fit_results(), ui.get_model(data_id)