#! /usr/bin/python """Output an ephemeris for comet McNaught around the height of its visibility around James' location.""" __license__ = "Public Domain" import ephem # McNaught body generated using content from # http://www.aerith.net/comet/catalog/2006P1/2006P1.html McNaught = ephem.HyperbolicBody() McNaught.name = 'C/2006 P1 ( McNaught )' McNaught._epoch = '2007/01/20.0' McNaught._epoch_p = '2007/01/12.79895' # Defined in the page as simply "incl" McNaught._inc = 77.83694 # Defined in the page as "Node" McNaught._Om = 267.41500 # Defined in the page as "Peri" McNaught._om = 155.97648 # Both "e" and "q" are used on the page McNaught._e = 1.0000135 McNaught._q = 0.1707278 # Calculated magnitude properties from the page's magnitude equations McNaught._g = 6.0 McNaught._k = 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