trust

Finished
88import numpy as np
99import erfa
1010
11from astropy import units as u
1112from astropy.coordinates.baseframe import frame_transform_graph
1213from astropy.coordinates.transformations import FunctionTransformWithFiniteDifference
13from astropy.coordinates.matrix_utilities import matrix_transpose
14from astropy.coordinates.matrix_utilities import rotation_matrix, matrix_transpose
1415
1516from .icrs import ICRS
1617from .gcrs import GCRS, PrecessedGeocentric
1718from .cirs import CIRS
1819from .itrs import ITRS
1920from .equatorial import TEME, TETE
20from .utils import get_polar_motion, get_jd12, EARTH_CENTER
21from .altaz import AltAz
22from .hadec import HADec
23from .utils import get_polar_motion, get_jd12, EARTH_CENTER, PIOVER2
2124
2225# # first define helper functions
2326
272275 return teme_frame.realize_frame(newrepr)
273276
274277
278def itrs_to_observed_mat(observed_frame):
279 """
280 Compute the rotation matrix from ITRS to observed frame (AltAz or HADec).
281
282 Parameters
283 ----------
284 observed_frame : AltAz or HADec
285 The target observed frame
286
287 Returns
288 -------
289 matrix : ndarray
290 3x3 rotation matrix from ITRS to observed frame
291 """
292 lon, lat, height = observed_frame.location.to_geodetic('WGS84')
293 elong = lon.to_value(u.radian)
294
295 if isinstance(observed_frame, AltAz):
296 # form ITRS to AltAz matrix
297 elat = lat.to_value(u.radian)
298 # AltAz frame is left handed
299 minus_x = np.eye(3)
300 minus_x[0][0] = -1.0
301 mat = (minus_x
302 @ rotation_matrix(PIOVER2 - elat, 'y', unit=u.radian)
303 @ rotation_matrix(elong, 'z', unit=u.radian))
304
305 else:
306 # form ITRS to HADec matrix
307 # HADec frame is left handed
308 minus_y = np.eye(3)
309 minus_y[1][1] = -1.0
310 mat = (minus_y
311 @ rotation_matrix(elong, 'z', unit=u.radian))
312 return mat
313
314
315@frame_transform_graph.transform(FunctionTransformWithFiniteDifference, ITRS, AltAz)
316@frame_transform_graph.transform(FunctionTransformWithFiniteDifference, ITRS, HADec)
317def itrs_to_observed(itrs_coo, observed_frame):
318 # Trying to synchronize the obstimes here makes no sense. In fact,
319 # it's a real gotcha as doing an ITRS->ITRS transform references
320 # ITRS coordinates, which should be tied to the Earth, to the SSB.
321 # Instead, we treat ITRS coordinates as time invariant here.
322
323 # form the Topocentric ITRS position
324 topocentric_itrs_repr = (itrs_coo.cartesian
325 - observed_frame.location.get_itrs().cartesian)
326 rep = topocentric_itrs_repr.transform(itrs_to_observed_mat(observed_frame))
327 return observed_frame.realize_frame(rep)
328
329
330@frame_transform_graph.transform(FunctionTransformWithFiniteDifference, AltAz, ITRS)
331@frame_transform_graph.transform(FunctionTransformWithFiniteDifference, HADec, ITRS)
332def observed_to_itrs(observed_coo, itrs_frame):
333 # form the Topocentric ITRS position
334 topocentric_itrs_repr = observed_coo.cartesian.transform(matrix_transpose(
335 itrs_to_observed_mat(observed_coo)))
336 # form the Geocentric ITRS position
337 rep = topocentric_itrs_repr + observed_coo.location.get_itrs().cartesian
338 return itrs_frame.realize_frame(rep)
339
340
275341# Create loopback transformations
276342frame_transform_graph._add_merged_transform(ITRS, CIRS, ITRS)
277343frame_transform_graph._add_merged_transform(PrecessedGeocentric, GCRS, PrecessedGeocentric)
Test NameStatus
astropy/coordinates/tests/test_intermediate_transformations.py::test_itrs_topo_to_altaz_with_refraction
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_itrs_topo_to_hadec_with_refraction
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_itrs_topo
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_itrs_straight_overhead
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_bothroutes[testframe0]
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_bothroutes[testframe1]
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_bothroutes[testframe2]
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_bothroutes[testframe3]
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_bothroutes[testframe4]
Fail
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs[icoo0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs[icoo1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs_dist_diff[gframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs_dist_diff[gframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_to_altaz
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_to_hadec
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_itrs
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_itrs
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_cirs
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_hadec
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_precessed_geocentric
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_precessed_geocentric_different_obstime
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_sunish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_sunish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_sunish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_sunish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_sunish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_moonish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_moonish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_moonish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_moonish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_moonish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_moonish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_moonish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_moonish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_moonish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_moonish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_nodist[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_nodist[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_nodist[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_nodist[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_altaz_nodist[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_icrs_moonish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_icrs_moonish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_icrs_moonish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_icrs_moonish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_icrs_moonish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_icrs_moonish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_icrs_moonish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_icrs_moonish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_icrs_moonish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_icrs_moonish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrscirs_sunish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrscirs_sunish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrscirs_sunish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrscirs_sunish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrscirs_sunish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_altaz_moonish[testframe0]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_altaz_moonish[testframe1]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_altaz_moonish[testframe2]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_altaz_moonish[testframe3]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_altaz_moonish[testframe4]
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_self_transform_closeby
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_teme_itrf
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_precessedgeocentric_loopback
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_teme_loopback
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_tete_transforms
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_straight_overhead
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::test_aa_high_precision_nodata
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::TestGetLocationGCRS::test_get_gcrs_posvel
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::TestGetLocationGCRS::test_tete_quick
Pass
astropy/coordinates/tests/test_intermediate_transformations.py::TestGetLocationGCRS::test_cirs_quick
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.