diff options
author | Aaron LI <aaronly.me@outlook.com> | 2016-10-27 10:12:36 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2016-10-27 10:12:36 +0800 |
commit | 3ca78329f6b3df293cfd8b16ea90586cae02c278 (patch) | |
tree | a520458922381f53a98658df6e5bbc9589058428 /bin/healpix2hpx | |
parent | 10283f5bb2b72b8b35d385636654c0a7f6f68fd0 (diff) | |
download | fg21sim-3ca78329f6b3df293cfd8b16ea90586cae02c278.tar.bz2 |
Check the output file existence first
Diffstat (limited to 'bin/healpix2hpx')
-rwxr-xr-x | bin/healpix2hpx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/healpix2hpx b/bin/healpix2hpx index 2a0e6a4..6f30795 100755 --- a/bin/healpix2hpx +++ b/bin/healpix2hpx @@ -62,11 +62,18 @@ 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) + hpx_data, hpx_header = healpix2hpx(args.infile, append_history=history, append_comment=comments) hdu = fits.PrimaryHDU(data=hpx_data, header=hpx_header) - hdu.writeto(args.outfile, clobber=args.clobber, checksum=True) + hdu.writeto(args.outfile, checksum=True) logger.info("HPX FITS images write to: %s" % args.outfile) |