Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite439852

Browse files
committed
Merge branch 'master' of ssh://github.com/sbu-python-class/python-science
2 parents1790e45 +9647fab commite439852

File tree

9 files changed

+6478
-891
lines changed

9 files changed

+6478
-891
lines changed

‎examples/scipy/FFT/cleaned.png‎

26.7 KB
Loading

‎examples/scipy/FFT/convolve.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
importnumpyasnp
2+
importmatplotlib.pyplotasplt
3+
fromscipyimportsignal
4+
5+
defmain():
6+
7+
data=np.loadtxt("signal.txt")
8+
9+
x=data[:,0]
10+
sig=data[:,2]
11+
orig=data[:,1]
12+
13+
N=len(x)
14+
15+
window=signal.gaussian(N,20.0)
16+
window/=np.sum(window)
17+
clean=signal.convolve(sig,window,mode="same")
18+
19+
plt.plot(x,clean)
20+
plt.plot(x,orig)
21+
plt.savefig("cleaned.png")
22+
23+
24+
25+
if__name__=="__main__":
26+
main()

‎examples/scipy/FFT/gaussian.png‎

56.2 KB
Loading

‎examples/scipy/FFT/make_signal.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
importnumpyasnp
2+
importmatplotlib.pyplotasplt
3+
4+
# make a signal that we will convolve
5+
6+
deff(x,L):
7+
A=L/10.0
8+
return2*np.sin(2*np.pi*x/L)+x*(L-x)**2/L**3*np.cos(x)+5*x*(L-x)/L**2+A/2+0.1*A*np.sin(13*np.pi*x/L)
9+
10+
11+
N=2048
12+
L=50.0
13+
14+
x=np.linspace(0,L,N,endpoint=False)
15+
f=f(x,L)
16+
fnew=f+0.5*np.random.randn(N)
17+
18+
withopen("signal.txt","w")asfo:
19+
forninrange(N):
20+
fo.write("{:20} {:20} {:20}\n".format(x[n],f[n],fnew[n]))
21+
22+
plt.plot(x,f)
23+
plt.plot(x,fnew,zorder=-100)
24+
25+
26+
27+
plt.savefig("test.png")

‎examples/scipy/FFT/signal.txt‎

Lines changed: 2048 additions & 0 deletions
Large diffs are not rendered by default.

‎examples/scipy/FFT/test.png‎

34.5 KB
Loading

‎lectures/05-scipy/scipy-exercises-2.ipynb‎

Lines changed: 103 additions & 11 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp