Coordinates in SunPy

Stuart Mumford

In Development

The first version of SunPy Coordinates was released in 0.7.

This presentation also contains "phase 2" which should be included in SunPy 0.8.

See PR #1975

Pretty Pictures

limb

Types of Coordinates

Pixel Coordinates

  • The indexes of your array
  • WCS - World Coordinate System
    • Converts pixel coordinates to physical coordinates.
    • A common convention is FITS-WCS.

Physical Coordinates

  • Represents a point in physical space.
  • Has some "Reference System"
    • An Origin
    • Some reference points to align the frame with respect to other things.
  • Can be "projected" when spherical meaning $r\rightarrow \infty$.

Physical Coordinate Frames

Defined in Thompson (2006):

  • Helioprojective (Cartesian)
  • Helioprojective (Radial) *
  • Heliocentric
  • Heliographic (Stonyhurst)
  • Heliographic (Carrington)

* Not in SunPy

1. Thompson, W. T. Coordinate systems for solar image data. Astronomy and Astrophysics 449, 791–803 (2006).

Helioprojective Cartesian is not Cartesian

It's spherical.

Transformations

Physical Coordinates in SunPy

In [1]:
import astropy.units as u

from astropy.coordinates import SkyCoord
import sunpy.coordinates
In [2]:
sc = SkyCoord(100*u.arcsec, 0.1*u.deg, frame='helioprojective')
sc
Out[2]:
<SkyCoord (Helioprojective: dateobs=None, rsun=695508.0 km, observer=<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, AU)
    ( 0.,  0.,  1.)>): (Tx, Ty) in arcsec
    ( 100.,  360.)>
In [4]:
sc.observer
Out[4]:
<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, AU)
    ( 0.,  0.,  1.)>

Transformations

Helioprojective to Heliographic

In [5]:
sc = SkyCoord(100*u.arcsec, 0.1*u.deg, frame='helioprojective')
sc
Out[5]:
<SkyCoord (Helioprojective: dateobs=None, rsun=695508.0 km, observer=<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, AU)
    ( 0.,  0.,  1.)>): (Tx, Ty) in arcsec
    ( 100.,  360.)>
In [6]:
sc.transform_to("heliographic_stonyhurst")
Out[6]:
<SkyCoord (HeliographicStonyhurst: dateobs=None): (lon, lat, radius) in (deg, deg, km)
    ( 6.42759277,  21.94999839,  695507.99999766)>

Off-Disk

In [7]:
sc = SkyCoord(100*u.arcsec, 1500*u.arcsec, frame='helioprojective')
sc
Out[7]:
<SkyCoord (Helioprojective: dateobs=None, rsun=695508.0 km, observer=<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, AU)
    ( 0.,  0.,  1.)>): (Tx, Ty) in arcsec
    ( 100.,  1500.)>
In [8]:
sc.transform_to("heliographic_stonyhurst")
/opt/miniconda/envs/RISE/lib/python3.5/site-packages/sunpy/coordinates/frames.py:353: RuntimeWarning: invalid value encountered in sqrt
  d = ((-1*b) - np.sqrt(b**2 - 4*c)) / 2
Out[8]:
<SkyCoord (HeliographicStonyhurst: dateobs=None): (lon, lat, radius) in (deg, deg, km)
    ( nan,  nan,  nan)>

Calculating Distance

In [6]:
sc = SkyCoord(100*u.arcsec, 900*u.arcsec, frame='helioprojective')
sc
Out[6]:
<SkyCoord (Helioprojective: dateobs=None, rsun=695508.0 km, observer=<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, AU)
    ( 0.,  0.,  1.)>): (Tx, Ty) in arcsec
    ( 100.,  900.)>
In [7]:
sc.frame.calculate_distance()
Out[7]:
<Helioprojective Coordinate (dateobs=None, rsun=695508.0 km, observer=<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, AU)
    ( 0.,  0.,  1.)>): (Tx, Ty, distance) in (arcsec, arcsec, km)
    ( 100.,  900.,   1.49367520e+08)>

World Coordinate System in SunPy

WCS is built into SunPy Map:

In [8]:
import sunpy.map
from sunpy.data.sample import AIA_171_ROLL_IMAGE
In [9]:
aia = sunpy.map.Map(AIA_171_ROLL_IMAGE) 
In [13]:
sc = aia.pixel_to_data(100*u.pixel, 100*u.pixel)
sc
Out[13]:
<SkyCoord (Helioprojective: dateobs=2014-04-09 06:00:12.970000, rsun=695508.0 km, observer=<HeliographicStonyhurst Coordinate (dateobs=None): (lon, lat, radius) in (deg, deg, m)
    ( 0., -6.047074,   1.49860274e+11)>): (Tx, Ty) in arcsec
    (-1652.90620495,  1.80900012)>
In [14]:
sc.transform_to("heliographic_carrington")
/opt/miniconda/envs/RISE/lib/python3.5/site-packages/sunpy/coordinates/frames.py:353: RuntimeWarning: invalid value encountered in sqrt
  d = ((-1*b) - np.sqrt(b**2 - 4*c)) / 2
Out[14]:
<SkyCoord (HeliographicCarrington: dateobs=2014-04-09 06:00:12.970000): (lon, lat, radius) in (deg, deg, km)
    ( nan,  nan,  nan)>
In [11]:
aia.data_to_pixel(sc)
Out[11]:
PixelPair(x=<Quantity 99.99999999980423 pix>, y=<Quantity 99.99999999990769 pix>)

Plotting Coordinates

This is where it get's fun.

In [15]:
%matplotlib notebook
import matplotlib.pyplot as plt
In [16]:
aia.peek()

Overlays

In [17]:
aia.peek(draw_grid=True)