In [62]:
import ephem
import matplotlib.pyplot as plt
import datetime
from matplotlib.dates import date2num
%matplotlib inline

In [41]:
sun = ephem.Sun()
crab = ephem.readdb('Crab Nebula,f|R,5:34:31.9,22:0:52,8.4,2000,360')

In [42]:
t = '1996/02/10 12:00'

In [43]:
sun.compute(t)
crab.compute(t)

In [44]:
print("%s %s" % (sun.a_dec, sun.a_ra))


-14:37:49.4 21:31:55.08

In [45]:
print("%s %s" % (crab.a_dec, crab.a_ra))


22:00:52.0 5:34:31.90

In [50]:
np.rad2deg(ephem.separation(sun, crab))


Out[50]:
123.51479666114865

In [94]:
start_date = datetime.datetime(2001, 6, 14, 12, 0)
dates = [start_date + datetime.timedelta(0,d,0) for d in range(1,10*6000)]
angular_separation = []
for d in dates:
    crab.compute(d)
    sun.compute(d)
    angular_separation.append(np.rad2deg(ephem.separation(sun, crab)))
fig = plt.figure()
ax = plt.plot(dates, np.rad2deg(angular_separation), '-')
plt.grid(True)
fig.autofmt_xdate()
plt.show()



In [86]:


In [ ]: