Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

```
def __sub__(self, body):
"""Subtract two ICRF vectors to produce a third."""
# TODO: set center and target of result
p = self.position.au - body.position.au
if self.velocity is None or body.velocity is None:
v = None
else:
v = body.velocity.au_per_d - self.velocity.au_per_d
return ICRF(p, v, self.t)
```

```
include_earth_deflection = array((False,))
else:
limb_angle, nadir_angle = compute_limb_angle(
position_au, gcrs_position)
include_earth_deflection = nadir_angle >= 0.8
add_deflection(position_au, observer_data.bcrs_position,
observer_data.ephemeris, t, include_earth_deflection)
add_aberration(position_au, observer_data.bcrs_velocity,
self.light_time)
return Apparent(position_au, t=t, observer_data=observer_data)
class Apparent(ICRF):
"""An apparent (x, y, z) position relative to a particular observer.
The *apparent position* of a body is its position relative to an
observer adjusted for light-time delay, deflection (light rays
bending as they pass large masses like the Sun or Jupiter), and
aberration (light slanting because of the observer's motion through
space).
Included in aberration is the relativistic transformation that takes
the position out of the BCRS centered on the solar system barycenter
and into the reference frame of the observer. In the case of an
Earth observer, the transform takes the coordinate into the GCRS.
"""
def altaz(self, temperature_C=None, pressure_mbar='standard'):
"""Compute (alt, az, distance) relative to the observer's horizon
```

```
>>> earth.at(t).observe(mars)
"""
p, v, t, light_time = body._observe_from_bcrs(self)
astrometric = Astrometric(p, v, t,
center=self.target, target=body.target,
observer_data=self.observer_data)
astrometric.light_time = light_time
return astrometric
# TODO: pre-create a Barycentric object representing the SSB, and make
# it possible for it to observe() a planet.
class Astrometric(ICRF):
"""An astrometric (x,y,z) position relative to a particular observer.
The *astrometric position* of a body is its position relative to an
observer, adjusted for light-time delay. It is the position of the
body back when it emitted (or reflected) the light that is now
reaching the observer's eyes or telescope.
Both the ``.position`` and ``.velocity`` are (x,y,z) vectors
oriented along the axes of the International Terrestrial Reference
Frame (ITRF), the modern replacement for J2000 coordinates.
Astrometric positions are usually generated in Skyfield by calling
the `Barycentric` method `observe()` to determine where a body will
appear in the sky relative to a specific observer.
"""
```

```
else:
limb_angle, nadir_angle = compute_limb_angle(
target_au, gcrs_position)
include_earth_deflection = nadir_angle >= 0.8
add_deflection(target_au, bcrs_position,
observer_data.ephemeris, t, include_earth_deflection)
add_aberration(target_au, bcrs_velocity, self.light_time)
return Apparent(target_au, t=t,
center=self.center, target=self.target,
observer_data=observer_data)
class Apparent(ICRF):
"""An apparent (x,y,z) position relative to a particular observer.
The *apparent position* of a body is its position relative to an
observer adjusted for light-time delay, deflection (light rays
bending as they pass large masses like the Sun or Jupiter), and
aberration (light slanting because of the observer's motion through
space).
Included in aberration is the relativistic transformation that takes
the ``.position`` and ``.velocity`` (x,y,z) vectors out of the BCRS,
centered on the Solar System barycenter, and into the reference
frame of the observer. In the case of an Earth observer, the
transform takes the coordinate into the GCRS.
"""
def altaz(self, temperature_C=None, pressure_mbar='standard'):
```

```
>>> earth.at(t).observe(mars)
"""
p, v, light_time = body._observe_from_bcrs(self)
t = self.t
astrometric = Astrometric(p, v, t, observer_data=self.observer_data)
astrometric.light_time = light_time
return astrometric
# TODO: pre-create a Barycentric object representing the SSB, and make
# it possible for it to observe() a planet.
class Astrometric(ICRF):
"""An astrometric (x, y, z) position relative to a particular observer.
The *astrometric position* of a body is its position relative to an
observer, adjusted for light-time delay: the position of the body
back when it emitted (or reflected) the light that is now reaching
the observer's eyes or telescope.
Astrometric positions are usually generated in Skyfield by calling
the `Barycentric` method `observe()` to determine where a body will
appear in the sky relative to a specific observer.
"""
def apparent(self):
"""Compute an :class:`Apparent` position for this body.
This applies two effects to the position that arise from
```

