MORLET2
The Morlet wavelet is a complex sinusoid modulated by a Gaussian envelope. It provides an excellent balance between time and frequency localization and is widely used in continuous wavelet transforms.
This version (morlet2) is designed for direct use with the CWT function.
Excel Usage
=MORLET2(m_points, s_width, w_omega)
m_points(int, required): Length of the wavelet (number of points).s_width(float, required): Width parameter of the wavelet.w_omega(float, optional, default: 5): Omega0 (central frequency parameter).
Returns (list[list]): A 1D array of the complex Morlet wavelet (interleaved real and imaginary).
Example 1: Basic Morlet2
Inputs:
| m_points | s_width | w_omega |
|---|---|---|
| 24 | 4 | 2 |
Excel formula:
=MORLET2(24, 4, 2)
Expected output:
| Result | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.00518711 | 0.00613401 | 0.00084149 | -0.0175205 | -0.0531354 | -0.099706 | -0.134882 | -0.125295 | -0.0456509 | 0.0974124 | 0.256137 | 0.361056 | 0.361056 | 0.256137 | 0.0974124 | -0.0456509 | -0.125295 | -0.134882 | -0.099706 | -0.0531354 | -0.0175205 | 0.00084149 | 0.00613401 | 0.00518711 |
| 0.00306145 | 0.0102887 | 0.022363 | 0.0351516 | 0.0370115 | 0.0108514 | -0.055695 | -0.155194 | -0.25201 | -0.293169 | -0.238617 | -0.0921926 | 0.0921926 | 0.238617 | 0.293169 | 0.25201 | 0.155194 | 0.055695 | -0.0108514 | -0.0370115 | -0.0351516 | -0.022363 | -0.0102887 | -0.00306145 |
Python Code
Show Code
import numpy as np
from scipy.signal import morlet2 as scipy_morlet2
def morlet2(m_points, s_width, w_omega=5):
"""
Generate a complex Morlet wavelet for a given length and width.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.morlet2.html
This example function is provided as-is without any representation of accuracy.
Args:
m_points (int): Length of the wavelet (number of points).
s_width (float): Width parameter of the wavelet.
w_omega (float, optional): Omega0 (central frequency parameter). Default is 5.
Returns:
list[list]: A 1D array of the complex Morlet wavelet (interleaved real and imaginary).
"""
try:
result = scipy_morlet2(int(m_points), float(s_width), w=float(w_omega))
# Return interleaved real and imag
return [result.real.tolist(), result.imag.tolist()]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Length of the wavelet (number of points).
Width parameter of the wavelet.
Omega0 (central frequency parameter).