Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ssatk/coordinates/geodetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def llh_to_gcrf(lon: float, lat: float, t: Time, height: float = 0.0, *, allow_p


def surface_rv(lon, lat, elevation=0.0, t=Time(0, format="gps", scale="utc")):
"""Return GCRF position and velocity of a surface point from Astropy."""
"""Return a WGS84 site's GCRF state using the shared Earth-rotation route."""
return astropy_surface_rv(lon=lon, lat=lat, elevation=elevation, t=t)


Expand Down
20 changes: 8 additions & 12 deletions ssatk/yastropy/astropy_surface_rv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from astropy.time import Time
import numpy as np

from .astropy_llh_to_gcrf import astropy_llh_to_gcrf


def astropy_surface_rv(lon, lat, elevation=0.0, t=Time(0, format="gps", scale="utc")):
Expand All @@ -25,14 +22,13 @@ def astropy_surface_rv(lon, lat, elevation=0.0, t=Time(0, format="gps", scale="u
Position vector in GCRF coordinates (m).
v : ndarray, shape (3,)
Velocity vector in GCRF coordinates (m/s).
"""
# Position in GCRF (meters)
r_gcrf = astropy_llh_to_gcrf(lon, lat, t, alt=elevation).reshape(3)

# Earth's angular velocity vector (rad/s)
omega_earth = np.array([0.0, 0.0, 7.2921150e-5]) # rotation about Z-axis

# Velocity in GCRF: v = omega × r
v_gcrf = np.cross(omega_earth, r_gcrf)
Uses :func:`ssatk.coordinates.geodetic.llh_to_gcrf`: a WGS84 site fixed
in ITRF, transformed with the shared IAU 2006/2000A rotation and its
time derivative. Epochs outside the packaged EOP table use the nearest
record and emit an EarthOrientationExtrapolationWarning.
"""
# Geodetic imports this module, so resolve the shared route at call time.
from ..coordinates.geodetic import llh_to_gcrf

return r_gcrf, v_gcrf
return llh_to_gcrf(lon, lat, t, height=elevation)
17 changes: 14 additions & 3 deletions tests/test_time_and_yastropy_helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Specified rigid-Earth cross product: 1e-10 m/s absolute arithmetic budget; not measured velocity.
import numpy as np
import astropy.units as u
from astropy.coordinates import EarthLocation
from astropy.time import Time

from astropy.utils import iers
from ssatk.data import data_path
from ssatk.yastropy.astropy_gcrf_to_llh import astropy_gcrf_to_llh
from ssatk.yastropy.astropy_llh_to_gcrf import astropy_llh_to_gcrf
from ssatk.yastropy.astropy_surface_rv import astropy_surface_rv
Expand All @@ -21,4 +23,13 @@ def test_astropy_llh_gcrf_roundtrip_and_surface_velocity():
assert r_surface.shape == (3,)
assert v_surface.shape == (3,)
assert np.isclose(np.linalg.norm(r_surface), 6_378_137.0, rtol=0, atol=1e-6)
np.testing.assert_allclose(v_surface, np.cross([0.0, 0.0, 7.2921150e-5], r_surface), rtol=0, atol=1e-10)

# R2: Astropy's independent transform, scoped to the packaged EOP.
# Use the core route's 2e-4 m/s budget for finite-difference roundoff
# and Astropy's omission of the celestial-pole offsets.
with data_path("environment/eop/finals2000A.all") as path:
table = iers.IERS_A.open(str(path))
with iers.conf.set_temp("auto_download", False), iers.earth_orientation_table.set(table):
reference = EarthLocation.from_geodetic(0 * u.deg, 0 * u.deg).get_gcrs(time)
v_ref = reference.cartesian.differentials["s"].d_xyz.to_value(u.m / u.s)
np.testing.assert_allclose(v_surface, v_ref, rtol=0, atol=2e-4)