```
high the atmosphere might lift the body's image, give the
argument ``temperature_C`` either the temperature in degrees
centigrade, or the string ``'standard'`` (in which case 10°C is
used).
When calculating refraction, Skyfield uses the observer’s
elevation above sea level to estimate the atmospheric pressure.
If you want to override that value, simply provide a number
through the ``pressure_mbar`` parameter.
"""
return _to_altaz(self.position.au, self.observer_data,
temperature_C, pressure_mbar)
class Geocentric(ICRF):
"""An (x,y,z) position measured from the center of the Earth.
A geocentric position is the difference between the position of the
Earth at a given instant and the position of a target body at the
same instant, without accounting for light-travel time or the effect
of relativity on the light itself.
Its ``.position`` and ``.velocity`` vectors have (x,y,z) axes that
are those of the Geocentric Celestial Reference System (GCRS), an
inertial system that is an update to J2000 and that does not rotate
with the Earth itself.
"""
_default_center = 399
def itrf_xyz(self):
```

```
def __sub__(self, body):
"""Subtract two ICRF vectors to produce a third."""
# TODO: set center and target of result
p = self.position.au - body.position.au
if self.velocity is None or body.velocity is None:
v = None
else:
v = self.velocity.au_per_d - body.velocity.au_per_d
return ICRF(p, v, self.t)
```

```
' knows the orientation of the horizon'
' and can understand altitude and azimuth')
alt = _interpret_angle('alt', alt, alt_degrees)
az = _interpret_angle('az', az, az_degrees)
r = 0.1 # close enough to make gravitational refraction irrelevant
p = from_polar(r, alt, az)
p = einsum('ji...,j...->i...', R, p)
return Apparent(p)
# For compatibility with my original name for the class. Not an
# important enough change to warrant a deprecation error for users, so:
ICRS = ICRF
class Geometric(ICRF):
"""An (x,y,z) vector between two instantaneous position.
A geometric position is the difference between the Solar System
positions of two bodies at exactly the same instant. It is *not*
corrected for the fact that, in real physics, it will take time for
light to travel from one position to the other.
"""
def altaz(self, temperature_C=None, pressure_mbar='standard'):
"""Compute (alt, az, distance) relative to the observer's horizon
The altitude returned is an `Angle` in degrees above the
horizon, while the azimuth is the compass direction in degrees
with north being 0 degrees and east being 90 degrees.
"""
```

```
light to travel from one position to the other.
"""
def altaz(self, temperature_C=None, pressure_mbar='standard'):
"""Compute (alt, az, distance) relative to the observer's horizon
The altitude returned is an `Angle` in degrees above the
horizon, while the azimuth is the compass direction in degrees
with north being 0 degrees and east being 90 degrees.
"""
return _to_altaz(self.position.au, self.observer_data,
temperature_C, pressure_mbar)
class Barycentric(ICRF):
"""An (x, y, z) position measured from the Solar System barycenter.
Each barycentric position is an ICRS position vector, meaning that
the coordinate axes are defined by the high-precision ICRF that has
replaced the old J2000.0 reference frame, and the coordinate origin
is the BCRS gravitational center of the Solar System.
Skyfield generates a `Barycentric` position whenever you ask a Solar
System body for its location at a particular time:
>>> t = ts.utc(2003, 8, 29)
>>> mars.at(t)
"""
def observe(self, body):
```

```
def build_position(position_au, velocity_au_per_d=None, t=None,
center=None, target=None, observer_data=None):
if center == 0:
cls = Barycentric
elif center == 399:
cls = Geocentric
elif observer_data is not None:
cls = Geometric
else:
cls = ICRF
return cls(position_au, velocity_au_per_d, t, center, target, observer_data)
```