Scene rendering & noise (wcc_sim.render)
Place PSF stamps on the detector grid and apply the ETC noise model.
- class wcc_sim.render.StampBlend(w, model, halo, core_scale)[source]
Bases:
objectEverything about one stamp geometry that does not depend on the star.
w is a cosine taper (1 in the core, 0 at r >= half-width) and model is the diffraction wing on the stamp grid; blending the stamp’s outer annulus into the smooth model removes the Airy-ring texture that would otherwise end abruptly at the square stamp edge. halo is the measured scattered-light profile on the same grid, and core_scale the weight on the diffraction term – both inert (0 and 1) when there is no scatter model, which reproduces the diffraction-only rendering exactly.
- wcc_sim.render.wing_blend(n_stamp, wing, blend_start=0.8)[source]
Precompute the stamp->wing crossfade and halo for one stamp geometry.
- wcc_sim.render.add_star(image, psf_os, x, y, flux_e, oversample, wing=None, floor_e=None, blend=None)[source]
Add one star at float pixel (x, y), sub-pixel placed, edge-clipped.
Sub-pixel shift is a fine-grid np.roll (error <= 1/(2*oversample) px); rolled wrap-around energy is negligible because stamp edges are ~0.
With a wing model (see wcc_sim.wings), the stamp’s outer annulus is crossfaded into the smooth wing profile and the halo is continued on a circular footprint out to where flux_e * profile(r) < floor_e. Star flux is renormalized by wing.flux_norm(half) for all stars so photometry stays magnitude-independent; the sub-floor halo of faint stars is simply not drawn.
A CombinedWing additionally carries the measured scattered-light halo, which is added across the stamp as well as beyond it.
- wcc_sim.render.render_scene(shape, xs, ys, fluxes_e, psf_os, oversample, wing=None, floor_e=None)[source]
Sum of PSF stamps (e-) for all stars on a float32 (ny, nx) grid.
- wcc_sim.render.star_saturated(satmask, x, y, radius=32)[source]
True if any saturated pixel lies within radius px of (x, y).
A window is used rather than the central pixel alone because the defocused PSFs are centrally depressed: a bright star can saturate its ring while its central pixel stays below full well. The 2-wave defocus PSF’s bright ring extends to ~29 px from center.
- wcc_sim.render.add_noise_and_digitize(image_sources_e, sim, exptime, n_reads, rng, add_noise=True)[source]
Apply sky+dark, per-frame saturation, Poisson + read noise, ADU conversion.
ETC semantics (wcc_etc.simulation): read-noise variance scales with n_reads; saturation is evaluated on the per-frame expectation.