astrowisp.hat_masks module
Utilities for working with HAT-style masks in FITS headers.
- astrowisp.hat_masks.parse_hat_mask(header)[source]
Extract the HAT-style mask contained in header.
- Parameters:
header – The header of the image whose mask to parse.
- Returns:
array with exactly the same resolution as the input image containing a bit-field for each pixel indicating any bad-pixel flags raised per the header.
- Return type:
numpy.array(dtype=uint8)
Examples
>>> from astropy.io import fits >>> >>> with fits.open('/Users/kpenev/tmp/1-447491_4.fits.fz', >>> mode='readonly') as f: >>> image_mask = parse_hat_mask(f[1].header) >>> >>> flag_name = 'OVERSATURATED' >>> >>> matched = numpy.bitwise_and(image_mask, >>> mask_flags[flag_name]).astype(bool) >>> >>> #Print number of pixels for which the OVERSATURATED flag is >>> #raised >>> print(flag_name + ': ' + repr(matched.sum())) >>> >>> #Output x, y, flux for the pixels flagged as OVERSATURATED >>> for y, x in zip(*numpy.nonzero(matched)): >>> print('%4d %4d %15d' % (x, y, f[1].data[y, x]))