[AstroPy] numpy.arange and quantities

Leonard Burtscher burtscher at strw.leidenuniv.nl
Tue Nov 29 04:07:16 EST 2016


Hi Ole,

r=np.arange(0,9,0.1)*u.km

works.

Best,
Leo

> Am 29.11.2016 um 09:39 schrieb Ole Streicher <astropy at liska.ath.cx>:
> 
> Hi,
> 
> how can I create a sequence of quantities, when start, end, and step are
> given?
> 
> The simplest approach doesn't work (astropy 1.2.1):
> 
>>>> import numpy
>>>> import astropy.units as u
>>>> z0 = 0
>>>> z1 = 9 * u.km
>>>> dz = 100 * u.m
>>>> r = numpy.arange(z0, z1, dz)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ValueError: setting an array element with a sequence.
> 
> Best regards
> 
> Ole
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy

--
http://strw.leidenuniv.nl/~burtscher






More information about the AstroPy mailing list