Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for offset coordinates #8363

Open
abeelen opened this issue Jan 21, 2019 · 2 comments
Open

Add support for offset coordinates #8363

abeelen opened this issue Jan 21, 2019 · 2 comments

Comments

@abeelen
Copy link
Contributor

abeelen commented Jan 21, 2019

I am reopening astrofrog/wcsaxes#8
I tried the SkyOffsetFrame solution, but the result is not satisfactory, considering this example :

import numpy as np
import matplotlib.pyplot as plt
from astropy.wcs import WCS
from astropy.coordinates import SkyCoord

header = {'CRVAL1': 15., 'CRVAL2': 20.,
          'CUNIT1': 'deg', 'CUNIT2': 'deg',
          'CRPIX1': 16, 'CRPIX2': 16,
          'CTYPE1': 'RA---TAN', 'CTYPE2': 'DEC--TAN' }
wcs = WCS(header)
coord = SkyCoord(header['CRVAL1'], header['CRVAL2'], unit="deg")

ax = plt.subplot(projection=wcs)
ax.imshow(np.zeros((32, 32)))
overlay = ax.get_coords_overlay(coord.skyoffset_frame())

the overlay axes looks good for the latitude but is an angle module 360° for the longitude.

test

@astrofrog
Copy link
Member

You can fix this by using:

from astropy import units as u
overlay[0].set_coord_type('longitude', 180)

However it would be nice to have this be automatic for offset frames.

@keflavich
Copy link
Contributor

I have a similar use case; I had to do the following to get a reasonable display:

ra = ax3.coords['ra']
ra.set_auto_axislabel(False)
dec = ax3.coords['dec']
ra.set_coord_type('longitude', 180)
overlay = ax3.get_coords_overlay(offset_loc.skyoffset_frame())
ra.set_ticklabel_visible(False)
dec.set_ticklabel_visible(False)
ra.set_ticks_visible(False)
dec.set_ticks_visible(False)

lon = overlay['lon']
lon.set_coord_type('longitude', 180)
lon.set_format_unit(u.arcsec)
lon.set_ticklabel(rotation=45, pad=40)
lon.set_ticks_position('b')
lon.set_ticklabel_position('b')
lon.set_axislabel_position('b')
lat = overlay['lat']
lat.set_format_unit(u.arcsec)
lat.set_ticklabel()
lat.set_ticks_position('l')
lat.set_ticklabel_position('l')
lat.set_axislabel_position('l')

I'd like to add this to the documentation, but I think we should also make this much easier (maybe it already is?). It feels like I had to do a huge amount of manual relocation here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants