pymap3d icon indicating copy to clipboard operation
pymap3d copied to clipboard

[Bug]: ecef2eci: different outputs when importing Astropy or not

Open xerpi opened this issue 8 months ago • 0 comments

What happened?

  • Python 3.12.3
  • pymap3d==3.1.0
  • astropy==7.0.1

ecef2eci gives different output depending on whether Astropy is imported or not: https://github.com/geospace-code/pymap3d/blob/v3.1.0/src/pymap3d/eci.py#L106-L129

Test code

from datetime import datetime
import numpy as np
import pymap3d as pm
from astropy.time import Time

lat = 33.6      # deg
lon = 134.3     # deg
alt = 0         # m

dt = datetime(2020, 8, 14, 0, 0, 41)

# Astropy time for comparison
astropy_time = Time(dt, scale="utc")
print("Astropy Time (UTC):", astropy_time.utc)
print("Julian Date (UTC):", astropy_time.utc.jd)
print("Julian Date (TT):", astropy_time.tt.jd)
print("GMST:", astropy_time.sidereal_time('mean', 'greenwich'))

# 1. Geodetic to ECEF
ecef = pm.geodetic2ecef(lat, lon, alt)
print("\nECEF Coordinates (meters):")
print(f"X: {ecef[0]:.8f}, Y: {ecef[1]:.8f}, Z: {ecef[2]:.8f}")

# 2. ECEF to ECI (J2000)
eci = pm.ecef2eci(ecef[0], ecef[1], ecef[2], dt)
print("\nECI Coordinates (meters):")
print(f"X: {eci[0]}, Y: {eci[1]}, Z: {eci[2]}")

Test output

Results when Astropy is imported:

Astropy Time (UTC): 2020-08-14 00:00:41
Julian Date (UTC): 2459075.5004745373
Julian Date (TT): 2459075.5012752777
GMST: 21h32m11.65977507s

ECEF Coordinates (meters):
X: -3714130.40060442, Y: 3806010.82935967, Z: 3509577.92600653

ECI Coordinates (meters):
X: -648947.4261356231, Y: 5277343.955927954, Z: 3510858.6262554014

Results when Astropy is not imported:

Astropy Time (UTC): 2020-08-14 00:00:41
Julian Date (UTC): 2459075.5004745373
Julian Date (TT): 2459075.5012752777
GMST: 21h32m11.65977507s

ECEF Coordinates (meters):
X: -3714130.40060442, Y: 3806010.82935967, Z: 3509577.92600653

ECI Coordinates (meters):
X: [-680272.16489017], Y: [5274249.97962485], Z: [3509577.92600653]

xerpi avatar Apr 17 '25 06:04 xerpi