diff options
| author | Aaron LI <aly@aaronly.me> | 2018-07-16 15:17:14 +0800 | 
|---|---|---|
| committer | Aaron LI <aly@aaronly.me> | 2018-07-16 15:17:14 +0800 | 
| commit | ff44047d1bcbf3f4e4d2a0ac6cd3ac7c0d841068 (patch) | |
| tree | d064f63e49eabe55f85b7f2f360b262bdaeb648b /astro | |
| parent | 738356825bee0cdea41e8b022d2c57f7f2aaceec (diff) | |
| download | atoolbox-ff44047d1bcbf3f4e4d2a0ac6cd3ac7c0d841068.tar.bz2 | |
astro/tile_slice.py: Check file existence first
Diffstat (limited to 'astro')
| -rwxr-xr-x | astro/21cm/tile_slice.py | 10 | 
1 files changed, 9 insertions, 1 deletions
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 <weitian@aaronly.me> +# Copyright (c) 2017-2018 Weitian LI <wt@liwt.net>  # 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)  | 
