Module API¶
OIS is a package to perform optimal image subtraction on astronomical images. It offers different methods to subtract images:
- Modulated multi-Gaussian kernel
- Delta basis kernel
- Adaptive Delta Basis kernel
Each method can (optionally) simultaneously fit and remove common background.
Usage:
>>> from ois import optimal_system
>>> difference, optimalImage, optimalKernel, background =
optimal_system(image, referenceImage)
(c) Martin Beroiz email: <martinberoiz@gmail.com> University of Texas at San Antonio
-
exception
ois.
EvenSideKernelError
¶
-
ois.
convolve2d_adaptive
(image, kernel, poly_degree)¶ Convolve image with the adaptive kernel of poly_degree degree.
-
ois.
eval_adpative_kernel
(kernel, x, y)¶ Return the adaptive kernel at position (x, y) = (col, row).
-
ois.
optimal_system
(image, refimage, kernelshape=(11, 11), bkgdegree=None, method='Bramich', gridshape=None, **kwargs)¶ Do Optimal Image Subtraction and return optimal image, kernel and background.
This is an implementation of a few Optimal Image Subtraction algorithms. They all (optionally) simultaneously fit a background.
Parameters: - gridshape – A tuple containing the number of vertical and horizontal
divisions of a grid. Subtraction will be performed on each grid
element.
None
is equivalent to a(1, 1)
grid (no grid). - kernelshape – Shape of the kernel to use. Must be of odd size.
- bkgdegree – Degree of the polynomial to fit the background.
To turn off background fitting set this to
None
. - method –
One of the following strings.
"Bramich"
: A Delta basis for the kernel (all pixels fit independently)"AdaptiveBramich"
: Same as Bramich, but with a polynomial variation across the image. It needs the parameterpoly_degree
, which is the polynomial degree of the variation."Alard-Lupton"
: A modulated multi-Gaussian kernel. It needs the gausslist keyword.
- poly_degree – Needed only for AdaptiveBramich. It is the degree of the polynomial for the kernel spatial variation.
- gausslist –
Needed only for Alard-Lupton. A list of dictionaries with info for the modulated multi-Gaussian. Dictionary keys are:
- center: a (row, column) tuple for the center of the Gaussian. Default: kernel center.
- modPolyDeg: the degree of the modulating polynomial. Default: 2
- sx: sigma in x direction. Default: 2.
- sy: sigma in y direction. Deafult: 2.
All keys are optional. Example:
gausslist=[{center: (5, 5), sx: 2., sy: 2., modPolyDeg: 3}, {sx: 1.0, sy: 2.5, modPolyDeg: 1}, {sx: 3.0, sy: 1.0},]
Returns: difference, optimal_image, kernel, background
Raises: EvenSideKernelError
– If any dimension ofkernelshape
is even.- gridshape – A tuple containing the number of vertical and horizontal
divisions of a grid. Subtraction will be performed on each grid
element.