petitRADTRANS.plotlib.plotlib#

Functions#

_corner_wrap(data_list, title_kwargs, labels_list, ...)

_get_parameter_range(sample_dict, retrieved_parameters)

_prepare_multiple_retrievals_plot(result_directory, ...)

contour_corner(sampledict, parameter_names[, ...])

Use the corner package to plot the posterior distributions produced by pymultinest.

nice_corner(samples, parameter_names, output_file[, ...])

Paul's custom hex grid corner plots.

plot_cloud_condensation_curves(metallicities, co_ratios)

plot_data(fig, ax, data[, resolution, scaling])

plot_multiple_posteriors(result_directory, ...[, ...])

plot_opacity_contributions(radtrans_object, mode[, ...])

plot_planet_context(, figure_font_size, ...)

Plot an exoplanet mass-radius scatter plot highlighting a planet using the NASA Exoplanet Archive.

plot_posterior(data[, label, true_value, cmp, bins, ...])

plot_radtrans_opacities(radtrans, species, ...[, ...])

plot_result_corner(retrieval_directory, ...[, ...])

Plot the posteriors of one or multiple retrievals in the same corner plot.

Module Contents#

petitRADTRANS.plotlib.plotlib._corner_wrap(data_list, title_kwargs, labels_list, label_kwargs, range_list, color_list, truths_list, contour_kwargs, hist_kwargs, bins=20, axes_scale='linear', weights=None, hist_bin_factor: numpy.typing.NDArray[float] = 1.0, smooth=None, smooth1d=None, titles=None, show_titles=True, title_quantiles=None, title_fmt=None, truth_color='r', scale_hist=False, quantiles=None, fig=None, max_n_ticks=5, top_ticks=False, use_math_text=False, reverse=False, labelpad=0.0, plot_contours=True, hist2d_levels=None, **hist2d_kwargs)#
petitRADTRANS.plotlib.plotlib._get_parameter_range(sample_dict, retrieved_parameters, spectral_model=None)#
petitRADTRANS.plotlib.plotlib._prepare_multiple_retrievals_plot(result_directory, retrieved_parameters, true_values, retrieval_name=None, spectral_model=None)#
petitRADTRANS.plotlib.plotlib.contour_corner(sampledict: dict, parameter_names: dict[str, list[str]], output_file: str = None, parameter_ranges: dict[str, numpy.typing.NDArray[float]] = None, parameter_plot_indices: dict[str, numpy.typing.NDArray[int]] = None, true_values: dict[str, numpy.typing.NDArray[float]] = None, short_name: dict[str, str] = None, quantiles: list[float] = None, hist2d_levels: list[float] = None, legend: bool = False, prt_plot_style: bool = True, plot_best_fit: bool = False, color_list: list[str] = None, bins: int = 20, axes_scale: str = 'linear', weights: numpy.typing.NDArray[float] = None, hist_bin_factor: numpy.typing.NDArray[float] = 1.0, smooth: float = None, smooth1d: float = None, titles: list = None, show_titles: bool = True, title_quantiles: list[float] = None, title_fmt: str = '.2f', truth_color: str = 'r', scale_hist: bool = False, fig: matplotlib.figure = None, max_n_ticks: int = 5, top_ticks: bool = False, use_math_text: bool = False, reverse: bool = False, labelpad: float = 0.0, plot_contours: bool = True, **kwargs)#

Use the corner package to plot the posterior distributions produced by pymultinest.

Args:
sampledictdict

A dictionary of samples, each sample has shape (N_Samples,N_params). The keys of the dictionary correspond to the names of each retrieval, and are the prefixes to the post_equal_weights.dat files. These are passed as arguments to retrieve.py. By default, this is only the current retrieval, and plots the posteriors for a single retrieval. If multiple names are passed, they are overplotted on the same figure.

parameter_namesdict

A dictionary with keys for each retrieval name, as in sampledict. Each value of the dictionary is the names of the parameters to be plotted, as set in the run_definition file.

output_filestr

Output file name

parameter_rangesdict

A dictionary with keys for each retrieval name as in sampledict. Each value contains the ranges of parameters that have a range set with corner_range in the parameter class. Otherwise, the range is +/- 4 sigma

parameter_plot_indicesdict

