Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# TODO: wobble
position_au = einsum('ij...,j...->i...', R, position_au)
r_au, alt, az = to_polar(position_au)
if temperature_C is None:
alt = Angle(radians=alt)
else:
if temperature_C == 'standard':
temperature_C = 10.0
if pressure_mbar == 'standard':
pressure_mbar = 1010.0 * exp(-elevation_m / 9.1e3)
alt = refract(alt * RAD2DEG, temperature_C, pressure_mbar)
alt = Angle(degrees=alt)
return alt, Angle(radians=az), Distance(r_au)
def distance(self):
"""Compute the distance from the origin to this position.
>>> v = ICRF([1, 1, 0])
>>> print(v.distance())
1.41421 au
"""
return Distance(length_of(self.position.au))
def galactic_xyz(self):
"""Compute galactic coordinates (x,y,z)"""
vector = _GALACTIC.dot(self.position.au)
return Distance(vector)
Reference Frame (ITRF), an internationally agreed upon
Earth-centered Earth-fixed (ECEF) coordinate system that
rotates with the surface of the Earth itself.
"""
if self.center != 399:
raise ValueError("you can only ask for an Earth-centered position"
" to be converted into an ITRF coordinate")
t = self.t
au = mxv(t.M, self.position.au)
spin = rot_z(- t.gast * tau / 24.0)
au = mxv(spin, array(au))
return Distance(au)
def ecliptic_latlon(self, epoch=None):
"""Compute J2000 ecliptic coordinates (lat, lon, distance)
If you instead want the coordinates referenced to the dynamical
system defined by the Earth's true equator and equinox, provide
an epoch time.
"""
vector = self.ecliptic_xyz(epoch)
d, lat, lon = to_spherical(vector.au)
return (Angle(radians=lat, signed=True),
Angle(radians=lon),
Distance(au=d))
raise TypeError('please provide either latitude_degrees='
' or latitude='
' with north being positive')
if longitude_degrees is not None:
longitude = Angle(degrees=longitude_degrees)
elif isinstance(longitude, (str, float, tuple)):
longitude = _interpret_ltude(longitude, 'longitude', 'E', 'W')
elif not isinstance(longitude, Angle):
raise TypeError('please provide either longitude_degrees='
' or longitude='
' with east being positive')
self.latitude = latitude
self.longitude = longitude
self.elevation = Distance(m=elevation_m)
self.x = x
self.y = y
self.R_lat = rot_y(latitude.radians)[::-1]
self.target = str(self)
def _to_spice_frame(self, name):
vector = self.position.au
vector = inertial_frames[name].dot(vector)
d, dec, ra = to_polar(vector)
return (Angle(radians=ra, preference='hours', signed=True),
Angle(radians=dec),
Distance(au=d))
def length(self):
"""Compute the length when this is an x,y,z vector.
The Euclidean vector length of this vector is returned as a new
:class:`~skyfield.units.Distance` object.
>>> from skyfield.api import Distance
>>> d = Distance(au=[1, 1, 0])
>>> d.length()
"""
return Distance(au=length_of(self.au))
def __init__(self, position_au, velocity_au_per_d=None, t=None,
center=None, target=None, observer_data=None):
self.t = t
self.position = Distance(position_au)
if velocity_au_per_d is None:
self.velocity = None
else:
self.velocity = Velocity(velocity_au_per_d)
# TODO: are center and target useful? Then why are they not
# propagated down to Astrometric and Apparent positions?
self.center = center
self.target = target
self.observer_data = observer_data
def frame_latlon(self, frame):
"""Return as longitude, latitude, and distance in the given frame."""
R = frame.rotation_at(self.t)
vector = mxv(R, self.position.au)
d, lat, lon = to_spherical(vector)
return (Angle(radians=lat, signed=True),
Angle(radians=lon),
Distance(au=d))