In [40]:
import ephem
import datetime
In [41]:
gatech = ephem.Observer()
gatech.lon, gatech.lat = '-84.39733', '33.775867'
start_date = datetime.datetime(2014,1,1,0,0,0)
gatech.date = start_date
In [42]:
sun, moon = ephem.Sun(), ephem.Moon()
sun.compute(gatech)
moon.compute(gatech)
In [43]:
print("%s %s" % (sun.alt, sun.az))
print("%s %s" % (moon.alt, moon.az))
In [44]:
print(ephem.separation((sun.az, sun.alt), (moon.az, moon.alt)))
In [45]:
print("%.8f %.8f %.11f" % (sun.size, moon.size, sun.size - moon.size))
In [46]:
gatech.date = ephem.date(gatech.date + 1)
In [47]:
type(gatech.date)
Out[47]:
In [48]:
dates = [start_date + datetime.timedelta(d,0,0) for d in range(1,356)]
In [49]:
a_dec = []
for d in dates:
gatech.date = d
sun.compute(gatech)
a_dec.append(sun.a_dec)
In [63]:
a_dec = np.array(a_dec)
In [64]:
import matplotlib.pyplot as plt
import matplotlib
In [65]:
%matplotlib inline
In [72]:
plt.figure()
plt.plot_date(matplotlib.dates.date2num(dates), np.rad2deg(a_dec), '-')
plt.show()
In [73]:
from sunpy.sun import apparent_declination
In [74]:
sunpy_adec = np.array([apparent_declination(d) for d in dates])
In [75]:
plt.figure()
plt.plot_date(matplotlib.dates.date2num(dates), sunpy_adec, '-')
plt.show()
In [88]:
fig, ax = plt.subplots()
ax.plot_date(matplotlib.dates.date2num(dates), np.rad2deg(a_dec) - sunpy_adec, '-', label = 'pyEphem - sun.py')
ax.xaxis.set_major_locator(matplotlib.dates.MonthLocator())
ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%m'))
plt.title("apparent declination")
plt.grid(True)
fig.autofmt_xdate()
plt.legend()
plt.show()
In [ ]: