Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up masking logic #424

Merged
merged 6 commits into from
Jan 12, 2024
Merged

Clean up masking logic #424

merged 6 commits into from
Jan 12, 2024

Conversation

jeremykubica
Copy link
Contributor

This PR refactors the masking code to clean up the interfaces, but does not change end-to-end behavior. A major part of this change is that most masking operations will now work on the LayeredImage's mask layer. For example, grow_mask will now expand the masked pixels in the mask layer instead of the science layer. LayeredImage's apply_mask() function will then apply the masks to the science and variance layers.

The motivations for these changes are:

  • Support binary masks coming via the standardizers and WorkUnits. These will be cases where all the masking logic is applied when the WorkUnit is constructed.
  • Maintain backwards compatibility with current input files.
  • Consolidate most masking logic in LayeredImage instead of across RawImage, LayeredImage, and ImageStack.
  • Reduce logic in RawImage for possible eventual removal of that class.

More detail on the changes:

LayeredImage: Move the majority of the masking logic into LayeredImage and perform most changes on the mask layer (instead of directly onto science and variance).

RawImage: Remove grow_mask function. All mask changes should be done through LayeredImage and then applied to RawImage with apply_mask().

ImageStack:

  • Remove masking functions that just loop over the individual LayeredImages, such as apply_mask_flags().
  • Remove global mask as an object attribute of ImageStack. Replace it with a function to create a new global mask on-demand. This allows the code to skip allocating a global mask in cases where no global masking is done.

masking.py:

  • Remove the class-based logic. This was added to support use cases that will be covered in the standardizer. We only need to apply the individual functions from LayeredImage and ImageStack. The new flow is much simpler.

run_search.py:

  • Move the masking logic into masking.py.

Closes #415 and #352.

@wilsonbb wilsonbb self-requested a review January 11, 2024 19:08
Copy link
Collaborator

@wilsonbb wilsonbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few nits

src/kbmod/masking.py Show resolved Hide resolved
src/kbmod/search/layered_image.h Outdated Show resolved Hide resolved
src/kbmod/search/pydocs/image_stack_docs.h Outdated Show resolved Hide resolved
tests/test_layered_image.py Outdated Show resolved Hide resolved
tests/test_layered_image.py Outdated Show resolved Hide resolved
@jeremykubica jeremykubica merged commit ecef117 into main Jan 12, 2024
2 checks passed
@jeremykubica jeremykubica deleted the masking2 branch January 12, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support BitMask Masks
2 participants