platon package

Submodules

platon.TP_profile module

class platon.TP_profile.Profile(num_profile_heights=500)[source]

Bases: object

set_from_arrays(P_profile, T_profile)[source]
set_from_opacity(T_irr, info_dict, visible_cutoff=8e-07, T_int=100)[source]
set_from_params_dict(profile_type, params_dict)[source]
set_from_radiative_solution(T_star, Rs, a, Mp, Rp, beta, k_th, gamma, gamma2=None, alpha=1, T_int=100, **ignored_kwargs)[source]
set_isothermal(T_day)[source]
set_parametric(T0, P1, alpha1, alpha2, P3, T3)[source]

platon.abundance_getter module

class platon.abundance_getter.AbundanceGetter(include_condensation=True)[source]

Bases: object

static from_file(filename)[source]

Reads abundances file in the ExoTransmit format (called “EOS” files in ExoTransmit), returning a dictionary mapping species name to an abundance array of dimension

get(logZ, CO_ratio=0.53)[source]

Get an abundance grid at the specified logZ and C/O ratio. This abundance grid can be passed to TransitDepthCalculator, with or without modifications. The end user should not need to call this except in rare cases.

Returns:abundances – A dictionary mapping species name to a 2D abundance array, specifying the number fraction of the species at a certain temperature and pressure.
Return type:dict of np.ndarray
is_in_bounds(logZ, CO_ratio, T)[source]

Check to see if a certain metallicity, C/O ratio, and temperature combination is within the supported bounds

platon.combined_retriever module

class platon.combined_retriever.CombinedRetriever[source]

Bases: object

static get_default_fit_info(Rs, Mp, Rp, T=None, logZ=0, CO_ratio=0.53, log_cloudtop_P=inf, log_scatt_factor=0, scatt_slope=4, error_multiple=1, T_star=None, T_spot=None, spot_cov_frac=None, frac_scale_height=1, log_number_density=-inf, log_part_size=-6, ri=None, profile_type='isothermal', **profile_kwargs)[source]

Get a FitInfo object filled with best guess values. A few parameters are required, but others can be set to default values if you do not want to specify them. All parameters are in SI.

Parameters:
  • Rs (float) – Stellar radius
  • Mp (float) – Planetary mass
  • Rp (float) – Planetary radius
  • T (float) – Temperature of the isothermal planetary atmosphere
  • logZ (float) – Base-10 logarithm of the metallicity, in solar units
  • CO_ratio (float, optional) – C/O atomic ratio in the atmosphere. The solar value is 0.53.
  • log_cloudtop_P (float, optional) – Base-10 log of the pressure level (in Pa) below which light cannot penetrate. Use np.inf for a cloudless atmosphere.
  • log_scatt_factor (float, optional) – Base-10 logarithm of scattering factoring, which make scattering that many times as strong. If scatt_slope is 4, corresponding to Rayleigh scattering, the absorption coefficients are simply multiplied by scattering_factor. If slope is not 4, scattering_factor is defined such that the absorption coefficient is that many times as strong as Rayleigh scattering at the reference wavelength of 1 um.
  • scatt_slope (float, optional) – Wavelength dependence of scattering, with 4 being Rayleigh.
  • error_multiple (float, optional) – All error bars are multiplied by this factor.
  • T_star (float, optional) – Effective temperature of the star. This is used to make wavelength binning of transit depths more accurate.
  • T_spot (float, optional) – Effective temperature of the star spots. This is used to make wavelength dependent correction to the observed transit depths.
  • spot_cov_frac (float, optional) – The spot covering fraction of the star by area. This is used to make wavelength dependent correction to the transit depths.
Returns:

fit_info – This object is used to indicate which parameters to fit for, which to fix, and what values all parameters should take.

Return type:

FitInfo object

pretty_print(fit_info)[source]
run_emcee(transit_bins, transit_depths, transit_errors, eclipse_bins, eclipse_depths, eclipse_errors, fit_info, nwalkers=50, nsteps=1000, include_condensation=True, plot_best=False)[source]

Runs affine-invariant MCMC to retrieve atmospheric parameters.

