From ff44047d1bcbf3f4e4d2a0ac6cd3ac7c0d841068 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 16 Jul 2018 15:17:14 +0800 Subject: astro/tile_slice.py: Check file existence first --- astro/21cm/tile_slice.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'astro') diff --git a/astro/21cm/tile_slice.py b/astro/21cm/tile_slice.py index 091d599..4222461 100755 --- a/astro/21cm/tile_slice.py +++ b/astro/21cm/tile_slice.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (c) 2017 Weitian LI +# Copyright (c) 2017-2018 Weitian LI # MIT License # @@ -9,6 +9,7 @@ Tile the given slices to the required FoV size, scale down to the wanted size (for faster simulation later). """ +import os import sys import argparse @@ -55,6 +56,13 @@ def main(): help="central frequency [MHz] of the selected cube") args = parser.parse_args() + if os.path.exists(args.outfile): + if args.clobber: + os.remove(args.outfile) + else: + raise FileExistsError('output file already exists: %s' % + args.outfile) + if args.zc: zc = args.zc fc = z2freq(zc, print_=False) -- cgit v1.2.2