1
Fork 0

Added bathymetry generation for olaFlow (stl)

This commit is contained in:
Edgar P. Burkhart 2022-03-04 12:50:00 +01:00
parent 7686aeffe5
commit c64ba2b31c
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -0,0 +1,35 @@
import argparse
import configparser
import logging
import pathlib
import subprocess
import tempfile
import shutil
import numpy as np
parser = argparse.ArgumentParser(
description="Convert swash output to olaFlow input"
)
parser.add_argument("-v", "--verbose", action="count", default=0)
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()
config.read("config.ini")
bathy = np.loadtxt(config.get("bathy", "bathy"))
with tempfile.TemporaryDirectory() as tmppath:
tmpdir = pathlib.Path(tmppath)
np.savetxt(tmpdir.joinpath("bathy.dat"), np.stack((bathy, bathy)))
shutil.copy2(
pathlib.Path(config.get("bathy", "scad")), tmpdir.joinpath("scad")
)
subprocess.run(("openscad", "scad", "-o", "bathy.stl"), cwd=tmpdir)
shutil.copy2(tmpdir.joinpath("bathy.stl"), config.get("bathy", "out"))