Parameters:
  • transit_bins (array_like, shape (N,2)) – Wavelength bins, where wavelength_bins[i][0] is the start wavelength and wavelength_bins[i][1] is the end wavelength for bin i.
  • transit_depths (array_like, length N) – Measured transit depths for the specified wavelength bins
  • transit_errors (array_like, length N) – Errors on the aforementioned transit depths
  • eclipse_bins (array_like, shape (N,2)) – Wavelength bins, where wavelength_bins[i][0] is the start wavelength and wavelength_bins[i][1] is the end wavelength for bin i.
  • eclipse_depths (array_like, length N) – Measured eclipse depths for the specified wavelength bins
  • eclipse_errors (array_like, length N) – Errors on the aforementioned eclipse depths
  • fit_info (FitInfo object) – Tells the method what parameters to freely vary, and in what range those parameters can vary. Also sets default values for the fixed parameters.
  • nwalkers (int, optional) – Number of walkers to use
  • nsteps (int, optional) – Number of steps that the walkers should walk for
  • include_condensation (bool, optional) – When determining atmospheric abundances, whether to include condensation.
  • plot_best (bool, optional) – If True, plots the best fit model with the data
Returns:

result – This returns emcee’s EnsembleSampler object. The most useful attributes in this item are result.chain, which is a (W x S X P) array where W is the number of walkers, S is the number of steps, and P is the number of parameters; and result.lnprobability, a (W x S) array of log probabilities. For your convenience, this object also contains result.flatchain, which is a (WS x P) array where WS = W x S is the number of samples; and result.flatlnprobability, an array of length WS

Return type:

EnsembleSampler object

run_multinest(transit_bins, transit_depths, transit_errors, eclipse_bins, eclipse_depths, eclipse_errors, fit_info, include_condensation=True, plot_best=False, **nestle_kwargs)[source]

Runs nested sampling to retrieve atmospheric parameters.

Parameters:
  • transit_bins (array_like, shape (N,2)) – Wavelength bins, where wavelength_bins[i][0] is the start wavelength and wavelength_bins[i][1] is the end wavelength for bin i.
  • transit_depths (array_like, length N) – Measured transit depths for the specified wavelength bins
  • transit_errors (array_like, length N) – Errors on the aforementioned transit depths
  • eclipse_bins (array_like, shape (N,2)) – Wavelength bins, where wavelength_bins[i][0] is the start wavelength and wavelength_bins[i][1] is the end wavelength for bin i.
  • eclipse_depths (array_like, length N) – Measured eclipse depths for the specified wavelength bins
  • eclipse_errors (array_like, length N) – Errors on the aforementioned eclipse depths
  • fit_info (FitInfo object) – Tells us what parameters to freely vary, and in what range those parameters can vary. Also sets default values for the fixed parameters.
  • include_condensation (bool, optional) – When determining atmospheric abundances, whether to include condensation.
  • plot_best (bool, optional) – If True, plots the best fit model with the data
  • **nestle_kwargs (keyword arguments to pass to nestle’s sample method)
Returns:

result – This returns the object returned by nestle.sample The object is dictionary-like and has many useful items. For example, result.samples (or alternatively, result[“samples”]) are the parameter values of each sample, result.weights contains the weights, and result.logl contains the log likelihoods. result.logz is the natural logarithm of the evidence.

Return type:

Result object

platon.constants module

platon.constants.AU = 149597870700.0

Astronomical unit

platon.constants.M_earth = 5.97236e+24

Earth mass

platon.constants.M_jup = 1.89819e+27

Jupiter mass

platon.constants.M_sun = 1.98848e+30

Solar mass

platon.constants.R_earth = 6378100.0

Earth radius

platon.constants.R_jup = 71492000.0

Jupiter radius

platon.constants.R_sun = 695700000.0

Solar radius

platon.eclipse_depth_calculator module

class platon.eclipse_depth_calculator.EclipseDepthCalculator[source]

Bases: object

