Beispiel #1
0
def process_Rfwhm(Rfwhm, wa, model, models):
    """ Convolve the input models using the Rfwhm option

    Return the new models.

    wa:  wavelength array, shape (N,)
    model: model flux array, shape (N,)
    models: list of model flux arrays each with shape (N,)

    Rfwhm is one of:

      'convolve_with_COS_FOS'
      a float
      an array floats with shape (N,)

    Returns
    -------
    new_model, new_models
    """

    model_out = None
    models_out = []

    #import pdb; pdb.set_trace()
    if Rfwhm is None:
        return model, models

    elif Rfwhm == 'convolve_with_COS_FOS':
        #print 'convolving with COS/FOS instrument profile'
        #import pdb; pdb.set_trace()
        model_out = convolve_with_COS_FOS(model, wa, use_COS_nuv=True)
        for m in models:
            #if m.min() < (1 - 1e-2):
            m = convolve_with_COS_FOS(m, wa, use_COS_nuv=True)
            models_out.append(m)

    elif isinstance(Rfwhm, float):
        #print 'Convolving with fwhm %.2f km/s' % Rfwhm
        # use a pixel velocity width 4 times smaller than the FWHM
        ndiv = 4.
        try:
            wa_dv = make_constant_dv_wa_scale(wa[0], wa[-1], Rfwhm / ndiv)
        except:
            import pdb
            pdb.set_trace()
        model_out = convolve_constant_dv(wa, model, wa_dv, ndiv)
        # do the same to every model if there's more than one
        for m in models:
            #if m.min() < (1 - 1e-2):
            m = convolve_constant_dv(wa, m, wa_dv, ndiv)
            models_out.append(m)
    else:
        raise ValueError('Unknown value for Rfwhm option')

    return model_out, models_out
Beispiel #2
0
def process_Rfwhm(Rfwhm, wa, model, models):
    """ Convolve the input models using the Rfwhm option

    Return the new models.

    wa:  wavelength array, shape (N,)
    model: model flux array, shape (N,)
    models: list of model flux arrays each with shape (N,)

    Rfwhm is one of:

      'convolve_with_COS_FOS'
      a float
      an array floats with shape (N,)

    Returns
    -------
    new_model, new_models
    """

    model_out = None
    models_out = []

    #import pdb; pdb.set_trace()
    if Rfwhm is None:
        return model, models

    elif Rfwhm == 'convolve_with_COS_FOS':
        #print 'convolving with COS/FOS instrument profile'
        #import pdb; pdb.set_trace()
        model_out = convolve_with_COS_FOS(model, wa, use_COS_nuv=True)
        for m in models:
            #if m.min() < (1 - 1e-2):
            m = convolve_with_COS_FOS(m, wa, use_COS_nuv=True)
            models_out.append(m)

    elif isinstance(Rfwhm, float):
        #print 'Convolving with fwhm %.2f km/s' % Rfwhm
        # use a pixel velocity width 4 times smaller than the FWHM
        ndiv = 4.
        try:
            wa_dv = make_constant_dv_wa_scale(wa[0], wa[-1], Rfwhm / ndiv)
        except:
            import pdb
            pdb.set_trace()
        model_out = convolve_constant_dv(wa, model, wa_dv, ndiv)
        # do the same to every model if there's more than one
        for m in models:
            #if m.min() < (1 - 1e-2):
            m = convolve_constant_dv(wa, m, wa_dv, ndiv)
            models_out.append(m)
    else:
        raise ValueError('Unknown value for Rfwhm option')

    return model_out, models_out
