Пример #1
0
def test_qscale():
    spec = np.array(["H2", "He", "H2O", "CO", "CO2", "CH4"])
    bulk = np.array(['H2', 'He'])
    molmodel = ['vert', 'scale']
    molfree = ['H2O', 'CO']
    molpars = [-4, 1.0]
    q2 = pa.qscale(q0, spec, molmodel, molfree, molpars, bulk)
    nlayers, nspec = np.shape(q0)
    # All H2O abundances set to constant value:
    np.testing.assert_equal(q2[:, 2], np.tile(10**molpars[0], nlayers))
    # All CO abundances scaled by value:
    np.testing.assert_allclose(q2[:, 3], q0[:, 3] * 10**molpars[1], rtol=1e-7)
Пример #2
0
def ZX(params, pyrat):
    """Compute metals mass fraction relative to solar."""
    q2 = pa.qscale(pyrat.atm.qbase,
                   pyrat.mol.name,
                   pyrat.atm.molmodel,
                   pyrat.atm.molfree,
                   params[pyrat.ret.imol],
                   pyrat.atm.bulk,
                   iscale=pyrat.atm.ifree,
                   ibulk=pyrat.atm.ibulk,
                   bratio=pyrat.atm.bulkratio,
                   invsrat=pyrat.atm.invsrat)[0]
    mu = pa.mean_weight(q2, pyrat.mol.name, mass=pyrat.mol.mass)[0]
    Y = pyrat.mol.mass[iHe] * q2[iHe]
    X = pyrat.mol.mass[iH] * (2 * q2[iH2] + q2[iH] + 2 * q2[iH2O] + q2[iHCN] +
                              4 * q2[iCH4])
    Z = mu - X - Y
    return np.log10(Z / X / (Zsun / Xsun))
Пример #3
0
def ZX(params, pyrat):
    Zsun = 0.0134  # Asplund et al. 2009
    Xsun = 0.7381
    q2 = pa.qscale(pyrat.atm.qbase,
                   pyrat.mol.name,
                   pyrat.atm.molmodel,
                   pyrat.atm.molfree,
                   params[pyrat.ret.imol],
                   pyrat.atm.bulk,
                   iscale=pyrat.atm.ifree,
                   ibulk=pyrat.atm.ibulk,
                   bratio=pyrat.atm.bulkratio,
                   invsrat=pyrat.atm.invsrat)[0]
    mu = pa.mean_weight(q2, pyrat.mol.name, mass=pyrat.mol.mass)[0]
    Y = pyrat.mol.mass[iHe] * q2[iHe]
    X = pyrat.mol.mass[iH] * (2 * q2[iH2] + q2[iH] + 2 * q2[iH2O] + q2[iHCN] +
                              4 * q2[iCH4])
    Z = mu - X - Y
    return np.log10(Z / X / (Zsun / Xsun))
        posterior[:, itemp], pyrat.atm.tmodel,
        pyrat.ret.params[pyrat.ret.itemp], ifree, pyrat.atm.press)

band_wl = 1.0 / (pyrat.obs.bandwn * pc.um)

contrib = np.zeros((nphase, nlayers))
abunds = atm_models[k]['abund']
temps = atm_models[k]['temp']
for i in range(nphase):
    if k != 2 and i > 8:
        continue
    q2 = pa.qscale(pyrat.atm.qbase,
                   pyrat.mol.name,
                   pyrat.atm.molmodel,
                   pyrat.atm.molfree,
                   np.log10(abunds[4 * i]),
                   pyrat.atm.bulk,
                   iscale=pyrat.atm.ifree,
                   ibulk=pyrat.atm.ibulk,
                   bratio=pyrat.atm.bulkratio,
                   invsrat=pyrat.atm.invsrat)
    pyrat.run(temps[4 * i], q2)
    cf = ps.contribution_function(pyrat.od.depth, pyrat.atm.press, pyrat.od.B)
    bcf = ps.band_cf(cf, pyrat.obs.bandtrans, pyrat.spec.wn, pyrat.obs.bandidx)
    bcf = np.sum(bcf, axis=1)
    contrib[i] = bcf / np.amax(bcf)

molecs = 'H2O CO CO2 CH4'.split()
nmol = len(molecs)

ranges = [(-5.5, -1.0), (-12.0, -1.0), (-12.0, -1.0), (-12.0, -1.0)]
nbins = 100
Пример #5
0
npars = np.shape(post)[1]

# Unique posterior values:
utemp, uind, uinv = np.unique(post[:, 0],
                              return_index=True,
                              return_inverse=True)
nunique = np.size(uind)
upost = post[uind]

# Base atmospheric model:
spec, press, t, q = pa.readatm("../run01/uniform_1500K_1xsolar.atm")

# Get mean molecular mass:
mu = np.zeros(nunique, np.double)
for i in np.arange(nunique):
    q2 = pa.qscale(q, spec, upost[i, 2:7], molscale, bulk)
    mu[i] = pa.meanweight(q2, spec)[0]

# Radius in Jupiter radii:
post[:, 1] *= pc.km / pc.rjup

# Move mols one position up:
post[:, 3] = post[:, 4]  # CH4
post[:, 4] = post[:, 5]  # HCN
post[:, 5] = post[:, 6]  # NH3
# Replace with mean molecular weight:
post[:, 6] = mu[uinv]

pname = [
    r"$T$ (K)", "Radius ($R_{\\rm Jup}$)", "$\log_{10}({\\rm H2O})$",
    "$\log_{10}({\\rm CH4})$", "$\log_{10}({\\rm HCN})$",