aboutsummaryrefslogtreecommitdiffstats
path: root/bin/hpx2healpix
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-10-27 10:12:36 +0800
committerAaron LI <aaronly.me@outlook.com>2016-10-27 10:12:36 +0800
commit3ca78329f6b3df293cfd8b16ea90586cae02c278 (patch)
treea520458922381f53a98658df6e5bbc9589058428 /bin/hpx2healpix
parent10283f5bb2b72b8b35d385636654c0a7f6f68fd0 (diff)
downloadfg21sim-3ca78329f6b3df293cfd8b16ea90586cae02c278.tar.bz2
Check the output file existence first
Diffstat (limited to 'bin/hpx2healpix')
-rwxr-xr-xbin/hpx2healpix10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/hpx2healpix b/bin/hpx2healpix
index ca485ac..bbc3e0d 100755
--- a/bin/hpx2healpix
+++ b/bin/hpx2healpix
@@ -60,11 +60,17 @@ def main():
'See also {0}'.format(fg21sim.__url__)
]
+ if os.path.exists(args.outfile):
+ if args.clobber:
+ logger.warning("Remove existing output file: %s" % args.outfile)
+ os.remove(args.outfile)
+ else:
+ raise OSError("Output file already exists: %s" % args.outfile)
+
hp_data, hp_header = hpx2healpix(args.infile,
append_history=history,
append_comment=comments)
- write_fits_healpix(args.outfile, hpmap=hp_data, header=hp_header,
- clobber=args.clobber)
+ write_fits_healpix(args.outfile, hpmap=hp_data, header=hp_header)
logger.info("HEALPix data write to FITS file: %s" % args.outfile)