Core (low-level)¶
The C++ core, exposed as delta._core and re-exported at the top level. These are the
building blocks the high-level pipeline orchestrates — basis evaluation,
convolution, the penalized GLS solver, thin-plate splines, stamp detection, noise
decorrelation, and FITS I/O.
Advanced
Most users should use the high-level pipeline instead. These
functions are documented for advanced use and for understanding the internals.
Signatures and docstrings are sourced from the _core.pyi type stub. The compiled
_core.subtract is re-exported as delta.subtract_model to avoid colliding with
the high-level delta.subtract.
Basis & convolution¶
gauss_hermite_basis1d
¶
gauss_hermite_kernels
¶
basis_convolve
¶
basis_convolve(
image: NDArray[float32],
beta: float,
n_max: int,
radius: int = ...,
) -> NDArray[float32]
Convolve image with each basis component; returns (ncomp, H, W).
Spatial model (thin-plate splines)¶
grid_knots
¶
tps_design
¶
tps_penalty
¶
tps_fit
¶
tps_fit(
knots: NDArray[float64],
points: NDArray[float64],
values: NDArray[float64],
lam: float,
) -> NDArray[float64]
Unweighted penalised fit: (D^T D + lam P) theta = D^T values.
tps_evaluate
¶
tps_evaluate(
knots: NDArray[float64],
points: NDArray[float64],
coeffs: NDArray[float64],
) -> NDArray[float64]
Evaluate a fitted TPS field at points: design(points) @ coeffs.
Solver¶
solve_gls
¶
solve_gls(
knots: NDArray[float64],
points: NDArray[float64],
target: NDArray[float64],
weights: NDArray[float64],
bn: NDArray[float64],
lam: float,
) -> GlsResult
Penalised GLS at fixed lambda over the factorized A&L model.
Source code in python/delta/_core.pyi
solve_gls_gcv
¶
solve_gls_gcv(
knots: NDArray[float64],
points: NDArray[float64],
target: NDArray[float64],
weights: NDArray[float64],
bn: NDArray[float64],
lambda_grid: NDArray[float64],
) -> GlsResult
Penalised GLS selecting lambda by GCV over lambda_grid.
Source code in python/delta/_core.pyi
solve_gls_cv
¶
solve_gls_cv(
knots: NDArray[float64],
points: NDArray[float64],
target: NDArray[float64],
weights: NDArray[float64],
bn: NDArray[float64],
lambda_grid: NDArray[float64],
group: NDArray[int32],
n_groups: int,
) -> GlsResult
Penalised GLS selecting lambda by k-fold group cross-validation.
Source code in python/delta/_core.pyi
weighted_mean
¶
Detection & stamps¶
detect_stamps
¶
detect_stamps(
data: NDArray[float32],
mask: NDArray[uint8] | None = ...,
stamp_radius: int = ...,
threshold_sigma: float = ...,
max_stamps: int = ...,
saturation: float = ...,
isolation_radius: int = ...,
border: int = ...,
fwhm_radius: int = ...,
match_radius: int = ...,
) -> DetectedStamps
Detect bright, isolated, unsaturated point-source stamps.
Source code in python/delta/_core.pyi
select_stamps
¶
select_stamps(
science: NDArray[float32],
reference: NDArray[float32],
science_mask: NDArray[uint8] | None = ...,
reference_mask: NDArray[uint8] | None = ...,
catalog_x: NDArray[int32] | None = ...,
catalog_y: NDArray[int32] | None = ...,
stamp_radius: int = ...,
threshold_sigma: float = ...,
max_stamps: int = ...,
saturation: float = ...,
isolation_radius: int = ...,
border: int = ...,
fwhm_radius: int = ...,
match_radius: int = ...,
) -> StampSelection
Select matched stamps across both images and the convolution direction.
Source code in python/delta/_core.pyi
Fit & subtract¶
fit_kernel
¶
fit_kernel(
science: NDArray[float32],
reference: NDArray[float32],
knots: NDArray[float64],
stamp_x: NDArray[int32],
stamp_y: NDArray[int32],
stamp_radius: int,
beta: float,
n_max: int,
lambda_grid: NDArray[float64],
radius: int = ...,
clip_sigma: float = ...,
clip_iterations: int = ...,
min_stamps: int = ...,
cv_folds: int = ...,
science_var: NDArray[float32] | None = ...,
reference_var: NDArray[float32] | None = ...,
science_mask: NDArray[uint8] | None = ...,
reference_mask: NDArray[uint8] | None = ...,
) -> KernelFit
Fit the matching kernel + background via penalised GLS with per-stamp sigma clipping. The returned dict adds reduced_chi2, n_stamps_total/used/ rejected and per-stamp stamp_x/stamp_y/stamp_chi2/stamp_accepted.
Source code in python/delta/_core.pyi
subtract
¶
subtract(
science: NDArray[float32],
reference: NDArray[float32],
knots: NDArray[float64],
theta: NDArray[float64],
beta: float,
n_max: int,
radius: int = ...,
saturation: float = ...,
science_var: NDArray[float32] | None = ...,
reference_var: NDArray[float32] | None = ...,
science_mask: NDArray[uint8] | None = ...,
reference_mask: NDArray[uint8] | None = ...,
) -> DiffProducts
Full-frame spatially-varying subtraction with variance/mask propagation; saturation>0 masks and grows bright/saturated cores.
Source code in python/delta/_core.pyi
photometric_scale
¶
photometric_scale(
knots: NDArray[float64],
theta: NDArray[float64],
component_sums: NDArray[float64],
height: int,
width: int,
) -> NDArray[float32]
Per-pixel photometric scale field sum_n a_n(x,y) S_n, shape (H, W).
Source code in python/delta/_core.pyi
photometric_scale_at
¶
photometric_scale_at(
knots: NDArray[float64],
theta: NDArray[float64],
component_sums: NDArray[float64],
points: NDArray[float64],
) -> NDArray[float64]
Photometric scale evaluated at points, shape (m,).
estimate_background
¶
Noise: decorrelation & scoring¶
decorrelation_kernel
¶
decorrelation_kernel(
kernel: NDArray[float32],
var_science: float,
var_reference: float,
n: int,
) -> NDArray[float32]
Real-space decorrelation kernel (centred, n x n) for QA.
decorrelate_block
¶
decorrelate_block(
image: NDArray[float32],
kernel: NDArray[float32],
var_science: float,
var_reference: float,
) -> NDArray[float32]
Whiten one square block with a constant kernel/noise (FFT core).
decorrelate
¶
decorrelate(
difference: NDArray[float32],
knots: NDArray[float64],
theta: NDArray[float64],
beta: float,
n_max: int,
var_science: NDArray[float32],
var_reference: NDArray[float32],
block: int = ...,
radius: int = ...,
kernel_cell_blocks: int = ...,
) -> DecorrelateResult
Spatially-varying noise decorrelation via apodized FFT blocks.
Returns {'difference', 'variance'} where variance is the
post-whitening noise level (for pulls and the match-filtered score).
Source code in python/delta/_core.pyi
matched_filter
¶
matched_filter(
image: NDArray[float32],
psf: NDArray[float32],
variance: NDArray[float32],
) -> NDArray[float32]
Match-filtered score image (per-pixel S/N map). variance must be a same-shape float32 image of per-pixel noise variance.
Source code in python/delta/_core.pyi
FITS I/O¶
read_fits
¶
write_fits
¶
write_fits(
path: str,
data: NDArray[float32],
variance: NDArray[float32] | None = ...,
mask: NDArray[uint8] | None = ...,
overwrite: bool = ...,
) -> None
Write data plus optional variance/mask layers to a FITS file.
Raises if the file exists unless overwrite=True.