Manual body entry¶
Important
This page is intended for use by people with no Python experience, as such it aims to be readable by non-programmers. It is not clean Python by any stretch of the imagination and doesn’t aim to be. If you’re not used to Python, and still find it unreadable drop me a mail and I’ll try to clear up any problems.
Return to the Comet McNaught page.
We aren’t always lucky enough to find Xephem database entries to use as input for calculation, but it is a simple task to enter your own data. Using Comet McNaught as an example again a quick Google search yields a page with information for the object we wish to chart, and a few bonus viewing charts too. Using the data on that page we can construct an object manually, instead of reading in the Xephem entry.
Let’s start with the simple parts, first we initialise a new hyperbolic body object and name it:
McNaught = ephem.HyperbolicBody()
McNaught.name = 'C/2006 P1 ( McNaught )'
Next we add the date information. The first, _epoch, is the calculation epoch which is simply the date we are specifying our elements for. The second, _epoch_p, is the date of the object’s perihelion which simply means the date and time our object will be closest to the Sun.
On the table contained in the page we find the _epoch is defined on the first line as 2007 Jan. 20.0. And the date of perihelion, _epoch_p, is specified in the second line field as 2007 Jan. 12.79895. It is common practise to quote these values in this format where the day includes a floating point part instead of specifying hours, minutes and seconds, and PyEphem supports using this style as input.
McNaught._epoch = '2007/01/20.0'
McNaught._epoch_p = '2007/01/12.79895'
Next up we need to define the actual orbital positions, unfortunately the page uses slightly different terminology but there is nothing too difficult here. We map the elements as follows:
# 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
Note
You can refer to the PyEphem documentation if you need an explanation of the properties or wish to enter the values in a different format. The page we’re using specifies the values in degrees so we can use the values directly, and don’t need to bother with any angular conversions.
Setting the magnitude values for the comet is unfortunately a little more difficult. The page has a section named “Magnitudes Graph” that gives us all the information we need, but not in a format we can directly use. If we take the data it specifies we can do a few quick transforms to get the data we need.
m1 = 6.0 + 5 log d + 10.0 log r
PyEphem expects us to enter the absolute magnitude and luminosity index. The magnitude calculation above is taken from the page and is a single instance of the common magnitude formula:
magnitude = (absolute magnitude) + 5 * log (distance from earth)
+ 2.5 * (luminosity index) * log (comet sun distance)
Note
Just to clear up a minor misunderstanding logarithms in the above functions are base 10. If you decide to use Python to calculate magnitudes bear in mind that you need to use either math.log10(x) or possibly the less concise math.log(x, 10) variant. Assumption of base 10 by default would appear to be the product of a British education :)
Note
Distances used in the formula are always given in AU, that is defined as approximately 150 billion metres or 150GM. Close to 93 million miles for people of that persuasion.
We can instantly see that absolute magnitude is 6, and the luminosity index is 4(10.0 / 2.5). We can add those properties to our object too:
McNaught._g = 6.0
McNaught._k = 4.0
PyEphem now has all the information needed to make our calculations, and when the manual body entry script is run it produces the following output:
2007-01-07
> McNaught rises @ 06:46:12
> Sun rises @ 08:10:14
> Duration 84 minutes
< Sun sets @ 16:04:44
< McNaught sets @ 17:30:08
< Duration 85 minutes
As a quick smoke test we can check the output against the output from the Xephem formatted entry we have already been using and see that it is correct to within a few seconds. We have obviously been expecting slightly different output, because the orbital information we fed in wasn’t exactly the same, and deviation of a few seconds is definitely acceptable as proof our method for inputting manual data was correct.
We can also ask PyEphem to generate a Xephem database entry for us using the data we have entered by adding print McNaught.writedb(). It produces the following output:
C/2006 P1 ( McNaught ),h,1/12.7989/2007,77.83694,267.415,155.9765,1.000013,0.1707278,1/20/2007,6,4,0
For future use you can feed this directly back in to PyEphem using the ephem.readdb() function we were using before. And that is all you need to do if you can’t find Xephem formatted entries. If you have any questions feel free to drop me a mail.
Return to the Comet McNaught page.