aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/sky.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-05-27 17:06:04 +0800
committerAaron LI <aaronly.me@outlook.com>2017-05-27 17:06:04 +0800
commitc121abe97ec4141400b9adcacb69589f06ce9be1 (patch)
treedff3d2a04041f158494f54a4a8e5235e90acc053 /fg21sim/sky.py
parent548f3b1ed9a784a8758754b27a60a8485cdbaee8 (diff)
downloadfg21sim-c121abe97ec4141400b9adcacb69589f06ce9be1.tar.bz2
sky.py: Fix FITS header write
Diffstat (limited to 'fg21sim/sky.py')
-rw-r--r--fg21sim/sky.py12
1 files changed, 8 insertions, 4 deletions
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)