pythoncoordinate-systemscoordinate-transformationcoordinateastropy

How to convert Earth Centered Inertial (ECI) coordinates to Earth Centered Earth Fixed (ECEF) AstroPy? Other?


I have position (x,y,z) and velocity (Vx,Vy,Vz) vectors in Earth Centered Inertial Coordinates (ECI) for a satellite orbit, and ultimately want to end up with geodetic coordinates (Latitude, Longitude, & Altitude).

According to this other Stack Overflow question it seems that I need to convert to Earth Centered Earth Fixed (ECEF) coordinates as an intermediate step (so ECI --> ECEF --> Lat/Lon/Alt).

I know ECI and ECEF share the same origin point (the center of mass of Earth) and the same z-axis that points to the North Pole. However, I am not sure what actual equations or adjustments I need to do to convert ECI to ECEF.

Otherwise, if anyone knows of any canned conversions on Astropy or something similar that would be even better. (I haven't seen ECI as an option on Astro Py or Space Py).

Here is the code I am using to generate my orbit and get the position and velocity vectors.

from scipy.constants import kilo
import orbital
from orbital import earth, KeplerianElements, Maneuver, plot, utilities
from orbital.utilities import Position, Velocity  
import matplotlib.pyplot as plt
import numpy as np

orbitPineapple = KeplerianElements.with_period(5760, body=earth, 
e=0.05, i=(np.deg2rad(0)), arg_pe=(np.deg2rad(30)))
plot(orbitPineapple)
plt.show()
print(orbitPineapple.r)
print(orbitPineapple.v)

Out: Position(x=5713846.540659178, y=3298890.8383577876, z=0.0) Velocity(x=-3982.305479346745, y=6897.555421488496, z=0.0)


Solution

  • There are a number of different Earth Centered Inertial frames, and the answer depends on which one you have your coordinates in.

    The most common is so-called J2000; which is defined w.r.t to the orientation of the Earth on Jan 1st 2000. Another common one is GCRF, which is almost the same (to within 80 milli arcseconds).

    If it’s either of those two, you should be able to create an astropy EarthLocation object and access the lat, lon and height attributes like so

    from astropy import coordinates as coord
    from astropy import units as u
    from astropy.time import Time
    now = Time('2017-09-27 12:22:00')
    # position of satellite in GCRS or J20000 ECI:
    cartrep = coord.CartesianRepresentation(x=5713846.540659178, 
                                            y=3298890.8383577876,
                                            z=0., unit=u.m)
    gcrs = coord.GCRS(cartrep, obstime=now)
    itrs = gcrs.transform_to(coord.ITRS(obstime=now))
    loc = coord.EarthLocation(*itrs.cartesian.cartrep )
    print(loc.lat, loc.lon, loc.height)