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

BUG: Mask cube is ignored in Cubeviz spectral extraction #2714

Open
pllim opened this issue Feb 19, 2024 · 2 comments
Open

BUG: Mask cube is ignored in Cubeviz spectral extraction #2714

pllim opened this issue Feb 19, 2024 · 2 comments
Labels
bug Something isn't working cubeviz plugin Label for plugins common to multiple configurations

Comments

@pllim
Copy link
Contributor

pllim commented Feb 19, 2024

The current documentation (at the time of original posting this issue) at https://jdaviz.readthedocs.io/en/latest/cubeviz/plugins.html#spectral-extraction does not mention at all how uncertainty and mask arrays are used in the extraction process. The uncertainty is yet another issue (#2713); here I am only focusing on mask:

nddata = spectral_cube.get_subset_object(
subset_id=self.aperture.selected, cls=NDDataArray
)

This was originally implemented by @bmorris3 via #2039 . In the code above, mask only takes account of the selected aperture (if any). However, our parser reads in a whole cube array that has the bitmask plane:

mask=['mask', 'dq', 'quality'])

While there is code to stuff the mask into Spectrum1D object, not all parser logic routes seem to trigger it (how Spectrum1D handle a bitplane is another story):

As a result, aperture seems to solely define the mask, while the actual mask cube is ignored. How is a user supposed to mask out certain bad pixels from extraction (in addition to the aperture)?

ADDITIONAL REQUIREMENT: When MASK cube does not exist, the extraction should not crash and treat all pixels as "good".

🐱

@pllim pllim added bug Something isn't working cubeviz plugin Label for plugins common to multiple configurations labels Feb 19, 2024
@bmorris3
Copy link
Contributor

bmorris3 commented Feb 19, 2024

The subset choice of the selected aperture was implemented in #2664. I think the simplest solution for now is to translate to NDDataArray with

nddata = spectral_cube.get_object(cls=NDDataArray)

without specifying the subset, to get the original mask cube for the full dataset. Then we can call to_mask on the aperture's glue subset, and take the logical-and with the full mask, something like:

nddata.mask &= ~aperture_subset.to_mask()  # the ~ may be needed b/c glue subset masks are "backwards"

How does that sound?

@pllim
Copy link
Contributor Author

pllim commented Feb 19, 2024

Maybe related?

#2679 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cubeviz plugin Label for plugins common to multiple configurations
Projects
None yet
Development

No branches or pull requests

2 participants