Commit 3ef492d0 authored by Gregor Moenke's avatar Gregor Moenke

finalized averaged Wspec

parent 4eb8f766
......@@ -141,78 +141,47 @@ def mk_Fourier_ax(fig, time_unit="a.u.", show_periods=False):
return ax
def Fourier_spec(ax, fft_freqs, fft_power, show_periods=False):
freq_bin_width = np.diff(fft_freqs)[0]
pow_max_ind = np.argmax(fft_power)
# heuristically determine bin width by looking
# at the most prominent period
if pow_max_ind < len(fft_freqs):
per_bin_width = 1/fft_freqs[pow_max_ind] - 1/fft_freqs[pow_max_ind + 1]
else:
per_bin_width = 1/fft_freqs[pow_max_ind] - 1/fft_freqs[pow_max_ind - 1]
if show_periods:
# period view, omit the last bin 2/(N*dt)
# skip 0-frequency
if len(fft_freqs) < 300:
ax.bar(
if len(fft_freqs) < 1000:
ax.vlines(
1 / fft_freqs[1:],
0,
fft_power[1:],
alpha=0.4,
edgecolor="k",
lw=1.5,
alpha=0.8,
color=FOURIER_COLOR,
width= 0.5 * per_bin_width,
)
# ax.vlines(
# 1 / fft_freqs[1:],
# 0,
# fft_power[1:],
# lw=2,
# alpha=0.8,
# color=FOURIER_COLOR,
# )
# plot differently for very long data
# plot differently for very long signals
else:
ax.plot(
1 / fft_freqs[1:],
fft_power[1:],
"--",
lw=1.5,
"-",
lw = 1.5,
alpha=0.8,
color=FOURIER_COLOR,
)
else:
if len(fft_freqs) < 300:
if len(fft_freqs) < 1000:
# frequency view
ax.bar(
ax.vlines(
fft_freqs,
0,
fft_power,
alpha=0.4,
edgecolor="k",
alpha=0.8,
color=FOURIER_COLOR,
width=0.8 * freq_bin_width,
lw = 1.5
)
else:
ax.plot(fft_freqs, fft_power, ".", ms=1, alpha=0.8, color=FOURIER_COLOR)
ax.plot(fft_freqs, fft_power, "-", lw=1.5, alpha=0.8, color=FOURIER_COLOR)
# --- time averaged Wavelet spectrum -> Fourier estimate
def plot_averaged_Wspec(averaged_Wspec, periods, time_unit = 'a.u', fig = None):
def averaged_Wspec(averaged_Wspec, periods, time_unit = 'a.u', fig = None):
if fig is None:
fig = ppl.figure(figsize = (5, 3.2))
......@@ -221,8 +190,8 @@ def plot_averaged_Wspec(averaged_Wspec, periods, time_unit = 'a.u', fig = None):
ax.set_ylabel("Power (wnp)", fontsize=label_size)
ax.set_xlabel(f"Period ({time_unit})", fontsize=label_size)
#ax.plot(periods, averaged_Wspec, lw = SIGNAL_LW, color = FOURIER_COLOR)
ax.vlines(periods, 0, averaged_Wspec, colors = FOURIER_COLOR)
ax.plot(periods, averaged_Wspec, lw = SIGNAL_LW, color = FOURIER_COLOR)
ax.fill_between(periods, 0, averaged_Wspec, color = FOURIER_COLOR, alpha = 0.3)
# --- Wavelet spectrum ------
......
......@@ -679,7 +679,7 @@ class AveragedWaveletWindow(QWidget):
# plot it
pCanvas.fig.clf()
pl.plot_averaged_Wspec(self.avWspec, self.parentWA.periods, fig = pCanvas.fig)
pl.averaged_Wspec(self.avWspec, self.parentWA.periods, fig = pCanvas.fig)
pCanvas.fig.subplots_adjust(left = 0.15, bottom = 0.17)
main_layout = QGridLayout()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment