Skip to content
Snippets Groups Projects
Commit 9165f777 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Use argparse

Preparing to introduce an option.
parent e74ae8d9
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,8 @@ import datetime ...@@ -27,8 +27,8 @@ import datetime
from numpy import loadtxt from numpy import loadtxt
import report_graph import report_graph
import util_eddies import util_eddies
import sys
import bisect import bisect
import argparse
def calculate_radii_rossby(start, end, inc, segment, e_overestim, handlers, def calculate_radii_rossby(start, end, inc, segment, e_overestim, handlers,
array_d_init): array_d_init):
...@@ -76,9 +76,9 @@ def get_SHPC(array_d_ini, date_index): ...@@ -76,9 +76,9 @@ def get_SHPC(array_d_ini, date_index):
t0 = time.perf_counter() t0 = time.perf_counter()
timings = open("timings.txt", "w") timings = open("timings.txt", "w")
parser = argparse.ArgumentParser()
if len(sys.argv) == 1: parser.add_argument("SHPC_dir", nargs='+')
sys.exit("Required arguments: SHPC-directory [SHPC-directory] ...") args = parser.parse_args()
# Grab e_overestim: # Grab e_overestim:
with open("node_id_param.json") as f: node_id_param = json.load(f) 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') ...@@ -125,7 +125,7 @@ g.ep['cost_function'] = g.new_ep('float')
# Set up the list of SHPC: # 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] array_d_init = [handler["d_init"] for handler in handlers]
# (create the list once and for all) # (create the list once and for all)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment