aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/sky.py
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-13 12:26:03 +0800
committerAaron LI <aly@aaronly.me>2017-08-13 12:26:03 +0800
commit4e393b5430d36750d644c50342d6481cf1567b36 (patch)
tree4edd2fd994b1a849eb09e0a4f93da667dcfbee23 /fg21sim/sky.py
parentaaf27c2ddd8a53b1669f05dde267ae4d5d096f71 (diff)
downloadfg21sim-4e393b5430d36750d644c50342d6481cf1567b36.tar.bz2
sky.py: Add parameter "clobber" to "write()" method
Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/sky.py')
-rw-r--r--fg21sim/sky.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/fg21sim/sky.py b/fg21sim/sky.py
index d10186f..53586c0 100644
--- a/fg21sim/sky.py
+++ b/fg21sim/sky.py
@@ -157,7 +157,7 @@ class SkyBase:
"""
raise NotImplementedError
- def write(self, outfile):
+ def write(self, outfile, clobber=None):
"""
Write the sky image (with current data) into a FITS file.
@@ -165,6 +165,10 @@ class SkyBase:
----------
outfile : str
The path/filename to the output FITS file.
+ clobber : bool, optional
+ If not ``None``, then overwrite the default ``self.clobber_``
+ from the configuration file, to determine whether to overwrite
+ the existing output file.
"""
raise NotImplementedError
@@ -350,13 +354,15 @@ class SkyPatch(SkyBase):
zoom = (self.ysize/self.ysize_in, self.xsize/self.xsize_in)
self.data = ndimage.zoom(self.data, zoom=zoom, order=1)
- def write(self, outfile):
+ def write(self, outfile, clobber=None):
"""
Write current data to file.
"""
+ if clobber is None:
+ clobber = self.clobber_
write_fits_image(outfile, image=self.data, header=self.header,
float32=self.float32_,
- clobber=self.clobber_,
+ clobber=clobber,
checksum=self.checksum_)
@property
@@ -553,10 +559,12 @@ class SkyHealpix(SkyBase):
logger.warning("Upgrade/downgrade sky map from Nside " +
"{0} to {1}".format(self.nside_in, self.nside))
- def write(self, outfile):
+ def write(self, outfile, clobber=None):
"""
Write current data to file.
"""
+ if clobber is None:
+ clobber = self.clobber_
write_fits_healpix(outfile, hpmap=self.data, header=self.header,
float32=self.float32_,
clobber=self.clobber_,