skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.43k stars 213 forks source link

Skyfield vs Swiss Ephemeris #231

Closed kpbird closed 5 years ago

kpbird commented 5 years ago

I am calculating Planet (Mars & Mercury) Position on 27 Feb 1983 17:34:00

Skyfield Result :

Mars 2.3836313274432888 deg Mercury 321.5257022360414 deg

Swiss Ephemeris Result:

Mars 2° 5'41.33844009 Mercury 318°16'42.00708980

I found the 3-degree difference between Skyfield and Swiss Ephemeris. Am I missing something in Skyfield?

I have used following Python code for calculation

from skyfield.api import load

planets = load('de421.bsp')
earth, mars, mercury = planets['earth'], planets['mars'], planets['mercury']

t = ts.utc(1983,2,27,17,34,0)
astroMars = earth.at(t).observe(mars)
raMars, _, _ = astroMars.radec()

marsDegree = raMars.to('degree')
print("Mars ",+marsDegree)

astroMercury = earth.at(t).observe(mercury)
raMercury, _,_ = astroMercury.radec()
mercuryDegree = raMercury.to('degree')
print("Mercury ",mercuryDegree)

Please click the following link for Swiss Ephemeris. (I have also attached a screenshot with email) https://www.astro.com/cgi/swetest.cgi?b=27.2.1983+-ut17%3A34%3A0&n=1&s=1&p=p&e=-eswe&f=PLBRS&arg=

screenshot 2018-12-29 at 4 25 45 pm
ghost commented 5 years ago

Off the top of my head:

brandon-rhodes commented 5 years ago

I suspect that the difference between de430 and de421 will only be a few fractions of an arcsecond in this situation — DE421 is a very, very accurate ephemeris. (I say this only to help @kpbird avoid a huge download that's unlikely to change Skyfield's answer much, not to complain about your attempt to help!)

GammaSagittarii commented 5 years ago

@kpbird You are comparing right ascension with ecliptic longitude, hence the difference. What you probably want is something like this:

astrometric_mercury = earth.at(t).observe(mercury)
apparent_mercury = astrometric_mercury.apparent()
lat, lon, d = apparent_mercury.ecliptic_latlon(epoch='date')

And lon will obviously be what you are looking for.

kpbird commented 5 years ago

@beaglebao - Thank You for developing sky field library @GammaSagittarii -Thank You, Your solution works for me