Extended sources (wcc_sim.extended)

Extended-source components for wcc-sim frames: analytic Sersic profiles, arbitrary GalSim profiles (GalSimComponent) and calibrated sky images with a WCS such as HST mosaics (ImageComponent). The last two need the optional galaxies extra (galsim, reproject).

Components are rendered in e-/s/pix on the NATIVE detector grid and convolved once per (template, ebv) group with an effective-PSF kernel (FFT). The native grid is adequate because the in-focus PSF FWHM is ~3 px; the cuspy Sersic center is the exception and is re-evaluated on a refined subgrid. Rendering on the 11x point-source grid would need ~TB of memory for a full frame; sampling profiles as dense point grids would need ~1e6 stamp placements per component. See the design spec (docs/superpowers/specs/2026-07-02-extended-sources-cepheids-design.md).

class wcc_sim.extended.MemoryEstimate(box, k, resample_bytes, shape_in=None)[source]

Bases: NamedTuple

Standard information for peak memory usage of an ExtendedComponent’s rate_map.

Parameters:
box: tuple | None

off-frame

Type:

footprint (y0, y1, x0, x1) [detector px]; None

k: int

sub-grid factor

resample_bytes: int

estimated peak memory of rate_map [bytes]

shape_in: tuple | None

input image shape (ny, nx), for the MemoryLimitError message

class wcc_sim.extended.ExtendedComponent(*, label=None)[source]

Bases: ABC

Base of extended sources: something whose light can be mapped onto the detector.

Only what every extended source has lives here: a label and the methods. Fields are keyword-only so subclasses can still take positional fields. Components describe the source only; observation settings (filter, detector WCS, sub-grid k) are method arguments.

Parameters:

label (str | None)

label: str | None = None
kind: ClassVar[str] = 'extended'
abstractmethod rate_map(det_wcs, det_shape, plate_scale_mas, sensorfilter, k=None)[source]

Unconvolved e-/s per sub-pixel on the detector sub-grid (resample.Subgrid; total_in = the source’s total e-/s), or None if it misses the detector.

abstractmethod footprint(det_wcs, det_shape)[source]

Detector pixels (y0, y1, x0, x1) the source covers, or None.

memory_estimate(det_wcs, det_shape, plate_scale_mas, k=None)[source]

Estimated max memory usage of rate_map as MemoryEstimate, or None if this component shall not be checked against max_memory_gb. Default: None; subclasses whose rate_map needs much memory should override it.

to_record()[source]

Description of the source for the COMP table (FITS output).

class wcc_sim.extended.SersicComponent(ra, dec, n, r_eff_arcsec, ellip=0.0, pa_deg=0.0, total_mag=None, sb_mag_arcsec2=None, template='G2V', ebv=0.0)[source]

Bases: object

One elliptical Sersic component.

Exactly one of total_mag (integrated Gaia-G vegamag, same normalization convention as point sources) or sb_mag_arcsec2 (surface brightness at r_eff, mag/arcsec^2) sets the flux. pa_deg is the major-axis angle in degrees CCW from the +x detector axis. n=1 is an exponential disk, n=4 a de Vaucouleurs bulge.

Parameters:
ra: float
dec: float
n: float
r_eff_arcsec: float
ellip: float = 0.0
pa_deg: float = 0.0
total_mag: float = None
sb_mag_arcsec2: float = None
template: str = 'G2V'
ebv: float = 0.0
class wcc_sim.extended.GalSimComponent(ra, dec, profile, total_mag, template='G2V', ebv=0.0)[source]

Bases: object

One extended component described by a galsim GSObject.

profile is any galsim.GSObject in arcsec (e.g. galsim.Sersic, galsim.Add of a bulge and disk, a sheared/rotated profile, or a RealGalaxy). Its own flux is ignored: total_mag (integrated Gaia-G vegamag, same convention as point sources and SersicComponent) sets the flux through the template spectrum and ebv reddening. galsim’s position-angle convention (CCW from +x) matches SersicComponent. Profiles smaller than a pixel belong in the point-source catalog, not here: the renderer samples surface brightness, it does not integrate it.

