contains#
- m4opt.fov.contains(region, target_coord)[source] [edit on github]#
Test if a region contains a given sky coordinate.
This is similar to
regions.SkyRegion.contains(), but does not require you to specify aWCS.- Parameters:
- Returns:
A flag indicating whether each targert coordinate is contained within the region.
- Return type:
Notes
Edges of polygons and rectangles are assumed to be great circle arcs.
When using a
regions.PolygonSkyRegion, this method is only valid for polygons that fit in a single hemisphere, because it relies on transforming the polygon to a gnomonic projection, which is a projection of half of the sphere in which great circles are straight lines.Examples
>>> from astropy.coordinates import SkyCoord >>> from astropy import units as u >>> from regions import CircleSkyRegion, PolygonSkyRegion, RectangleSkyRegion >>> from m4opt.fov import contains >>> region = CircleSkyRegion(SkyCoord(0 * u.deg, 0 * u.deg), 5 * u.deg) >>> contains(region, SkyCoord(0 * u.deg, 0 * u.deg)) np.True_ >>> region = PolygonSkyRegion(SkyCoord([359, 1, 1, 359] * u.deg, [-2, -2, 2, 2] * u.deg)) >>> contains(region, SkyCoord(0 * u.deg, 0 * u.deg)) True >>> region = RectangleSkyRegion(SkyCoord(0 * u.deg, 0 * u.deg), 2 * u.deg, 4 * u.deg) >>> contains(region, SkyCoord(0 * u.deg, 0 * u.deg)) True