in metropolis/utils/geo.py [0:0]
def ecef_from_topocentric_transform(lat, lon, alt):
"""
Transformation from a topocentric frame at reference position to ECEF.
The topocentric reference frame is a metric one with the origin
at the given (lat, lon, alt) position, with the X axis heading east,
the Y axis heading north and the Z axis vertical to the ellipsoid.
>>> a = ecef_from_topocentric_transform(30, 20, 10)
>>> b = ecef_from_topocentric_transform_finite_diff(30, 20, 10)
>>> np.allclose(a, b)
True
"""
x, y, z = ecef_from_lla(lat, lon, alt)
sa = np.sin(np.radians(lat))
ca = np.cos(np.radians(lat))
so = np.sin(np.radians(lon))
co = np.cos(np.radians(lon))
return np.array(
[
[-so, -sa * co, ca * co, x],
[co, -sa * so, ca * so, y],
[0, ca, sa, z],
[0, 0, 0, 1],
]
)