#! /usr/bin/python """Output an ephemeris for comet McNaught around the height of its visibility around James' location.""" __license__ = "Public Domain" import ephem # McNaught Xephem entry from # http://cfa-www.harvard.edu/iau/Ephemerides/Comets/Soft03Cmt.txt McNaught = ephem.readdb("C/2006 P1 (McNaught),h,01/12.7961/2007,77.8349,267.4144,155.9771,1.000019,0.170742,2000,6.0,4.0") # We are also going to calculate sun rise/set times to allow estimation of # visibility on a given day. Sun = ephem.Sun() # Location for my house :) Approximately, 50 kilometres south west of # Cambridge, UK. For all intents and purposes elevation is entirely # redundant for these calculations, and can be ignored. The # accuracy expressed in the latitude and longitude values are also # neither required, nor particularly useful outside of being a good # example of false precision. I just happen to have the information # to hand in this format from my FOAF file. home = ephem.Observer() home.lat, home.long, home.elev = '52.015', '-0.221', 60.0 home.date = ephem.date('2007/1/5') for i in range(10): McNaught.compute(home) Sun.compute(home) print "%i-%02i-%02i" % home.date.tuple()[:3] # Only display McNaught rise times *before* the Sun rises if McNaught.rise_time.tuple() < Sun.rise_time.tuple(): print " > McNaught rises @", str(McNaught.rise_time).split(" ")[1] print " > Sun rises @", str(Sun.rise_time).split(" ")[1] duration = (Sun.rise_time - McNaught.rise_time) / ephem.minute print " > Duration %0i minutes" % duration # Only display McNaught set times *after* the Sun sets if McNaught.set_time.tuple() > Sun.set_time.tuple(): print " < Sun sets @", str(Sun.set_time).split(" ")[1] print " < McNaught sets @", str(McNaught.set_time).split(" ")[1] duration = (McNaught.set_time - Sun.set_time) / ephem.minute print " < Duration %0i minutes" % duration home.date += 1