autowisp.fits_utilities module

Class Inheritance Diagram

Inheritance diagram of BadImageError, DataReductionFile, ImageMismatchError

General use convenience functions for working with FITS images.

autowisp.fits_utilities.get_primary_header(fits_image, add_filename_keywords=False)[source]

Return the primary header of the given image (filename or opened).

Parameters:
  • fits_image – Either the filename or open FITS image to get the primary header of.

  • add_filename_keywords – If True appends to the header keywords parsed from the filename.

Returns:

The first header in the input file with non-zero NAXIS.

Return type:

fits.Header

autowisp.fits_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:

2-D array:

The primary image in the file. Always present.

2-D array:

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.

2-D array:

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.

astropy.io.fits.Header:

The header of the image HDU in the file. This is omitted from the output if read_header == False.

Return type:

(tuple)

autowisp.fits_utilities.update_stack_header(master_header, frame_header, filename, first_time)[source]

Update the master header per header from one of the individual frames.

Should be called once for each frame participating in the stack with the second argument being the header of that frame. The first argument should initially be an empty FITS header, which will get updated each time.

Parameters:
  • master_header – The header to use for the stacked master frame, describing the frames being stacked. On exit contains only keywords shared with frame header and only if their corresponding values match.

  • frame_header – The header of an individual frame being added to the stack.

  • filename – The filename where the header was read from. Only used for reporting errors.

  • first_time – Is this the first time this function is called for the current stack? Subsequent calls remove keywords that are discrepant between current header and the new frame being stacked.

Returns:

None