change_wavelength_bins(bins)[source]
compute_depths(t_p_profile, star_radius, planet_mass, planet_radius, T_star, logZ=0, CO_ratio=0.53, add_gas_absorption=True, add_scattering=True, scattering_factor=1, scattering_slope=4, scattering_ref_wavelength=1e-06, add_collisional_absorption=True, cloudtop_pressure=inf, custom_abundances=None, T_spot=None, spot_cov_frac=None, ri=None, frac_scale_height=1, number_density=0, part_size=1e-06, num_mu=50, min_mu=0.01, max_mu=1, full_output=False)[source]

platon.errors module

exception platon.errors.AtmosphereError[source]

Bases: Exception

platon.fit_info module

class platon.fit_info.FitInfo(guesses_dict)[source]

Bases: object

add_gaussian_fit_param(name, std, low_guess=None, high_guess=None)[source]

Fit for the parameter name using a Gaussian prior with standard deviation std. If using emcee, the walkers’ initial values for this parameter are randomly selected to be between low_guess and high_guess. If low_guess is None, it is set to mean-2*std; if high_guess is None, it is set to mean+2*std.

add_uniform_fit_param(name, low_lim, high_lim, low_guess=None, high_guess=None)[source]

Fit for the parameter name using a uniform prior between low_lim and high_lim. If using emcee, the walkers’ initial values for this parameter are randomly selected to be between low_guess and high_guess. If not specified, low_guess is set to low_lim, and similarly with high_guess.

platon.retriever module

class platon.retriever.Retriever[source]

Bases: object

static get_default_fit_info(Rs, Mp, Rp, T, logZ=0, CO_ratio=0.53, log_cloudtop_P=inf, log_scatt_factor=0, scatt_slope=4, error_multiple=1, T_star=None, T_spot=None, spot_cov_frac=None, frac_scale_height=1, log_number_density=-inf, log_part_size=-6, part_size_std=0.5, ri=None)[source]

Get a FitInfo object filled with best guess values. A few parameters are required, but others can be set to default values if you do not want to specify them. All parameters are in SI. For information on the parameters, see the documentation for compute_depths()

Returns:fit_info – This object is used to indicate which parameters to fit for, which to fix, and what values all parameters should take.
Return type:FitInfo object
run_emcee(wavelength_bins, depths, errors, fit_info, nwalkers=50, nsteps=1000, include_condensation=True, plot_best=False)[source]

Runs affine-invariant MCMC to retrieve atmospheric parameters.

Parameters:
  • wavelength_bins (array_like, shape (N,2)) – Wavelength bins, where wavelength_bins[i][0] is the start wavelength and wavelength_bins[i][1] is the end wavelength for bin i.
  • depths (array_like, length N) – Measured transit depths for the specified wavelength bins
  • errors (array_like, length N) – Errors on the aforementioned transit depths
  • fit_info (FitInfo object) – Tells the method what parameters to freely vary, and in what range those parameters can vary. Also sets default values for the fixed parameters.
  • nwalkers (int, optional) – Number of walkers to use
  • nsteps (int, optional) – Number of steps that the walkers should walk for
  • include_condensation (bool, optional) – When determining atmospheric abundances, whether to include condensation.
  • plot_best (bool, optional) – If True, plots the best fit model with the data
Returns:

result – This returns emcee’s EnsembleSampler object. The most useful attributes in this item are result.chain, which is a (W x S X P) array where W is the number of walkers, S is the number of steps, and P is the number of parameters; and result.lnprobability, a (W x S) array of log probabilities. For your convenience, this object also contains result.flatchain, which is a (WS x P) array where WS = W x S is the number of samples; and result.flatlnprobability, an array of length WS

Return type:

EnsembleSampler object

run_multinest(wavelength_bins, depths, errors, fit_info, include_condensation=True, plot_best=False, **nestle_kwargs)[source]

Runs nested sampling to retrieve atmospheric parameters.