A dictionary with keys for each retrieval name as in sampledict. Each value contains the indices of the sample to plotlib, as set by the plot_in_corner parameter of the parameter class

true_valuesdict

A dictionary with keys for each retrieval name as in sampledict. Each value contains the known values of the parameters.

short_namedict

A dictionary with keys for each retrieval name as in sampledict. Each value contains the names to be plotted in the corner plotlib legend. If non, uses the retrieval names used as keys for sampledict

quantileslist

A list with the quantiles to plotlib over the 1D histograms. Note: the conversion from sigma to quantile is:

quantile_m = (1 - erf(sigma / sqrt(2))) / 2 quantile_p = 1 - quantile_m

hist2d_levelslist

A list with the sigmas-level to plotlib over the 2D histograms. The sigmas are converted into their corresponding level-value following the formula for 2D normal distribution (see https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4358977/pdf/pone.0118537.pdf).

legendbool

Turn the legend on or off

prt_plot_stylebool

Use the prt plotlib style, changes the colour scheme and fonts to match the rest of the prt plots.

plot_best_fitbool

Plot the maximum likelihood values as vertical lines for each parameter.

color_listlist

List of colours for plotting multiple retrievals.

binsint or array_like[ndim,]

The number of bins to use in histograms, either as a fixed value for all dimensions, or as a list of integers for each dimension.

axes_scalestr or iterable (ndim,)

Scale ("linear", "log") to use for each data dimension. If only one scale is specified, use that for all dimensions.

weightsarray_like[nsamples,]

The weight of each sample. If None (default), samples are given equal weight.

hist_bin_factorfloat or array_like[ndim,]

This is a factor (or list of factors, one for each dimension) that will multiply the bin specifications when making the 1-D histograms. This is generally used to increase the number of bins in the 1-D plots to provide more resolution.

smoothfloat

