Skip to content

drpangloss.plotting

Functions

posterior_predictive_summary(dra_samples, ddec_samples, flux_samples, oidata, model_class)

Compute posterior predictive means and standard deviations for visibilities and phases.

Parameters:

Name Type Description Default
dra_samples array - like

Posterior samples for Cartesian offset and flux ratio.

required
ddec_samples array - like

Posterior samples for Cartesian offset and flux ratio.

required
flux_samples array - like

Posterior samples for Cartesian offset and flux ratio.

required
oidata OIData

Data object defining observable conventions and geometry.

required
model_class type

Model class with signature model_class(dra=..., ddec=..., flux=...).

required

Returns:

Type Description
dict

Dictionary containing vis_mean, vis_std, phi_mean, phi_std arrays.

plot_data_model_correlation(oidata, predictions_by_label, colors=None, figsize=(10, 5), phase_title='Phase correlation', square_axes=True)

Plot data-vs-model correlation panels for visibility and phase observables.

Parameters:

Name Type Description Default
oidata OIData

Observed data container.

required
predictions_by_label dict

Mapping label -> prediction summary where each summary contains vis_mean, vis_std, phi_mean, phi_std arrays.

required
colors list

Matplotlib color list. If omitted, cycle C0, C1, ...

None
figsize tuple

Figure size.

(10, 5)
phase_title str

Title for the phase panel.

'Phase correlation'
square_axes bool

If True, enforce square panel boxes for both subplots.

True

Returns:

Type Description
tuple

(fig, (ax1, ax2)) for visibility and phase axes.

plot_trace_panels(samples_dict, keys, title, color='C0', figsize=(10, 6))

Plot simple one-dimensional trace panels for selected sample keys.

Parameters:

Name Type Description Default
samples_dict dict

Mapping from key name to one-dimensional sample arrays.

required
keys list

Ordered list of keys to plot.

required
title str

Figure title.

required
color str

Line color.

'C0'
figsize tuple

Figure size.

(10, 6)

Returns:

Type Description
tuple

(fig, axes).

plot_likelihood_grid(loglike_im, samples_dict, truths=None, best_point=None, truth_label='Truth', best_label='Grid max', colorbar_label='Log likelihood', cmap='inferno', figsize=(12, 6))

Plot the results of a likelihood_grid calculation.

Parameters:

Name Type Description Default
loglike_im array

The likelihood grid, output of likelihood_grid

required
samples_dict dict

Dictionary of samples used in the grid calculation

required
truths list

List of true values for the parameters, default None

None

plot_chainconsumer_diagnostics(chains_by_label, columns, truth, colors=None, walk_columns=None)

Plot comparison diagnostics using ChainConsumer for multiple posterior chains.

Parameters:

Name Type Description Default
chains_by_label dict

Mapping label -> pandas.DataFrame containing chain samples.

required
columns list[str]

Columns used for contour/corner plotting.

required
truth dict

Truth mapping for columns displayed.

required
colors list[str]

Per-chain colors.

None
walk_columns list[str]

Columns to show in walk plots. Defaults to columns.

None

Returns:

Type Description
ChainConsumer

Configured ChainConsumer instance.

diagnostics_table_from_samples(samples, dra_key='dra', ddec_key='ddec', flux_key='flux', log10_flux=False)

Build a standardized diagnostics table from posterior sample arrays.

Parameters:

Name Type Description Default
samples dict - like

Mapping of sample arrays.

required
dra_key str

Key for right-ascension offsets.

'dra'
ddec_key str

Key for declination offsets.

'ddec'
flux_key str

Key for flux or log10-flux samples.

'flux'
log10_flux bool

If True, exponentiate flux_key values as base-10.

False

Returns:

Type Description
DataFrame

Table with dra, ddec, flux, sep, and pa columns.

truth_cartesian_and_polar(truth)

Return truth mappings for shared ChainConsumer Cartesian and polar interfaces.

Parameters:

Name Type Description Default
truth dict

Mapping with dra, ddec, and flux values.

required

Returns:

Type Description
tuple[dict, dict]

Cartesian and polar truth dictionaries.

plot_hmc_fisher_chainconsumer(hmc_table, fisher_table, truth_cartesian, colors=('#1f77b4', '#ff7f0e'))

Plot paired Cartesian and polar ChainConsumer diagnostics for HMC and Fisher-HMC.

Parameters:

Name Type Description Default
hmc_table DataFrame

Posterior table for vanilla HMC.

required
fisher_table DataFrame

Posterior table for Fisher-reparameterized HMC.

required
truth_cartesian dict

Truth mapping in Cartesian coordinates.

required
colors tuple[str, str]

