diff --git a/swash/.gitignore b/swash/.gitignore index 58dac9f..c9994d8 100644 --- a/swash/.gitignore +++ b/swash/.gitignore @@ -1,2 +1,3 @@ /cache +/out /swash_buoytoartha diff --git a/swash/config.ini b/swash/config.ini index 3a14e2c..8d6b9e0 100644 --- a/swash/config.ini +++ b/swash/config.ini @@ -11,3 +11,6 @@ psize=Psize.dat [out] root=cache + +[swash] +out=out diff --git a/swash/processing/post.py b/swash/processing/post.py new file mode 100644 index 0000000..6ad9a62 --- /dev/null +++ b/swash/processing/post.py @@ -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) diff --git a/swash/processing/read_swash.py b/swash/processing/read_swash.py new file mode 100644 index 0000000..1d1da2c --- /dev/null +++ b/swash/processing/read_swash.py @@ -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) + )