2022-03-28 10:15:36 +02:00
|
|
|
import argparse
|
|
|
|
import configparser
|
|
|
|
import logging
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
from .stl import stl_from_1d
|
|
|
|
|
2022-03-29 09:47:45 +02:00
|
|
|
parser = argparse.ArgumentParser(description="Convert swash output to olaFlow input")
|
2022-03-28 10:15:36 +02:00
|
|
|
parser.add_argument("-v", "--verbose", action="count", default=0)
|
2022-03-29 09:38:11 +02:00
|
|
|
parser.add_argument("-c", "--config", default="config.ini")
|
2022-03-28 10:15:36 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
|
|
|
|
log = logging.getLogger("sws_ola")
|
|
|
|
|
|
|
|
log.info("Starting sws -> olaFlow converter")
|
|
|
|
config = configparser.ConfigParser()
|
2022-03-29 09:38:11 +02:00
|
|
|
config.read(args.config)
|
2022-03-28 10:15:36 +02:00
|
|
|
|
2022-03-28 10:27:38 +02:00
|
|
|
bathy = np.loadtxt(config.get("bathy", "bathy"))[::-1]
|
|
|
|
hstru = np.loadtxt(config.get("bathy", "hstru"))[::-1]
|
|
|
|
poro = bathy + np.where(hstru == 0, -5, hstru)
|
2022-03-28 10:15:36 +02:00
|
|
|
|
|
|
|
out = pathlib.Path(config.get("bathy", "out"))
|
|
|
|
out.mkdir(exist_ok=True)
|
|
|
|
stl_from_1d(
|
|
|
|
bathy,
|
|
|
|
out.joinpath("bathy.stl"),
|
|
|
|
config.get("bathy", "scale", fallback=[1, 1, 1]),
|
|
|
|
config.get("bathy", "translate", fallback=[0, 0, 0]),
|
|
|
|
)
|
|
|
|
stl_from_1d(
|
|
|
|
poro,
|
|
|
|
out.joinpath("poro.stl"),
|
|
|
|
config.get("bathy", "scale", fallback=[1, 1, 1]),
|
|
|
|
config.get("bathy", "translate", fallback=[0, 0, 0]),
|
|
|
|
)
|