Commit 80799261 authored by Leo Pound Singer's avatar Leo Pound Singer
Browse files

Register AutoScaledWCSAxes as projection named 'astro wcs'

parent c6a73f3e
...@@ -14,6 +14,10 @@ Changelog ...@@ -14,6 +14,10 @@ Changelog
``astropy.convolution.convolve_fft`` in order to correctly handle points near ``astropy.convolution.convolve_fft`` in order to correctly handle points near
the projection boundary where invalid values must be masked out. the projection boundary where invalid values must be masked out.
- Register ``AutoScaledWCSAxes`` as a Matplotlib projection with the name
``astro wcs`` so that subclasses can be created using
``plt.axes(..., projection='astro wcs', header='...')``.
0.1.7 (2019-04-24) 0.1.7 (2019-04-24)
================== ==================
......
...@@ -159,7 +159,9 @@ class AutoScaledWCSAxes(WCSAxes): ...@@ -159,7 +159,9 @@ class AutoScaledWCSAxes(WCSAxes):
"""Axes base class. The pixel scale is adjusted to the DPI of the image, """Axes base class. The pixel scale is adjusted to the DPI of the image,
and there are a variety of convenience methods.""" and there are a variety of convenience methods."""
def __init__(self, header, *args, **kwargs): name = 'astro wcs'
def __init__(self, *args, header, **kwargs):
super(AutoScaledWCSAxes, self).__init__(*args, aspect=1, **kwargs) super(AutoScaledWCSAxes, self).__init__(*args, aspect=1, **kwargs)
h = Header(header, copy=True) h = Header(header, copy=True)
naxis1 = h['NAXIS1'] naxis1 = h['NAXIS1']
...@@ -382,9 +384,8 @@ class GlobeAxes(AutoScaledWCSAxes): ...@@ -382,9 +384,8 @@ class GlobeAxes(AutoScaledWCSAxes):
name = 'astro globe' name = 'astro globe'
def __init__(self, *args, **kwargs): def __init__(self, *args, center='0d 0d', **kwargs):
kwargs = dict(kwargs) center = SkyCoord(center).icrs
center = SkyCoord(kwargs.pop('center', '0d 0d')).icrs
header = { header = {
'NAXIS': 2, 'NAXIS': 2,
'NAXIS1': 180, 'NAXIS1': 180,
...@@ -399,17 +400,16 @@ class GlobeAxes(AutoScaledWCSAxes): ...@@ -399,17 +400,16 @@ class GlobeAxes(AutoScaledWCSAxes):
'CTYPE2': 'DEC--SIN', 'CTYPE2': 'DEC--SIN',
'RADESYS': 'ICRS'} 'RADESYS': 'ICRS'}
super(GlobeAxes, self).__init__( super(GlobeAxes, self).__init__(
header, *args, frame_class=EllipticalFrame, **kwargs) *args, frame_class=EllipticalFrame, header=header, **kwargs)
class ZoomSkyAxes(AutoScaledWCSAxes): class ZoomSkyAxes(AutoScaledWCSAxes):
name = 'astro zoom' name = 'astro zoom'
def __init__(self, *args, **kwargs): def __init__(self, *args, center='0d 0d', radius='1 deg', **kwargs):
kwargs = dict(kwargs) center = SkyCoord(center).icrs
center = SkyCoord(kwargs.pop('center', '0d 0d')).icrs radius = u.Quantity(radius).to(u.deg).value
radius = u.Quantity(kwargs.pop('radius', '1 deg')).to(u.deg).value
header = { header = {
'NAXIS': 2, 'NAXIS': 2,
'NAXIS1': 512, 'NAXIS1': 512,
...@@ -429,9 +429,7 @@ class ZoomSkyAxes(AutoScaledWCSAxes): ...@@ -429,9 +429,7 @@ class ZoomSkyAxes(AutoScaledWCSAxes):
class AllSkyAxes(AutoScaledWCSAxes): class AllSkyAxes(AutoScaledWCSAxes):
"""Base class for a multi-purpose all-sky projection""" """Base class for a multi-purpose all-sky projection"""
def __init__(self, *args, **kwargs): def __init__(self, *args, obstime=None, **kwargs):
kwargs = dict(kwargs)
obstime = kwargs.pop('obstime', None)
header = { header = {
'NAXIS': 2, 'NAXIS': 2,
'NAXIS1': 360, 'NAXIS1': 360,
...@@ -448,7 +446,7 @@ class AllSkyAxes(AutoScaledWCSAxes): ...@@ -448,7 +446,7 @@ class AllSkyAxes(AutoScaledWCSAxes):
if obstime is not None: if obstime is not None:
header['DATE-OBS'] = Time(obstime).utc.isot header['DATE-OBS'] = Time(obstime).utc.isot
super(AllSkyAxes, self).__init__( super(AllSkyAxes, self).__init__(
header, *args, frame_class=EllipticalFrame, **kwargs) *args, frame_class=EllipticalFrame, header=header, **kwargs)
self.coords[0].set_ticks(spacing=45 * u.deg) self.coords[0].set_ticks(spacing=45 * u.deg)
self.coords[1].set_ticks(spacing=30 * u.deg) self.coords[1].set_ticks(spacing=30 * u.deg)
self.coords[0].set_ticklabel(exclude_overlapping=True) self.coords[0].set_ticklabel(exclude_overlapping=True)
...@@ -543,6 +541,7 @@ class GeoHoursMollweideAllSkyAxes(Geo, Hours, Mollweide, AllSkyAxes): ...@@ -543,6 +541,7 @@ class GeoHoursMollweideAllSkyAxes(Geo, Hours, Mollweide, AllSkyAxes):
projection_registry.register( projection_registry.register(
AutoScaledWCSAxes,
AstroDegreesAitoffAllSkyAxes, AstroDegreesAitoffAllSkyAxes,
AstroDegreesMollweideAllSkyAxes, AstroDegreesMollweideAllSkyAxes,
AstroHoursAitoffAllSkyAxes, AstroHoursAitoffAllSkyAxes,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment