def test_polygon_spatial_request(poly, poly_payload): polygon_region = PolygonSkyRegion(vertices=poly) request_payload = cds.query_region(region=polygon_region, intersect='overlaps', get_query_payload=True) assert request_payload['stc'] == poly_payload
def to_region(self, **kwargs): """Model outline (`~regions.PolygonSkyRegion`).""" footprint = self.map.geom.wcs.calc_footprint() return PolygonSkyRegion(vertices=SkyCoord( footprint, unit="deg", frame=self.frame, **kwargs))
print(results) filtered_results = clean_up_results(results, obj_name=obj_name, id_type=id_type, location=location) print(filtered_results) # Using regions import matplotlib.pyplot as plt from astropy.coordinates import SkyCoord from regions import PixCoord, PolygonSkyRegion, PolygonPixelRegion, CirclePixelRegion patch_xs = parse_s_region(stcs)['ra'] patch_ys = parse_s_region(stcs)['dec'] polygon_sky = PolygonSkyRegion( vertices=SkyCoord(patch_xs, patch_ys, unit='deg', frame='icrs')) # Treating as pixels for simplicity (and since I have no WCS) polygon_pix = PolygonPixelRegion(vertices=PixCoord(x=patch_xs, y=patch_ys)) PixCoord(eph['RA'][1], eph['DEC'][1]) in polygon_pix radius = 0.0083 target_coords = PixCoord(eph['RA'][0], eph['DEC'][0]) target_circle = CirclePixelRegion(center=target_coords, radius=radius) intersection = target_circle & polygon_pix # intersection.area # not implemented yet fig, ax = plt.subplots(figsize=(8, 4)) patch = polygon_pix.as_artist(facecolor='none', edgecolor='red', lw=2) ax.add_patch(patch) plt.plot([eph['RA'][1]], [eph['DEC'][1]], 'ko') plt.xlim(84.2, 81.4)