def test_hpxgeom_read_write(tmp_path, nside, nested, coordsys, region, axes): geom0 = HpxGeom(nside, nested, coordsys, region=region, axes=axes) hdu_bands = geom0.make_bands_hdu(hdu="BANDS") hdu_prim = fits.PrimaryHDU() hdu_prim.header.update(geom0.make_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 = HpxGeom.from_header(hdulist[0].header, hdulist["BANDS"]) assert_allclose(geom0.nside, geom1.nside) assert_allclose(geom0.npix, geom1.npix) assert_allclose(geom0.nest, geom1.nest) assert geom0.coordsys == geom1.coordsys
def test_hpxgeom_read_write(tmpdir, nside, nested, coordsys, region, axes): geom0 = HpxGeom(nside, nested, coordsys, region=region, axes=axes) hdu_bands = geom0.make_bands_hdu(hdu="BANDS") hdu_prim = fits.PrimaryHDU() hdu_prim.header.update(geom0.make_header()) filename = str(tmpdir / "hpxgeom.fits") hdulist = fits.HDUList([hdu_prim, hdu_bands]) hdulist.writeto(filename, overwrite=True) hdulist = fits.open(filename) geom1 = HpxGeom.from_header(hdulist[0].header, hdulist["BANDS"]) assert_allclose(geom0.nside, geom1.nside) assert_allclose(geom0.npix, geom1.npix) assert_allclose(geom0.nest, geom1.nest) assert geom0.coordsys == geom1.coordsys