From f329690c3d2a1082b50199e3ee1aaba82df40aef Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 2 Mar 2022 11:47:57 +0100 Subject: [PATCH] Added output of bathy and hstru to preprocess --- swash/.gitignore | 1 + swash/config.ini | 3 +++ swash/processing/bathy.py | 20 +++++++++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/swash/.gitignore b/swash/.gitignore index ee44a53..58dac9f 100644 --- a/swash/.gitignore +++ b/swash/.gitignore @@ -1 +1,2 @@ +/cache /swash_buoytoartha diff --git a/swash/config.ini b/swash/config.ini index 75e53d3..31a9864 100644 --- a/swash/config.ini +++ b/swash/config.ini @@ -8,3 +8,6 @@ bathy=buoyarthabathy.dat hstru=Hstru.dat poro=Poro.dat psize=Psize.dat + +[out] +root=cache diff --git a/swash/processing/bathy.py b/swash/processing/bathy.py index 26aa1ea..9494bf3 100644 --- a/swash/processing/bathy.py +++ b/swash/processing/bathy.py @@ -31,10 +31,20 @@ x_hstru = np.arange(-0.5 * hstru.size, 0, 0.5) bathy_hires_pd = pd.Series(bathy_hires.copy(), index=x_hires) bathy_lores_pd = pd.Series(bathy_lores.copy(), index=x_lores) -bathy = bathy_lores_pd.reindex( - bathy_lores_pd.index.union(bathy_hires_pd.index) +bathy = pd.DataFrame( + index=bathy_lores_pd.index.union(bathy_hires_pd.index), + columns=("z", "hstru"), ) -bathy[bathy_hires_pd.index] = bathy_hires_pd +bathy.z[bathy_lores_pd.index] = bathy_lores_pd +bathy.z[bathy_hires_pd.index] = bathy_hires_pd + +bathy.hstru = 0 +bathy.loc[x_hstru, "hstru"] = hstru + +if config.has_section("out"): + out = pathlib.Path(config.get("out", "root")) + np.savetxt(out.joinpath("bathy.dat"), bathy.z, newline=" ") + np.savetxt(out.joinpath("hstru.dat"), bathy.hstru, newline=" ") if config.getboolean("proc", "plot", fallback=False): if plt is None: @@ -44,8 +54,8 @@ if config.getboolean("proc", "plot", fallback=False): fig, ax = plt.subplots() ax.plot(x_hires, bathy_hires, label="High-res") ax.plot(x_lores, bathy_lores, label="Low-res") - ax.plot(x_hstru, bathy[x_hstru]+hstru, label="H stru") - ax.plot(bathy.index, bathy, ls="-.", c="k", label="Combined") + ax.plot(bathy.index, bathy.z, ls="-.", c="k", label="Combined") + ax.plot(bathy.index, bathy.hstru, label="H stru") ax.grid() ax.legend()