Standalone template convolution

After a successful HOTPANTS fit you can reuse the saved kernel on a template image without re-running stamp finding or kernel fitting. This is useful for applying a previously derived kernel to another (same-shape) template or for offline inspection of the spatial convolution alone.

Important

convolve_template returns the raw spatial convolution only. It does not add the spatial background polynomial that Hotpants.convolve_and_difference includes in the full pipeline.

Quick start

from hotpants import Hotpants, HotpantsConfig, KernelModel, convolve_template

hp = Hotpants(template, science, config=HotpantsConfig(...))
hp.run_pipeline()

kernel = KernelModel.from_hotpants(hp)
convolved = convolve_template(template, kernel)

The template passed to convolve_template must have the same (ny, nx) shape as the image the kernel was fit on. Spatial kernel variation is tied to those dimensions.

API

Standalone template convolution using a saved HOTPANTS kernel solution.

class hotpants.convolve.KernelModel(kernel_solution: ndarray, config: HotpantsConfig, fit_shape: Tuple[int, int])

Bases: object

Portable kernel fit result for standalone template convolution.

kernel_solution

1D coefficient vector of length n_comp_total + 1. Includes both convolution-kernel and background polynomial terms; only the kernel portion is used by convolve_template().

Type:

numpy.ndarray

config

Configuration used during fitting. Kernel-critical fields (rkernel, ko, bgo, ngauss, deg_fixe, sigma_gauss, use_pca) must match the fit.

Type:

hotpants.config.HotpantsConfig

fit_shape

(ny, nx) image shape the kernel was fit on.

Type:

Tuple[int, int]

config: HotpantsConfig
fit_shape: Tuple[int, int]
classmethod from_hotpants(hp: Hotpants) KernelModel

Build a KernelModel from a fitted Hotpants instance.

kernel_solution: ndarray
hotpants.convolve.convolve_template(template: ndarray, kernel: KernelModel | ndarray, config: HotpantsConfig | None = None) ndarray

Convolve a template image with a saved HOTPANTS kernel solution.

Returns the raw spatial_convolve output only (no spatial background polynomial is added). The template must have the same shape as the image the kernel was fit on.

Parameters:
  • template – 2D image to convolve.

  • kernel – A KernelModel or raw kernel_solution array.

  • config – Required when kernel is a raw array; ignored when kernel is a KernelModel.

Returns:

Convolved template as a float32 array with the same shape as template.