petitRADTRANS.plotlib
=====================

.. py:module:: petitRADTRANS.plotlib


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/petitRADTRANS/plotlib/plotlib/index
   /autoapi/petitRADTRANS/plotlib/style/index


Attributes
----------

.. autoapisummary::

   petitRADTRANS.plotlib.wavelength_units
   petitRADTRANS.plotlib.wavenumber_units
   petitRADTRANS.plotlib.flux_units


Functions
---------

.. autoapisummary::

   petitRADTRANS.plotlib.contour_corner
   petitRADTRANS.plotlib.plot_cloud_condensation_curves
   petitRADTRANS.plotlib.plot_data
   petitRADTRANS.plotlib.plot_multiple_posteriors
   petitRADTRANS.plotlib.plot_opacity_contributions
   petitRADTRANS.plotlib.plot_planet_context
   petitRADTRANS.plotlib.plot_posterior
   petitRADTRANS.plotlib.plot_radtrans_opacities
   petitRADTRANS.plotlib.plot_result_corner
   petitRADTRANS.plotlib.get_species_color
   petitRADTRANS.plotlib.set_petitradtrans_plot_style
   petitRADTRANS.plotlib.update_figure_font_size


Package Contents
----------------

.. py:function:: contour_corner(sampledict: dict[str, Any], parameter_names: dict[str, list[str]], output_file: str = None, parameter_ranges: dict[str, numpy.typing.NDArray[numpy.floating]] = None, parameter_plot_indices: dict[str, numpy.typing.NDArray[numpy.integer]] = None, true_values: dict[str, numpy.typing.NDArray[numpy.floating]] = 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[numpy.floating] = None, hist_bin_factor: numpy.typing.NDArray[numpy.floating] = 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.axes.Axes = 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, label_kwargs: dict = None, title_kwargs: dict = None, hist_kwargs: dict = None, hist2d_kwargs: dict = None, contour_kwargs: dict = None, **_)

   Use the corner package to plot the posterior distributions produced by pymultinest.
   Args:
       sampledict : dict
           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_names : dict
           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_file : str
           Output file name
       parameter_ranges : dict
           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_indices : dict
           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_values : dict
           A dictionary with keys for each retrieval name as in sampledict. Each value
           contains the known values of the parameters.
       short_name : dict
           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
       quantiles : list
           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_levels :  list
           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).
       legend : bool
           Turn the legend on or off
       prt_plot_style : bool
           Use the prt plotlib style, changes the colour scheme and fonts to match the rest of
           the prt plots.
       plot_best_fit : bool
           Plot the maximum likelihood values as vertical lines for each parameter.
       color_list : list
           List of colours for plotting multiple retrievals.
       bins : int 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_scale : str or iterable (ndim,)
           Scale (``"linear"``, ``"log"``) to use for each data dimension. If only one scale is specified, use that
           for all dimensions.
       weights : array_like[nsamples,]
           The weight of each sample. If `None` (default), samples are given equal weight.
       hist_bin_factor : float 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.
       smooth : float
          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.
       smooth1d : float
          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.
       titles : iterable (ndim,)
           A list of titles for the dimensions. If `None` (default), uses labels as titles.
       show_titles : bool
           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_quantiles : iterable
           A list of 3 fractional quantiles to show as 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_fmt : string
           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_color : str
           A ``matplotlib`` style colour for the ``truths`` makers.
       scale_hist : bool
           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_ticks : bool
           If true, label the top ticks of each axis.
       use_math_text : bool
           If true, then axis tick labels for very large or small exponents will be displayed as powers of 10 rather
           than using `e`.
       reverse : bool
           If true, plot the corner plot starting in the upper-right corner instead of the usual bottom-left corner.
       labelpad : float
           Padding between the axis and the x- and y-labels in units of the fraction of the axis from the lower left.
       plot_contours : bool
           Draw contours for dense regions of the plot.
       kwargs : dict
           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.


.. py:function:: plot_cloud_condensation_curves(metallicities, co_ratios, pressures=None, temperatures=None)

.. py:function:: plot_data(fig, ax, data, resolution=None, scaling=1.0)

.. py:function:: 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)

.. py:function:: 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[numpy.floating] = None, star_radius: float = None, **kwargs) -> dict[str, numpy.typing.NDArray[numpy.floating]]

.. py:function:: 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.


.. py:function:: 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')

.. py:function:: plot_radtrans_opacities(radtrans, species, temperature, pressure_bar, mass_fractions=None, co_ratio=0.55, log10_metallicity=0.0, return_opacities=False, **kwargs)

.. py:function:: 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.
       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.
       smooth : float
          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.


.. py:function:: get_species_color(species, implemented_only=False)

.. py:data:: wavelength_units
   :value: 'cm'


.. py:data:: wavenumber_units
   :value: 'cm$^{-1}$'


.. py:data:: flux_units
   :value: 'erg$\\cdot$s$^{-1}\\cdot$cm${-2}$/cm$^{-1}$'


.. py:function:: set_petitradtrans_plot_style()

.. py:function:: update_figure_font_size(font_size)

   Update the figure font size in a nice way.
   :param font_size: new font size


