mask module

A module providing facilities for creating masking arrays for all-sky images.

This module contains methods to create three different kinds of masking arrays. The masks are as follows:

  • One that masks hot pixels
  • One that masks hot pixels and any horizon objects
  • One that masks hot pixels, horizon objects and everything outside the circular image.

Further methods are provided to save a given mask as an image, and to apply a masking array to an image.

mask.apply_mask(mask, img)[source]

Apply a mask to a given image.

Parameters:
Returns:

The masked image, where masked pixels have been set to 0.

Return type:

image.AllSkyImage

Notes

In order to apply a mask, it is inverted and then multiplied by the image. This zeroes out the masked pixels while leaving the non masked pixels untouched. In a rigorous analysis of the image, the masked pixels will count as zeroes. In these cases it is better to use the generated mask in conjunction with NumPy”s masked arrays to complete ignore the pixels you want to mask, instead of setting them to 0.

mask.generate_clean_mask()[source]

Generate a clean mask for KPNO images.

Generates a masking array for KPNO images that only masks out hot pixels.

Returns:The mask array where 1 represents pixels that are to be masked and 0 represents pixels that should remain visible.
Return type:numpy.ndarray

Notes

generate_clean_mask requires there to be median images in Images/mask/. These images can be downloaded from the kpno-allsky github or may be generated by median.median_all_date and moved.

mask.generate_full_mask(forcenew=False)[source]

Generates a complete mask for KPNO images.

Generates a masking array for KPNO images that masks out not only hot pixels, but also the horizon objects and then additionally masks pixels outside of the circular all-sky image.

Parameters:forcenew (bool, optional) – Whether or not this method should load a previously saved mask or if it should generate it completely from scratch.
Returns:The mask array where 0 represents pixels that are to be masked and 1 represents pixels that should remain visible.
Return type:numpy.ndarray

See also

generate_mask()
Used by generate_full_mask to generate the hot pixel and horizon mask.

Notes

generate_full_mask calls generate_mask, which requires there to be median images in Images/mask/ but also additionally requires an image named Ignore.png in Images/ that deliniates the horizon objects to be ignored. These images can be downloaded from the kpno-allsky github.

mask.generate_mask(forcenew=False)[source]

Generate a mask for KPNO images.

Generates a masking array for KPNO images that masks out not only hot pixels, but also the horizon objects.

Parameters:forcenew (bool, optional) – Whether or not this method should load a previously saved mask or if it should generate it completely from scratch.
Returns:The mask array where 1 represents pixels that are to be masked and 0 represents pixels that should remain visible.
Return type:numpy.ndarray

See also

generate_clean_mask()
Used by generate_mask to generate the hot pixel mask.

Notes

generate_mask requires there to be median images in Images/mask/ but also additionally requires an image named Ignore.png in Images/ that deliniates the horizon objects to be ignored. These images can be downloaded from the kpno-allsky github or may be generated by median.median_all_date and moved.

mask.save_mask(mask)[source]

Save a masking image.

Parameters:mask (numpy.ndarray) – The mask to save.

See also

image.save_image()
Save an image.