Added bathymetry generation for olaFlow (stl)
This commit is contained in:
parent
7686aeffe5
commit
c64ba2b31c
1 changed files with 35 additions and 0 deletions
35
olaflow/processing/bathy.py
Normal file
35
olaflow/processing/bathy.py
Normal 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"))
|
Loading…
Reference in a new issue