diff --git a/swash/processing/post.py b/swash/processing/post.py index 4ad36b1..ec4977c 100644 --- a/swash/processing/post.py +++ b/swash/processing/post.py @@ -7,6 +7,7 @@ import matplotlib.pyplot as plt import numpy as np import pandas as pd import scipy.signal as sgl +import scipy.fft as fft from .read_swash import * @@ -68,9 +69,18 @@ ax_vel.axvline(t0, c="k", alpha=0.2) fig.tight_layout() fig_r, ax_r = plt.subplots() +ax_fft = ax_r.twinx() -ax_r.plot(1 / phi_eta[0, 1:], R[1:], marker="+", lw=1) -ax_r.set(xlim=(1, 30), ylim=(0, 1), xlabel="t (s)", ylabel="R") +ax_fft.plot( + fft.rfftfreq(eta.size, dt), + np.abs(fft.rfft(eta)), + lw=1, + c="k", + alpha=0.2, +) +ax_r.plot(phi_eta[0], R, marker="+") +ax_r.set(xlim=(0, 0.3), ylim=(0, 1), xlabel="f (Hz)", ylabel="R") +ax_fft.set(ylim=0, ylabel="FFT") ax_r.grid() fig_x, ax_x = plt.subplots() @@ -88,8 +98,8 @@ out = pathlib.Path(config.get("post", "out")).joinpath(f"t{t0}x{x0}") log.info(f"Saving plots in '{out}'") out.mkdir(parents=True, exist_ok=True) -fig.savefig(out.joinpath(f"t.png")) -fig_r.savefig(out.joinpath(f"R.png")) -fig_x.savefig(out.joinpath(f"x.png")) +fig.savefig(out.joinpath("t.png")) +fig_r.savefig(out.joinpath("R.png")) +fig_x.savefig(out.joinpath("x.png")) log.info("Finished post-processing")