autowisp.image_utilities module
Class Inheritance Diagram

A collection of functions for working with pipeline images.
- autowisp.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:
2-D array
- autowisp.image_utilities.create_snapshot(fits_fname, snapshot_fname_pattern, *, image_index=0, overwrite=False, skip_existing=False, create_directories=True)[source]
Create a snapshot (e.g. JPEG image) from a fits file in zscale.
- Parameters:
fits_fname (str) – The FITS image to create a snapshot of.
snapshot_fname_pattern (str) – A %-substitution pattern that when filled using the header and the extra keyword FITS_ROOT (set to the filename of the FITS file with path and extension removed) expands to the filename to save the snapshot as.
image_index (int) – Offset from the first non-empty HDU in the FITS file to make a snapshot of.
overwrite (bool) – If a file called snapshot_fname already exists, an OSError is raised if this argument and skip_existing are both False (default). That file is overwritten if this argument is True and skip_existing is False.
skip_existing (bool) – If True and a file already exists with the name determined for the snapshot, this function exists immediately without error.
create_directories (bool) – Whether the script is allowed to create the directories where the output snapshot will be stored. OSError is raised if this argument is False and the destination directory does not exist.
- Returns:
None
- autowisp.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:
The frame pointing information contained in the header.
- Return type:
astropy.coordinates.SkyCoord
- autowisp.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.
- Returns:
The zoomed image.
- Return type:
2-D array