stdpipe.reproject module

Image reprojection routines.

Provides reproject_swarp() (SWarp wrapper) and reproject_lanczos() (pure-Python Lanczos interpolation with SWarp-style oversampling and Jacobian flux conservation).

stdpipe.reproject.reproject_lanczos(input=None, wcs=None, shape=None, width=None, height=None, header=None, order=3, conserve_flux=True, oversamp=None, is_flags=False, use_nans=True, parallel=False, return_footprint=False, verbose=False)[source]

Reproject images using Lanczos interpolation with automatic oversampling.

Implements SWarp-style oversampling (sub-pixel averaging when output pixels are larger than input pixels) and Jacobian area scaling for flux conservation.

Accepts the same input format as reproject_swarp(): a list of (image, header/WCS) tuples or a list of FITS filenames. For multiple inputs the reprojected frames are averaged (simple coadd).

Parameters:
inputlist or tuple

List of (image, header_or_wcs) tuples or FITS filenames. A single (image, header_or_wcs) tuple is also accepted (wrapped into a list automatically for reproject compatibility).

wcs~astropy.wcs.WCS, optional

Output WCS. Ignored if header already contains WCS.

shapetuple, optional

Output (height, width).

width, heightint, optional

Output dimensions (alternative to shape).

header~astropy.io.fits.Header, optional

Output FITS header (overrides wcs/shape/width/height).

orderint

Lanczos kernel order (default 3).

conserve_fluxbool

If True (default), multiply by the Jacobian area ratio so that total flux is conserved. If False, surface brightness is conserved instead.

oversampint or None

Sub-pixel oversampling factor per axis. None (default) selects automatically: max(1, round(output_scale / input_scale)).

is_flagsbool

If True, treat input as integer flag/mask images: use nearest-neighbor resampling (no interpolation) and bitwise AND for combining multiple inputs. Overrides order, conserve_flux and oversamp.

use_nansbool

If True (default), fill regions with no input coverage with NaN (floating-point images) or 0xFFFF (integer flag images).

parallelbool or int

If True, use threads for parallel interpolation (number chosen automatically). If int > 1, use that many threads. Gives ~3-4x speedup on multi-core machines.

return_footprintbool

If True, return (coadd, footprint) where footprint is a float array with values between 0.0 (no coverage) and 1.0 (full coverage). When oversampling is active, fractional values indicate partial sub-pixel coverage. Default is False for backward compatibility.

verbosebool or callable

Logging control.

Returns:
coadd2D ~numpy.ndarray or None

Reprojected (and optionally coadded) image.

footprint2D ~numpy.ndarray

Coverage map (only returned when return_footprint=True).

stdpipe.reproject.reproject_swarp(input=None, wcs=None, shape=None, width=None, height=None, header=None, extra=None, is_flags=False, use_nans=True, get_weights=False, _workdir=None, _tmpdir=None, _exe=None, verbose=False)[source]

Wrapper for running SWarp for re-projecting and mosaicking of images onto target WCS grid.

It accepts as input either list of filenames, or list of tuples where first element is an image, and second one - either FITS header or WCS.

If the input images are integer flags, set is_flags=True so that it will be handled by passing RESAMPLING_TYPE=FLAGS and COMBINE_TYPE=AND.

If use_nans=True, the regions with zero weights will be filled with NaNs (or 0xFFFF).

Any additional configuration parameter may be passed to SWarp through extra argument which should be the dictionary with parameter names as keys.