simonsobs / pixell

A rectangular pixel map manipulation and harmonic analysis library derived from Sigurd Naess' enlib.
Other
42 stars 32 forks source link

Print warning if no wcs is provided in `write_map` #274

Open zonca opened 4 weeks ago

zonca commented 4 weeks ago

write_map attaches a default WCS if the input map has no WCS, it might be useful to add a warning (or even an error) if this happens. This can be a source of bugs if a user is not careful (e.g. https://github.com/galsci/pysm/issues/192) @msyriac

Minimal example below:

import pixell.enmap
import numpy as np

shape, wcs = pixell.enmap.fullsky_geometry(
    np.radians(5),
    dims=(3,),
    variant="fejer1",
)

m = pixell.enmap.zeros(shape, wcs)
pixell.enmap.write_map("map_with_wcs.fits", m)
pixell.enmap.write_map("map_no_wcs.fits", np.array(m))

print(pixell.enmap.read_map("map_with_wcs.fits").wcs)
car:{cdelt:[-5,5],crval:[2.5,0],crpix:[36.50,18.50]}

print(pixell.enmap.read_map("map_no_wcs.fits").wcs)
:{cdelt:[1,1],crval:[0,0],crpix:[0.00,0.00]}