diff --git a/src/nested/map/fits/read.rs b/src/nested/map/fits/read.rs index 0ef9952..fb89aaa 100644 --- a/src/nested/map/fits/read.rs +++ b/src/nested/map/fits/read.rs @@ -161,7 +161,7 @@ pub fn from_fits_skymap_internal(mut reader: R) -> Result unreachable!(), }?; let n_hash = n_hash(depth); - skymap_kws.check_lastpix(n_hash)?; + skymap_kws.check_lastpix(n_hash - 1)?; // Check whether TForm compatible with N bytes per row let n_hash_2 = coltype_1.n_pack() as u64 * n_rows; if n_hash != n_hash_2 { diff --git a/src/nested/map/fits/write.rs b/src/nested/map/fits/write.rs index 42a7c13..ae45bea 100644 --- a/src/nested/map/fits/write.rs +++ b/src/nested/map/fits/write.rs @@ -158,7 +158,7 @@ fn write_skymap_fits_header( it.next().unwrap()[0..20].copy_from_slice(b"EXTNAME = 'xtension'"); write_uint_mandatory_keyword_record(it.next().unwrap(), b"NSIDE ", nside as u64); it.next().unwrap()[0..30].copy_from_slice(b"FIRSTPIX= 0"); - write_uint_mandatory_keyword_record(it.next().unwrap(), b"LASTPIX ", n_cells); + write_uint_mandatory_keyword_record(it.next().unwrap(), b"LASTPIX ", n_cells - 1); it.next().unwrap()[0..20].copy_from_slice(b"INDXSCHM= 'IMPLICIT'"); it.next().unwrap()[0..20].copy_from_slice(b"OBJECT = 'FULLSKY '"); it.next().unwrap()[0..28].copy_from_slice(b"CREATOR = 'CDS HEALPix Rust'"); diff --git a/src/nested/map/mod.rs b/src/nested/map/mod.rs index 7aeb63e..07fd0cb 100644 --- a/src/nested/map/mod.rs +++ b/src/nested/map/mod.rs @@ -67,5 +67,21 @@ mod tests { false, ) .unwrap(); + + let path = "test/resources/skymap/hats_test.fits"; + let skymap = SkyMapEnum::from_fits_file(path).unwrap(); + skymap + .to_png_file::( + (1600, 800), + None, + None, + None, + Some(PosConversion::EqMap2GalImg), + None, + Some(ColorMapFunctionType::LinearLog), //Some(ColorMapFunctionType::LinearSqrt) + "test/resources/skymap/hats_tets.png", + false, + ) + .unwrap(); } } diff --git a/src/nested/map/mom/mod.rs b/src/nested/map/mom/mod.rs index f4556fa..66d30c6 100644 --- a/src/nested/map/mom/mod.rs +++ b/src/nested/map/mom/mod.rs @@ -149,6 +149,9 @@ pub trait Mom<'a> { } } + /// # Warning + /// * assumes that the order of the elements returned by `zuniqs()` is the same as the one returned + /// by `entries()`. fn check_is_mom(&'a self) -> Result<(), String> { let mut it = self.zuniqs(); if let Some(mut l) = it.next() { diff --git a/test/resources/skymap/hats_test.fits b/test/resources/skymap/hats_test.fits new file mode 100644 index 0000000..0aafa48 Binary files /dev/null and b/test/resources/skymap/hats_test.fits differ diff --git a/test/resources/skymap/hats_tets.png b/test/resources/skymap/hats_tets.png new file mode 100644 index 0000000..fa41318 Binary files /dev/null and b/test/resources/skymap/hats_tets.png differ diff --git a/test/resources/skymap/skymap.fits b/test/resources/skymap/skymap.fits index a49acc2..999177d 100644 Binary files a/test/resources/skymap/skymap.fits and b/test/resources/skymap/skymap.fits differ