petitRADTRANS.retrieval.util

This module contains a set of useful functions that don’t really fit anywhere else. This includes flux conversions, prior functions, mean molecular weight calculations, transforms from mass to number fractions, and fits file output.

Module Contents

Functions

surf_to_meas(flux, p_rad, dist)

surf_to_meas

log_prior(cube, lx1, lx2)

uniform_prior(cube, x1, x2)

gaussian_prior(cube, mu, sigma)

log_gaussian_prior(cube, mu, sigma)

delta_prior(cube, x1, x2)

b_range(x, b)

a_b_range(x, a, b)

getMM(species)

Get the molecular mass of a given species.

calc_MMW(abundances)

calc_MMW

get_MMW_from_mfrac(m_frac)

wraps calc_MMW

get_MMW_from_nfrac(n_frac)

Calculate the mean molecular weight from a number fraction

mass_to_number(m_frac)

Convert mass fractions to number fractions

number_to_mass(n_fracs)

Convert number fractions to mass fractions

fits_output(wavelength, spectrum, covariance, object, output_dir='', correlation=None)

Generate a fits file that can be used as an input to a pRT retrieval.

Attributes

SQRT2

petitRADTRANS.retrieval.util.SQRT2
petitRADTRANS.retrieval.util.surf_to_meas(flux, p_rad, dist)

surf_to_meas Convert from emission flux to measured flux at earth Args:

fluxnumpy.ndarray

Absolute flux value or spectrum as emitted by a source of radius p_rad

p_radfloat

Planet radius, in same units as dist

distfloat

Distance to the object, in the same units as p_rad

Returns:
m_fluxnumpy.ndarray

Apparent flux

petitRADTRANS.retrieval.util.log_prior(cube, lx1, lx2)
petitRADTRANS.retrieval.util.uniform_prior(cube, x1, x2)
petitRADTRANS.retrieval.util.gaussian_prior(cube, mu, sigma)
petitRADTRANS.retrieval.util.log_gaussian_prior(cube, mu, sigma)
petitRADTRANS.retrieval.util.delta_prior(cube, x1, x2)
petitRADTRANS.retrieval.util.b_range(x, b)
petitRADTRANS.retrieval.util.a_b_range(x, a, b)
petitRADTRANS.retrieval.util.getMM(species)

Get the molecular mass of a given species.

This function uses the molmass package to calculate the mass number for the standard isotope of an input species. If all_iso is part of the input, it will return the mean molar mass.

Args:
speciesstring

The chemical formula of the compound. ie C2H2 or H2O

Returns:

The molar mass of the compound in atomic mass units.

petitRADTRANS.retrieval.util.calc_MMW(abundances)

calc_MMW Calculate the mean molecular weight in each layer.

Args:
abundancesdict

dictionary of abundance arrays, each array must have the shape of the pressure array used in pRT, and contain the abundance at each layer in the atmosphere.

petitRADTRANS.retrieval.util.get_MMW_from_mfrac(m_frac)

wraps calc_MMW

petitRADTRANS.retrieval.util.get_MMW_from_nfrac(n_frac)

Calculate the mean molecular weight from a number fraction

Args:
n_fracsdict

A dictionary of number fractions

petitRADTRANS.retrieval.util.mass_to_number(m_frac)

Convert mass fractions to number fractions

Args:
m_fracsdict

A dictionary of mass fractions

petitRADTRANS.retrieval.util.number_to_mass(n_fracs)

Convert number fractions to mass fractions

Args:
n_fracsdict

A dictionary of number fractions

petitRADTRANS.retrieval.util.fits_output(wavelength, spectrum, covariance, object, output_dir='', correlation=None)

Generate a fits file that can be used as an input to a pRT retrieval.

Args:
wavelengthnumpy.ndarray

The wavelength bin centers in micron. dim(N)

spectrumnumpy.ndarray

The flux density in W/m2/micron at each wavelength bin. dim(N)

covariancenumpy.ndarray

The covariance of the flux in (W/m2/micron)^2 dim(N,N)

objectstring

The name of the object, used for file naming.

output_dirstring

The parent directory of the output file.

correlationnumpy.ndarray

The correlation matrix of the flux points (See Brogi & Line 2018, https://arxiv.org/pdf/1811.01681.pdf)

Returns:
hdulastropy.fits.HDUlist

The HDUlist object storing the spectrum.