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 | |
parent | 10283f5bb2b72b8b35d385636654c0a7f6f68fd0 (diff) | |
download | fg21sim-3ca78329f6b3df293cfd8b16ea90586cae02c278.tar.bz2 |
Check the output file existence first
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/healpix2hpx | 9 | ||||
-rwxr-xr-x | bin/hpx2healpix | 10 | ||||
-rwxr-xr-x | bin/zea2healpix | 10 |
3 files changed, 24 insertions, 5 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) 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) diff --git a/bin/zea2healpix b/bin/zea2healpix index 33cb694..334bf6d 100755 --- a/bin/zea2healpix +++ b/bin/zea2healpix @@ -76,14 +76,20 @@ 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, __ = zea2healpix(args.infile1, args.infile2, nside=args.nside, order=args.interp_order, inpaint=args.inpaint, 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) |