The standard deviation for Gaussian kernel passed to scipy.ndimage.gaussian_filter` to smooth the 2-D histogram. If None (default), no smoothing is applied.

smooth1dfloat

The standard deviation for Gaussian kernel passed to scipy.ndimage.gaussian_filter to smooth the 1-D histogram. If None (default), no smoothing is applied.

titlesiterable (ndim,)

A list of titles for the dimensions. If None (default), uses labels as titles.

show_titlesbool

Displays a title above each 1-D histogram showing the 0.5 quantile with the upper and lower errors supplied by the quantiles argument.

title_quantilesiterable

A list of 3 fractional quantiles to show as the the upper and lower errors. If None (default), inherit the values from quantiles, unless quantiles is None, in which case it defaults to [0.16, 0.5, 0.84].

title_fmtstring

The format string for the quantiles given in titles. If you explicitly set show_titles=True and title_fmt=None, the labels will be shown as the titles. (default: .2f).

truth_colorstr

A matplotlib style color for the truths makers.

scale_histbool

Should the 1-D histograms be scaled in such a way that the zero line is visible?

fig~matplotlib.figure.Figure

Overplot onto the provided figure object, which must either have no axes yet, or ndim * ndim axes already present. If not set, the plot will be drawn on a newly created figure.

max_n_ticks: int

Maximum number of ticks to try to use.

top_ticksbool

If true, label the top ticks of each axis.

use_math_textbool

If true, then axis tick labels for very large or small exponents will be displayed as powers of 10 rather than using e.

reversebool

If true, plot the corner plot starting in the upper-right corner instead of the usual bottom-left corner.

labelpadfloat

Padding between the axis and the x- and y-labels in units of the fraction of the axis from the lower left.

plot_contoursbool

Draw contours for dense regions of the plot.

kwargsdict

Each kwarg can be one of the kwargs used in corner.corner. These can be used to adjust the title_kwargs,label_kwargs,hist_kwargs, hist2d_kwargs or the contour kwargs. Each kwarg must be a dictionary with the arguments as keys and values as the values.

petitRADTRANS.plotlib.plotlib.nice_corner(samples, parameter_names, output_file, n_samples=None, parameter_ranges=None, parameter_plot_indices=None, true_values=None, max_val_ratio=None)#

Paul’s custom hex grid corner plots. Won’t work with sampledict setup in retrieve.py!

petitRADTRANS.plotlib.plotlib.plot_cloud_condensation_curves(metallicities, co_ratios, pressures=None, temperatures=None)#
petitRADTRANS.plotlib.plotlib.plot_data(fig, ax, data, resolution=None, scaling=1.0)#
petitRADTRANS.plotlib.plotlib.plot_multiple_posteriors(result_directory, retrieved_parameters, log_evidences=None, true_values=None, add_rectangle=None, parameter_names_ref=None, bins=15, color='C0', figure_font_size=11, use_titles=True, save=False, figure_directory='./', figure_name='fig', image_format='png', fig_size=19.2)#
petitRADTRANS.plotlib.plotlib.plot_opacity_contributions(radtrans_object: petitRADTRANS.radtrans.Radtrans, mode: str, include: list = 'all', exclude: list = None, opacity_contributions: dict = None, colors: dict = None, line_styles: dict = None, fill_below: bool = False, fill_alpha: float = 0.5, x_axis_scale: str = 'linear', y_axis_scale: str = 'linear', fig_size: tuple = (12.8, 4.8), opaque_cloud_top_pressure: float = None, power_law_opacity_350nm: float = None, power_law_opacity_coefficient: float = None, gray_opacity: float = None, cloud_photosphere_median_optical_depth: float = None, additional_absorption_opacities_function: callable = None, additional_scattering_opacities_function: callable = None, stellar_intensities: numpy.typing.NDArray[float] = None, star_radius: float = None, **kwargs)#
petitRADTRANS.plotlib.plotlib.plot_planet_context(planet_name: str, mass_radius_uncertainty_tolerance: float = 0.15, fig_size: tuple[float, float] = (6.4, 5.6), figure_font_size: float = 12, plot_annotations: bool = True, plot_planet_references: bool = True, tight_layout: bool = True, save: bool = False, figure_directory: str = './', figure_name: str = 'result_corner', image_format: str = 'png') None#

Plot an exoplanet mass-radius scatter plot highlighting a planet using the NASA Exoplanet Archive.

Args:
planet_name:

Name of the planet to highlight.

mass_radius_uncertainty_tolerance:

Plot only planets with a maximum relative mass and radius uncertainty lower to this value.

fig_size:

Size of the figure.

figure_font_size:

Base size of the figure font.

plot_annotations:

If True, plot the mass limits between rocky planets, sub-neptunes, ice giants and gas giants.

plot_planet_references:

If True, place Earth, Neptune and Jupiter on the scatter plot.

tight_layout:

If True, apply tight layout on the figure.

save:

If True, save the figure.

figure_directory:

Directory in which to save the figure.

figure_name:

Name of the figure.

image_format:

Image format of the saved figure.

petitRADTRANS.plotlib.plotlib.plot_posterior(data, label=None, true_value=None, cmp=None, bins=15, color='C0', axe=None, y_max=None, y_label=None, tight_layout=True, fmt='.2f')#
petitRADTRANS.plotlib.plotlib.plot_radtrans_opacities(radtrans, species, temperature, pressure_bar, mass_fractions=None, co_ratio=0.55, log10_metallicity=0.0, return_opacities=False, **kwargs)#
petitRADTRANS.plotlib.plotlib.plot_result_corner(retrieval_directory: str, retrieved_parameters: dict, retrieval_name=None, true_values: dict[str, float] = None, spectral_model: petitRADTRANS.spectral_model.SpectralModel = None, smooth: float = 1.0, figure_font_size: float = 8, save: bool = True, figure_directory: str = './', figure_name: str = 'result_corner', image_format: str = 'png', **kwargs)#

Plot the posteriors of one or multiple retrievals in the same corner plot.

Args:
retrieval_directory:

String or list of string containing the retrieval directories.

retrieved_parameters:

Dictionary containing all the retrieved parameters and their prior. # TODO retrieved parameters should be automatically stored in retrievals

retrieval_name:

Name of the retrieval. If None, the name is extracted from the retrieval directory.

true_values:

True values for the parameters.

spectral_model:

SpectralModel used to make the retrievals.

smoothfloat

The standard deviation for Gaussian kernel passed to scipy.ndimage.gaussian_filter` to smooth the 2-D histogram. If None (default), no smoothing is applied.

figure_font_size:

Size of the font in the figure.

save:

If True, save the figure.

figure_directory:

Directory to save the figure.

figure_name:

Name of the figure.

image_format:

Format (extension) of the figure.

**kwargs:

contour_corner keyword arguments.