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

freq_to_micron(frequency)

fnu_to_flambda(wlen, spectrum)

spectrum_cgs_to_si(frequency, spectrum)

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)

inverse_gamma_prior(cube, a, b)

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

teff_calc(waves, model[, dist, r_pl])

This function takes in the wavelengths and flux of a model

bin_species_exok(species, resolution)

This function uses exo-k to bin the c-k table of a

compute_gravity(parameters)

set_resolution(lines, abundances, resolution)

deprecated

fixed_length_amr(p_clouds, pressures[, scaling, width])

This function takes in the cloud base pressures for each cloud,

fits_output(wavelength, spectrum, covariance, object)

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.freq_to_micron(frequency)
petitRADTRANS.retrieval.util.fnu_to_flambda(wlen, spectrum)
petitRADTRANS.retrieval.util.spectrum_cgs_to_si(frequency, spectrum)
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.inverse_gamma_prior(cube, a, b)
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_fracdict

A dictionary of number fractions

petitRADTRANS.retrieval.util.mass_to_number(m_frac)

Convert mass fractions to number fractions

Args:
m_fracdict

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.teff_calc(waves, model, dist=1.0, r_pl=1.0)

This function takes in the wavelengths and flux of a model in units of W/m2/micron and calculates the effective temperature by integrating the model and using the stefan boltzmann law. Args:

wavesnumpy.ndarray

Wavelength grid in units of micron

modelnumpy.ndarray

Flux density grid in units of W/m2/micron

distOptional(float)

Distance to the object. Must have same units as r_pl

r_plOptional(float)

Object radius. Must have same units as dist

petitRADTRANS.retrieval.util.bin_species_exok(species, resolution)

This function uses exo-k to bin the c-k table of a single species to a desired (lower) spectral resolution.

Args:
speciesstring

The name of the species

resolutionint

The desired spectral resolving power.

petitRADTRANS.retrieval.util.compute_gravity(parameters)
petitRADTRANS.retrieval.util.set_resolution(lines, abundances, resolution)

deprecated

petitRADTRANS.retrieval.util.fixed_length_amr(p_clouds, pressures, scaling=10, width=3)

This function takes in the cloud base pressures for each cloud, and returns an array of pressures with a high resolution mesh in the region where the clouds are located.

Author: Francois Rozet.

The output length is always

len(pressures[::scaling]) + len(p_clouds) * width * (scaling - 1)

Args:
P_cloudsnumpy.ndarray

The cloud base pressures in bar

pressnp.ndarray

The high resolution pressure array.

scalingint

The factor by which the low resolution pressure array is scaled

widthint

The number of low resolution bins to be replaced for each cloud layer.

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.