Plotting helpers (wcc_sim.plotting)
See Plotting for the .plot_* methods built on these.
Shared plotting helpers for wcc_sim and wcc_phot.
Every public plot function in the two packages takes ax=None: pass an
axes to draw into your own figure, or leave it out and get a new one in the
packaged house style (plot_default.mplstyle). The result objects expose
the same functions as methods, field.plot_cutout(...) and
result.plot_lightcurve(...), so a tutorial cell is usually one line.
This module holds what the rest of the plotting code shares: the style, the
colour tokens, the ax=None helper, and the handful of plots that every
tutorial used to rewrite by hand (an image with a catalog overlay, a radial
profile, a PSF stamp, an encircled-energy curve).
pyplot is imported only when a function has to create a figure, so the report writers stay headless.
- wcc_sim.plotting.STYLE_PATH = '/home/docs/checkouts/readthedocs.org/user_builds/schmidt-observatories-wcc-sim/checkouts/latest/src/wcc_sim/data/plot_default.mplstyle'
The packaged house style, usable with
plt.style.use(STYLE_PATH).
- wcc_sim.plotting.TEAL = '#00798c'
Colour tokens of the house palette, in cycle order.
- wcc_sim.plotting.TARGET_COLOR = '#d1495b'
Semantic roles used across the packages.
- wcc_sim.plotting.style_context()[source]
Context manager applying the packaged style to what is drawn inside.
Two rcParams are deliberately not rolled back on exit.
interactive: in a fresh Jupyter kernel the inline backend is activated lazily by the first figure and switches it on, so a context entered before then would restoreFalseand the kernel would stop flushing figures to the cell output.backend: reading it resolves matplotlib’s auto-backend sentinel, which imports pyplot and selects a backend, and the report writers must stay pyplot-free (matplotlib.rc_contextskips it for the same reason).
- wcc_sim.plotting.use_style()[source]
Apply the packaged style globally (for notebooks and scripts).
- wcc_sim.plotting.axes(ax=None, **subplots_kw)[source]
Yield
ax, or a new styled pyplot axes when it is None.The style is applied only to a figure this helper creates; an axes passed in keeps the caller’s own rcParams.
- wcc_sim.plotting.block_max(image, factor)[source]
Downsample by taking the max of each
factor x factorblock.Max, not mean: a 61-Mpix frame has to be reduced ~8x to display, and averaging would wash stars and the inner halo out of the picture.
- wcc_sim.plotting.azimuthal_average(image, xc, yc, edges)[source]
Mean pixel value in each annulus of
edges; NaN where empty.Returns
(mean, count)with one entry per bin.
- wcc_sim.plotting.radial_profile(image, xc, yc, r_max=None, n_bins=80, log=False, bg=0.0)[source]
Azimuthally averaged profile of
imageabout(xc, yc).Returns
(r, profile)withrthe bin centres in pixels andprofilethe mean ofimage - bgin each annulus.log=Trueuses log-spaced bins from 1 px, which is what a PSF wing wants.
- wcc_sim.plotting.encircled_energy(image, xc=None, yc=None, total=None)[source]
Cumulative fraction of
imageinside radius r, about(xc, yc).Returns
(r_sorted, ee); the centre defaults to the array centre, which is the right choice for a PSF stamp.eeis normalised tototal, by default the sum of the image, so a stamp reaches 1; pass the star’s true flux to see how far a truncated render falls short.
- wcc_sim.plotting.plot_image(image, ax=None, catalog=None, satmask=None, stretch='asinh', percent=99.7, norm=None, cmap='gray_r', max_px=1200, title=None, **imshow_kw)[source]
An image with an asinh stretch, optional catalog circles and satmask.
catalogis a table withx/ycolumns (anin_imagecolumn, when present, selects the rows drawn);satmaska boolean array of the image’s shape, drawn as a contour.normreplaces thestretch/percentdefault for a hand-set stretch. Frames larger thanmax_pxon a side are block-max reduced for display, with the axes kept in native pixels (the reduction drops up tofactor - 1edge rows and columns, so the extent is that of the pixels shown). Returns the axes.
- wcc_sim.plotting.plot_radial_profile(image, xc, yc, ax=None, bg=0.0, r_max=None, n_bins=80, log=False, **plot_kw)[source]
Draw
radial_profile()on log-y axes; returns the axes.
- wcc_sim.plotting.plot_stamp(stamp, ax=None, half_width=None, decades=8, cmap='magma', plate_scale_mas=None, title=None)[source]
A centred PSF stamp on a log10 colour scale; returns the axes.
The extent is in pixels from the centre, or in arcsec when
plate_scale_masis given.decadessets the dynamic range below the peak;half_widthcrops the view.
- wcc_sim.plotting.plot_encircled_energy(image, ax=None, xc=None, yc=None, log_x=True, **plot_kw)[source]
Draw
encircled_energy(); returns the axes.