1
Fork 0

Added postprocessing script

This commit is contained in:
Edgar P. Burkhart 2022-03-02 14:25:53 +01:00
parent dca8114bb9
commit a9570bf333
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 60 additions and 0 deletions

1
swash/.gitignore vendored
View file

@ -1,2 +1,3 @@
/cache /cache
/out
/swash_buoytoartha /swash_buoytoartha

View file

@ -11,3 +11,6 @@ psize=Psize.dat
[out] [out]
root=cache root=cache
[swash]
out=out

26
swash/processing/post.py Normal file
View file

@ -0,0 +1,26 @@
import configparser
import pathlib
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from .read_swash import *
config = configparser.ConfigParser()
config.read("config.ini")
cache = pathlib.Path(config.get("out", "root"))
root = pathlib.Path(config.get("swash", "out"))
bathy = pd.read_hdf(cache.joinpath("bathy.h5"), "bathy")
n = bathy.index.size
botl = read_nohead_scalar(root.joinpath("botl.dat"), n)
dep = read_nohead_scalar(root.joinpath("dep.dat"), n)
watl = read_nohead_scalar(root.joinpath("watl.dat"), n)
plt.plot(dep.T-botl.T, label="dep")
plt.plot(-botl.T[:, 0], label="botl")
plt.show(block=True)

View file

@ -0,0 +1,30 @@
import numpy as np
def read_nohead(path):
with open(path) as file:
return file.read()
def read_nohead_scalar(path, n):
return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape(
(-1, n)
)
def read_nohead_k(path, n, k):
return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape(
(-1, n, k)
)
def read_nohead_vect(path, n):
return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape(
(-1, n, 2)
)
def read_nohead_vect_k(path, n):
return np.asarray(read_nohead(path).split(), dtype=np.float64).reshape(
(-1, n, 2, k)
)