1
Fork 0

Add cli arg for config file

This commit is contained in:
Edgar P. Burkhart 2022-03-29 09:38:11 +02:00
parent 59e33da9a6
commit fe17378bb0
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
9 changed files with 18 additions and 13 deletions

View file

@ -14,6 +14,7 @@ from .lambert import Lambert
parser = argparse.ArgumentParser(description="Pre-process bathymetry") parser = argparse.ArgumentParser(description="Pre-process bathymetry")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -21,7 +22,7 @@ log = logging.getLogger("bathy")
log.info("Starting bathymetry pre-processing") log.info("Starting bathymetry pre-processing")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
inp_root = pathlib.Path(config.get("inp", "root")) inp_root = pathlib.Path(config.get("inp", "root"))
out_root = pathlib.Path(config.get("out", "root")) out_root = pathlib.Path(config.get("out", "root"))

View file

@ -7,6 +7,7 @@ import numpy as np
parser = argparse.ArgumentParser(description="Pre-process bathymetry") parser = argparse.ArgumentParser(description="Pre-process bathymetry")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -14,7 +15,7 @@ log = logging.getLogger("bathy")
log.info("Starting bathymetry pre-processing") log.info("Starting bathymetry pre-processing")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
artha = np.array( artha = np.array(
(config.getfloat("artha", "lon"), config.getfloat("artha", "lat")) (config.getfloat("artha", "lon"), config.getfloat("artha", "lat"))

View file

@ -11,6 +11,7 @@ parser = argparse.ArgumentParser(
description="Convert swash output to olaFlow input" description="Convert swash output to olaFlow input"
) )
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -18,7 +19,7 @@ log = logging.getLogger("sws_ola")
log.info("Starting sws -> olaFlow converter") log.info("Starting sws -> olaFlow converter")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
bathy = np.loadtxt(config.get("bathy", "bathy"))[::-1] bathy = np.loadtxt(config.get("bathy", "bathy"))[::-1]
hstru = np.loadtxt(config.get("bathy", "hstru"))[::-1] hstru = np.loadtxt(config.get("bathy", "hstru"))[::-1]

View file

@ -13,6 +13,7 @@ parser = argparse.ArgumentParser(
description="Convert swash output to olaFlow input" description="Convert swash output to olaFlow input"
) )
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -20,7 +21,7 @@ log = logging.getLogger("sws_ola")
log.info("Starting sws -> olaFlow converter") log.info("Starting sws -> olaFlow converter")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
sws_out = pathlib.Path(config.get("swash", "np_out")) sws_out = pathlib.Path(config.get("swash", "np_out"))
def data(var): def data(var):

View file

@ -9,6 +9,7 @@ import numpy as np
parser = argparse.ArgumentParser(description="Animate swash output") parser = argparse.ArgumentParser(description="Animate swash output")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -16,7 +17,7 @@ log = logging.getLogger("post")
log.info("Starting post-processing") log.info("Starting post-processing")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
inp = pathlib.Path(config.get("post", "inp")) inp = pathlib.Path(config.get("post", "inp"))
root = pathlib.Path(config.get("swash", "out")) root = pathlib.Path(config.get("swash", "out"))

View file

@ -6,13 +6,10 @@ import pathlib
import matplotlib.animation as animation import matplotlib.animation as animation
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
<<<<<<< HEAD
=======
import pandas as pd
>>>>>>> olaflow
parser = argparse.ArgumentParser(description="Animate swash output") parser = argparse.ArgumentParser(description="Animate swash output")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -20,7 +17,7 @@ log = logging.getLogger("post")
log.info("Starting post-processing") log.info("Starting post-processing")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
inp = pathlib.Path(config.get("post", "inp")) inp = pathlib.Path(config.get("post", "inp"))
root = pathlib.Path(config.get("swash", "out")) root = pathlib.Path(config.get("swash", "out"))

View file

@ -12,6 +12,7 @@ from .read_swash import *
parser = argparse.ArgumentParser(description="Post-process swash output") parser = argparse.ArgumentParser(description="Post-process swash output")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -19,7 +20,7 @@ log = logging.getLogger("post")
log.info("Starting post-processing") log.info("Starting post-processing")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
inp = pathlib.Path(config.get("post", "inp")) inp = pathlib.Path(config.get("post", "inp"))
root = pathlib.Path(config.get("swash", "out")) root = pathlib.Path(config.get("swash", "out"))

View file

@ -10,6 +10,7 @@ import tempfile
parser = argparse.ArgumentParser(description="Run swash model") parser = argparse.ArgumentParser(description="Run swash model")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -17,7 +18,7 @@ log = logging.getLogger("swash")
log.info("Starting swash model") log.info("Starting swash model")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
inp = pathlib.Path(config.get("swash", "input")) inp = pathlib.Path(config.get("swash", "input"))
out = pathlib.Path(config.get("swash", "out")) out = pathlib.Path(config.get("swash", "out"))

View file

@ -11,6 +11,7 @@ from .read_swash import ReadSwash
parser = argparse.ArgumentParser(description="Convert swash output to numpy") parser = argparse.ArgumentParser(description="Convert swash output to numpy")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
@ -18,7 +19,7 @@ log = logging.getLogger("sws_npz")
log.info("Starting sws -> npz converter") log.info("Starting sws -> npz converter")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("config.ini") config.read(args.config)
sws_out = pathlib.Path(config.get("swash", "out")) sws_out = pathlib.Path(config.get("swash", "out"))
inp = pathlib.Path(config.get("post", "inp")) inp = pathlib.Path(config.get("post", "inp"))