Coordinate Frame Transformation of Spherical Regions

The SkyCoord class provides functionality for representing celestial coordinates and for transforming between different coordinate frames (see the Astronomical Coordinate Systems (astropy.coordinates) documentation for full details).

Since the SphericalSkyRegion class represents geometric shapes on the celestial sphere, these idealized shapes can also be represented in, and transformed between, any spherical coordinate reference frame. Transforming spherical regions can be useful in cases where a region of interest is defined in one coordinate frame, but a query searching for targets in this region needs to be specified in second coordinate frame.

As an example, let’s start by defining two sky regions in the Galactic coordinate frame:

>>> from astropy.coordinates import SkyCoord
>>> from astropy import units as u
>>> from regions import CircleSphericalSkyRegion, RangeSphericalSkyRegion
>>> sph_circ = CircleSphericalSkyRegion(SkyCoord(100,-30,unit=u.deg,
...                                              frame="galactic"),
...                                     30*u.deg)
>>> sph_range = RangeSphericalSkyRegion(frame="galactic",
...                                     longitude_range=[-45,45]*u.deg,
...                                     latitude_range=[0,45]*u.deg)
>>> print(sph_circ)
Region: CircleSphericalSkyRegion
center: <SkyCoord (Galactic): (l, b) in deg
    (100., -30.)>
radius: 30.0 deg
>>> print(sph_range)
Region: RangeSphericalSkyRegion
frame: galactic
longitude_range: [-45.  45.] deg
latitude_range: [ 0. 45.] deg

To convert these regions to the ICRS coordinate frame, the transform_to() method is used.

>>> sph_circ_transf = sph_circ.transform_to("icrs")
>>> sph_range_transf = sph_range.transform_to("icrs")
>>> print(sph_circ_transf)
Region: CircleSphericalSkyRegion
center: <SkyCoord (ICRS): (ra, dec) in deg
    (350.21026136, 28.80607705)>
radius: 30.0 deg
>>> print(sph_range_transf)
Region: RangeSphericalSkyRegion
frame: icrs
longitude_bounds: <LuneSphericalSkyRegion(center_gc1=<SkyCoord (ICRS): (ra, dec) in deg
    (288.42757587, 10.72370325)>, center_gc2=<SkyCoord (ICRS): (ra, dec) in deg
    (217.98010947, -60.49575721)>)>
latitude_bounds: <CircleAnnulusSphericalSkyRegion(center=<SkyCoord (ICRS): (ra, dec) in deg
    (192.85947789, 27.12825241)>, inner_radius=45.0 deg, outer_radius=90.0 deg)>

Note that the Range region boundaries cannot be simply described by longitude/latitude boundaries in a transformed frame, so the underlying circular annulus and lune boundaries (capturing the original frame latitude and longitude bounds, respectively) are used to describe this Range regions after a transformation.

These original and transformed regions are shown below on full-sky projections for the Galactic and ICRS coordinate reference frames (respectively).

(Source code, png, hires.png, pdf, svg)

_images/spherical_frame_transform-1.png