Working with Astronomical Coordinate Systems¶
Author: Eduardo Martín Calleja
The purpose of this post is to show how you can work with the various astronomical coordinate systems using appropriate Python libraries.
Converting between various types of astronomical coordinates will be useful in future posts.This entry, as most of the following, will be fully written with the IPython Notebook
Imports and references¶
%matplotlib inline
from __future__ import division
# Import of the PyEphem package
import ephem
from astropy.coordinates import SkyCoord
#This removes some nasty deprecation warnings that do not interfere with the execution
import warnings
warnings.filterwarnings('ignore')
# This IPython magic generates a table with version information
#https://github.com/jrjohansson/version_information
%load_ext version_information
%version_information ephem, astropy
1. Equatorial spherical coordinates¶
They are defined by Right Ascension (ra), Declination (dec) and an epoch.
The ra is normally represented as a string of the form "hh: mm: ss"
The dec is usually represented as a string of the form "/ - °: ':''"
The default is epoch J2000.0
Its elements are:
- The origin is the center of the Earth (ie, they are geocentric coordinates)
- The fundamental plane is the projection of the terrestrial Ecuador on the celestial sphere
- The primary direction is the spring equinox on a date (the epoch)
By convention the ra is measured positively to the east and north.
The equatorial coordinates of an object are represented in ephem as instances of the Equatorial class. ra, dec and epoch are object attributes
# Let's define the equatorial coordinates of an object
eq=ephem.Equatorial('13:24:42.5','-60:15:59.4')
# The values are internally stored in radians
eq.ra, eq.dec, eq.epoch
# However they are printed as strings
print eq.ra, '\t', eq.dec, '\t', eq.epoch
# We can get a tuple (ra,dec) by using the get() method
print eq.get()
# To find the constellation corresponding to a coordinate tuple:
ephem.constellation((eq.ra,eq.dec))
We may also use other epoch different of J2000:
eq50=ephem.Equatorial('13:24:42.5','-60:15:59.4',epoch=ephem.B1950)
print eq50.ra, '\t', eq50.dec, '\t', eq50.epoch
2. Galactic coordinates¶
This is another spherical coordinate system. Its elements are:
- The center is located in the Sun (they are heliocentric coordinates)
- The fundamental plane is approximately the plane of our galaxy (the Milky Way)
- The primary direction points about to the center of our own galaxy
- By comnvention the directions are positive northward and eastward at the fundamental plane.
The coordinates are longitude (lon / l) and latitude (lat / b), both expressed in degrees, not hours
# Definition of the galactic coordinates of an object
ga=ephem.Galactic('1:59:55.9','+89:59:59.9')
print ga.lon, ga.lat
# Longitude and latitude are returned by the get() method. They are shown in radians
print ga.get()
3. Conversion between coordinate systems¶
The coordinates can be converted from one system to another giving an object of the first type as an input to a class of the second type:
# Conversion of equatorial coordinates between epochs
eq1 = eq=ephem.Equatorial('13:24:42.5','-60:15:59.4')
eq2 = ephem.Equatorial(eq1,epoch=ephem.B1950)
print eq1.get()
print eq2.get()
# Conversióo from galactic to equatorial coordinates
# (we can in fact omit to declare the epoch, J2000 by default)
ga1 = ephem.Galactic('0','90',epoch=ephem.J2000)
eq1 = ephem.Equatorial(ga1)
print eq1.ra, eq1.dec
4. Get the coordinates of an object by name¶
For this we'll use the SkyCoord module from the astropy library, which gets the coordinates from the SESAME server
The "International Celestial Reference System" (ICRS) is the celestial reference system adopted as standard today by the International Astronomical Union (IAU). These coordinates coincide very nearly with the J2000.0 equatorial coordinates. ICRS coordinates can be obtained by giving the name of the object in any of the catalogs used by the service SESAME
# Whirlpool Galaxy
SkyCoord.from_name("M51") # "icrs" es la opción por defecto
# We can as well use other names for the same galaxy
SkyCoord.from_name('NGC 5194')
# The same object in galactic coordinates
SkyCoord.from_name("M51", frame='galactic')
To get the values of the angles (longitude and latitude in this case) there are several options:
c = SkyCoord.from_name("M51", frame='galactic')
# longitude and latitude can be accessed internally with c.l y c.b
# The internal representation of the angles is in degrees
# However, these values can not be operated directly
c.l, c.b
To obtain numerical values of the angles at which to operate, proceed as follows:
# angles in radians
print c.l.radian, c.b.radian
# Angles in degrees
print c.l.degree, c.b.degree
# Arithmetic operation example
c.l.degree + 90
In the case of ICRS coordinates, the coordinate angles are ra and dec
c = SkyCoord.from_name("M51", frame='icrs')
# Prints a string representation unfit to operate with
print c
# provides a tuple "hours", "minutes", "seconds"
print c.ra.hms
# Values in degrees
print c.dec.degree
# Of course they can be expressed in other types of units
print c.ra.radian, c.dec.radian
Another coordinate system provided by the astropy package is FK5. It is an equatorial coordinate system based on the Epoch J2000, which practically coincides with the coordinates ICRS
# ICRS coordinates
c = SkyCoord.from_name("M51", frame='icrs')
# FK5 coordinates
c5 = SkyCoord.from_name("M51", frame='fk5')
# In this example you can see the similarity between the two
print 'ICRS coordinates: ',c.ra.hms, c.dec.degree
print 'FK5 coordinates: ', c5.ra.hms, c5.dec.degree
5. Convert between coordinate systems with astropy¶
# Let's obtain the galactic coordinates of a star
# We chose a southern hemisphere star
c = SkyCoord.from_name('Achernar', frame='galactic')
c
# Let's turn to FK5 equatorial coordinates:
c.fk5
# Conversely, from the ICRS obtain the galactic coordinates:
c = SkyCoord.from_name('Achernar', frame='icrs')
c.galactic
No hay comentarios:
Publicar un comentario