# wavelet denoising routine for environmental data series

I have a time series of water temperature, e.g.

y = 1+(30-10).*rand(1,365);


I have previously used the wavelet denoising routine in the wavelet toolbox by matlab to remove unwanted noise from a signal, e.g.

[s_denoised, ~, ~] = wden(y, 'minimaxi', 's', 'sln', 2, 'db4');


However, I am unsure whether I am using this method correctly! If my time series is of water temperature which is characteristic of an environmental data series i.e. high power at low frequency (e.g. seasonal cycle) and low power at high frequency (e.g. diel cycle) and I wish to remove noise caused by internal wave motion in lakes (which cause sudden increases or decreases in temperature), should I be using the wavelet shown here or is there a better wavelet to use?

-
My answer should give you a good starting point: You can find a wavelet that matches noise, or a wavelet that matches your signal. Also, it would help if you put up some plots of all the cases. –  Mohammad Feb 11 '13 at 20:55

First, a comment - before you denoise, you are basically going to be converting your data from the (time)-domain into the wavelet domain. This is nothing but a series of projections of your data unto user-picked basis functions. (The wavelets).

When you denoise, you will be zeroing out, or shrinking, coefficients which (ostensibly) belong to the noise.

Now, imagine that you picked a wavelet type, and when you transformed your noiseless signal, the very first coefficient was some number, and the rest were zero. This means that you know, that your pure signal, will always give you a non-zero as the first coefficient in the wavelet domain, with other coefficients always being zero.

Now imagine that you transformed your noisy signal. You would probably still see a high value for that first coefficient, (belonging to your true data), but all the other coefficients that you were expecting to be zero have some small value. If you zero them out and inverse transform, you have denoised your signal.

The question you want to answer then becomes, "Which wavelet type, when projected against my data, gives me the sparsest representation in the wavelet domain?" In other words, which wavelet, when used against your (pure, noiseless) data, gives you coefficients that are mostly zero?

Mathematically, what you want is a wavelet that has as many vanishing moments as your data template.

Example: For example, let us say that know that your data template (in your case, the temperature without internal wave motion corruption) is a polynomial of 0th order, (a constant), then you want to use the Haar wavelet, since it has 1 vanishing moment. This means that if you transform your pure-signal into the Haar domain, most of the coefficients will be zero. However when you transform your data-with-internal-wave-corruption, the coefficients that were normally zero now have some value, that you can then clobber and inverse transform.

The same thing can be said for other templates. Let us say that your pure-data was a polynomial with maximum degree of 7. That means then that you want a wavelet that makes my polynomials of maximum degree 7 disappear, or in other words, has 8 vanishing moments. This would make your signal look quite sparse in the transform domain, and thus any other noise of higher order would make it less sparse, and you would be able to denoise by removing those suspicious coefficients that were supposed to be zero.

-
So I'm guessing the Haar is the only wavelet with 1 vanishing moment, but there are many wavelets with 7 vanishing moments? –  endolith Mar 6 '13 at 17:23
@endolith I suspect so. For example, looking at this page here, there are a number of different wavelets, (Daubechies, symlets, coiflets) have the same number of vanishing moments, but are different wavelets. –  Mohammad Mar 6 '13 at 18:09