Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve CWT docs #387

Merged
merged 4 commits into from
Jul 20, 2018
Merged

improve CWT docs #387

merged 4 commits into from
Jul 20, 2018

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Jul 18, 2018

Document the equations for the CWT wavelets.

see #386

mathjax renders the equations like:
cwt_docs

@grlee77 grlee77 added this to the v1.0 milestone Jul 18, 2018
@codecov-io
Copy link

codecov-io commented Jul 18, 2018

Codecov Report

Merging #387 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #387   +/-   ##
=======================================
  Coverage   84.26%   84.26%           
=======================================
  Files          22       22           
  Lines        3540     3540           
  Branches      600      600           
=======================================
  Hits         2983     2983           
  Misses        489      489           
  Partials       68       68
Impacted Files Coverage Δ
pywt/_extensions/_pywt.pyx 71.7% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2689f6...255dfa7. Read the comment docs.

@rgommers
Copy link
Member

Good idea. Covers all wavelet types and looks correct from a quick read.

@rgommers
Copy link
Member

LGTM. I've added a commit with some typos and more doc formatting fixes.

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 20, 2018

thanks. the edits you made look good to me

@rgommers
Copy link
Member

Okay, in it goes then. Thanks @grlee77!

@rgommers rgommers merged commit 6684479 into PyWavelets:master Jul 20, 2018
@ggrrll
Copy link

ggrrll commented Jul 20, 2018

Hi,

I also agree that an improvement is needed, especially since the definition of the morlet function differs from the one in the seminal paper on CWT.

...is this already live? it doesn't look so here

Thanks

@rgommers
Copy link
Member

Thanks for asking. There was an issue in this PR that broke the doc build on readthedocs. I just pushed a fix in commit a057128, so it should appear within 15 minutes or so.

@ggrrll
Copy link

ggrrll commented Jul 20, 2018

Hi,

it's live thanks @rgommers

however, why you opted for such different definition ? even 1/pi^(1/2) ... is that correct or it's a typo (1/pi^(1/4)) ? , like in the usual definition

It seems impossible to find a B, such that the two definitions are equivalent (referring of course to this paper)

Thanks

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 20, 2018

however, why you opted for such different definition ? even 1/pi^(1/2) ... is that correct or it's a typo

The normalization used here is consistent with the definition in Matlab and their documentation references the following source:
Teolis, A. (1998), Computational signal processing with wavelets, Birkhäuser.

I accessed that text electronically via my university library and they state that this form makes the L1-norm of the wavelet equal to 1 (and that it's Fourier transform will have a peak value of 1). A quick numerical check seems to verify this claim:

import pywt
import numpy as np
wav = pywt.ContinuousWavelet('cmor')
psi, x = wav.wavefun()
dx = x[1]  - x[0]

L1 = np.trapz(np.abs(psi)) * dx  # L1-norm is the integral of the magnitude
print("Integral of magnitude = {}".format(L1))

I am not sure the reason one would use this normalization vs. others. Unfortunately my expertise in the CWT is limited and the author of the CWT routines in PyWavelets hasn't been active here lately. I think in typical applications the absolute normalization shouldn't be too important? Isn't one typically looking for features in a spectrogram where a global scaling of the plots shouldn't matter?

@grlee77
Copy link
Contributor Author

grlee77 commented Jul 20, 2018

We could perhaps add a reference to the Teolis text to the docs as the source of the equations stated in that section. I had transcribed the equations based on inspection of the numpy functions in the test suite. I tried to double check things, so hopefully there are no typos.

@grlee77 grlee77 deleted the cwt_docs branch July 20, 2018 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants