Search code examples
python-2.7pyephem

Basic pyephem code


I have a very simple code to get the longitude of the sun but when I compare the output to Astrolog and Astrodienst its incorrect, there is a 13 minute difference. I have not added Observer as I think default is midnight GMT (which is what I want). What am I doing wrong?

import ephem

start = ephem.date('2015/01/01')
end = ephem.date('2015/12/31')
f2 = open("Sun", 'w')
while start <= end:
    sun = ephem.Sun(start)
    ecl = ephem.Ecliptic(sun)
    f2.write(str(ephem.date(start))+' '+ str(ecl.lon) +'\n')
    start+=1
f2.close()

Example of results for 2015/12/30:

code - 2015/12/30 00:00:00 277:43:36.6

Astrodienst - 7°56'39 Cap

Thanks


Solution

  • The reason why the 13 minute difference is because of the epoch setting, when I added

    sun = ephem.Sun(start, epoch = start)

    the results were the same as swiss ephemeris.