def test_cutout_info(): geom = WcsGeom.create( skydir=(0, 0), npix=10, ) position = SkyCoord(0, 0, unit="deg") cutout_geom = geom.cutout(position=position, width="2 deg") assert cutout_geom.cutout_info["parent-slices"][0].start == 3 assert cutout_geom.cutout_info["parent-slices"][1].start == 3 assert cutout_geom.cutout_info["cutout-slices"][0].start == 0 assert cutout_geom.cutout_info["cutout-slices"][1].start == 0 header = cutout_geom.make_header() assert "PSLICE1" in header assert "PSLICE2" in header assert "CSLICE1" in header assert "CSLICE2" in header geom = WcsGeom.from_header(header) assert geom.cutout_info["parent-slices"][0].start == 3 assert geom.cutout_info["parent-slices"][1].start == 3 assert geom.cutout_info["cutout-slices"][0].start == 0 assert geom.cutout_info["cutout-slices"][1].start == 0
def test_wcsgeom_read_write(tmp_path, npix, binsz, frame, proj, skydir, axes): geom0 = WcsGeom.create(npix=npix, binsz=binsz, proj=proj, frame=frame, axes=axes) hdu_bands = geom0.to_bands_hdu(hdu_bands="TEST_BANDS") hdu_prim = fits.PrimaryHDU() hdu_prim.header.update(geom0.to_header()) hdulist = fits.HDUList([hdu_prim, hdu_bands]) hdulist.writeto(tmp_path / "tmp.fits") with fits.open(tmp_path / "tmp.fits", memmap=False) as hdulist: geom1 = WcsGeom.from_header(hdulist[0].header, hdulist["TEST_BANDS"]) assert_allclose(geom0.npix, geom1.npix) assert geom0.frame == geom1.frame
def test_wcsgeom_read_write(tmpdir, npix, binsz, coordsys, proj, skydir, axes): geom0 = WcsGeom.create( npix=npix, binsz=binsz, proj=proj, coordsys=coordsys, axes=axes ) hdu_bands = geom0.make_bands_hdu(hdu="BANDS") hdu_prim = fits.PrimaryHDU() hdu_prim.header.update(geom0.make_header()) filename = str(tmpdir / "wcsgeom.fits") hdulist = fits.HDUList([hdu_prim, hdu_bands]) hdulist.writeto(filename, overwrite=True) with fits.open(filename) as hdulist: geom1 = WcsGeom.from_header(hdulist[0].header, hdulist["BANDS"]) assert_allclose(geom0.npix, geom1.npix) assert geom0.coordsys == geom1.coordsys