[python-dtcwt] 397/497: update usage example of 1d transform
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit 6004650f1294c55812640dd9e5e798c5f8da60dc
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Mon Feb 10 17:12:12 2014 +0000
update usage example of 1d transform
---
docs/1dtransform.rst | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/docs/1dtransform.rst b/docs/1dtransform.rst
index 2343f78..349fd1b 100644
--- a/docs/1dtransform.rst
+++ b/docs/1dtransform.rst
@@ -3,40 +3,50 @@
This example generates two 1D random walks and demonstrates reconstructing them
using the forward and inverse 1D transforms. Note that
-:py:func:`dtcwt.dtwavexfm` and :py:func:`dtcwt.dtwaveifm` will transform
-columns of an input array independently::
+:py:func`dtcwt.Transform1d.forward` and :py:func:`dtcwt.Transform1d.inverse`
+will transform columns of an input array independently
- import numpy as np
- from matplotlib.pyplot import *
+.. plot::
+ :include-source: true
+
+ from matplotlib.pylab import *
+ import dtcwt
# Generate a 300x2 array of a random walk
vecs = np.cumsum(np.random.rand(300,2) - 0.5, 0)
# Show input
- figure(1)
+ figure()
plot(vecs)
title('Input')
- import dtcwt
+ # 1D transform, 5 levels
+ transform = dtcwt.Transform1d()
+ vecs_t = transform.forward(vecs, nlevels=5)
- # 1D transform
- Yl, Yh = dtcwt.dtwavexfm(vecs)
+ # Show level 2 highpass coefficient magnitudes
+ figure()
+ plot(np.abs(vecs_t.highpasses[1]))
+ title('Level 2 wavelet coefficient magnitudes')
+
+ # Show last level lowpass image
+ figure()
+ plot(vecs_t.lowpass)
+ title('Lowpass signals')
# Inverse
- vecs_recon = dtcwt.dtwaveifm(Yl, Yh)
+ vecs_recon = transform.inverse(vecs_t)
# Show output
- figure(2)
+ figure()
plot(vecs_recon)
title('Output')
# Show error
- figure(3)
+ figure()
plot(vecs_recon - vecs)
title('Reconstruction error')
print('Maximum reconstruction error: {0}'.format(np.max(np.abs(vecs - vecs_recon))))
- show()
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list