From c121abe97ec4141400b9adcacb69589f06ce9be1 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 27 May 2017 17:06:04 +0800 Subject: sky.py: Fix FITS header write --- fg21sim/sky.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'fg21sim/sky.py') diff --git a/fg21sim/sky.py b/fg21sim/sky.py index 8f15ca8..2c176ff 100644 --- a/fg21sim/sky.py +++ b/fg21sim/sky.py @@ -171,9 +171,11 @@ class SkyPatch: os.makedirs(outdir) logger.info("Created output directory: %s" % outdir) image = self.data.reshape(self.ysize, self.xsize) - header = self.wcs.to_header() - header.extend(self.header, update=True) - hdu = fits.PrimaryHDU(data=image, header=self.header) + if hasattr(self, "header"): + header = self.header.copy(strip=True) + wcs_header = self.wcs.to_header() + header.extend(wcs_header, update=True) + hdu = fits.PrimaryHDU(data=image, header=header) hdu.writeto(outfile, clobber=clobber, checksum=checksum) logger.info("Write sky map to file: %s" % outfile) @@ -364,7 +366,9 @@ class SkyHealpix: if not os.path.exists(outdir): os.makedirs(outdir) logger.info("Created output directory: %s" % outdir) - write_fits_healpix(outfile, self.data, header=self.header, + if hasattr(self, "header"): + header = self.header + write_fits_healpix(outfile, self.data, header=header, clobber=clobber, checksum=checksum) logger.info("Write sky map to file: %s" % outfile) -- cgit v1.2.2