Pipeline¶
The orchestration layer: coerce inputs, select stamps, pick the convolution direction and basis scale, run the kernel solve and subtraction, and optionally decorrelate and score. See the usage guide for the per-knob tuning notes.
subtract
¶
subtract(science, reference, **kwargs) -> DiffResult
Convenience wrapper: configure a :class:Subtractor and run it once.
Configuration keywords (n_max, beta, n_knots, stamp_radius,
threshold_sigma, max_stamps, saturation, bright_mask,
lambda_grid, clip_sigma, clip_iterations, min_stamps, cv_folds,
spatial_scale, decorrelate, score, block, rescale_variance)
are split from the per-call inputs
(science_var, reference_var, science_mask, reference_mask,
gain, read_noise, catalog, direction).
Source code in python/delta/pipeline.py
apply
¶
apply(
solution: KernelSolution, science, reference, **kwargs
) -> DiffResult
Convenience wrapper: apply a frozen solution without re-fitting.
Configuration keywords (a subset of those accepted by :func:subtract:
saturation, bright_mask, stamp_radius, decorrelate, score,
block — the fit-only knobs are ignored) are split from the per-call inputs
(science_var, reference_var, science_mask, reference_mask,
gain, read_noise). The convolution direction, kernel basis, knots and
coefficients all come from solution; the inputs must match
solution.shape. See :meth:Subtractor.apply.
Source code in python/delta/pipeline.py
Subtractor
¶
Subtractor(
*,
n_max: int = 6,
beta: float | None = None,
n_knots: int = 5,
radius: int = 0,
stamp_radius: int = 15,
threshold_sigma: float = 5.0,
max_stamps: int = 200,
saturation: float = 0.0,
match_radius: int = 2,
fwhm_radius: int = 0,
bright_mask: float = 0.0,
lambda_grid: NDArray[float64] | None = None,
clip_sigma: float = 4.0,
clip_iterations: int = 5,
min_stamps: int = 5,
cv_folds: int = 5,
spatial_scale: float | None = None,
decorrelate: bool = False,
score: bool = False,
source_catalog: bool = True,
block: int = 256,
rescale_variance: bool = False,
)
Reusable difference-imaging configuration (SPEC §7 object-oriented path).
Source code in python/delta/pipeline.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
config_cards
¶
Reproducibility cards for knobs not already in KernelSolution.header_cards().
Source code in python/delta/pipeline.py
fit
¶
fit(
science,
reference,
*,
science_var=None,
reference_var=None,
science_mask=None,
reference_mask=None,
gain=None,
read_noise=0.0,
catalog=None,
direction=None,
) -> KernelSolution
Select stamps and fit the kernel/background, returning the solution.
Source code in python/delta/pipeline.py
subtract
¶
subtract(
science,
reference,
*,
science_var=None,
reference_var=None,
science_mask=None,
reference_mask=None,
gain=None,
read_noise=0.0,
catalog=None,
direction=None,
) -> DiffResult
Fit and produce the difference (and optional decorrelation/score).
Source code in python/delta/pipeline.py
apply
¶
apply(
solution: KernelSolution,
science,
reference,
*,
science_var=None,
reference_var=None,
science_mask=None,
reference_mask=None,
gain=None,
read_noise=0.0,
) -> DiffResult
Apply a frozen solution to a new pair without re-fitting.
Runs only the full-frame subtraction (+ optional decorrelation/score)
using the supplied :class:KernelSolution — the convolution direction,
kernel basis, knots and coefficients all come from solution. The
inputs must match solution.shape. Use this to reuse one fit across a
stack of frames, or to re-apply a saved solution for QA/reproducibility.
Source code in python/delta/pipeline.py
DiffResult
dataclass
¶
DiffResult(
difference: NDArray[float32],
variance: NDArray[float32] | None,
mask: NDArray[uint8] | None,
score: NDArray[float32] | None,
solution: KernelSolution,
psf: NDArray[float32] | None = None,
source_catalog: NDArray | None = None,
config: dict[str, object] = dict(),
elapsed: float = float("nan"),
variance_scale: float | None = None,
)
Products of a subtraction run.
header_cards
¶
Full provenance card set: fit + config + environment + runtime.
Combines :meth:KernelSolution.header_cards, the producing
Subtractor's :meth:~Subtractor.config_cards, and
:func:delta._provenance.environment_cards, enough on its own to
reproduce this run (modulo the input pixel data itself).
Source code in python/delta/pipeline.py
write
¶
write(
path: str,
overwrite: bool = False,
*,
compress: bool = True,
extra_cards: dict[str, object] | None = None,
) -> None
Write products to a multi-extension FITS with provenance (needs astropy).
With compress (the default) each image layer is stored as a tile-
compressed CompImageHDU (RICE), which shrinks noise-dominated
difference frames by roughly an order of magnitude. A FITS primary HDU
cannot itself be compressed, so the provenance header lives in a
dataless primary and the difference moves to a DIFFERENCE extension.
Pass compress=False for the plain layout (difference in the primary).
extra_cards adds/overrides header cards on top of
:meth:header_cards — e.g. input file paths or the invoking command
line, which this method has no way to know on its own.
Source code in python/delta/pipeline.py
build_catalog
¶
build_catalog(
*,
threshold_sigma: float = 5.0,
threshold_sigma_dipole: float = 3.0,
fwhm_tolerance_lo: float = 0.3,
fwhm_tolerance_hi: float = 3.0,
aperture_radius: int = 0,
exclude_bad_pixels: bool = True,
fit_psf_shape: bool = False,
shape_chi2_tolerance: float = 3.0,
bright_x: NDArray | None = None,
bright_y: NDArray | None = None,
bright_star_radius: float = 0.0,
max_shape_fit: int = 5000,
polarity: str = "positive",
as_table: bool = False,
)
Rebuild the source catalog from self.score with custom thresholds
(SPEC §3.7), instead of the defaults used to auto-populate
self.source_catalog.
The expected PSF FWHM is measured from self.psf (the stamp built for
the match filter); requires the originating subtract() /
Subtractor.subtract() call to have used score=True.
fit_psf_shape=True adds a per-candidate PSF chi^2 shape fit (using
self.psf and self.variance, so it stays consistent with what
the matched filter itself scored with) -- see
catalog.build_catalog for the false-positive rationale.
bright_x/bright_y add a bright-star proximity flag; when
omitted (the default) they're sourced from self.solution.stamp_x/
stamp_y (the bright stars used for the kernel fit) if available,
since that's a free input -- pass empty arrays to opt out.