# Path: skyfield/framelib.py
# def build_matrix():
#     def rotation_at(t):
# def build_ecliptic_matrix(t):
#     def rotation_at(t):
#     def rotation_at(t):
#     def _dRdt_times_RT_at(t):
#     def rotation_at(t):
#     def _dRdt_times_RT_at(t):
#     def rotation_at(self, t):
#     def __init__(self, doc, matrix):
#     def rotation_at(self, t):
# class ICRS(object):
# class true_equator_and_equinox_of_date(object):
# class tirs(object):
# class itrs(object):
# class ecliptic_frame(object):
# class InertialFrame(object):
#         R = mxm(rot_z(-t.gast * tau / 24.0), t.M)
#             R = mxm(t.polar_motion_matrix(), R)
# 
# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/constants.py
# AU_M = 149597870700             # per IAU 2012 Resolution B2
# 
# ERAD = 6378136.6                # meters
# 
# Path: skyfield/positionlib.py
# class Geocentric(ICRF):
#     """An |xyz| 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 |xyz| 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):
#         """Deprecated; instead, call ``.frame_xyz(itrs)``. \
#         See `reference_frames`."""
#         return self.frame_xyz(framelib.itrs)
# 
#     def subpoint(self):
#         """Deprecated; instead, call either ``iers2010.subpoint(pos)`` or \
#         ``wgs84.subpoint(pos)``."""
#         from .toposlib import iers2010
#         return iers2010.subpoint(self)


from numpy import cos
from skyfield import framelib
from skyfield.api import Topos, load, wgs84
from skyfield.constants import AU_M, ERAD
from skyfield.positionlib import Geocentric
    assert round(ra_rate.arcseconds.per_hour * cos(dec.radians),
                 4) == round(75.15571, 4)  # TODO: get last digit to agree?
    assert abs(range_rate.km_per_s - 16.7926932) < 2e-5

    # Verify altitude and azimuth.

    frame = top
    alt, az, distance, alt_rate, az_rate, range_rate = (
        a.frame_latlon_and_rates(frame))

    assert round(alt.degrees, 4) == 65.2758
    assert round(az.degrees, 4) == 131.8839
    assert abs(distance.m - 1.21164331503552 * AU_M) < 120.0

    # Verify altitude and azimuth rates of change.

    assert abs(range_rate.km_per_s - 16.7926932) < 2e-5
    assert round(alt_rate.arcseconds.per_minute, 2) == 548.66
    assert round(az_rate.arcseconds.per_minute * cos(alt.radians), 2) == 663.55

def test_frame_round_trip():
    # Does a frame's rotation and twist get applied in the right
    # directions?  Let's test whether the position and velocity of an
    # ITRS vector (ERAD,0,0) are restored to the proper orientation.
    top = Topos(latitude_degrees=0, longitude_degrees=0)
    ts = load.timescale()
    t = ts.utc(2020, 11, 27, 15, 34)  # Arbitrary time; LST ~= 20.03.
    p = top.at(t)

    r = p.frame_xyz(framelib.itrs)

# Path: skyfield/framelib.py
# def build_matrix():
#     def rotation_at(t):
# def build_ecliptic_matrix(t):
#     def rotation_at(t):
#     def rotation_at(t):
#     def _dRdt_times_RT_at(t):
#     def rotation_at(t):
#     def _dRdt_times_RT_at(t):
#     def rotation_at(self, t):
#     def __init__(self, doc, matrix):
#     def rotation_at(self, t):
# class ICRS(object):
# class true_equator_and_equinox_of_date(object):
# class tirs(object):
# class itrs(object):
# class ecliptic_frame(object):
# class InertialFrame(object):
#         R = mxm(rot_z(-t.gast * tau / 24.0), t.M)
#             R = mxm(t.polar_motion_matrix(), R)
# 
# Path: skyfield/api.py
# N = E = +1.0
# S = W = -1.0
# 
# Path: skyfield/constants.py
# AU_M = 149597870700             # per IAU 2012 Resolution B2
# 
# ERAD = 6378136.6                # meters
# 
# Path: skyfield/positionlib.py
# class Geocentric(ICRF):
#     """An |xyz| 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 |xyz| 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):
#         """Deprecated; instead, call ``.frame_xyz(itrs)``. \
#         See `reference_frames`."""
#         return self.frame_xyz(framelib.itrs)
# 
#     def subpoint(self):
#         """Deprecated; instead, call either ``iers2010.subpoint(pos)`` or \
#         ``wgs84.subpoint(pos)``."""
#         from .toposlib import iers2010
#         return iers2010.subpoint(self)


# Path: skyfield/tests/test_frames.py
from numpy import cos
from skyfield import framelib
from skyfield.api import Topos, load, wgs84
from skyfield.constants import AU_M, ERAD
from skyfield.positionlib import Geocentric

    assert round(ra_rate.arcseconds.per_hour * cos(dec.radians),
                 4) == round(75.15571, 4)  # TODO: get last digit to agree?
    assert abs(range_rate.km_per_s - 16.7926932) < 2e-5

    # Verify altitude and azimuth.

    frame = top
    alt, az, distance, alt_rate, az_rate, range_rate = (
        a.frame_latlon_and_rates(frame))

    assert round(alt.degrees, 4) == 65.2758
    assert round(az.degrees, 4) == 131.8839
    assert abs(distance.m - 1.21164331503552 * AU_M) < 120.0

    # Verify altitude and azimuth rates of change.

    assert abs(range_rate.km_per_s - 16.7926932) < 2e-5
    assert round(alt_rate.arcseconds.per_minute, 2) == 548.66
    assert round(az_rate.arcseconds.per_minute * cos(alt.radians), 2) == 663.55

def test_frame_round_trip():
    # Does a frame's rotation and twist get applied in the right
    # directions?  Let's test whether the position and velocity of an
    # ITRS vector (ERAD,0,0) are restored to the proper orientation.
    top = Topos(latitude_degrees=0, longitude_degrees=0)
    ts = load.timescale()
    t = ts.utc(2020, 11, 27, 15, 34)  # Arbitrary time; LST ~= 20.03.
    p = top.at(t)

    r = p.frame_xyz(framelib.itrs)

    assert max(abs(r.m - [ERAD, 0, 0])) < 4e-8 # meters