MaskCollection Class
Description
Currently, the NDCube.mask implementation is simply a boolean array. However I there may be many components to a mask and in some cases users may want to keep them separate, e.g. parts of the CCD not illuminated, dusk in the optical path, cosmic rays hits, and also feature masks, e.g. active region, of flare.
Is there currently a class out there, e.g. MaskCollection, that can store all these components and return a master mask which is a combination of them all a a subset of them. If not, implementing one might not be so hard.
Proposed implementation
MaskCollectioninherits fromdict.- Mask components are stored as boolean arrays or
Maskobjects where:Mask.maskis a boolean arrayMask.metais a dictionary-like including a description/info entry giving more info on what the mask represents.
MaskCollection.mask_and(masks)is a method returning a logical AND combination ofmaskswhich is a list ofkeyvalues of masks within the collection.MaskCollection.mask_or(masks): same asMaskCollection.mask_and(masks)except that a logical OR combination is returned.MaskCollection.maskis a property returning a combined mask using the conditions defined inMaskCollection._mask_defaults.MaskCollection._mask_defaults: a **kwargs-like dictionary defining how theMaskCollection.maskis computed.MaskCollection._mask_defaults.masks:listofkeynames of masks to be combined.MaskCollection._mask_defaults.func(): The function via which the masks are to be combined.- Must take
MaskCollection._mask_defaults.masksas the input. - Can be as simple as
self.mask_or()or a complicated combination combining different masks differently. - Default is
self.mask_or
- Must take
MaskCollection.set_mask_defaults(masks=None, func=None): a method allowing users to set the defaults inMaskCollection._mask_defaults.
Additional context
@mwcraig, given your comment on astropy issue 11176 perhaps this feature might be of interest to nddata. Let me know if you have any thoughts.