def synth_halpha(atmos, dopplerLines=False):
    atmos.convert_scales()
    atmos.quadrature(5)

    Hatom = H_6_doppler if dopplerLines else H_6_atom
    aSet = lw.RadiativeSet([
        Hatom(),
        C_atom(),
        O_atom(),
        Si_atom(),
        Al_atom(),
        CaII_atom(),
        Fe_atom(),
        He_9_atom(),
        MgII_atom(),
        N_atom(),
        Na_atom(),
        S_atom()
    ])
    aSet.set_active('H')
    spect = aSet.compute_wavelength_grid()

    eqPops = aSet.compute_eq_pops(atmos)
    ctx = lw.Context(atmos, spect, eqPops, Nthreads=8)
    iterate_ctx(ctx)
    Iwave = ctx.compute_rays(wave, [1.0], stokes=False)
    return ctx, Iwave
Exemplo n.º 2
0
def synth_8542(atmos, backgroundProvider=None):
    atmos.convert_scales()
    atmos.quadrature(5)
    aSet = lw.RadiativeSet([
        H_6_atom(),
        C_atom(),
        O_atom(),
        Si_atom(),
        Al_atom(),
        CaII_atom(),
        Fe_atom(),
        He_9_atom(),
        MgII_atom(),
        N_atom(),
        Na_atom(),
        S_atom()
    ])
    aSet.set_active('Ca')
    spect = aSet.compute_wavelength_grid()

    eqPops = aSet.compute_eq_pops(atmos)
    ctx = lw.Context(atmos,
                     spect,
                     eqPops,
                     Nthreads=8,
                     backgroundProvider=backgroundProvider)
    iterate_ctx(ctx)
    eqPops.update_lte_atoms_Hmin_pops(atmos)
    Iwave = ctx.compute_rays(wave, [atmos.muz[-1]], stokes=False)
    return ctx, Iwave
Exemplo n.º 3
0
def synth_line(atmos, conserve, useNe=True, prd=False):
    atmos.convert_scales()
    atmos.quadrature(5)
    aSet = lw.RadiativeSet([
        H_6_atom(),
        C_atom(),
        O_atom(),
        Si_atom(),
        Al_atom(),
        CaII_atom(),
        Fe_atom(),
        He_9_atom(),
        MgII_atom(),
        N_atom(),
        Na_atom(),
        S_atom()
    ])
    aSet.set_active('H', 'Ca', 'Mg')
    spect = aSet.compute_wavelength_grid()

    molPaths = [get_default_molecule_path() + m + '.molecule' for m in ['H2']]
    mols = lw.MolecularTable(molPaths)

    if useNe:
        eqPops = aSet.compute_eq_pops(atmos, mols)
    else:
        eqPops = aSet.iterate_lte_ne_eq_pops(atmos, mols)
    ctx = lw.Context(atmos,
                     spect,
                     eqPops,
                     ngOptions=NgOptions(0, 0, 0),
                     hprd=False,
                     conserveCharge=conserve,
                     Nthreads=8)
    ctx.depthData.fill = True
    start = time.time()
    iterate_ctx(ctx, atmos, eqPops, prd=prd, updateLte=False)
    end = time.time()
    print('%.2f s' % (end - start))
    eqPops.update_lte_atoms_Hmin_pops(atmos)
    Iwave = ctx.compute_rays(wave, [atmos.muz[-1]], stokes=False)
    return ctx, Iwave
Exemplo n.º 4
0

fal_sampler = fal_height_upsampler()
coarse = fal_sampler(2, outer=True)
fine = fal_sampler(4)
coarse.quadrature(5)
fine.quadrature(5)
aSet = lw.RadiativeSet([
    H_6_atom(),
    C_atom(),
    O_atom(),
    Si_atom(),
    Al_atom(),
    CaII_atom(),
    Fe_atom(),
    He_9_atom(),
    MgII_atom(),
    N_atom(),
    Na_atom(),
    S_atom()
])
aSet.set_active('Ca')
spect = aSet.compute_wavelength_grid()

coarseEqPops = aSet.compute_eq_pops(coarse)
fineEqPops = aSet.compute_eq_pops(fine)
trueEqPops = aSet.compute_eq_pops(fine)

coarseCtx = lw.Context(coarse,
                       spect,
                       coarseEqPops,
Exemplo n.º 5
0
def synth_8542(atmos, conserve, useNe, wave):
    '''
    Synthesise a spectral line for given atmosphere with different
    conditions.

    Parameters
    ----------
    atmos : lw.Atmosphere
        The atmospheric model in which to synthesise the line.
    conserve : bool
        Whether to start from LTE electron density and conserve charge, or
        simply use from the electron density present in the atomic model.
    useNe : bool
        Whether to use the electron density present in the model as the
        starting solution, or compute the LTE electron density.
    wave : np.ndarray
        Array of wavelengths over which to resynthesise the final line
        profile for muz=1.

    Returns
    -------
    ctx : lw.Context
        The Context object that was used to compute the equilibrium
        populations.
    Iwave : np.ndarray
        The intensity at muz=1 for each wavelength in `wave`.
    '''
    # Configure the atmospheric angular quadrature
    atmos.quadrature(5)
    # Configure the set of atomic models to use.
    aSet = lw.RadiativeSet([
        H_6_atom(),
        C_atom(),
        O_atom(),
        Si_atom(),
        Al_atom(),
        CaII_atom(),
        Fe_atom(),
        He_9_atom(),
        MgII_atom(),
        N_atom(),
        Na_atom(),
        S_atom()
    ])
    # Set H and Ca to "active" i.e. NLTE, everything else participates as an
    # LTE background.
    aSet.set_active('H', 'Ca')
    # Compute the necessary wavelength dependent information (SpectrumConfiguration).
    spect = aSet.compute_wavelength_grid()

    # Either compute the equilibrium populations at the fixed electron density
    # provided in the model, or iterate an LTE electron density and compute the
    # corresponding equilibrium populations (SpeciesStateTable).
    if useNe:
        eqPops = aSet.compute_eq_pops(atmos)
    else:
        eqPops = aSet.iterate_lte_ne_eq_pops(atmos)

    # Configure the Context which holds the state of the simulation for the
    # backend, and provides the python interface to the backend.
    # Feel free to increase Nthreads to increase the number of threads the
    # program will use.
    ctx = lw.Context(atmos, spect, eqPops, conserveCharge=conserve, Nthreads=1)
    start = time.time()
    # Iterate the Context to convergence
    iterate_ctx(ctx)
    end = time.time()
    print('%.2f s' % (end - start))
    # Update the background populations based on the converged solution and
    # compute the final intensity for mu=1 on the provided wavelength grid.
    eqPops.update_lte_atoms_Hmin_pops(atmos)
    Iwave = ctx.compute_rays(wave, [atmos.muz[-1]], stokes=False)
    return ctx, Iwave
Exemplo n.º 6
0
def make_fal_context(velShift=0.0):
    atmos = Falc82()
    atmos.vlos[:] = velShift
    atmos.convert_scales()
    atmos.quadrature(5)
    aSet = lw.RadiativeSet([H_6_atom(), C_atom(), O_atom(), Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_9_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom()])
    aSet.set_active('H', 'Ca')
    spect = aSet.compute_wavelength_grid()

    eqPops = aSet.compute_eq_pops(atmos)

    ctx = lw.Context(atmos, spect, eqPops, ngOptions=NgOptions(0,0,0), Nthreads=1)
    return ctx