-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Adding a Time and Quantity works when the Quantity is a scalar and a 1D vector. If the Quantity array is reshaped to a 2D array, an OperandTypeError is thrown.
import astropy.coordinates as c
import astropy.time as t
import astropy.units as u
import numpy as np
base_date = t.Time('2014-01-01')
offsets = np.arange(0,10) * u.day
offsets
Out[7]: <Quantity [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.] d>
base_date + offsets
Out[8]:
<Time object: scale='utc' format='iso' value=['2014-01-01 00:00:00.000' '2014-01-02 00:00:00.000'
'2014-01-03 00:00:00.000' '2014-01-04 00:00:00.000'
'2014-01-05 00:00:00.000' '2014-01-06 00:00:00.000'
'2014-01-07 00:00:00.000' '2014-01-08 00:00:00.000'
'2014-01-09 00:00:00.000' '2014-01-10 00:00:00.000']>
offsets.reshape( (2,5))
Out[9]:
<Quantity [[ 0., 1., 2., 3., 4.],
[ 5., 6., 7., 8., 9.]] d>
base_date + offsets.reshape((2,5))
---------------------------------------------------------------------------
OperandTypeError Traceback (most recent call last)
<ipython-input-10-4402dbceaf11> in <module>()
----> 1 base_date + offsets.reshape((2,5))
C:\Users\bnordgren\AppData\Local\Enthought\Canopy\User\lib\site-packages\astropy\time\core.pyc in __add__(self, other)
993 other = TimeDelta(other)
994 except:
--> 995 raise OperandTypeError(self, other, '+')
996
997 # Tdelta + something is dealt with in TimeDelta, so we have
OperandTypeError: Unsupported operand type(s) for +: 'Time' and 'Quantity'