Skip to content

Commit ae00caa

Browse files
committed
Manually write wcs maps with astropy, to avoid pixell incompatibility.
1 parent 688256e commit ae00caa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/toast/pixels_io_wcs.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import os
66

7+
import astropy.io.fits as af
78
import numpy as np
89
import pixell
910
import pixell.enmap
@@ -246,7 +247,14 @@ def write_wcs_fits(pix, path, comm_bytes=10000000, report_memory=False):
246247
if rank == 0:
247248
if os.path.isfile(path):
248249
os.remove(path)
249-
endata.write(path, fmt="fits")
250+
# Basic wcs header
251+
header = endata.wcs.to_header(relax=True)
252+
# Add map dimensions
253+
header["NAXIS"] = endata.ndim
254+
for i, n in enumerate(endata.shape[::-1]):
255+
header[f"NAXIS{i+1}"] = n
256+
hdus = af.HDUList([af.PrimaryHDU(endata, header)])
257+
hdus.writeto(path)
250258

251259
del endata
252260
return

0 commit comments

Comments
 (0)