Parameters:
ra: float
dec: float
profile: object
total_mag: float
template: str = 'G2V'
ebv: float = 0.0
class wcc_sim.extended.ImageComponent(data, wcs, zp_ab, template='G2V', ebv=0.0)[source]

Bases: object

A calibrated sky image (e.g. an HST drizzled mosaic) as an extended source, reprojected onto the frame.

data is a 2-D array with WCS wcs; a pixel of value v has AB magnitude zp_ab - 2.5 log10(v), so for an HST product in e-/s zp_ab = -2.5 log10(PHOTFLAM) - 5 log10(PHOTPLAM) - 2.408 (see wcc_sim.phangs.ab_zeropoint). Each pixel is treated as an AB-flat source, i.e. the image’s own band is taken to be the WCC band it is simulated in. template/ebv only pick the PSF kernel in chromatic mode. NaNs (outside the mosaic footprint) and negative pixels render as zero.

Parameters:
data: object
wcs: object
zp_ab: float
template: str = 'G2V'
ebv: float = 0.0
wcc_sim.extended.component_total_rate(comp, sensorfilter)[source]

Integrated e-/s of a component with total_mag set (reddened).

wcc_sim.extended.sersic_total_over_amplitude(n, r_eff_pix, ellip)[source]

F_total / amplitude for a Sersic2D profile (analytic).

Sersic2D’s amplitude is the surface brightness at r_eff per pixel area; integrating the profile over the plane gives 2 pi n r_eff^2 (1-ellip) e^bn bn^(-2n) Gamma(2n).

wcc_sim.extended.component_amplitude(comp, sensorfilter, plate_scale_mas)[source]

Sersic2D amplitude in e-/s/pix for the (reddened) component.

wcc_sim.extended.render_galsim_profile(comp, wcs, shape, plate_scale_mas, sensorfilter)[source]

GalSimComponent surface brightness in e-/s/pix on the native grid (unconvolved); None if its footprint misses the frame.

The profile is drawn with galsim (method=”no_pixel”: surface brightness sampled at pixel centers times pixel area, so the pixel response enters once through the PSF kernel in render_extended) directly onto the part of the frame inside its getGoodImageSize box, so a profile larger than the frame never allocates more than the frame. The central cusp box is re-drawn on a _REFINE x subgrid and summed, as the Sersic path does, so compact or high-n profiles keep their flux.

wcc_sim.extended.render_image_profile(comp, wcs, shape, plate_scale_mas, sensorfilter)[source]

ImageComponent surface brightness in e-/s/pix on the native grid (unconvolved); None if the frame misses the image.

The input is first cut to the frame’s footprint (so a 12000^2 HST mosaic is not interpolated whole), bilinearly reprojected onto the frame WCS with reproject, and scaled by the pixel-area ratio so surface brightness is conserved. No pixel-response convolution is applied here: as for the other components it enters once through the PSF kernel.

wcc_sim.extended.render_component_profile(comp, wcs, shape, plate_scale_mas, sensorfilter)[source]

Component surface brightness in e-/s/pix on the native grid (unconvolved); None if the 99.9%-flux footprint misses the frame.

GalSimComponents are drawn by render_galsim_profile and ImageComponents by render_image_profile. For Sersic components the profile is evaluated at pixel centers in row chunks (full-frame float64 temporaries would be ~GB); a box around the center is re-evaluated on a _REFINE x subgrid and averaged, since a Sersic cusp changes across a pixel while the rest of the profile does not.

wcc_sim.extended.render_extended(components, wcs, shape, plate_scale_mas, sensorfilter, kernels, wing=None)[source]

PSF-convolved sum of all components, e-/s/pix on the native grid.

kernels maps (template, ebv) -> native-resolution PSF kernel; the caller decides whether those are chromatic effective PSFs or copies of the monochromatic one. Kernels are normalized to unit sum here and, when a wing model is given, scaled by 1/wing.flux_norm(half) so extended flux follows the same stamp-truncation convention as add_star. No wing halo is drawn: for smooth extended light the halo is a sub-noise redistribution.