Choosing parameters#
PyWavelet exposes a few key parameters that control the time–frequency grid and the window overlap.
The hard constraint: input length#
For the time-domain transform, your input must have length:
If your data does not naturally have that length, pad or crop it first (see below).
How Nt and Nf affect resolution#
For a signal of duration T:
So increasing Nt gives finer time bins (smaller ΔT) but makes each frequency bin
wider (larger ΔF). The grid is a deliberate time–frequency tradeoff.
How mult affects overlap#
mult controls the window support length K = 2 * mult * Nf (see Window function).
Rules of thumb:
start with
mult = 16or32for exploratory plotsif you see leakage, increase
mult(up to roughlyNt/2)if runtime is too slow, decrease
multbefore changingNt/Nf
Padding/cropping recipes#
If you want to keep a fixed dt and choose an Nt × Nf grid:
ND = Nt * Nf
y = y[:ND] # crop
Or pad:
import numpy as np
ND = Nt * Nf
if len(y) < ND:
y = np.pad(y, (0, ND - len(y)))
If you just want a convenient length (power-of-two FFTs), consider the helper:
from pywavelet.types import TimeSeries
ts = TimeSeries(data=y, time=t).zero_pad_to_power_of_2(tukey_window_alpha=0.1)
Backend/precision#
If you’re tuning performance, also see Backends & Precision for switching NumPy/JAX/CuPy and float32/float64.