# Zeroing input frequencies to improve inverse CWT

This is a follow up of my previous question Why is inverse CWT inexact / inaccurate?

Rephrasing its accepted answer in my own words:

• The filterbank's transfer function gives information on what band of frequency is well represented using CWT. In my case, an important part of the spectrum lied in the not-so-well-reconstructed region (low frequencies).
• A quick fix for better reconstruction is to remove this part of the spectrum using regular FFT, and the other part can then be accurately reconstructed via CWT.
• The x_mean argument implements exactly this, only considering the 0 frequency. Your fix is a generalization of this trick

What I mean by generalization is exemplified in the following code (adapted from the answer):

import numpy as np
from numpy.fft import rfft, irfft
import matplotlib.pyplot as plt
from ssqueezepy import cwt, icwt, Wavelet, padsignal
from ssqueezepy.visuals import plot, plotscat

wavelet = Wavelet('gmw')
nv = 16

n = 100
t = np.linspace(0.,1.,n)
x = np.sin(10*t*t)

n_cutoff = 3

xf = rfft(x)

xf_low = np.copy(xf)
xf_low[n_cutoff:] = 0

xf_high = np.copy(xf)
xf_high[:n_cutoff] = 0

x_high = irfft(xf_high)
x_low = irfft(xf_low)

Wx, scales = cwt(x_high, wavelet=wavelet, nv=nv, padtype=None)
x_high_inv = icwt(Wx, wavelet=wavelet, scales=scales, nv=nv)

x_inv = x_low + x_high_inv

plot(x, color='b')
plt.show()


Setting n_cutoff = 0 is exactly what I strated with (only the mean is being reconstructed), higher values let me treat a larger part of the spectrum independently.

My question is, is my understanding of the referenced answer correct?

• Try not to address / "speak to" specific users in your question; use third-person or focus on subject alone for StackExchange. Mar 17 at 14:53
• Noted, edited ! Mar 17 at 14:57

• x_mean is needed since CWT can never capture the mean; wavelets are zero-mean by definition (sometimes this is relaxed but it's a bad idea for most purposes)