diff --git a/cost_function.py b/cost_function.py index 663aee5028fdd0aed7f748bf25279024bad868ff..e8d6e8314367a4582904226c1bf12ca8741a69dd 100755 --- a/cost_function.py +++ b/cost_function.py @@ -27,8 +27,8 @@ import datetime from numpy import loadtxt import report_graph import util_eddies -import sys import bisect +import argparse def calculate_radii_rossby(start, end, inc, segment, e_overestim, handlers, array_d_init): @@ -76,9 +76,9 @@ def get_SHPC(array_d_ini, date_index): t0 = time.perf_counter() timings = open("timings.txt", "w") - -if len(sys.argv) == 1: - sys.exit("Required arguments: SHPC-directory [SHPC-directory] ...") +parser = argparse.ArgumentParser() +parser.add_argument("SHPC_dir", nargs='+') +args = parser.parse_args() # Grab e_overestim: with open("node_id_param.json") as f: node_id_param = json.load(f) @@ -125,7 +125,7 @@ g.ep['cost_function'] = g.new_ep('float') # Set up the list of SHPC: -handlers = [util_eddies.open_shpc(shpc_dir) for shpc_dir in sys.argv[1:]] +handlers = [util_eddies.open_shpc(shpc_dir) for shpc_dir in args.SHPC_dir] array_d_init = [handler["d_init"] for handler in handlers] # (create the list once and for all)