Пример #1
0
def test_read_write_atm_ptqr(tmpdir):
    atmfile = "WASP-00b.atm"
    atm = "{}/{}".format(tmpdir, atmfile)
    nlayers = 11
    pressure = pa.pressure('1e-8 bar', '1e2 bar', nlayers)
    temperature = pa.tmodels.Isothermal(nlayers)(1500.0)
    species = ["H2", "He", "H2O", "CO", "CO2", "CH4"]
    abundances = [0.8496, 0.15, 1e-4, 1e-4, 1e-8, 1e-4]
    qprofiles = pa.uniform(pressure, temperature, species, abundances)
    radius = pa.hydro_g(pressure, temperature, 2.3, 2479.0, pc.bar, pc.rjup)
    io.write_atm(atm,
                 pressure,
                 temperature,
                 species,
                 qprofiles,
                 radius=radius,
                 punits='bar',
                 runits='km',
                 header='# Test write atm\n')
    assert atmfile in os.listdir(str(tmpdir))

    atm_input = io.read_atm(atm)
    assert atm_input[0] == ('bar', 'kelvin', 'volume', 'km')
    np.testing.assert_equal(atm_input[1], np.array(species))
    np.testing.assert_allclose(atm_input[2], pressure / pc.bar)
    np.testing.assert_allclose(atm_input[3], temperature)
    np.testing.assert_allclose(atm_input[4], qprofiles)
    np.testing.assert_allclose(atm_input[5], radius / pc.km, rtol=1e-5)
Пример #2
0
def test_qcapcheck(qcap, qcap_result):
    nlayers = 11
    pressure = pa.pressure(1e-8, 1e2, nlayers, units='bar')
    temperature = np.tile(1500.0, nlayers)
    species = ["H2", "He", "H2O"]
    abundances = [0.8495, 0.15, 5e-4]
    qprofiles = pa.uniform(pressure, temperature, species, abundances)
    ibulk = [0, 1]
    assert pa.qcapcheck(qprofiles, qcap, ibulk) == qcap_result
Пример #3
0
def test_ideal_gas_density():
    nlayers = 11
    pressure = pa.pressure(1e-8, 1e2, nlayers, units='bar')
    temperature = np.tile(1500.0, nlayers)
    species = ["H2", "He", "H2O", "CO", "CO2", "CH4"]
    abundances = [0.8496, 0.15, 1e-4, 1e-4, 1e-8, 1e-4]
    qprofiles = pa.uniform(pressure, temperature, species, abundances)
    dens = pa.ideal_gas_density(qprofiles, pressure, temperature)
    for i, density in enumerate(dens):
        np.testing.assert_allclose(density, expected_dens * 10**i, rtol=1e-7)
Пример #4
0
def test_uniform():
    nlayers = 11
    pressure = pa.pressure(1e-8, 1e2, nlayers, units='bar')
    temperature = np.tile(1500.0, nlayers)
    species = ["H2", "He", "H2O", "CO", "CO2", "CH4"]
    abundances = [0.8496, 0.15, 1e-4, 1e-4, 1e-8, 1e-4]
    qprofiles = pa.uniform(pressure, temperature, species, abundances)
    assert np.shape(qprofiles) == (nlayers, len(species))
    for q in qprofiles:
        np.testing.assert_equal(q, np.array(abundances))
Пример #5
0
import pyratbay.atmosphere as pa

# Reformat TauREx cross section into pyratbay format:
taurex_xs_files = [
    '../inputs/taurex/H2O.R15000.TauREx.pickle',
    '../inputs/taurex/CH4.R15000.TauREx.pickle',
    '../inputs/taurex/CO.R15000.TauREx.pickle',
    '../inputs/taurex/CO2.R15000.TauREx.pickle',
]
for tr_file in taurex_xs_files:
    mol = os.path.basename(tr_file).split('.')[0]
    pb_file = f'../run_setup/taurex_{mol}_opacity_R15000.npz'
    xs, press, temp, wn, specs = io.import_xs(tr_file,
                                              source='taurex',
                                              ofile=pb_file)

# Generate an atmospheric profile at TauREx pressure levels:
T0 = 500.0
nlayers = len(press)
temperature = pa.tmodels.Isothermal(nlayers)(T0)
species = 'H2     He      H2O      CH4      CO       CO2'.split()
abund = [0.853, 0.1467, 1.0e-04, 1.0e-04, 1.0e-04, 1.0e-07]
q = pa.uniform(press, temperature, species, abund)
io.write_atm('taurex.atm',
             press,
             temperature,
             species,
             q,
             header='# TauREx profile\n',
             punits='bar')
wl_exomol = 1.0 / (wn_exomol * pc.um)
xs_H2O = xs_H2O[3::3]
xs_CO = xs_CO[3::3]
xs_CO2 = xs_CO2[3::3]
press_exomol = press_exomol[3::3]

# Create an atmospheric file at same selected pressures:
nlayers = 7
press = pa.pressure('1e-4 bar', '1e2 bar', nlayers)
temp = np.tile(1000.0, nlayers)
species = 'H2    He     H2O   CH4   CO    CO2'.split()
abundances = [0.86, 0.14, 1e-4, 1e-4, 1e-4, 1e-4]
atmfile = 'exomol_opacity_benchmark.atm'

q_atm = pa.uniform(press, temp, species, abundances, atmfile=atmfile)

# :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ipress = 3
itemp = 9

pyrat = pb.run('H2O_spectrum.cfg', run_step='init')
wl_pyrat = 1.0 / (pyrat.spec.wn * pc.um)
ec_H2O = pyrat.get_ec(ipress)[0][0]

pyrat = pb.run('CO_spectrum.cfg', run_step='init')
ec_CO = pyrat.get_ec(ipress)[0][0]

pyrat = pb.run('CO2_spectrum.cfg', run_step='init')
pyrat.iso.ratio[1:] = 1e-30  # Consider only the first isotope
ec_CO2 = pyrat.get_ec(ipress)[0][0]
Пример #7
0
        ax2.set_xticklabels([])
        ax2.set_xticks(ax.get_xticks())
        ax2.set_xlim(ax.get_xlim())


# ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Transmission model with only H2 Rayleigh and CIA opacity:

nlayers = 41
T0 = 1300.0
pressure = pa.pressure('1e-8 bar', '100 bar', nlayers)
temperature = pa.tmodels.Isothermal(nlayers)(T0)

species = 'H2  He  Na  K  H2O  CH4  CO  CO2'.split()
q = [0.85, 0.1492, 3.0e-06, 1.0e-06, 4.0e-04, 1.0e-04, 3.0e-04, 1.0e-07]
Q = pa.uniform(pressure, temperature, species, q)
mu = pa.mean_weight(Q, species)

iH2 = species.index('H2')
iHe = species.index('He')
iH2O = species.index('H2O')
iCO = species.index('CO')
iCH4 = species.index('CH4')
iNa = species.index('Na')
iK = species.index('K')

molecs, mass, diameter = io.read_molecs(
    f'{pc.ROOT}/pyratbay/data/molecules.dat')
H2_mass = mass[molecs == 'H2'][0]
He_mass = mass[molecs == 'He'][0]
H2O_mass = mass[molecs == 'H2O'][0]