61 """Check if a set of sky positions are in the bounding box.
63 This uses a two-step process: first check that the coordinates are
64 inside a padded version of the bbox projected on the sky, and then
65 project the remaining points onto the bbox, to avoid inverting
66 the WCS outside of the valid region. The default padding
67 size was chosen to be sufficient for the most warped detectors at
68 the edges of the HyperSuprimeCam focal plane.
72 bbox : `lsst.geom.Box2I`
73 Pixel bounding box to check sky positions in.
74 wcs : `lsst.afw.image.SkyWcs`
75 WCS associated with the bounding box.
76 ra : `astropy.Quantity`, (N,)
77 Array of Right Ascension, angular units.
78 dec : `astropy.Quantity`, (N,)
79 Array of Declination, angular units.
81 Pixel padding to ensure that bounding box is entirely contained
82 within the resulting polygon.
86 contained : `np.ndarray`, (N,)
87 Boolean array indicating which points are contained in the
90 poly = bbox_to_convex_polygon(bbox, wcs, padding=padding)
92 _ra = np.atleast_1d(ra.to(units.radian).value).astype(np.float64)
93 _dec = np.atleast_1d(dec.to(units.radian).value).astype(np.float64)
95 radec_contained = poly.contains(_ra, _dec)
97 contained = np.zeros_like(radec_contained, dtype=bool)
99 x_in, y_in = wcs.skyToPixelArray(_ra[radec_contained], _dec[radec_contained], degrees=
False)
100 xy_contained = bbox.contains(x_in, y_in)
103 contained[radec_contained] = xy_contained