POSEIDON.visuals
Plotting routines to visualise POSEIDON output.
Module Contents
Functions
|
Scale the lightness of a colour by the given factor. |
|
Subfunction used by the 'plot_geometry' function below. This function plots |
|
Plots two 2D slice plots through the planetary atmosphere (to scale), |
|
|
|
Plot the pressure-temperature (P-T) profiles defining the atmosphere. |
|
Plot the mixing ratio profiles defining the atmosphere. |
|
Calculates default x axis tick spacing for spectra plots in POSEIDON. |
|
Plot a collection of individual model spectra. This function can plot |
|
Plot a collection of datasets. This function can plot transmission or |
|
Plot a collection of individual model spectra. This function can plot |
|
Plot retrieved Pressure-Temperature (P-T) profiles. |
|
Plot retrieved mixing ratio profiles. |
|
Straightforward function to plot an emergent stellar spectrum. |
|
|
|
|
|
|
|
Plot a set of histograms from one or more retrievals. |
|
Helper function. |
|
Attributes
- POSEIDON.visuals.linestyles
- POSEIDON.visuals.scale_lightness(colour_name, scale)
Scale the lightness of a colour by the given factor.
- Parameters:
colour_name (str) – The name of the colour to be scaled, in matplotlib colour format.
scale (float) – The factor by which to scale the lightness of the colour (< 1 makes the colour darker).
- Returns:
A tuple containing the RGB values of the scaled colour.
- Return type:
tuple
- POSEIDON.visuals.plot_transit(ax, R_p, R_s, b_p, r, T, phi, phi_edge, theta, theta_edge, perspective, y_p=0.0, plot_labels=True, show_star=False, annotate_Rp=False, back_colour='white')
Subfunction used by the ‘plot_geometry’ function below. This function plots a 2D slice through an exoplanet and its atmosphere (to scale) from various observer perspectives.
- Parameters:
ax (matplotlib axis object) – A matplotlib axis instance.
R_p (float) – White light planetary radius.
r (3D np.array of float) – Radial distance profile (m).
T (3D np.array of float) – Temperature profile (K).
phi (np.array of float) – Mid-sector angles (radians).
phi_edge (np.array of float) – Boundary angles for each sector (radians).
dphi (np.array of float) – Angular width of each sector (radians).
theta (np.array of float) – Mid-zone angles (radians).
theta_edge (np.array of float) – Boundary angles for each zone (radians).
dtheta (np.array of float) – Angular width of each zone (radians).
perspective (str) – Observer viewing perspective for 2D slice. (Options: terminator / day-night).
y_p (float) – Projected coordinate of planet centre from observer perspective
plot_labels (bool) – If False, removes text labels from the plot.
show_star (bool) – If True, plots the star in the background from observer perspective
annotate_Rp (bool) – If True, adds an arrow to the terminator perspective plot showing the radius of the planet (works best when show_star = True).
back_colour (str) – Background colour of figure.
- Returns:
Patch collection containing atmosphere slices and temperature colour bar. The figure itself is written to the provided axis.
- Return type:
p (matplotlib PatchCollection)
- POSEIDON.visuals.plot_geometry(planet, star, model, atmosphere, plot_labels=True)
Plots two 2D slice plots through the planetary atmosphere (to scale), coloured according to the temperature field. The left panel corresponds to a slice through the terminator plane, while the right panel is a slice through the north pole - observer plane.
- Parameters:
planet (dict) – POSEIDON planet properties dictionary.
star (dict) – POSEIDON stellar properties dictionary (currently unused).
model (dict) – POSEIDON model properties dictionary.
atmosphere (dict) – POSEIDON atmospheric properties dictionary.
plot_labels (bool) – If False, removes text labels from the plot.
- Returns:
The geometric slice plot.
- Return type:
fig (matplotlib figure object)
- POSEIDON.visuals.plot_geometry_spectrum_mixed(planet, star, model, atmosphere, spectra, y_p=0.0, plot_labels=False, show_star=True, annotate_Rp=True, back_colour='black', data_properties=None, show_data=False, plot_full_res=True, bin_spectra=True, R_to_bin=100, wl_min=None, wl_max=None, y_min=None, y_max=None, y_unit='transit_depth', plt_label=None, colour_list=[], spectra_labels=[], data_colour_list=[], data_labels=[], data_marker_list=[], data_marker_size_list=[], wl_axis='log', figure_shape='default', legend_location='upper right', legend_box=True)
- POSEIDON.visuals.plot_PT(planet, model, atmosphere, show_profiles=[], PT_label=None, log_P_min=None, log_P_max=None, T_min=None, T_max=None, colour='darkblue', legend_location='lower left', ax=None)
Plot the pressure-temperature (P-T) profiles defining the atmosphere.
- Parameters:
planet (dict) – POSEIDON planet properties dictionary.
model (dict) – POSEIDON model properties dictionary.
atmosphere (dict) – Dictionary containing atmospheric properties.
show_profiles (list, optional) –
List of profiles to plot. Default is an empty list. For a 1D model, a single P-T profile is plotted. For 2D or 3D models, the user can specify the regions for which the P-T profiles should be plotted. This is handled through ‘show_profiles’. Valid choices for 2D and 3D models:
2D Day-Night: [‘day’, ‘night’, ‘terminator’] 2D Evening-Morning: [‘morning’, ‘evening’, ‘average’] 3D: [‘evening-day’, ‘evening-night’, ‘evening-terminator’,
’morning-day’, ‘morning-night’, ‘morning-terminator’, ‘terminator-average’]
- Any subset of the above can be passed via ‘show_profiles’.
PT_label (str, optional):
- Label for the P-T profile.
log_P_min (float, optional):
- Minimum value for the log10 pressure.
log_P_max (float, optional):
- Maximum value for the log10 pressure.
T_min (float, optional):
- Minimum temperature to plot.
T_max (float, optional):
- Maximum temperature to plot.
colour (str, optional):
- Colour of the plotted P-T profile.
legend_location (str, optional):
Location of the legend. Default is ‘lower left’.
ax (matplotlib axis object, optional) – Matplotlib axis provided externally.
- Return type:
fig (matplotlib figure object)
The P-T profile plot.
- POSEIDON.visuals.plot_chem(planet, model, atmosphere, plot_species=[], colour_list=[], show_profiles=[], log_X_min=None, log_X_max=None, log_P_min=None, log_P_max=None, legend_title=None, legend_location='upper right')
Plot the mixing ratio profiles defining the atmosphere.
The user specifies which chemical species to plot via the list ‘plot_species’. The colours used for each species can be specified by the user via ‘colour_list’, or else default colours will be used. This function supports plotting up to 8 chemical species.
- Parameters:
planet (dict) – Dictionary containing planet properties.
model (dict) – Dictionary containing model properties.
atmosphere (dict) – Dictionary containing atmospheric properties.
plot_species (list, optional) – List of chemical species to plot. If not specified, default to all chemical species in the model (including bulk species).
colour_list (list, optional) – List of colours to use for each species in plot_species. Default is a predefined list, if the user doesn’t provide one.
show_profiles (list, optional) –
List of chemical profiles to plot. Default is an empty list. For a 1D model, a single P-T profile is plotted. For 2D or 3D models, the user can specify the regions for which the P-T profiles should be plotted. This is handled through ‘show_profiles’. Valid choices for 2D and 3D models:
2D Day-Night: [‘day’, ‘night’, ‘terminator’] 2D Evening-Morning: [‘morning’, ‘evening’, ‘average’] 3D: [‘evening-day’, ‘evening-night’, ‘evening-terminator’,
’morning-day’, ‘morning-night’, ‘morning-terminator’, ‘terminator-average’]
Any subset of the above can be passed via ‘show_profiles’.
log_X_min (float, optional) – Minimum log10 mixing ratio to plot. If not specified, the range is calculated automatically.
log_X_max (float, optional) – Minimum log10 mixing ratio to plot. If not specified, the range is calculated automatically.
log_P_min (float, optional) – Minimum log10 pressure to plot. If not specified, the range is calculated automatically.
log_P_max (float, optional) – Minimum log10 pressure to plot. If not specified, the range is calculated automatically.
legend_title (str, optional) – Title for the legend. Defaults to the model name if not provided.
legend_location (str, optional) – Location of the legend. Default is ‘upper right’.
Returns –
- fig (matplotlib figure object):
Chemical mixing ratio plot.
- POSEIDON.visuals.set_spectrum_wl_ticks(wl_min, wl_max, wl_axis='log')
Calculates default x axis tick spacing for spectra plots in POSEIDON.
- Parameters:
wl_min (float) – The minimum wavelength to plot.
wl_max (float) – The maximum wavelength to plot.
wl_axis (str, optional) – The type of x-axis to use (‘log’ or ‘linear’).
- Returns:
The x axis tick values for the given wavelength range.
- Return type:
np.array
- POSEIDON.visuals.plot_spectra(spectra, planet, data_properties=None, show_data=False, plot_full_res=True, bin_spectra=True, R_to_bin=100, wl_min=None, wl_max=None, y_min=None, y_max=None, y_unit='transit_depth', plt_label=None, colour_list=[], spectra_labels=[], data_colour_list=[], data_labels=[], data_marker_list=[], data_marker_size_list=[], text_annotations=[], annotation_pos=[], wl_axis='log', figure_shape='default', legend_location='upper right', legend_box=True, ax=None, save_fig=True)
Plot a collection of individual model spectra. This function can plot transmission or emission spectra, according to the user’s choice of ‘y_unit’.
- Parameters:
spectra (list of tuples) – A list of model spectra to be plotted, each with the format (wl, spectrum).
planet (dict) – POSEIDON planet properties dictionary.
data_properties (dict, optional) – POSEIDON observational data properties dictionary.
show_data (bool, optional) – Flag indicating whether to plot the observational data.
plot_full_res (bool, optional) – Flag indicating whether to plot full resolution model spectra.
bin_spectra (bool, optional) – Flag indicating whether to bin model spectra to the resolution specified by ‘R_to_bin’.
R_to_bin (int, optional) – Spectral resolution (R = wl/dwl) to bin the model spectra to.
wl_min (float, optional) – The minimum wavelength to plot.
wl_max (float, optional) – The maximum wavelength to plot.
y_min (float, optional) – The minimum value for the y-axis.
y_max (float, optional) – The maximum value for the y-axis.
y_unit (str, optional) – The unit of the y-axis (Options: ‘transit_depth’, ‘eclipse_depth’, ‘(Rp/Rs)^2’, ‘(Rp/R*)^2’, ‘Fp/Fs’, ‘Fp/F*’, ‘Fp’).
plt_label (str, optional) – The label for the plot.
colour_list (list, optional) – A list of colours for the model spectra.
spectra_labels (list, optional) – A list of labels for the model spectra.
data_colour_list (list, optional) – A list of colours for the observational data points.
data_labels (list, optional) – A list of labels for the observational data.
data_marker_list (list, optional) – A list of marker styles for the observational data.
data_marker_size_list (list, optional) – A list of marker sizes for the observational data.
text_annotations (list of str, optional) – A list of text annotations for Figure decoration (e.g. molecule names)
annotation_pos (list of tuples of str, optional) – (x, y) locations of the text annotations in the previous argument.
wl_axis (str, optional) – The type of x-axis to use (‘log’ or ‘linear’).
figure_shape (str, optional) – The shape of the figure (‘default’ or ‘wide’ - the latter is 16:9).
legend_location (str, optional) – The location of the legend (‘upper left’, ‘upper right’, ‘lower left’, ‘lower right’).
legend_box (bool, optional) – Flag indicating whether to plot a box surrounding the figure legend.
ax (matplotlib axis object, optional) – Matplotlib axis provided externally.
save_fig (bool, optional) – If True, saves a PDF in the POSEIDON output folder.
- Returns:
The spectra plot.
- Return type:
fig (matplotlib figure object)
- POSEIDON.visuals.plot_data(data, planet_name, wl_min=None, wl_max=None, y_min=None, y_max=None, y_unit='transit_depth', plt_label=None, data_colour_list=[], data_labels=[], data_marker_list=[], data_marker_size_list=[], wl_axis='log', figure_shape='default', legend_location='upper right')
Plot a collection of datasets. This function can plot transmission or emission datasets, according to the user’s choice of ‘y_unit’.
- Parameters:
data (dict) – POSEIDON observational data properties dictionary.
planet_name (str) – Name of the planet.
wl_min (float, optional) – The minimum wavelength to plot.
wl_max (float, optional) – The maximum wavelength to plot.
y_min (float, optional) – The minimum value for the y-axis.
y_max (float, optional) – The maximum value for the y-axis.
y_unit (str, optional) – The unit of the y-axis (Options: ‘transit_depth’, ‘eclipse_depth’, ‘(Rp/Rs)^2’, ‘(Rp/R*)^2’, ‘Fp/Fs’, ‘Fp/F*’, ‘Fp’).
plt_label (str, optional) – The label for the plot.
data_colour_list (list, optional) – A list of colours for the observational data points.
data_labels (list, optional) – A list of labels for the observational data.
data_marker_list (list, optional) – A list of marker styles for the observational data.
data_marker_size_list (list, optional) – A list of marker sizes for the observational data.
wl_axis (str, optional) – The type of x-axis to use (‘log’ or ‘linear’).
figure_shape (str, optional) – The shape of the figure (‘default’ or ‘wide’ - the latter is 16:9).
legend_location (str, optional) – The location of the legend (‘upper left’, ‘upper right’, ‘lower left’, ‘lower right’).
- Returns:
The data plot.
- Return type:
fig (matplotlib figure object)
- POSEIDON.visuals.plot_spectra_retrieved(spectra_median, spectra_low2, spectra_low1, spectra_high1, spectra_high2, planet_name, data_properties, R_to_bin=100, plt_label=None, show_ymodel=True, wl_min=None, wl_max=None, y_min=None, y_max=None, y_unit='transit_depth', colour_list=[], spectra_labels=[], data_colour_list=[], data_labels=[], data_marker_list=[], data_marker_size_list=[], binned_colour_list=[], text_annotations=[], annotation_pos=[], wl_axis='log', figure_shape='default', legend_location='upper right', legend_box=False, ax=None, save_fig=True)
Plot a collection of individual model spectra. This function can plot transmission or emission spectra, according to the user’s choice of ‘y_unit’.
- Parameters:
spectra_median (list of tuples) – A list of median spectra to be plotted, each with the format (wl, spec_median).
spectra_low2 (list of tuples) – Corresponding list of -2σ confidence intervals on the retrieved spectra, each with the format (wl, spec_low2).
spectra_low1 (list of tuples) – Corresponding list of -1σ confidence intervals on the retrieved spectra, each with the format (wl, spec_low1).
spectra_high1 (list of tuples) – Corresponding list of +1σ confidence intervals on the retrieved spectra, each with the format (wl, spec_high1).
spectra_high2 (list of tuples) – Corresponding list of +2σ confidence intervals on the retrieved spectra, each with the format (wl, spec_high2).
planet_name (str) – Planet name to overplot on figure.
data_properties (dict, optional) – POSEIDON observational data properties dictionary.
R_to_bin (int, optional) – Spectral resolution (R = wl/dwl) to bin the model spectra to.
plt_label (str, optional) – The label for the plot.
show_ymodel (bool, optional) – Flag indicating whether to plot the median retrieved spectra binned to the data resolution.
wl_min (float, optional) – The minimum wavelength to plot.
wl_max (float, optional) – The maximum wavelength to plot.
y_min (float, optional) – The minimum value for the y-axis.
y_max (float, optional) – The maximum value for the y-axis.
y_unit (str, optional) – The unit of the y-axis (Options: ‘transit_depth’, ‘eclipse_depth’, ‘(Rp/Rs)^2’, ‘(Rp/R*)^2’, ‘Fp/Fs’, ‘Fp/F*’, ‘Fp’).
colour_list (list, optional) – A list of colours for the model spectra.
spectra_labels (list, optional) – A list of labels for the model spectra.
data_colour_list (list, optional) – A list of colours for the observational data points.
data_labels (list, optional) – A list of labels for the observational data.
data_marker_list (list, optional) – A list of marker styles for the observational data.
data_marker_size_list (list, optional) – A list of marker sizes for the observational data.
binned_colour_list (list, optional) – A list of colours for the binned models.
text_annotations (list of str, optional) – A list of text annotations for Figure decoration (e.g. molecule names)
annotation_pos (list of tuples of str, optional) – (x, y) locations of the text annotations in the previous argument.
wl_axis (str, optional) – The type of x-axis to use (‘log’ or ‘linear’).
figure_shape (str, optional) – The shape of the figure (‘default’ or ‘wide’ - the latter is 16:9).
legend_location (str, optional) – The location of the legend (‘upper left’, ‘upper right’, ‘lower left’, ‘lower right’).
legend_box (bool, optional) – Flag indicating whether to plot a box surrounding the figure legend.
ax (matplotlib axis object, optional) – Matplotlib axis provided externally.
save_fig (bool, optional) – If True, saves a PDF in the POSEIDON output folder.
- Returns:
The retrieved spectra plot.
- Return type:
fig (matplotlib figure object)
- POSEIDON.visuals.plot_PT_retrieved(planet_name, PT_median, PT_low2, PT_low1, PT_high1, PT_high2, T_true=None, Atmosphere_dimension=1, TwoD_type=None, plt_label=None, show_profiles=[], PT_labels=[], colour_list=[], log_P_min=None, log_P_max=None, T_min=None, T_max=None, legend_location='lower left')
Plot retrieved Pressure-Temperature (P-T) profiles.
- Parameters:
planet_name (str) – The name of the planet.
PT_median (list of tuples) – List of tuples containing the median temperature and pressure grids for each model, each with the format (T_median, P).
PT_low2 (list of tuples) – Corresponding list of -2σ confidence intervals on the retrieved temperature, each with the format (T_low2, P).
PT_low1 (list of tuples) – Corresponding list of -1σ confidence intervals on the retrieved temperature, each with the format (T_low1, P).
PT_high1 (list of tuples) – Corresponding list of +1σ confidence intervals on the retrieved temperature, each with the format (T_high1, P).
PT_high2 (list of tuples) – Corresponding list of +2σ confidence intervals on the retrieved temperature, each with the format (T_high2, P).
T_true (np.array, optional) – True temperature profile (optional).
Atmosphere_dimension (int, optional) – Dimensionality of the atmospheric model.
TwoD_type (str, optional) – If ‘Atmosphere_dimension’ = 2, the type of 2D model (Options: ‘D-N’ for day-night, ‘E-M’ for evening-morning).
plt_label (list, optional) – List of labels for each model.
show_profiles (list, optional) – If model is 2D or 3D, which profiles to plot.
PT_labels (list, optional) – List of labels for each retrieved P-T profile.
colour_list (list, optional) –
- List of colours for each retrieved P-T profile.
log_P_min (float, optional):
- Minimum value for the log10 pressure.
log_P_max (float, optional):
- Maximum value for the log10 pressure.
T_min (float, optional):
- Minimum temperature to plot.
T_max (float, optional):
- Maximum temperature to plot.
legend_location (str, optional):
Location of the legend. Default is ‘lower left’.
- Return type:
fig (matplotlib figure object)
The retrieved P-T profile plot.
- POSEIDON.visuals.plot_chem_retrieved(planet_name, chemical_species, log_Xs_median, log_Xs_low2, log_Xs_low1, log_Xs_high1, log_Xs_high2, log_X_true=None, plot_species=[], plot_two_sigma=False, Atmosphere_dimension=1, TwoD_type=None, plt_label=None, show_profiles=[], model_labels=[], colour_list=[], log_P_min=None, log_P_max=None, log_X_min=None, log_X_max=None)
Plot retrieved mixing ratio profiles.
- Parameters:
planet_name (str) – The name of the planet.
chemical_species (list, optional) – List of chemical species to plot. If not specified, default to all chemical species in the model (including bulk species).
log_Xs_median (list of tuples) – List of tuples containing the median retrieved log10 mixing ratio for each chemical species (for a single model) and its corresponding pressure grid, each with the format (log10 X_median, P).
log_Xs_low2 (list of tuples) – Corresponding list of -2σ confidence intervals on the retrieved log10 mixing ratio for each chemical species, each with the form (log10 X_low2, P).
log_Xs_low1 (list of tuples) – Corresponding list of -1σ confidence intervals on the retrieved log10 mixing ratio for each chemical species, each with the form (log10 X_low1, P).
log_Xs_high1 (list of tuples) – Corresponding list of +1σ confidence intervals on the retrieved log10 mixing ratio for each chemical species, each with the form (log10 X_high1, P).
log_Xs_high2 (list of tuples) – Corresponding list of +2σ confidence intervals on the retrieved log10 mixing ratio for each chemical species, each with the form (log10 X_high2, P).
log_X_true (2D np.array, optional) – True log10 mixing ratio profiles for each chemical species.
plot_species (list, optional) – List of chemical species to plot. If not specified, default to all chemical species in the model (including bulk species).
plot_two_sigma (bool, optional) – If False, only plots the median and +/- 1σ confidence intervals for each chemical species (default behaviour to avoid clutter).
Atmosphere_dimension (int, optional) – Dimensionality of the atmospheric model.
TwoD_type (str, optional) – If ‘Atmosphere_dimension’ = 2, the type of 2D model (Options: ‘D-N’ for day-night, ‘E-M’ for evening-morning).
plt_label (list, optional) – List of labels for each model.
show_profiles (list, optional) – If model is 2D or 3D, which profiles to plot.
model_labels (list, optional) – List of labels for each retrieved chemical profile (only one model currently supported).
colour_list (list, optional) –
- List of colours for each retrieved chemical profile.
log_P_min (float, optional):
- Minimum value for the log10 pressure.
log_P_max (float, optional):
- Maximum value for the log10 pressure.
log_X_min (float, optional):
- Minimum log10 mixing ratio to plot.
log_X_max (float, optional):
- Maximum log10 mixing ratio to plot.
legend_location (str, optional):
Location of the legend. Default is ‘lower left’.
- Return type:
fig (matplotlib figure object)
The retrieved mixing ratio profile plot.
- POSEIDON.visuals.plot_stellar_flux(flux, wl, wl_min=None, wl_max=None, flux_min=None, flux_max=None, flux_axis='linear', wl_axis='log')
Straightforward function to plot an emergent stellar spectrum.
- Parameters:
flux (np.array) – Surface flux of the star as a function of wavelength.
wl (np.array) – Corresponding wavelength array.
wl_min (float, optional) – Minimum wavelength for x axis.
wl_max (float, optional) – Maximum wavelength for x axis.
flux_min (float, optional) – Minimum flux for y axis.
flux_max (float, optional) – Maximum flux for y axis.
flux_axis (str, optional) – ‘linear’ or ‘log’ axis scaling for the y-axis. Default is ‘linear’.
wl_axis (str, optional) – ‘linear’ or ‘log’ axis scaling for the x-axis. Default is ‘log’.
- Returns:
The simplest stellar flux plot you’ve ever seen.
- Return type:
fig (matplotlib figure object)
- POSEIDON.visuals.plot_histogram(nbins, vals, colour, ax, shrink_factor)
- POSEIDON.visuals.plot_parameter_panel(ax, param_vals, N_bins, param, param_min, param_max, colour)
- POSEIDON.visuals.plot_retrieved_parameters(axes_in, param_vals, plot_parameters, parameter_colour_list, retrieval_colour_list, retrieval_labels, span, truths, N_rows, N_columns, N_bins)
- POSEIDON.visuals.plot_histograms(planet_name, models, plot_parameters, parameter_colour_list=[], retrieval_colour_list=[], retrieval_labels=[], span=[], truths=[], N_bins=[], He_fraction=0.17, N_rows=None, N_columns=None, axes=[], retrieval_codes=[], external_samples=[], external_param_names=[], plt_label=None, save_fig=True)
Plot a set of histograms from one or more retrievals.
Detailed docstring TBD.
- POSEIDON.visuals.elemental_ratio(all_species, X_vals, element_1, element_2)
Helper function.
- POSEIDON.visuals.plot_retrieved_element_ratios(X_vals, all_species, plot_ratios, colour_list, retrieval_labels, span, truths, N_rows, N_columns, N_bins, abundance_fmt='.2f')