Maps in relative coordinates with WCSAxes

Hello,

I find the WCSAxes framework extremely useful for making maps in celestial coordinates (e.g. RA and Dec.). However, I sometime need to make maps in relative coordinates instead (that is RA and Dec spherical offsets with respect to given position).

How can I do this with WCSAxes?

Thanks,
Sébastien

1 Like

Perhaps you could define a new coordinate system centred on the current target, and use that in your plots?

Thanks for your answer. In practice, how do you define this news coordinate system?

Hey @smaret

If you create yourself a SkyOffsetFrame and then generate an overlay using that frame (Overlaying coordinate systems — Astropy v4.3.1) you should achieve what you want.

Let us know how it goes, and maybe provide a picture of the result :slight_smile:

1 Like

Thanks for your answer @Cadair, and sorry for the long silence.

I was able to make a map in relative coordinates as you suggested:

fig = plt.figure(0, clear=True)
w = astropy.wcs.WCS(hdu.header)
ax = fig.add_subplot(1, 1, 1, projection=w)

# Remove the absolute coordinates
ra = ax.coords["ra"]
dec = ax.coords["dec"]
ra.set_ticks_visible(False)
ra.set_ticklabel_visible(False)
dec.set_ticks_visible(False)
dec.set_ticklabel_visible(False)
ra.set_axislabel("")
dec.set_axislabel("")

# Create an overlay with relative coordinates
aframe = continuum_peak.skyoffset_frame()
overlay = ax.get_coords_overlay(aframe)
ra_offset = overlay["lon"]
dec_offset = overlay["lat"]
ra_offset.set_axislabel("RA offset")
dec_offset.set_axislabel("Dec offset")
ra_offset.set_major_formatter("s.s")
dec_offset.set_major_formatter("s.s")
ra_offset.set_ticks_position("bt")
ra_offset.set_ticklabel_position("b")
dec_offset.set_ticks_position("lr")
dec_offset.set_ticklabel_position("l")
ra_offset.set_axislabel_position("b")
dec_offset.set_axislabel_position("l")
ra_offset.coord_wrap = 180 # avoid wrapping
1 Like