# Maps in relative coordinates with WCSAxes

**URL:** <https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186>\
**Category:** Astropy\
**Tags:** astropy, question\
**Created:** [September 29, 2021, 3:59pm UTC](https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186 "2021-09-29T15:59:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![smaret](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/smaret/32/94_2.png) [@smaret](https://community.openastronomy.org/u/smaret)\
**Post date:** [September 29, 2021, 3:59pm UTC](https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186/1 "2021-09-29T15:59:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![varunbhalerao](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/varunbhalerao/32/129_2.png) [@varunbhalerao](https://community.openastronomy.org/u/varunbhalerao)\
**Post date:** [September 30, 2021, 3:53am UTC](https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186/2 "2021-09-30T03:53:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smaret](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/smaret/32/94_2.png) [@smaret](https://community.openastronomy.org/u/smaret)\
**Post date:** [September 30, 2021, 8:09am UTC](https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186/3 "2021-09-30T08:09:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cadair](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/cadair/32/422_2.png) [@Cadair](https://community.openastronomy.org/u/Cadair)\
**Post date:** [October 5, 2021, 12:34pm UTC](https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186/4 "2021-10-05T12:34:11Z")

</div>

Hey @smaret

If you create yourself a [`SkyOffsetFrame`](https://docs.astropy.org/en/stable/coordinates/matchsep.html#astropy-skyoffset-frames) and then generate an overlay using that frame ([Overlaying coordinate systems — Astropy v4.3.1](https://docs.astropy.org/en/stable/visualization/wcsaxes/overlaying_coordinate_systems.html)) you should achieve what you want.

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

---

<div class="post-metadata">

**Author:** ![smaret](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/smaret/32/94_2.png) [@smaret](https://community.openastronomy.org/u/smaret)\
**Post date:** [June 29, 2022, 12:21pm UTC](https://community.openastronomy.org/t/maps-in-relative-coordinates-with-wcsaxes/186/5 "2022-06-29T12:21:16Z")

</div>

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

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

```nohighlight
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

```
