Skip to content

Commit 3b3f197

Browse files
authored
Validate the -f parameter
1 parent c0bb42f commit 3b3f197

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

blimpy/bl_scrunch.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
producing a new HDF5 file of Filterbank file.
44
"""
55

6-
import os
6+
import os, sys
77
from argparse import ArgumentParser
88
from blimpy.waterfall import Waterfall
99
from .utils import change_the_ext
@@ -40,6 +40,10 @@ def bl_scrunch(in_path, out_dir='./', new_filename='', max_load=None, f_scrunch=
4040
else:
4141
out_path = out_dir + new_filename
4242

43+
if f_scrunch < 2 or f_scrunch >= wf.header["nchans"] :
44+
print("\n*** Number of frequency channels to average together must be > 1 and < the input file header nchans value!!\n")
45+
sys.exit(1)
46+
4347
print("bl_scrunch: Output path: {}".format(out_path))
4448
wf.write_to_hdf5(out_path, f_scrunch=f_scrunch)
4549
print("bl_scrunch: End")
@@ -66,7 +70,7 @@ def cmd_tool(args=None):
6670
args = p.parse_args()
6771
else:
6872
args = p.parse_args(args)
69-
73+
7074
bl_scrunch(args.filepath, out_dir=args.out_dir, new_filename=args.new_filename,
7175
max_load=args.max_load, f_scrunch=args.f_scrunch)
7276

0 commit comments

Comments
 (0)