How to calculate SUN coordinates in ECEF (geocenter) frame?

838 Views Asked by At

I want to find the python library in which I may obtain the SUN coordinates in ECEF (Eart-Centered, Earth-Fixed) frame - geocenter coordinates. I try using jplephem, pyephem etc. but none of them availalbe to give these coordinates. Please give me library, algorithm or etc. in which I may obtained these coordinates. With greetings.

1

There are 1 best solutions below

2
On

You are correct that neither of those libraries has quick support for an ECEF reference frame, though it can be faked in PyEphem by creating an Observer at latitude 0° and longitude 0° and whose elevation is negative enough to put them at the center of the Earth.

If you are interested in a more modern library, the new 1.34 version of Skyfield directly supports the standard ITRS reference frame, which is ECEF:

from skyfield import framelib
from skyfield.api import load

ts = load.timescale()
t = ts.now()

planets = load('de421.bsp')
sun = planets['sun']
earth = planets['earth']

apparent = earth.at(t).observe(sun).apparent()
vector = apparent.frame_xyz(framelib.itrs)
print(vector.au)

The result:

[-0.653207   -0.62839897 -0.38480108]

The operations you can perform with reference frames are explained in more detail here:

https://rhodesmill.org/skyfield/positions.html#coordinates-in-other-reference-frames