From fe17378bb0fcedc48556ff1e07c9d831105fc8f0 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Tue, 29 Mar 2022 09:38:11 +0200 Subject: [PATCH] Add cli arg for config file --- data/processing/projection.py | 3 ++- data/processing/subdomain.py | 3 ++- olaflow/processing/bathy.py | 3 ++- olaflow/processing/sws_ola.py | 3 ++- swash/processing/animate.py | 3 ++- swash/processing/layers.py | 7 ++----- swash/processing/post.py | 3 ++- swash/processing/swash.py | 3 ++- swash/processing/sws_npz.py | 3 ++- 9 files changed, 18 insertions(+), 13 deletions(-) diff --git a/data/processing/projection.py b/data/processing/projection.py index 2647b29..4add6bc 100644 --- a/data/processing/projection.py +++ b/data/processing/projection.py @@ -14,6 +14,7 @@ from .lambert import Lambert parser = argparse.ArgumentParser(description="Pre-process bathymetry") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -21,7 +22,7 @@ log = logging.getLogger("bathy") log.info("Starting bathymetry pre-processing") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) inp_root = pathlib.Path(config.get("inp", "root")) out_root = pathlib.Path(config.get("out", "root")) diff --git a/data/processing/subdomain.py b/data/processing/subdomain.py index 54113cc..edba50a 100644 --- a/data/processing/subdomain.py +++ b/data/processing/subdomain.py @@ -7,6 +7,7 @@ import numpy as np parser = argparse.ArgumentParser(description="Pre-process bathymetry") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -14,7 +15,7 @@ log = logging.getLogger("bathy") log.info("Starting bathymetry pre-processing") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) artha = np.array( (config.getfloat("artha", "lon"), config.getfloat("artha", "lat")) diff --git a/olaflow/processing/bathy.py b/olaflow/processing/bathy.py index 8440fa5..85834cf 100644 --- a/olaflow/processing/bathy.py +++ b/olaflow/processing/bathy.py @@ -11,6 +11,7 @@ parser = argparse.ArgumentParser( description="Convert swash output to olaFlow input" ) parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -18,7 +19,7 @@ log = logging.getLogger("sws_ola") log.info("Starting sws -> olaFlow converter") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) bathy = np.loadtxt(config.get("bathy", "bathy"))[::-1] hstru = np.loadtxt(config.get("bathy", "hstru"))[::-1] diff --git a/olaflow/processing/sws_ola.py b/olaflow/processing/sws_ola.py index c10673c..dd67763 100644 --- a/olaflow/processing/sws_ola.py +++ b/olaflow/processing/sws_ola.py @@ -13,6 +13,7 @@ parser = argparse.ArgumentParser( description="Convert swash output to olaFlow input" ) parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -20,7 +21,7 @@ log = logging.getLogger("sws_ola") log.info("Starting sws -> olaFlow converter") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) sws_out = pathlib.Path(config.get("swash", "np_out")) def data(var): diff --git a/swash/processing/animate.py b/swash/processing/animate.py index b6c6804..6749f74 100644 --- a/swash/processing/animate.py +++ b/swash/processing/animate.py @@ -9,6 +9,7 @@ import numpy as np parser = argparse.ArgumentParser(description="Animate swash output") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -16,7 +17,7 @@ log = logging.getLogger("post") log.info("Starting post-processing") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) inp = pathlib.Path(config.get("post", "inp")) root = pathlib.Path(config.get("swash", "out")) diff --git a/swash/processing/layers.py b/swash/processing/layers.py index 4bbf97f..b1943dc 100644 --- a/swash/processing/layers.py +++ b/swash/processing/layers.py @@ -6,13 +6,10 @@ import pathlib import matplotlib.animation as animation import matplotlib.pyplot as plt import numpy as np -<<<<<<< HEAD -======= -import pandas as pd ->>>>>>> olaflow parser = argparse.ArgumentParser(description="Animate swash output") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -20,7 +17,7 @@ log = logging.getLogger("post") log.info("Starting post-processing") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) inp = pathlib.Path(config.get("post", "inp")) root = pathlib.Path(config.get("swash", "out")) diff --git a/swash/processing/post.py b/swash/processing/post.py index 796b90d..671153c 100644 --- a/swash/processing/post.py +++ b/swash/processing/post.py @@ -12,6 +12,7 @@ from .read_swash import * parser = argparse.ArgumentParser(description="Post-process swash output") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -19,7 +20,7 @@ log = logging.getLogger("post") log.info("Starting post-processing") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) inp = pathlib.Path(config.get("post", "inp")) root = pathlib.Path(config.get("swash", "out")) diff --git a/swash/processing/swash.py b/swash/processing/swash.py index 0d8b294..814c8b0 100644 --- a/swash/processing/swash.py +++ b/swash/processing/swash.py @@ -10,6 +10,7 @@ import tempfile parser = argparse.ArgumentParser(description="Run swash model") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -17,7 +18,7 @@ log = logging.getLogger("swash") log.info("Starting swash model") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) inp = pathlib.Path(config.get("swash", "input")) out = pathlib.Path(config.get("swash", "out")) diff --git a/swash/processing/sws_npz.py b/swash/processing/sws_npz.py index 6b61507..5f7fa2a 100644 --- a/swash/processing/sws_npz.py +++ b/swash/processing/sws_npz.py @@ -11,6 +11,7 @@ from .read_swash import ReadSwash parser = argparse.ArgumentParser(description="Convert swash output to numpy") parser.add_argument("-v", "--verbose", action="count", default=0) +parser.add_argument("-c", "--config", default="config.ini") args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) @@ -18,7 +19,7 @@ log = logging.getLogger("sws_npz") log.info("Starting sws -> npz converter") config = configparser.ConfigParser() -config.read("config.ini") +config.read(args.config) sws_out = pathlib.Path(config.get("swash", "out")) inp = pathlib.Path(config.get("post", "inp"))