MaskCollection Class

Open
#257 1 comment 0 reactions 1 assignee View on GitHub

@DanRyanIrish is already working on this.

Since Apr 7, 2020.

Assessment

This issue has not been assessed yet.

Description

Feature Request new feature
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
  • MaskCollection inherits from dict.
  • Mask components are stored as boolean arrays or Mask objects where:
    • Mask.mask is a boolean array
    • Mask.meta is 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 of masks which is a list of key values of masks within the collection.
  • MaskCollection.mask_or(masks): same as MaskCollection.mask_and(masks) except that a logical OR combination is returned.
  • MaskCollection.mask is a property returning a combined mask using the conditions defined in MaskCollection._mask_defaults.
  • MaskCollection._mask_defaults: a **kwargs-like dictionary defining how the MaskCollection.mask is computed.
    • MaskCollection._mask_defaults.masks: list of key names of masks to be combined.
    • MaskCollection._mask_defaults.func(): The function via which the masks are to be combined.
      • Must take MaskCollection._mask_defaults.masks as the input.
      • Can be as simple as self.mask_or() or a complicated combination combining different masks differently.
      • Default is self.mask_or
  • MaskCollection.set_mask_defaults(masks=None, func=None): a method allowing users to set the defaults in MaskCollection._mask_defaults.
Additional context
Dominant language
Python
Stars
49
Forks
56
Avg merge
5h 54m
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sunpy/ndcube

All issues in sunpy/ndcube

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.