superphot_pipeline.image_utilities module¶
Class Inheritance Diagram¶

A collection of functions for working with pipeline images.
-
superphot_pipeline.image_utilities.
bin_image
(image, bin_factor)[source]¶ Bins the image to a lower resolution (must be exact factor of image shape).
The output pixels are the sum of the pixels in each bin.
Parameters: - image – The image to bin.
- bin_factor – Either a single integer in which case this is the binning in both directions, or a pair of integers, specifying different binnin in each direction.
Returns: - The binned image with a resolution decreased by the
binning factor for each axis, which has the same total flux as the input image.
Return type: binned_image
-
superphot_pipeline.image_utilities.
get_pointing_from_header
(frame)[source]¶ Return the sky coordinates of this frame’s pointing per its header.
Parameters: frame – The frame to return the pointing of. Could be in one of the following formats:
- string: the filanema of a FITS frame. The pointing information
- is extracted from the header of the first non-trivial HDU.
- HDUList: Same as above, only this time the file is
- already opened.
- astropy.io.fits ImageHDU or TableHDU, containing the header to
- extract the pointing information from.
- asrtopy.io.fits.Header instance: the header from which to
- extract the pointing information.
Returns: - An instance of astropy.coordinates.SkyCoord containing the
- frame pointing information contained in the header.
Return type: pointing
-
superphot_pipeline.image_utilities.
read_image_components
(fits_fname, *, read_image=True, read_error=True, read_mask=True, read_header=True)[source]¶ Read image, its error estimate, mask and header from pipeline FITS file.
Parameters: - fits_fname – The filename of the FITS file to read the componets of. Must have been produced by the pipeline.
- read_image – Should the pixel values of the primary image be read.
- read_error – Should the error extension be searched for and read.
- read_mask – Should the mask extension be searched for and read.
- read_header – Should the header of the image extension be returned.
Returns: The primary image in the file. Always present.
- error: The error estimate of image, identified by IMAGETYP==’error’.
Set to None if none of the extensions have IMAGETYP==’error’. This is omitted from the output if read_error == False.
- mask: A bitmask of quality flags for each image pixel (identified
by IMAGETYP=’mask’). Set to None if none of the extensions have IMAGETYP=’mask’. This is omitted from the output if read_mask == False.
- header: The header of the image HDU in the file. This is omitted from
the output if read_header == False.
Return type: image
-
superphot_pipeline.image_utilities.
zoom_image
(image, zoom, interp_order)[source]¶ Increase the resolution of an image using flux conserving interpolation.
Interpolation is performed using the following recipe:
create a cumulative image (C), i.e. C(x, y) = sum( image(x’, y’), {x’, 0, x}, {y’, 0, y}). Note that C’s x and y resolutions are both bigger than image’s by one with all entries in the first row and the first column being zero.
Interpolate the cumulative image using a bivariate spline to get a continuous cumulative flux F(x, y).
Create the final image I by setting each pixel to the flux implied by F(x, y) from step 2, i.e. if zx is the zoom factor along x and zy is the zoom factor along y:
I(x, y) = F((x+1)/z, (y+1)/z) - F((x+1)/z, y/z) - F(x/z, (y+1)/z) + F(x/z, y/z)
Since this is a flux conserving method, zooming and then binning an image reproduces the original image with close to machine precision.
Parameters: - image – The image to zoom.
- zoom – The factor(s) by which to zoom the image. Should be either an integer defining a common zoom factor both dimensions or a pair of numbers, specifying the zoom along each axis (y first, then x).
- interp_order – The order of the interpolation of the cumulative array.