Added sws->npz conversion
This commit is contained in:
parent
837172b84f
commit
955a370a4c
2 changed files with 37 additions and 0 deletions
|
@ -17,6 +17,8 @@ out=out_sws
|
||||||
mpi=4
|
mpi=4
|
||||||
|
|
||||||
[post]
|
[post]
|
||||||
|
inp=inp_post
|
||||||
out=out_post
|
out=out_post
|
||||||
dt=0.25
|
dt=0.25
|
||||||
x0=125
|
x0=125
|
||||||
|
t0=180
|
||||||
|
|
35
swash/processing/sws_npz.py
Normal file
35
swash/processing/sws_npz.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import argparse
|
||||||
|
import configparser
|
||||||
|
import pathlib
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="Convert swash output to numpy")
|
||||||
|
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("post")
|
||||||
|
|
||||||
|
log.info("Starting sws -> npz converter")
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read("config.ini")
|
||||||
|
|
||||||
|
data_out = pathlib.Path(config.get("data", "out"))
|
||||||
|
sws_out = pathlib.Path(config.get("swash", "out"))
|
||||||
|
inp = pathlib.Path(config.get("post", "inp"))
|
||||||
|
|
||||||
|
log.info(f"Reading bathymetry from '{data_out}'")
|
||||||
|
bathy = pd.read_hdf(data_out.joinpath("bathy.h5"), "bathy")
|
||||||
|
n_x = bathy.index.size
|
||||||
|
|
||||||
|
log.info(f"Reading swash output from '{sws_out}'")
|
||||||
|
botl_np = read_nohead_scalar(root.joinpath("botl.dat"), n_x)
|
||||||
|
dep = np.maximum(0, read_nohead_scalar(root.joinpath("dep.dat"), n))
|
||||||
|
vel = read_nohead_vect(root.joinpath("vel.dat"), n)
|
||||||
|
|
||||||
|
botl.savez_compressed(inp.joinpath("botl"))
|
||||||
|
dep.savez_compressed(inp.joinpath("dep"))
|
||||||
|
vel.savez_compressed(inp.joinpath("vel"))
|
Loading…
Reference in a new issue