Parameters:
  • wavelength_bins (array_like, shape (N,2)) – Wavelength bins, where wavelength_bins[i][0] is the start wavelength and wavelength_bins[i][1] is the end wavelength for bin i.
  • depths (array_like, length N) – Measured transit depths for the specified wavelength bins
  • errors (array_like, length N) – Errors on the aforementioned transit depths
  • fit_info (FitInfo object) – Tells us what parameters to freely vary, and in what range those parameters can vary. Also sets default values for the fixed parameters.
  • include_condensation (bool, optional) – When determining atmospheric abundances, whether to include condensation.
  • plot_best (bool, optional) – If True, plots the best fit model with the data
  • **nestle_kwargs (keyword arguments to pass to nestle’s sample method)
Returns:

result – This returns the object returned by nestle.sample The object is dictionary-like and has many useful items. For example, result.samples (or alternatively, result[“samples”]) are the parameter values of each sample, result.weights contains the weights, and result.logl contains the log likelihoods. result.logz is the natural logarithm of the evidence.

Return type:

Result object

platon.transit_depth_calculator module

class platon.transit_depth_calculator.TransitDepthCalculator(include_condensation=True, num_profile_heights=250, ref_pressure=100000.0)[source]

Bases: object

__init__(include_condensation=True, num_profile_heights=250, ref_pressure=100000.0)[source]

All physical parameters are in SI.

Parameters:
  • include_condensation (bool) – Whether to use equilibrium abundances that take condensation into account.
  • num_profile_heights (int) – The number of zones the atmosphere is divided into
  • ref_pressure (float) – The planetary radius is defined as the radius at this pressure
change_wavelength_bins(bins)[source]

Specify wavelength bins, instead of using the full wavelength grid in self.lambda_grid. This makes the code much faster, as compute_depths will only compute depths at wavelengths that fall within a bin.

Parameters:bins (array_like, shape (N,2)) – Wavelength bins, where bins[i][0] is the start wavelength and bins[i][1] is the end wavelength for bin i. If bins is None, resets the calculator to its unbinned state.
Raises:NotImplementedError – Raised when change_wavelength_bins is called more than once, which is not supported.
compute_depths(star_radius, planet_mass, planet_radius, temperature, logZ=0, CO_ratio=0.53, add_gas_absorption=True, add_scattering=True, scattering_factor=1, scattering_slope=4, scattering_ref_wavelength=1e-06, add_collisional_absorption=True, cloudtop_pressure=inf, custom_abundances=None, custom_T_profile=None, custom_P_profile=None, T_star=None, T_spot=None, spot_cov_frac=None, ri=None, frac_scale_height=1, number_density=0, part_size=1e-06, part_size_std=0.5, full_output=False, min_abundance=1e-99)[source]

Computes transit depths at a range of wavelengths, assuming an isothermal atmosphere. To choose bins, call change_wavelength_bins().

