From 8a351c1a0bd413dd055b7529e97fe4e7ca2654c3 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 25 Nov 2017 13:59:19 +0800 Subject: astro/ps2d.py: Check outfile existence before calculation --- astro/ps2d.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/astro/ps2d.py b/astro/ps2d.py index c8a4620..718b59a 100755 --- a/astro/ps2d.py +++ b/astro/ps2d.py @@ -533,6 +533,9 @@ def main(): help="output 2D power spectrum FITS file") args = parser.parse_args() + if (not args.clobber) and os.path.exists(args.outfile): + raise OSError("outfile '%s' already exists" % args.outfile) + with fits.open(args.infile[0]) as f: cube = f[0].data header = f[0].header -- cgit v1.2.2