pymgp.satorb.ecef2eci#
- pymgp.satorb.ecef2eci(t, xsate, vsate=[])[source]#
Convert position and velocity from ECEF to ECI reference frame.
Convert position and velocity given in an Earth Centered Earth Fixed (ECEF) reference frame into a non-rotating pseudo-inertial Earth Centered Inertial (ECI) reference frame.
- Parameters:
- tarray_like with shape (n,) or scalar, of type datetime64, str or float
Universal time as datetime64 object, ISO date string or sequential date number (days since 1970-01-01).
- xsatearray_like with shape (…,n,3) or (…,n,6), or, shape (3,) or (6,)
Array with Cartesian coordinates (m) or state vector with positions (m) and velocities (m/s) in an ECEF reference frame .
- vsatearray_like with shape (…,n,3), optional
Array with velocities in ECEF reference frame (m/s). If empty, velocities are taken from ‘xsate[…,3:6]’, or if xsate has shape (…,n,3) or (3,) velocities are assumed to be zero (e.g. non-moving points on the Earth surface)
- Returns:
- xsatndarray with shape (…,n,3) or shape (…,n,6)
Array with Cartesian coordinates (m) or state vector with positions (m) and velocities (m/s) in ECI reference frame.
- vsatndarray with shape (…,n,3), optional
Array with velocities in ECI reference frame (m/s), only if xsat is not a state vector.
Notes
The function returns a single ndarray xsat with the ECI state vector when the parameter xsate is a state vector (having 6 elements). Otherwise, it returns two ndarrays.
If the parameter xsate has shape (3,) or (…,1,3), and parameter t has shape (n,) with ‘n > 1’, then xsate is extended to match the length of t.
The function always returns ndarrays with at least two dimensions.
Examples
Example with single statevector (note the two dimensional result(s))
>>> ecef2eci('2012-01-04 15:00:00',[ -3312531.1007, -5646883.8176, 2737195.4374, 5670.7751, -3969.9994, -1280.2560 ]) array([[-5.76770178e+06, -3.09738201e+06, 2.73719544e+06, 3.00142403e+03, -6.76210591e+03, -1.28025600e+03]]) >>> ecef2eci('2012-01-04 15:00:00',[ -3312531.1007, -5646883.8176, 2737195.4374], [ 5670.7751, -3969.9994, -1280.2560 ]) (array([[-5767701.77861271, -3097382.01317908, 2737195.4374 ]]), array([[ 3001.4240322 , -6762.10590869, -1280.256 ]]))
Two dimensional examples
>>> t = np.array(['2012-01-04 15:00:00', '2012-01-04 16:00:00', '2012-01-04 17:00:00', '2012-01-04 18:00:00'], dtype='datetime64[ns]') >>> svece = [[-3312531.1007, -5646883.8176, 2737195.4374, 5670.7751, -3969.9994, -1280.2560 ], ... [ 1413410.4872, -7049655.8712, 16233.9739, -1633.0415, -309.5460, 7358.7436 ], ... [-2450115.4006, 6613647.9795, 968353.5303, -6085.7029, -1802.9846, -2992.6557 ], ... [ -649857.9621, 7022897.5289, 968353.5303, -6345.1020, -161.9056, -2992.6557 ]] >>> ecef2eci(t, svece) array([[-5.76770178e+06, -3.09738201e+06, 2.73719544e+06, 3.00142403e+03, -6.76210591e+03, -1.28025600e+03], [-6.25224361e+05, -7.16271398e+06, 1.62339739e+04, -1.13189509e+03, 1.16387949e+02, 7.35874360e+03], [-2.30122094e+06, 6.66691737e+06, 9.68353530e+05, -6.61075561e+03, -1.83389708e+03, -2.99265570e+03], [-2.30122094e+06, 6.66691737e+06, 9.68353530e+05, -6.61075556e+03, -1.83389711e+03, -2.99265570e+03]])
>>> svece_array = np.asarray(svece) >>> xsate = svece_array[:,0:3] >>> vsate = svece_array[:,3:] >>> ecef2eci(t, xsate, vsate) (array([[-5767701.77861271, -3097382.01317908, 2737195.4374 ], [ -625224.36062227, -7162713.98329963, 16233.9739 ], [-2301220.9380175 , 6666917.37367665, 968353.5303 ], [-2301220.93814086, 6666917.37358403, 968353.5303 ]]), array([[ 3001.4240322 , -6762.10590869, -1280.256 ], [-1131.89509013, 116.38794901, 7358.7436 ], [-6610.7556061 , -1833.89707562, -2992.6557 ], [-6610.75556101, -1833.89710895, -2992.6557 ]]))
Check that inverse operation returns the original
>>> svec = ecef2eci(t, svece) >>> svece2 = eci2ecef(t,svec) >>> print(np.max(np.abs(svece2-svece)) < 1e-8) True
Example with more than two dimensions
>>> svec = ecef2eci(t, svece) >>> svec23 = ecef2eci(t,[[svece, svece, svece],[svece, svece, svece]]) >>> svec23.shape (2, 3, 4, 6) >>> np.max(np.abs(svec23 - svec), axis=(-1,-2)) array([[0., 0., 0.], [0., 0., 0.]])
Special case, point on the Earth surface (Delft), ECEF velocity is assumed to be zero
>>> xDelftECI, vDelftECI= ecef2eci('2012-01-04 15:00:00',[ 3924687.7018, 301132.7660, 5001910.7746]) >>> print(xDelftECI, vDelftECI) [[ 3507848.04809349 -1785736.98256649 5001910.7746 ]] [[130.21800963 255.79634368 0. ]]
Check that the inverse transformation returns the original result
>>> eci2ecef('2012-01-04 15:00:00', xDelftECI, vDelftECI) (array([[3924687.7018, 301132.766 , 5001910.7746]]), array([[0., 0., 0.]]))
If ECI velocity is not specified in the inverse operation, ‘nan’ is returned for the ECEF velocity. This is intentional, as there is no sensible default for velocites in an ECI.
>>> eci2ecef('2012-01-04 15:00:00', xDelftECI) (array([[3924687.7018, 301132.766 , 5001910.7746]]), array([[nan, nan, nan]]))