Parameters:
  • star_radius (float) – Radius of the star
  • planet_mass (float) – Mass of the planet, in kg
  • planet_radius (float) – Radius of the planet at 100,000 Pa. Must be in metres.
  • temperature (float) – Temperature of the isothermal atmosphere, in Kelvin
  • logZ (float) – Base-10 logarithm of the metallicity, in solar units
  • CO_ratio (float, optional) – C/O atomic ratio in the atmosphere. The solar value is 0.53.
  • add_gas_absorption (float, optional) – Whether gas absorption is accounted for
  • add_scattering (bool, optional) – whether Rayleigh scattering is taken into account
  • scattering_factor (float, optional) – if add_scattering is True, make scattering this many times as strong. If scattering_slope is 4, corresponding to Rayleigh scattering, the absorption coefficients are simply multiplied by scattering_factor. If slope is not 4, scattering_factor is defined such that the absorption coefficient is that many times as strong as Rayleigh scattering at scattering_ref_wavelength.
  • scattering_slope (float, optional) – Wavelength dependence of scattering, with 4 being Rayleigh.
  • scattering_ref_wavelength (float, optional) – Scattering is scattering_factor as strong as Rayleigh at this wavelength, expressed in metres.
  • add_collisional_absorption (float, optional) – Whether collisionally induced absorption is taken into account
  • cloudtop_pressure (float, optional) – Pressure level (in Pa) below which light cannot penetrate. Use np.inf for a cloudless atmosphere.
  • custom_abundances (str or dict of np.ndarray, optional) – If specified, overrides logZ and CO_ratio. Can specify a filename, in which case the abundances are read from a file in the format of the EOS/ files. These are identical to ExoTransmit’s EOS files. It is also possible, though highly discouraged, to specify a dictionary mapping species names to numpy arrays, so that custom_abundances[‘Na’][3,4] would mean the fractional number abundance of Na at a temperature of self.T_grid[3] and pressure of self.P_grid[4].
  • custom_T_profile (array-like, optional) – If specified and custom_P_profile is also specified, divides the atmosphere into user-specified P/T points, instead of assuming an isothermal atmosphere with T = temperature.
  • custom_P_profile (array-like, optional) – Must be specified along with custom_T_profile to use a custom P/T profile. Pressures must be in Pa.
  • T_star (float, optional) – Effective temperature of the star. If you specify this and use wavelength binning, the wavelength binning becomes more accurate.
  • T_spot (float, optional) – Effective temperature of the star spots. This can be used to make wavelength dependent correction to the observed transit depths.
  • spot_cov_frac (float, optional) – The spot covering fraction of the star by area. This can be used to make wavelength dependent correction to the transit depths.
  • ri (complex, optional) – Complex refractive index n - ik (where k > 0) of the particles responsible for Mie scattering. If provided, Mie scattering will be computed. In that case, scattering_factor and scattering_slope must be set to 1 and 4 (the default values) respectively.
  • frac_scale_height (float, optional) – The number density of Mie scattering particles is proportional to P^(1/frac_scale_height). This is similar to, but a bit different from, saying that the scale height of the particles is frac_scale_height times that of the gas.
  • number_density (float, optional) – The number density (in m^-3) of Mie scattering particles
  • part_size (float, optional) – The mean radius of Mie scattering particles. The distribution is assumed to be log-normal, with a standard deviation of part_size_std
  • part_size_std (float, optional) – The geometric standard deviation of particle radii. We recommend leaving this at the default value of 0.5.
  • full_output (bool, optional) – If True, returns info_dict as a third return value.
Raises:

ValueError – Raised when invalid parameters are passed to the method

Returns:

  • wavelengths (array of float) – Central wavelengths, in metres
  • transit_depths (array of float) – Transit depths at wavelengths
  • info_dict (dict) – Returned if full_output is True, containing intermediate quantities calculated by the method. These are: absorption_coeff_atm, tau_los, stellar_spectrum, radii, P_profile, T_profile, mu_profile, atm_abundances, unbinned_depths, unbinned_wavelengths

platon.visualizer module

class platon.visualizer.Visualizer(size=1000)[source]

Bases: object

draw(transit_info, color_bins, star_color=[1, 1, 1], method='disk', star_radius=None, star_margin=0.5, max_dist=None, blur_std=1)[source]

Draws an image of a transiting exoplanet.

Parameters:
  • transit_info (dict) – the dictionary returned by compute_depths in TransitDepthCalculator when full_output = True
  • color_bins (array-like, shape (3,2)) – Wavelength bins to use for the R, G, B channels. For example, if color_bins[0] is [3e-6, 4e-6], the red channel will reflect all light transmitted through the atmosphere between 3 and 4 microns.
  • star_color (array-like, length 3, optional) – R, G, B values of the star light, with [1,1,1] being white
  • method (str, optional) – Either ‘disk’ to draw the entire planetary disk with atmosphere, or ‘layers’ to draw a 1D atmospheric profile–essentially an extreme zoom-in on the disk.
  • star_radius (float, optional) – Stellar radius, in meters. If given, the stellar limb will be drawn
  • star_margin (float, optional) – Distance from left side of canvas to stellar limb is star_margin * max_dist
  • max_dist (float, optional) – Maximum distance from planet center to draw, in meters
  • blur_std (float, optional) – STD of Gaussian blur to apply, in pixels
Returns:

canvas – The image of the planet. Can be displayed with plt.imshow()

Return type:

array, shape (self.size, self.size, 3)

Module contents