问题
What is the quickest/most efficient way to convert a np.ndarray (importing numpy as np) into the astropy.coordinates.Angle class? I am having trouble keeping it as np.ndarray because the .wrap_at() operation will not work.
回答1:
What exactly is your intention? np.asarray
is quite ambiguous. If you are dealing with np.ndarray
it is quite easy:
from astropy.coordinates import Angle
import astropy.units as u
import numpy as np
angles = np.array([100,200,300,400])
angles_quantity = a * u.degree # Could also be u.radian, u.arcmin, etc.
Angle(angles_quantity).wrap_at('360d')
But I'm not really sure if that solves your problem.
Converting such an Angle
object back to a simple np.ndarray
can be done with the .value
attribute:
Angle(angles_quantity).wrap_at('360d').value # This returns a simple ndarray again.
来源:https://stackoverflow.com/questions/35094743/how-to-covert-np-ndarray-into-astropy-coordinates-angle-class