moonwatcher.it

Gianluca Riccardi's minimalist weblog

Home About

Have fun tracking Comet ISON with PyEphem


I'm not an astronomer, but since I was 10 I've had enough curiosity to let me look at night skies and practice the base notions of amateur astronomy. 2013 is a lucky year for comet observations, C/2011 L4 (PANSTARRS), C/2012 F6 (Lemmon) for example and currently transiting C/2012 S1 (ISON).

PyEphem "provides scientific-grade astronomical computations for the Python programming language" and it uses Xephem routines.

Not all sky bodies can be natively computed by PyEphem. A comet must be loaded from external catalog definitions of orbital parameters. PyEphem documentation provides links to various catalogs.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
gianluca:~$ mkvirtualenv astropy --no-site-packages
New python executable in astropy/bin/python
Installing setuptools............done.
Installing pip...............done.
gianluca:~$ workon astropy
(astropy)gianluca:~$ pip install ephem
Downloading/unpacking pyephem
  Downloading pyephem-3.7.5.1.tar.gz (703kB): 703kB downloaded
  Running setup.py egg_info for package pyephem

Installing collected packages: pyephem
  Running setup.py install for pyephem
    building 'ephem._libastro' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Ilibastro-3.7.5 -I/usr/include/python2.7 -c extensions/_libastro.c -o build/temp.linux-x86_64-2.7/extensions/_libastro.o
...
...
...
Successfully installed pyephem
Cleaning up...
(astropy)gianluca:~$

After installing virtualenv and virtualenvwrapper I created a virtualenv called astropy and installed PyEphem therein, a simple script shows how fun(and powerful) is to use the PyEphem library.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import ephem

# load Comet ISON object from catalog http://www.minorplanetcenter.net/iau/Ephemerides/Comets/Soft03Cmt.txt
ison = ephem.readdb("C/2012 S1 (ISON),h,11/28.7747/2013,62.3990,295.6529,345.5644,1.000002,0.012444,2000,7.5,3.2")
date = '2013/10/31'

# compute on date
ison.compute(date)

# define an observer
Rome = ephem.city('Rome')
rome_watcher = ephem.Observer()
rome_watcher.lat = Rome.lat
rome_watcher.lon = Rome.lon
rome_watcher.date = date

# print some useful data computed on the loaded body
print("Tracking object: %s on date: %s from: %s" % (ison.name, date, Rome.name))
print "%s is in constellation: %s with magnitude %s" % (ison.name, ephem.constellation(ison)[1], ison.mag)
print("Rome next rising: %s" % rome_watcher.next_rising(ison))
print("Rome next setting: %s" % rome_watcher.next_setting(ison))
print("Earth distance: %s AUs" % ison.earth_distance)
print("Sun distance: %s AUs" % ison.sun_distance)

Output:

1
2
3
4
5
6
7
(astropy)gianluca:~$ python tracking_comet_ison.py 
Tracking object: C/2012 S1 (ISON) on date: 2013/10/31 from: Rome
C/2012 S1 (ISON) is in constellation: Leo with magnitude 8.07
Rome next rising: 2013/10/31 01:12:31
Rome next setting: 2013/10/31 14:07:39
Earth distance: 1.24149298668 AUs
Sun distance: 1.00681865215 AUs

Clear skies to all :) and have fun!


Moon at -62:38:12.8, 15:31:15.0 observing from Rome, IT


Recent Posts

La Luna by Bert Jansch
Have fun tracking Comet ISON with PyEphem
APOD Full Moon Silhouettes

Python All Posts

Categories

Astro
Music
Sysadmin
all entries feeds   follow me on twitter   my LinkedIn profile  

Powered by Moonwatcher.it ShortPosts.