[AstroPy] Summing an array
Homeier, Derek
dhomeie at gwdg.de
Mon Jul 11 10:10:33 EDT 2022
On 11 Jul 2022, at 3:03 pm, Rudolf Baer <rbaer25 at gmail.com> wrote:
>
> I have not been able to sum an array; the array is created as follows
>
This is really a pure numpy issue, but it looks like something in your numpy installation is broken or overwritten in the `np` namespace.
> rpflux = np.array(rpflux, dtype=float)
> rpflux=np.zeros(len(rptime),dtype='float64')
The above is redundant btw. as np.genfromtxt will create, populate and return the array on the fly
(and simply replace your previously created objects).
> rpflux=np.genfromtxt(path,delimiter=',',dtype="float64",autostrip=True,skip_header=137,skip_footer=0, usecols=(19))
> print(rpflux.astype('float64'))
> [3140. nan 2770. 3080. 3170. 3050. 3060.
> 3100. 2990. 3120. 3060. nan 3100. 3070.
> 3020. nan 3200. 3150. 3350. 2990. 2910.
> 2920. 3030. 3000. 2800. 2980. 2860. 2840.
> 2610. 2650. 2610. 2650. 2490. 2490. 2540.
> 2510. 2470. nan nan 35. nan 3099.
> nan ]
>
>
> print (np.sum(rpflux))
> and
> print (np.sum([rpflux]))
> result in
> 'numpy.ndarray' object is not callable'
>
Could you post some details on your Numpy installation as well?
print(np.version.version)
print(np.sum.__class__)
print(np.sum.__name__)
print(np.sum.__module__)
print(rpflux.sum())
On another note, you’ll probably want to use `np.nansum()` on those particular data.
HTH
Derek
More information about the AstroPy
mailing list