-->

Etiquetas

Working with Astronomical Coordinate Systems

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

In [1]:
%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
Out[1]:
SoftwareVersion
Python2.7.9 64bit [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
IPython2.3.1
OSLinux 3.13.0 45 generic x86_64 with debian jessie sid
ephem3.7.5.3
astropy0.4.3
Fri Feb 20 12:51:19 2015 CET

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

In [2]:
# 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
Out[2]:
(3.511202483725676, -1.0518488536531627, 36524.5)
In [3]:
# However they are printed as strings
print eq.ra, '\t', eq.dec, '\t', eq.epoch
13:24:42.50  -60:15:59.4  2000/1/1 00:00:00

In [4]:
# We can get a tuple (ra,dec) by using the get() method
print eq.get()
(3.511202483725676, -1.0518488536531627)

In [5]:
# To find the constellation corresponding to a coordinate tuple:
ephem.constellation((eq.ra,eq.dec))
Out[5]:
('Cen', 'Centaurus')

We may also use other epoch different of J2000:

In [6]:
eq50=ephem.Equatorial('13:24:42.5','-60:15:59.4',epoch=ephem.B1950)
print eq50.ra, '\t', eq50.dec, '\t', eq50.epoch
13:24:42.50  -60:15:59.4  1949/12/31 22:09:50

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

In [7]:
# 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()
1:59:55.9 89:59:59.9
(0.0348867076789611, 1.5707958419812156)

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:

In [8]:
# 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()
(3.511202483725676, -1.0518488536531627)
(3.49702212460356, -1.04730555904456)

In [9]:
# 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
12:51:26.28 27:07:41.7

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

In [10]:
# Whirlpool Galaxy
SkyCoord.from_name("M51")    # "icrs" es la opción por defecto
Out[10]:
<SkyCoord (ICRS): ra=202.469575 deg, dec=47.1952583 deg>
In [11]:
# We can as well use other names for the same galaxy
SkyCoord.from_name('NGC 5194')
Out[11]:
<SkyCoord (ICRS): ra=202.469575 deg, dec=47.1952583 deg>
In [12]:
# The same object in galactic coordinates
SkyCoord.from_name("M51", frame='galactic')
Out[12]:
<SkyCoord (Galactic): l=104.851584722 deg, b=68.5607018112 deg>

To get the values of the angles (longitude and latitude in this case) there are several options:

In [13]:
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
Out[13]:
(<Longitude 104.85158472198123 deg>, <Latitude 68.5607018112399 deg>)

To obtain numerical values of the angles at which to operate, proceed as follows:

In [14]:
# 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
1.83000537933 1.19660998408
104.851584722 68.5607018112

Out[14]:
194.85158472198123

In the case of ICRS coordinates, the coordinate angles are ra and dec

In [15]:
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
<SkyCoord (ICRS): ra=202.469575 deg, dec=47.1952583 deg>
hms_tuple(h=13.0, m=29.0, s=52.69800000000572)
47.1952583
3.53376071886 0.823712648664

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

In [16]:
# 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
ICRS coordinates:  hms_tuple(h=13.0, m=29.0, s=52.69800000000572) 47.1952583
FK5 coordinates:  hms_tuple(h=13.0, m=29.0, s=52.697952632941849) 47.1952580768

5. Convert between coordinate systems with astropy

In [17]:
# Let's obtain the galactic coordinates of a star
# We chose a southern hemisphere star

c = SkyCoord.from_name('Achernar', frame='galactic')
c
Out[17]:
<SkyCoord (Galactic): l=290.841241695 deg, b=-58.7920097022 deg>
In [18]:
# Let's turn to FK5 equatorial coordinates:
c.fk5
Out[18]:
<SkyCoord (FK5): equinox=J2000.000, ra=24.4285197401 deg, dec=-57.2367527786 deg>
In [19]:
# Conversely, from the ICRS obtain the galactic coordinates:
c = SkyCoord.from_name('Achernar', frame='icrs')
c.galactic
Out[19]:
<SkyCoord (Galactic): l=290.841241695 deg, b=-58.7920097022 deg>

No hay comentarios:

Publicar un comentario