Plotting (wcc_etc.plotting)
Convenience plotting helpers for SimulatedImage (matplotlib + bokeh).
Every function accepts either a SimulatedImage (positional source) or explicit raw arrays as keywords, so the Flask web portal can pass arrays directly.
- wcc_etc.plotting.set_wcc_style()[source]
Apply the WCC plotting style to matplotlib’s global rcParams.
Call once (e.g. at the top of a notebook) so every subsequent matplotlib figure shares the same look. Mutates global state by design.
- wcc_etc.plotting.apply_ax_settings(ax, ticksize=None)[source]
Apply the standard per-axis tweaks: minor ticks, tick padding, faint grid.
Unlike set_wcc_style this touches one axis rather than global rcParams, so it is safe to call on a figure that also carries someone else’s style.
- wcc_etc.plotting.plot_image_mpl(source=None, *, noise=True, show_saturation=False, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, stretch='log', cmap='viridis', vmin=None, vmax=None, colorbar=True, title='', units='pix', sat_color='red', sat_alpha=0.6, ax=None)[source]
Plot a single simulated detector image with equal x/y scale.
noise=True shows the noisy image_e; noise=False shows the noiseless image_clean. show_saturation overlays the saturation mask. units=’mas’ or ‘arcsec’ labels the axes in angle using pixel_scale_mas; ‘pix’ in pixels. Returns (fig, ax).
- wcc_etc.plotting.plot_image_row_mpl(source=None, *, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, stretch='log', cmap='viridis', units='pix', sat_cmap='gray', figsize=(15, 5), axes=None)[source]
Three panels: PSF+noise, PSF (no noise), and the saturation mask.
The two image panels share a common color scale (computed from the noisy image). Returns (fig, axes) where axes has length 3.
- wcc_etc.plotting.plot_radial_mpl(source=None, *, noise=False, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, units='mas', annulus_width=1, show_hwhm=True, title='', label=None, ax=None, **kwargs)[source]
Azimuthally-averaged radial profile of the simulated image.
Uses image_clean by default (noise=True uses image_e). units=’mas’ scales the radius by pixel_scale_mas. label and any extra keyword arguments are passed to ax.plot, so several profiles can be overlaid on one axis with a legend. Returns (fig, ax, (radius, profile)).
- wcc_etc.plotting.plot_encircled_energy_mpl(source=None, *, noise=False, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, units='mas', ee_target=0.9, title='', label=None, ax=None, **kwargs)[source]
Encircled-energy curve (normalized to 1) of the simulated image.
Uses image_clean by default. units=’mas’ uses the mas radius from psf_to_encircled_energy; units=’pix’ divides by pixel_scale_mas. ee_target defaults to 0.9 (marks the 90% encircled-energy radius); pass ee_target=None to disable the marker or another fraction to override. label and any extra keyword arguments are passed to ax.plot, so several curves can be overlaid on one axis with a legend. Returns (fig, ax, (radius, ee)).
- wcc_etc.plotting.plot_bandpass_mpl(bandpass, *, wave=None, title='', label=None, ax=None, **kwargs)[source]
Plot a filter throughput curve.
bandpass is a synphot SpectralElement or an object carrying one (a Sensor). wave overrides the sampling grid; label and extra keyword arguments go to ax.plot so several filters can be overlaid. Returns (fig, ax, (wavelength_angstrom, throughput)).
- wcc_etc.plotting.plot_lightcurve_mpl(source=None, *, show_noise=True, show_model=True, time=None, flux=None, flux_clean=None, flux_err=None, ax=None, **kw)[source]
Matplotlib light-curve plot: clean model line, noisy points with error bars, or both. Accepts a LightCurve (positional) or raw arrays.
- wcc_etc.plotting.plot_image_bokeh(source=None, *, noise=True, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, units='pix', palette='Viridis256', title='', width=400, height=400, return_='obj')[source]
Bokeh single-image plot with equal x/y scale (match_aspect=True).
return_selects the output form (see _finish_bokeh).
- wcc_etc.plotting.plot_image_row_bokeh(source=None, *, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, units='pix', palette='Viridis256', sat_palette='Greys256', width=300, height=300, return_='obj')[source]
Bokeh 3-panel row: PSF+noise, PSF (no noise), saturation mask.
return_selects the output form (see _finish_bokeh).
- wcc_etc.plotting.plot_radial_bokeh(source=None, *, noise=False, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, units='mas', annulus_width=1, title='', width=500, height=350, return_='obj')[source]
Bokeh radial profile.
return_selects the output form (see _finish_bokeh).
- wcc_etc.plotting.plot_encircled_energy_bokeh(source=None, *, noise=False, image_e=None, image_clean=None, saturation_mask=None, pixel_scale_mas=None, units='mas', ee_target=0.9, title='', width=500, height=350, return_='obj')[source]
Bokeh encircled-energy curve. ee_target defaults to 0.9 (marks the 90% encircled-energy radius); pass ee_target=None to disable.
return_selects the output form.
- wcc_etc.plotting.plot_lightcurve_bokeh(source=None, *, show_noise=True, show_model=True, time=None, flux=None, flux_clean=None, flux_err=None, width=600, height=350, return_='obj')[source]
Bokeh light-curve plot.
return_selects the output form (see _finish_bokeh). Accepts a LightCurve (positional) or raw arrays.
- wcc_etc.plotting.plot_snr(sim, time, *, psf=None, n_reads=None, warn=False, ax=None, **kw)[source]
SNR vs exposure time for a Simulation.
time is an array of exposure times (seconds, or a Quantity). psf, n_reads and warn go to get_snr; kw goes to ax.plot, so several simulations overlay on one axis with label=. Returns (fig, ax).
- wcc_etc.plotting.plot_snr_vs_mag(sim, mags, *, time=None, psf=None, n_reads=None, warn=False, ax=None, **kw)[source]
SNR vs source magnitude at a fixed exposure time.
Uses get_image_snr(mags=…), which rescales the source off one cached render instead of rebuilding the scene per point. psf, n_reads and warn go to get_image_snr; kw goes to ax.plot. Returns (fig, ax).
- wcc_etc.plotting.plot_sweep(sim, key, values, *, time=None, psf=None, n_reads=None, warn=False, ax=None, **kw)[source]
SNR vs any update() key (e.g. ‘host__mag’, ‘host__r_eff’, ‘n_reads’).
Each value is set with sim.update(key=value) and the SNR evaluated at time; the original value is restored afterwards, even if a point raises. psf, n_reads and warn go to get_snr; kw goes to ax.plot. Returns (fig, ax).
- wcc_etc.plotting.plot_peak_pixel(sim, time, *, units='adu', psf=None, n_reads=None, show_ceiling=True, ax=None, **kw)[source]
Peak pixel vs exposure time on log axes, with the saturation ceiling.
The dashed line is sensor.saturation_e (the smaller of full well and ADC clip) in the chosen units; a dotted vertical line marks the earliest time at which is_saturated is True. time is in seconds or a Quantity; psf and n_reads go to get_peak_pixel. Returns (fig, ax).
- wcc_etc.plotting.plot_exptime_for_snr(sim, snr, *, psf=None, n_reads=None, warn=False, ax=None, **kw)[source]
Exposure time needed to reach each target SNR (PSF-aware inverse).
psf, n_reads and warn go to get_image_exptime_for_snr; kw goes to ax.plot. Returns (fig, ax).
- wcc_etc.plotting.plot_snr_vs_aperture(sim, radii, *, time=None, psf=None, n_reads=None, warn=False, show_markers=True, ax=None, **kw)[source]
SNR vs fixed aperture radius, with the default and optimized apertures.
A square marks the aperture get_image_snr picks by default and a circle the optimize=True radius. psf, n_reads and warn go to get_image_snr; kw goes to ax.plot. Returns (fig, ax).
- wcc_etc.plotting.plot_psf(imsim, psf=None, *, jitter_sigma_mas=None, npix=None, units='mas', ax=None, **kw)[source]
The bare normalized PSF on the detector grid (log stretch by default).
Wraps ImageSimulator.render_psf and plot_image_mpl; kw reaches the latter (title=, cmap=, colorbar=, stretch= …). Returns (fig, ax).