Open KathleenLabrie opened 1 year ago
Probably related to https://github.com/astropy/astropy/pull/14175
Also broken is the multiplication with a file without a mask.
ad_withmask.multiply(ad_nomask)
If I do ad_withmask.multiply(ad_withmask)
, no error. Starting to look more and more like a bug in astropy itself. The propagation of the mask does not take into account that one of the operand might not have a mask.
Completely removing astrodata
from the equation. Just using NDDataRef
now. Either I'm not using it the right way, or there is a bug in astropy
v5.3. I need someone with more knowledge than me to assess that.
>>> import numpy as np
>>> from astropy.nddata import NDDataRef
>>> array = np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]])
>>> mask = np.array([[0, 1, 64], [8, 0, 1], [2, 1, 0]])
>>> nref_nomask = NDDataRef(array)
>>> nref_mask = NDDataRef(array, mask=mask)
# multiply no mask by constant (no mask * no mask)
>>> nref_nomask.multiply(1., handle_mask=np.bitwise_or).mask # returns nothing, no mask
# multiply no mask by itself (no mask * no mask)
>>> nref_nomask.multiply(nref_nomask, handle_mask=np.bitwise_or).mask # return nothing, no mask
# multply mask by constant (mask * no mask)
>>> nref_mask.multiply(1., handle_mask=np.bitwise_or).mask
...
TypeError: unsupported operand type(s) for |: 'int' and 'NoneType'
# multiply mask by itself (mask * mask)
>>> nref_mask.multiply(nref_mask, handle_mask=np.bitwise_or).mask
array([[ 0, 1, 64],
[ 8, 0, 1],
[ 2, 1, 0]])
# multiply mask by no mask (mask * no mask)
>>> nref_mask.multiply(nref_nomask, handle_mask=np.bitwise_or).mask
...
TypeError: unsupported operand type(s) for |: 'int' and 'NoneType'
@chris-simpson @saimn, do you think that this needs reporting to astropy
or am I doing something I shouldn't be doing?
@KathleenLabrie - Yes please open a new issue, with the example to reproduce :+1:
The astrodata multiply method fails with astropy 5.3. It does not fail on a raw file, so it has to be something to do with either the variance or the mask. (Looks like the mask from the error.)
Test file at: https://drive.google.com/drive/folders/1diCPWxBYZ7Dw6SHmGyJkJ2Z3IHxvtyxZ?usp=share_link