def to_wcs_geom(self, width_min=None): """Get the minimal equivalent geometry which contains the region. Parameters ---------- width_min : `~astropy.quantity.Quantity` Minimal width for the resulting geometry. Can be a single number or two, for different minimum widths in each spatial dimension. Returns ------- wcs_geom : `~WcsGeom` A WCS geometry object. """ if width_min is not None: width = np.min( [self.width.to_value("deg"), _check_width(width_min)], axis=0) else: width = self.width wcs_geom_region = WcsGeom(wcs=self.wcs, npix=self.wcs.array_shape) wcs_geom = wcs_geom_region.cutout(position=self.center_skydir, width=width) wcs_geom = wcs_geom.to_cube(self.axes) return wcs_geom
def test_check_width(width, out): width = _check_width(width) assert isinstance(width, tuple) assert isinstance(width[0], float) assert isinstance(width[1], float) assert width == out geom = WcsGeom.create(width=width, binsz=1.0) assert tuple(geom.npix) == out
def test_check_width_bad_input(): with pytest.raises(IndexError): _check_width(width=(10, ))