diff --git a/swash/processing/wavelet.py b/swash/processing/wavelet.py index d4fe66b..5ac907a 100644 --- a/swash/processing/wavelet.py +++ b/swash/processing/wavelet.py @@ -4,6 +4,7 @@ import logging import pathlib import matplotlib.pyplot as plt +from matplotlib.ticker import MultipleLocator, LogLocator, NullFormatter import numpy as np import scipy.signal as sgl @@ -49,12 +50,13 @@ J = 1 / dj * np.log2(N * dt / s0) j = np.arange(0, J) sj = s0 * 2 ** (j * dj) Mw = sj / dt -sig = np.var(watl[:, i0]) +sig = np.std(watl[:, i0]) M = np.stack([(np.abs(sgl.cwt(watl[:, i], sgl.morlet2, Mw))/sig)**2 for i in i0]) v = np.max(M) +T = 2 * sj * np.pi / 5 for ax_x, M_, x_ in zip(ax.reshape(-1), M, x[i0]): - c = ax_x.contourf(t, sj, M_, cmap="Greys", vmin=0, levels=[1, 2.5, 5, 10, 20, 40], extend="both") + c = ax_x.contourf(t, T, M_, cmap="Greys", vmin=0, levels=[1, 2.5, 5, 10, 20, 40], extend="both") fig_x.colorbar(c, ax=ax_x, label="NWPS") ax_x.grid(color="k", alpha=0.2) ax_x.text( @@ -71,6 +73,10 @@ for ax_x, M_, x_ in zip(ax.reshape(-1), M, x[i0]): ax_x.set_rasterization_zorder(1.5) ax_x.set(ylabel="T (s)", ylim=(sj[0], sj[-1])) + ax_x.xaxis.set_minor_locator(MultipleLocator(100)) + ax_x.yaxis.set_major_locator(LogLocator(10, numticks=2**10)) + ax_x.yaxis.set_minor_locator(LogLocator(10, subs=np.arange(10), numticks=2**10)) + ax_x.yaxis.set_minor_formatter(NullFormatter()) if ax_x != ax.reshape(-1)[-1]: ax_x.axes.set_xticklabels([]) else: diff --git a/swash/processing/zero_cross.py b/swash/processing/zero_cross.py index 2a4e45c..6469641 100644 --- a/swash/processing/zero_cross.py +++ b/swash/processing/zero_cross.py @@ -76,7 +76,7 @@ ax.grid() fig.savefig(out.joinpath("wsize.pdf")) fig2, ax2 = plt.subplots( - figsize=(10 / 2.54, 2 / 3 * 10 / 2.54), constrained_layout=True + figsize=(10 / 2.54, 4 / 2.54), constrained_layout=True ) ax2.plot( t[cr0[i0 - 5] : cr0[i0 + 7]] * 1e-3,