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.
A similar structure should work for multiplication somewhere in the codebase around here.
Describe the feature
Currently,
NDCube
does not support arithmetic operations withNDData
instances because it does not make sense to combine cubes on different coordinate grids. However, this is not a concern when theNDData
instance has awcs
set toNone
. Therefore, we should support arithmetic operations betweenNDCube
and WCS-lessNDData
instances. This would serve the cases where users want toNDCube
with data with uncertainties and a mask.Proposed solution
This would need to be explicitly supported in
NDCube.__add__
andNDCube.__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 inNDCube.__pow__
for multipy uncertainty propagation.A similar structure should work for multiplication somewhere in the codebase around here.