stdpipe.plots module¶
- stdpipe.plots.imshow(image, qq=None, mask=None, show_colorbar=True, show_axis=True, stretch='linear', r0=None, ax=None, max_plot_size=4096, fast=True, xlim=None, ylim=None, **kwargs)[source]¶
Display a 2D image with percentile-based intensity scaling.
- Parameters:
- imagendarray
2D array to display.
- qqlist of float, optional
Two-element
[low, high]percentile range for intensity normalization. Default is[0.5, 99.5]. Overridden by explicitvmin/vmax.- maskndarray of bool, optional
Boolean mask; masked pixels are excluded from intensity normalization.
- show_colorbarbool, optional
If True, display a colorbar alongside the image.
- show_axisbool, optional
If True, display axis ticks and labels.
- stretchstr, optional
Intensity stretch:
'linear','log','asinh','histeq', or any stretch supported by Astropy visualization.- r0float, optional
Gaussian smoothing sigma in pixels applied before display.
- axmatplotlib.axes.Axes, optional
Axes to draw on; defaults to the current axes.
- max_plot_sizeint or None, optional
Images larger than this (in pixels) are downscaled for rendering. Set to None to disable. Default is 4096.
- fastbool, optional
If True, use faster approximate methods for large images (subsampled percentiles, float32, FFT convolution).
- xlimtuple of float, optional
(xmin, xmax)region selection in original image coordinates.- ylimtuple of float, optional
(ymin, ymax)region selection in original image coordinates.- **kwargs
Additional keyword arguments passed to
matplotlib.pyplot.imshow().
- stdpipe.plots.binned_map(x, y, value, bins=16, statistic='mean', qq=[0.5, 97.5], color=None, show_colorbar=True, show_axis=True, show_dots=False, ax=None, range=None, **kwargs)[source]¶
Plot statistical estimators binned onto a regular grid.
- Parameters:
- xarray_like
Abscissae of the data points.
- yarray_like
Ordinates of the data points.
- valuearray_like
Values to aggregate.
- binsint, optional
Number of bins per axis.
- statisticstr or callable, optional
Aggregation statistic:
'mean','median', or a callable.- qqlist of float, optional
[low, high]percentile range for color scaling. Default[0.5, 97.5]. Overridden by explicitvmin/vmax.- colorcolor, optional
Color used for the data-point overlay (requires
show_dots=True).- show_colorbarbool, optional
If True, display a colorbar.
- show_axisbool, optional
If True, display axis ticks and labels.
- show_dotsbool, optional
If True, overlay the raw data point positions.
- rangelist of list, optional
Data range
[[xmin, xmax], [ymin, ymax]].- axmatplotlib.axes.Axes, optional
Axes to draw on; defaults to the current axes.
- **kwargs
Additional keyword arguments passed to
matplotlib.pyplot.imshow().
- stdpipe.plots.adaptive_binned_map(x, y, value, target_count=50, target_sn=None, err=None, statistic='mean', method='auto', qq=[0.5, 97.5], color=None, show_colorbar=True, show_axis=True, show_dots=False, show_edges=True, ax=None, range=None, verbose=False, **kwargs)[source]¶
Plot statistical estimators with adaptive (density-based) binning.
Bins have variable sizes: sparse regions get larger bins, dense regions get finer resolution. Bins target approximately
target_countpoints each, or a specifiedtarget_snS/N ratio.- Parameters:
- xarray_like
Abscissae of the data points.
- yarray_like
Ordinates of the data points.
- valuearray_like
Values to aggregate.
- target_countint, optional
Target number of points per bin.
- target_snfloat, optional
Target S/N per bin (alternative to
target_count).- errarray_like, optional
Per-point value errors; required when
target_snis set.- statisticstr or callable, optional
Aggregation:
'mean','median','std','count', or callable.- methodstr, optional
Binning algorithm:
'auto','powerbin', or'kdtree'.- qqlist of float, optional
[low, high]percentile range for color scaling. Default[0.5, 97.5].- colorcolor, optional
Color for the data-point overlay (requires
show_dots=True).- show_colorbarbool, optional
If True, display a colorbar.
- show_axisbool, optional
If True, display axis ticks and labels.
- show_dotsbool, optional
If True, overlay the raw data point positions.
- show_edgesbool, optional
If True, draw bin boundaries.
- axmatplotlib.axes.Axes, optional
Axes to draw on; defaults to the current axes.
- rangelist of list, optional
Data range
[[xmin, xmax], [ymin, ymax]].- verbosebool, optional
If True, enable verbose output from the binning backend.
- **kwargs
Additional keyword arguments passed to matplotlib.
- stdpipe.plots.plot_cutout(cutout, planes=['image', 'template', 'diff', 'mask'], fig=None, axs=None, mark_x=None, mark_y=None, mark_r=5.0, mark_r2=None, mark_r3=None, mark_color='red', mark_lw=2, mark_ra=None, mark_dec=None, r0=None, show_title=True, title=None, additional_title=None, **kwargs)[source]¶
Display image planes from a cutout structure in a single row.
- Parameters:
- cutoutdict
Cutout structure as returned by
stdpipe.cutouts.get_cutout().- planeslist of str, optional
Names of cutout planes to show (in order).
- figmatplotlib.figure.Figure, optional
Figure to draw into; a new figure is created if not provided.
- axslist of matplotlib.axes.Axes, optional
Axes to draw into; must be the same length as
planes.- mark_xfloat, optional
X coordinate (in cutout pixels) of the circular overlay mark.
- mark_yfloat, optional
Y coordinate (in cutout pixels) of the circular overlay mark.
- mark_rfloat, optional
Radius of the overlay mark in pixels.
- mark_r2float, optional
Radius of a secondary dashed overlay circle.
- mark_r3float, optional
Radius of a tertiary dashed overlay circle.
- mark_colorcolor, optional
Color of the overlay mark.
- mark_lwfloat, optional
Line width of the overlay mark.
- mark_rafloat, optional
RA of the overlay mark; overrides
mark_x/mark_y.- mark_decfloat, optional
Dec of the overlay mark; overrides
mark_x/mark_y.- r0float, optional
Gaussian smoothing sigma applied to
image,template, anddiffplanes.- show_titlebool, optional
If True (default), display a title above the cutout row.
- titlestr, optional
Title text. Auto-generated from cutout metadata if not provided.
- additional_titlestr, optional
Text appended to the auto-generated title.
- **kwargs
Additional keyword arguments passed to
imshow()for each plane.
- stdpipe.plots.plot_photometric_match(m, ax=None, mode='mag', show_masked=True, show_final=True, **kwargs)[source]¶
Plot photometric match diagnostics.
Displays various representations of the results returned by
stdpipe.photometry.match()orstdpipe.pipeline.calibrate_photometry().Available modes:
'mag'— photometric residuals vs catalogue magnitude'normed'— residuals divided by errors vs catalogue magnitude'color'— residuals vs catalogue color'zero'— spatial map of the empirical zero point'model'— spatial map of the zero-point model'residuals'— spatial map of zero-point fitting residuals'dist'— spatial map of angular separation (arcsec)
- Parameters:
- mdict
Photometric match results dictionary.
- axmatplotlib.axes.Axes, optional
Axes to draw on; defaults to the current axes.
- modestr, optional
Plotting mode (see above).
- show_maskedbool, optional
If True, include masked objects in the plot.
- show_finalbool, optional
If True, highlight objects used in the final fit.
- **kwargs
Additional keyword arguments passed to
binned_map()where applicable.
- stdpipe.plots.plot_detection_limit(obj, sn=5, mag_name=None, obj_col_mag='mag_calib', obj_col_mag_err='magerr', show_local=True, ax=None)[source]¶
Plot S/N vs magnitude with detection limit model.
- Parameters:
- objastropy.table.Table
Table with calibrated object detections.
- snfloat, optional
S/N threshold defining the detection limit.
- mag_namestr, optional
Axis label for the magnitude.
- obj_col_magstr, optional
Column name for calibrated magnitude.
- obj_col_mag_errstr, optional
Column name for magnitude error.
- show_localbool, optional
If True, overlay local per-object detection limits from
bg_fluxerr.- axmatplotlib.axes.Axes, optional
Axes to draw on; defaults to the current axes.
- stdpipe.plots.plot_mag_histogram(obj, cat=None, cat_col_mag=None, sn=None, obj_col_mag='mag_calib', obj_col_mag_err='magerr', accept_flags=0, ax=None)[source]¶
Plot a histogram of calibrated magnitudes.
- Parameters:
- objastropy.table.Table
Table with calibrated object detections.
- catastropy.table.Table, optional
Reference catalogue; its magnitudes are overlaid as a separate histogram.
- cat_col_magstr, optional
Column name for catalogue magnitudes.
- snfloat, optional
If set, overplot the S/N detection limit as a vertical line.
- obj_col_magstr, optional
Column name for object calibrated magnitude.
- obj_col_mag_errstr, optional
Column name for object magnitude error.
- accept_flagsint, optional
Bitmask of acceptable object flags (objects matching this mask are shown as unflagged).
- axmatplotlib.axes.Axes, optional
Axes to draw on; defaults to the current axes.
- stdpipe.plots.figure_saver(filename=None, show=False, tight_layout=True, **kwargs)[source]¶
Context manager that creates a Figure, saves it, and optionally displays it.
Example:
with figure_saver('/tmp/figure.png', show=True, figsize=(10, 6)) as fig: ax = fig.add_subplot(111) ax.plot(x, y, '.-')
- Parameters:
- filenamestr, optional
Output file path. Any format supported by Matplotlib is accepted.
- showbool, optional
If True, display the figure in a Jupyter notebook after saving.
- tight_layoutbool, optional
If True, call
fig.tight_layout()before saving.- **kwargs
Additional keyword arguments passed to
matplotlib.pyplot.Figure.
- stdpipe.plots.plot_outline(x, y, *args, ax=None, **kwargs)[source]¶
Plot the convex hull outline of (x, y) points.
- Parameters:
- x, yarray-like
Coordinates of points to outline.
- *args, **kwargs
Passed through to
matplotlib.axes.Axes.plotfor line styling.- axmatplotlib.axes.Axes or None
Target axes; defaults to current axes when None.
Notes
Uses
scipy.spatial.ConvexHullto compute the outline.Requires at least 3 non-collinear points; otherwise ConvexHull may fail.
If you pass masked arrays or NaNs, pre-filter to finite values to avoid distorting the hull.
- stdpipe.plots.cornerplot(features, scales=None, lines=None, subsets=None, show_all=True, extra=None, fig=None, **kwargs)[source]¶
Plot pairwise feature scatter panels in an upper-left triangular corner layout.
- Parameters:
- featureslist[tuple[array-like, str]]
List of (values, label) pairs. Each values array is 1D and aligned.
- scaleslist[str] or None
Per-feature axis scale (e.g., ‘linear’, ‘log’); length must match features.
- lineslist[float] or None
Per-feature reference line positions; length must match features.
- subsetslist[dict] or None
Optional subsets to overlay. Each dict must include an ‘idx’ boolean mask, plus any matplotlib style kwargs (e.g., label, color, marker).
- extracallable or None
If set, this callable will be called for every panel, with axes instance and two features (for x and y axes) as arguments
- show_allbool
If True, plot the full dataset in each panel excluding subset masks.
- figmatplotlib.figure.Figure or None
Figure to plot into; a new figure is created when None.
- **kwargs
Additional matplotlib plot kwargs for the main dataset and subsets.
Notes
Only off-diagonal panels are drawn, resulting in a (N-1)x(N-1) grid.
Subsets are excluded from the “all data” layer when
show_all=True.