Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f14e13

Browse files
committed
added cohere demo
svn path=/trunk/matplotlib/; revision=4062
1 parent 39a01ad commit 6f14e13

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

examples/backend_driver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
'barh_demo.py',
3333
'color_demo.py',
3434
'colorbar_only.py',
35+
'cohere_demo.py',
3536
'contour_demo.py',
3637
'contourf_demo.py',
37-
'csd_demo.py',
38+
'csd_demo.py',
3839
'custom_ticker1.py',
3940
'customize_rc.py',
4041
'date_demo1.py',

examples/cohere_demo.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
"""
3+
Compute the coherence of two signals
4+
"""
5+
import numpy as n
6+
7+
from pylab import figure, show
8+
9+
dt = 0.01
10+
t = n.arange(0, 30, dt)
11+
Nt = len(t)
12+
nse1 = n.random.randn(Nt) # white noise 1
13+
nse2 = n.random.randn(Nt) # white noise 2
14+
r = n.exp(-t/0.05)
15+
16+
cnse1 = n.convolve(nse1, r)*dt # colored noise 1
17+
cnse1 = cnse1[:Nt]
18+
cnse2 = n.convolve(nse2, r)*dt # colored noise 2
19+
cnse2 = cnse2[:Nt]
20+
21+
# two signals with a coherent part and a random part
22+
s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1
23+
s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2
24+
25+
fig = figure()
26+
ax = fig.add_subplot(211)
27+
ax.plot(t, s1, 'b-', t, s2, 'g-')
28+
ax.set_xlim(0,5)
29+
ax.set_xlabel('time')
30+
ax.set_ylabel('s1 and s2')
31+
32+
ax = fig.add_subplot(212)
33+
cxy, f = ax.cohere(s1, s2, 256, 1./dt)
34+
35+
show()
36+
37+

examples/image_slices_viewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, ax, X):
1717
self.update()
1818

1919
def onscroll(self, event):
20-
20+
print event.button
2121
if event.button=='up':
2222
self.ind = numpy.clip(self.ind+1, 0, self.slices-1)
2323
else:

0 commit comments

Comments
 (0)