@@ -1844,7 +1844,7 @@ def from_astropy_regions(cls, region, max_depth: int):
1844
1844
The supported sky regions are `~regions.CircleSkyRegion`,
1845
1845
`~regions.CircleAnnulusSkyRegion`, `~regions.EllipseSkyRegion`,
1846
1846
`~regions.RectangleSkyRegion`, `~regions.PolygonSkyRegion`,
1847
- `~regions.PointSkyRegion`.
1847
+ `~regions.PointSkyRegion`, `~regions.Regions` .
1848
1848
max_depth : int
1849
1849
The maximum HEALPix cell resolution of the MOC. Should be comprised between
1850
1850
0 and 29.
@@ -1853,6 +1853,14 @@ def from_astropy_regions(cls, region, max_depth: int):
1853
1853
-------
1854
1854
`~mocpy.moc.MOC`
1855
1855
1856
+ Notes
1857
+ -----
1858
+ - For the `~regions.Regions`, the returned MOC will be the union of all the regions.
1859
+ - For the `~regions.PolygonSkyRegion` and the `~regions.RectangleSkyRegion`, the MOC
1860
+ will consider the sides to follow great circles on the sky sphere while in
1861
+ astropy-regions the sides follow straight lines in the projected space (depending on
1862
+ a given WCS, see issue https://github.com/astropy/regions/issues/564).
1863
+
1856
1864
Examples
1857
1865
--------
1858
1866
>>> from astropy.coordinates import SkyCoord
@@ -1869,6 +1877,7 @@ def from_astropy_regions(cls, region, max_depth: int):
1869
1877
regions .RectangleSkyRegion ,
1870
1878
regions .PolygonSkyRegion ,
1871
1879
regions .PointSkyRegion ,
1880
+ regions .Regions ,
1872
1881
)
1873
1882
if isinstance (region , regions .CircleSkyRegion ):
1874
1883
center = region .center .icrs
@@ -1927,6 +1936,13 @@ def from_astropy_regions(cls, region, max_depth: int):
1927
1936
return cls .from_polygon_skycoord (region .vertices , max_depth = max_depth )
1928
1937
if isinstance (region , regions .PointSkyRegion ):
1929
1938
return cls .from_skycoords (region .center , max_norder = max_depth )
1939
+ if isinstance (region , regions .Regions ):
1940
+ mocs = [
1941
+ cls .from_astropy_regions (reg , max_depth = max_depth ) for reg in region
1942
+ ]
1943
+ if len (mocs ) == 1 :
1944
+ return mocs [0 ]
1945
+ return mocs [0 ].union (* mocs [1 :]) # fastest multi-union
1930
1946
1931
1947
raise ValueError (
1932
1948
"'from_astropy_regions' does not support this region type."
0 commit comments