Colors used for HMC and Fisher-HMC chains.

('#1f77b4', '#ff7f0e')

Returns:

Type Description
dict

Mapping containing configured ChainConsumer objects and truth mappings.

plot_recovery_residuals(params, truth, estimates_by_label, std_by_label, figsize=(8, 4))

Plot parameter recovery and normalized residuals for multiple estimators.

Parameters:

Name Type Description Default
params list[str]

Parameter names.

required
truth array - like

Truth values in the same order as params.

required
estimates_by_label dict

Mapping of label to posterior median arrays.

required
std_by_label dict

Mapping of label to posterior standard-deviation arrays.

required
figsize tuple

Base figure size.

(8, 4)

Returns:

Type Description
tuple

((fig1, ax1), (fig2, ax2)) for recovery and residual panels.

radial_limit_summary(limit_map, dra_axis, ddec_axis, center=(0.0, 0.0), r_max=350.0, n_bins=20)

Compute radial median and percentile bands for a 2D contrast-limit map.

Parameters:

Name Type Description Default
limit_map array - like

Two-dimensional map of contrast limits.

required
dra_axis array - like

Right-ascension axis in milliarcseconds.

required
ddec_axis array - like

Declination axis in milliarcseconds.

required
center tuple[float, float]

Radial center in milliarcseconds.

(0.0, 0.0)
r_max float

Maximum radial separation to summarize.

350.0
n_bins int

Number of radial edges (bins are n_bins - 1).

20

Returns:

Type Description
dict

Mapping with r_centers, median, q16, and q84 arrays.

plot_contrast_limit_map(limit_map, dra_axis, ddec_axis, truth=None, unit_mode='flux_ratio', title='Contrast-limit map', cmap='inferno', figsize=(8, 6))

Plot a 2D contrast-limit map in flux-ratio or Δmag units.

Parameters:

Name Type Description Default
limit_map array - like

Two-dimensional contrast-limit map.

required
dra_axis array - like

Right-ascension axis in milliarcseconds.

required
ddec_axis array - like

Declination axis in milliarcseconds.

required
truth dict or tuple

Truth location to overplot.

None
unit_mode (flux_ratio, delta_mag)

Display units for the map.

"flux_ratio"
title str

Axes title.

'Contrast-limit map'
cmap str

Matplotlib colormap name.

'inferno'
figsize tuple

Figure size.

(8, 6)

Returns:

Type Description
tuple

(fig, ax).

plot_radial_limit_summary(radial_summary, unit_mode='flux_ratio', title='Radial limit summary', figsize=(8, 4), ax=None)

Plot radial median and percentile spread from radial_limit_summary output.

Parameters:

Name Type Description Default
radial_summary dict

Output mapping from radial_limit_summary.

required
unit_mode (flux_ratio, delta_mag)

Display units for the y-axis.

"flux_ratio"
title str

Plot title.

'Radial limit summary'
figsize tuple

Figure size.

(8, 4)
ax Axes

Existing axes to draw on. If omitted, create a new figure and axes.

None

Returns:

Type Description
tuple

(fig, ax).

plot_optimized_and_grid(loglike_im, optimized, samples_dict)

Plot optimized contrast results alongside the brute-force grid maximum.

Parameters:

Name Type Description Default
loglike_im array

Full 3D log-likelihood cube from likelihood_grid.

required
optimized array

2D optimized contrast map from optimized_contrast_grid.

required
samples_dict dict

Sampling dictionary containing dra, ddec, and flux axes.

required

plot_optimized_and_sigma(contrast, sigma_grid, samples_dict, snr=False)

Plot the results of an optimized contrast grid calculation and the corresponding uncertainty grid.

Parameters:

Name Type Description Default
contrast array

The optimized contrast grid, output of optimized_contrast_grid

required
sigma_grid array

The uncertainty grid, output of laplace_contrast_uncertainty_grid

required
samples_dict dict

Dictionary of samples used in the grid calculation

required
snr bool

If True, plot the SNR instead of the uncertainty, default False

False

plot_contrast_limits(contrast_limits, samples_dict, rad_width, avg_width, std_width, true_values=None, limit_label='98% Upper Limit')

Plot the contrast limits calculated with the Ruffio or Absil methods.

Parameters:

Name Type Description Default
contrast_limits array

The contrast limits calculated with the Ruffio or Absil methods.

required
samples_dict dict

Dictionary of samples used in the grid calculation

required
rad_width array

Radial width of the contrast limits.

required
avg_width array

Average width of the contrast limits.

required
std_width array

Standard deviation of the contrast limits.

required
true_values list

List of true values for the parameters, default None

None
limit_label str

Label used for the map title and curve legend.

'98% Upper Limit'