Beispiel #3
0
def process_Rfwhm(Rfwhm, wa, model, models):
    """ Convolve the input models using the Rfwhm option

    Return the new models.

    wa:  wavelength array, shape (N,)
    model: model flux array, shape (N,)
    models: list of model flux arrays each with shape (N,)

    Rfwm is one of:

      'convolve_with_COS_FOS'
      a float

    Returns
    -------
    new_model, new_models
    """

    model_out = None
    models_out = []

    if Rfwhm is None:
        return model, models

    elif Rfwhm == 'convolve_with_COS_FOS':
        print 'convolving with COS/FOS instrument profile'
        model_out = convolve_with_COS_FOS(model, wa, wa[1] - wa[0])
        models_out = [convolve_with_COS_FOS(m, wa, wa[1] - wa[0]) for m
                      in models]

    elif isinstance(Rfwhm, float):
        print 'Convolving with fwhm %.2f km/s' % Rfwhm
        # use a pixel velocity width 4 times smaller than the FWHM
        ndiv = 4.
        wa_dv = make_constant_dv_wa_scale(wa[0], wa[-1], Rfwhm / ndiv)
        model_out = convolve_constant_dv(wa, model, wa_dv, ndiv)
        # do the same to every model if there's more than one
        for m in models:
            models_out.append(convolve_constant_dv(wa, m, wa_dv, ndiv))
    else:
        raise ValueError('Unknown value for Rfwhm option')

    return model_out, models_out
Beispiel #4
0
                            (240+vzero,400+vzero)],
             'CIII 977': [(-190+vzero,-155+vzero), (0+vzero,400+vzero),],
             'CII 1334': [(0,300)],
             'SiII 1526': [(60,300)],
             'NV 1238': [(90+vzero,200+vzero),(280+vzero, 403+vzero)],
             'OVI 1031': [(-500,-360),(-100, -20),(45,200)],
             'OVI 1037': [(-500,-290), (-100, +45), (70,200)],
             }

cfg = parse_config(config)
transitions = read_transitions(cfg.trfilename, ATOMDAT)

if 1:
    sp = barak.spec.read(cfg.spfilename)
    ndiv = 4.
    wa_dv = make_constant_dv_wa_scale(sp.wa[0], sp.wa[-1], cfg.Rfwhm / ndiv)

    expand_cont_adjustment = 5

    vp = readf26(cfg.f26name)
    lines = vp.lines[vp.lines.name != '<>']
    tau, ticks, alltau = find_tau(sp.wa, lines, ATOMDAT, per_trans=1)
    model = convolve_constant_dv(sp.wa, np.exp(-tau), wa_dv, ndiv)
    models = [convolve_constant_dv(sp.wa, np.exp(-t), wa_dv, ndiv) for t in
              alltau]
    adjust = [l for l in vp.lines if l['name'].strip() == '<>']
    print 'Nadjust', adjust
    if len(adjust) > 0:
        regions = vp.regions
        isort = regions.wmin.argsort()
        print 'Applying continuum adjustments for', len(adjust), 'regions'
Beispiel #5
0
        (0 + vzero, 400 + vzero),
    ],
    'CII 1334': [(0, 300)],
    'SiII 1526': [(60, 300)],
    'NV 1238': [(90 + vzero, 200 + vzero), (280 + vzero, 403 + vzero)],
    'OVI 1031': [(-500, -360), (-100, -20), (45, 200)],
    'OVI 1037': [(-500, -290), (-100, +45), (70, 200)],
}

cfg = parse_config(config)
transitions = read_transitions(cfg.trfilename, ATOMDAT)

if 1:
    sp = barak.spec.read(cfg.spfilename)
    ndiv = 4.
    wa_dv = make_constant_dv_wa_scale(sp.wa[0], sp.wa[-1], cfg.Rfwhm / ndiv)

    expand_cont_adjustment = 5

    vp = readf26(cfg.f26name)
    lines = vp.lines[vp.lines.name != '<>']
    tau, ticks, alltau = find_tau(sp.wa, lines, ATOMDAT, per_trans=1)
    model = convolve_constant_dv(sp.wa, np.exp(-tau), wa_dv, ndiv)
    models = [
        convolve_constant_dv(sp.wa, np.exp(-t), wa_dv, ndiv) for t in alltau
    ]
    adjust = [l for l in vp.lines if l['name'].strip() == '<>']
    print 'Nadjust', adjust
    if len(adjust) > 0:
        regions = vp.regions
        isort = regions.wmin.argsort()