petitRADTRANS.sbi.plotting#

Lightweight plotting helpers for SBI outputs.

Functions#

plot_posterior_marginals(→ tuple[Any, numpy.ndarray])

Plot one histogram per posterior dimension.

plot_posterior_corner(→ tuple[Any, numpy.ndarray])

Plot a lower-triangular corner view of posterior structure.

plot_local_sensitivity_jacobians(→ tuple[Any, ...)

Plot whitened Jacobian heatmaps for each representative point.

plot_local_sensitivity_fisher_correlations(...)

Plot Fisher-correlation heatmaps for each representative point.

plot_local_sensitivity_singular_values(→ tuple[Any, ...)

Plot singular spectra of the whitened Jacobian for each point.

plot_posterior_predictive_report(→ tuple[Any, ...)

Plot observed values against posterior-predictive means and intervals.

plot_sbc_rank_histograms(→ tuple[Any, numpy.ndarray])

Plot one SBC rank histogram per inferred parameter.

save_validation_plots(→ None)

Render and save the standard validation plot set (marginals, corner, SBC

Module Contents#

petitRADTRANS.sbi.plotting.plot_posterior_marginals(samples: Any, parameter_names: Sequence[str] | None = None, bins: int = 40, figsize: tuple[float, float] | None = None) tuple[Any, numpy.ndarray]#

Plot one histogram per posterior dimension.

Parameters#

samples:

Posterior samples with shape (n_samples, n_dim) or a scalar-vector equivalent.

parameter_names:

Optional display names for each posterior dimension.

bins:

Number of histogram bins per dimension.

figsize:

Optional Matplotlib figure size.

Returns#

tuple[Any, np.ndarray]

Matplotlib figure and axes array for further customization or saving.

petitRADTRANS.sbi.plotting.plot_posterior_corner(samples: Any, parameter_names: Sequence[str] | None = None, bins: int = 40, figsize: tuple[float, float] | None = None, max_points: int = 8192) tuple[Any, numpy.ndarray]#

Plot a lower-triangular corner view of posterior structure.

Parameters#

samples:

Posterior samples with shape (n_samples, n_dim) or a scalar-vector equivalent.

parameter_names:

Optional display names for each posterior dimension.

bins:

Number of bins used for one- and two-dimensional histograms.

figsize:

Optional Matplotlib figure size.

max_points:

Maximum number of posterior draws plotted. Larger sample sets are evenly subsampled to keep rendering costs bounded.

Returns#

tuple[Any, np.ndarray]

Matplotlib figure and axes array for further customization or saving.

petitRADTRANS.sbi.plotting.plot_local_sensitivity_jacobians(report: petitRADTRANS.sbi.calibration.LocalSensitivityReport, figsize: tuple[float, float] | None = None) tuple[Any, numpy.ndarray]#

Plot whitened Jacobian heatmaps for each representative point.

petitRADTRANS.sbi.plotting.plot_local_sensitivity_fisher_correlations(report: petitRADTRANS.sbi.calibration.LocalSensitivityReport, figsize: tuple[float, float] | None = None) tuple[Any, numpy.ndarray]#

Plot Fisher-correlation heatmaps for each representative point.

petitRADTRANS.sbi.plotting.plot_local_sensitivity_singular_values(report: petitRADTRANS.sbi.calibration.LocalSensitivityReport, figsize: tuple[float, float] | None = None) tuple[Any, numpy.ndarray]#

Plot singular spectra of the whitened Jacobian for each point.

petitRADTRANS.sbi.plotting.plot_posterior_predictive_report(report: petitRADTRANS.sbi.calibration.PosteriorPredictiveReport, dataset_names: Sequence[str] | None = None, figsize: tuple[float, float] | None = None, x_coordinates: Mapping[str, Any] | Any | None = None, x_label: str = 'Wavelength [$\\mu$m]', y_label: str = 'Observation scale') tuple[Any, numpy.ndarray]#

Plot observed values against posterior-predictive means and intervals.

Parameters#

report:

Posterior-predictive report to visualize.

dataset_names:

Optional subset of dataset names to plot. Defaults to all datasets in the report.

figsize:

Optional Matplotlib figure size.

x_coordinates:

Physical x-axis sample positions (e.g. wavelength in micron). May be a single array applied to every dataset, or a mapping from dataset name to array. When None – or when a supplied array does not match the number of plotted samples – the helper falls back to the integer sample index. Supplying wavelengths replaces the bare coordinate index on the x-axis.

x_label:

Label for the x-axis (defaults to a wavelength label). Used only when an x_coordinates array is actually applied.

y_label:

Label for the y-axis. Pass the observable-specific unit, e.g. "Flux [W m^-2 um^-1]" for emission or "Transit depth" for transmission.

Returns#

tuple[Any, np.ndarray]

Matplotlib figure and axes array.

Notes#

Spectrum plots adopt the full petitRADTRANS.plotlib.style style (fonts, ticks and colour cycle) for the duration of the call via a temporary rc context, so the global Matplotlib state is left untouched on return.

For batched reports the helper currently visualizes only the first case for each dataset, which keeps the plot compact for quick inspection.

petitRADTRANS.sbi.plotting.plot_sbc_rank_histograms(report: petitRADTRANS.sbi.calibration.SimulationBasedCalibrationReport, parameter_names: Sequence[str] | None = None, figsize: tuple[float, float] | None = None) tuple[Any, numpy.ndarray]#

Plot one SBC rank histogram per inferred parameter.

Parameters#

report:

SBC report containing per-parameter rank histogram counts.

parameter_names:

Optional display names for each inferred parameter.

figsize:

Optional Matplotlib figure size.

Returns#

tuple[Any, np.ndarray]

Matplotlib figure and axes array.

petitRADTRANS.sbi.plotting.save_validation_plots(run_root: Any, posterior_samples: numpy.ndarray, parameter_names: Sequence[str], validation_sbc_report: petitRADTRANS.sbi.calibration.SimulationBasedCalibrationReport, validation_predictive_report: petitRADTRANS.sbi.calibration.PosteriorPredictiveReport, target_predictive_report: petitRADTRANS.sbi.calibration.PosteriorPredictiveReport, dataset_names: Sequence[str], spectrum_wavelengths: numpy.ndarray | None = None, x_label: str = 'Wavelength [$\\mu$m]', y_label: str = 'Observation scale', dpi: int = 160) None#

Render and save the standard validation plot set (marginals, corner, SBC rank histograms, and validation/target posterior-predictive spectra) into run_root. A no-op if matplotlib is unavailable.