Hei group,
As an answer to myself:
I ended up with the following routine. Most of the dirty work is actually already implemented in pyorbital:
======================
from pyorbital import astronomy
def ecef_to_eci(xyz,utc_times):
""" Convert ECEF (Earth Centered Earth Fixed) positions to ECI (Earth Centered Inertial)
positions:
XYZ are cartesian positions in ECEF. Should have shape (...,3)
UTC_times are UTC_times. Sould have shape (...)
http://ccar.colorado.edu/ASEN5070/handouts/coordsys.doc
[X] [C -S 0][X]
[Y] = [S C 0][Y]
[Z]eci [0 0 1][Z]ecf
C and S are cos() and sin() of gmst (Greenwich Meridian Sideral Time)
Inspired from satellite-js (
https://github.com/shashwatak/satellite-js)
"""
# XYZ and utc_time must have the same shape
if not xyz.shape[:-1] == utc_times.shape:
raise ValueError("shape mismatch for XYZ and utc_times (got {} and {})".format(xyz.shape[:-1],utc_times.shape))
gmst = -1 * astronomy.gmst(utc_times)
eci = xyz.copy()
eci[:,0] = xyz[:,0]*np.cos(gmst) - xyz[:,1]*np.sin(gmst)
eci[:,1] = xyz[:,0]*np.sin(gmst) + xyz[:,1]*np.cos(gmst)
return eci
======================
This routine could belong to pyorbital/astronomy.py
Things I did not really check:
* the computation of Greenwich Meridian Sidereal Time (GMST) involves UTC times, and thus leap seconds. I am not sure they are correctly treated in the provided gmst routine.
* for some reason, I had to use "-1 * gmst()" in the formula...
Thomas
> --
> You received this message because you are subscribed to the Google Groups
> "pytroll" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
pytroll+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
>