Now I have a scaled Mexican hat wavelet, i.e. $$ \psi(a,x)=\frac{1}{\sqrt{a}}…\left(1-\frac{x^2}{a^2}\right)e^{-x^2/(2a^2)}, $$ which decays quickly along the x-axis. Here I want to define a periodized wavelet in the following way $$ \psi^P(a,x)=\sum_{m\in\mathbb{Z}}\psi(a,x-mL), $$ where $L$ is the period of $\psi^P(a,x)$. However, I have no idea how to achieve it by using programs, e.g. Python. Can you help me?
Asked
Active
Viewed 317 times
0
-
What is the context? Note, "periodization" could mean something else. – OverLordGoldDragon Apr 26 '22 at 21:41
1 Answers
1
This is quite straight forward, if you use Python's numpy library. It is capable of array operations and thus, this task is just a few lines.
import numpy as np
import matplotlib.pyplot as plt
#parameters
a = 0.5
L = 512
length = 2**15
samplingPeriod = .01
nbrOfWavelets = int(length/L)
#calculate single wavelet for x=-length to x=length
xArray = (np.arange(2length)-length)samplingPeriod
singleWavelet = (1/np.sqrt(a)) * (1-((xArray2)/(a2))) * np.exp((-1xArray2)/(a*2))
#define initial wavelet beginning at zero time, cut in half
periodicWavelet = np.zeros(length) + singleWavelet[length:]
#iteratively add following wavelets hopping in steps of L
for m in range(1,nbrOfWavelets):
periodicWavelet += singleWavelet[length-mL:-mL]
fig = plt.plot(periodicWavelet)
plt.show()
Max
- 2,283
- 9
- 14