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

Support Arithmetic Operations between NDCube and WCS-less NDData #734

Open
DanRyanIrish opened this issue Jun 21, 2024 · 0 comments
Open

Comments

@DanRyanIrish
Copy link
Member

DanRyanIrish commented Jun 21, 2024

Describe the feature

Currently, NDCube does not support arithmetic operations with NDData instances because it does not make sense to combine cubes on different coordinate grids. However, this is not a concern when the NDData instance has a wcs set to None. Therefore, we should support arithmetic operations between NDCube and WCS-less NDData instances. This would serve the cases where users want to NDCube with data with uncertainties and a mask.

Proposed solution

This would need to be explicitly supported in NDCube.__add__ and NDCube.__mul__.

For adding, code needs to be inserted here that checks if not hasattr(value, wcs) or value.wcs is None: and then add then convert the value to the right units ( u.Quantity(value.data, unit=value.unit).to_value(self.unit) ), add the data as masked_arrays, (new_data = np.ma.masked_array(self.data, mask=self.mask) + np.ma.masked_array(value.data, mask=value.mask), and propagate the uncertainties, An example can be seen in NDCube.__pow__ for multipy uncertainty propagation. Also, see astropy.nddata.NDUncertainty.propagate for more info.

A similar structure should work for multiplication somewhere in the codebase around here.

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

No branches or pull requests

1 participant