DRAGONS icon indicating copy to clipboard operation
DRAGONS copied to clipboard

ad[0].multiply(1.) fails with astropy 5.3

Open KathleenLabrie opened this issue 1 year ago • 4 comments

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

import astrodata, gemini_instruments

ad = astrodata.open('N20160102S0423_varAdded_crash.fits')
ad[0].multiply(1.)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/klabrie/data/GemKLRepo/activedragons/astrodata/core.py", line 798, in __imul__
    self._standard_nddata_op(NDDataObject.multiply, oper)
  File "/Users/klabrie/data/GemKLRepo/activedragons/astrodata/core.py", line 759, in _standard_nddata_op
    return self._oper(partial(fn, handle_mask=np.bitwise_or,
  File "/Users/klabrie/data/GemKLRepo/activedragons/astrodata/core.py", line 756, in _oper
    ndd[ind[n]] = operator(ndd[ind[n]], operand)
  File "/Users/klabrie/condaenvs/testastropy53/lib/python3.10/site-packages/astropy/nddata/mixins/ndarithmetic.py", line 618, in multiply
    return self._prepare_then_do_arithmetic(
  File "/Users/klabrie/condaenvs/testastropy53/lib/python3.10/site-packages/astropy/nddata/mixins/ndarithmetic.py", line 731, in _prepare_then_do_arithmetic
    result, init_kwds = operand._arithmetic(operation, operand2, **kwargs)
  File "/Users/klabrie/data/GemKLRepo/activedragons/astrodata/nddata.py", line 73, in _arithmetic
    return super()._arithmetic(
  File "/Users/klabrie/condaenvs/testastropy53/lib/python3.10/site-packages/astropy/nddata/mixins/ndarithmetic.py", line 335, in _arithmetic
    kwargs["mask"] = self._arithmetic_mask(
  File "/Users/klabrie/condaenvs/testastropy53/lib/python3.10/site-packages/astropy/nddata/mixins/ndarithmetic.py", line 527, in _arithmetic_mask
    return handle_mask(self.mask, operand.mask, **kwds)
TypeError: unsupported operand type(s) for |: 'int' and 'NoneType'

KathleenLabrie avatar Jun 03 '23 01:06 KathleenLabrie