Exemplo n.º 1
0
#coding:utf-8
from pylab import *
import numpy as np
import singou as sg

x = [0.0]*7 + [np.sin(2*np.pi*(n-8)/16) for n in range(8,41)] + [0.0]*24

X = sg.dft(x)
xd = sg.ift(X)
N = len(x)
h1 = [complex(np.cos(2*np.pi*(k-N)/(N*2)),-np.sin(2*np.pi*(k-N)/(N*2))) for k in range(33,N)]
h2 = [complex(np.cos(2*np.pi*k/(N*2)),-np.sin(2*np.pi*k/(N*2))) for k in range(0,33)]

h = h2+h1

print len(h)
Y = [h[k]*X[k] for k in range(N)]
#Y = sg.fir(h,X)
y = sg.ift(Y)

plot(x,label='x(n)')
plot(y,label="x'(x)")
legend()

show()

Exemplo n.º 2
0
title = argvs[1]
xdata = []
ydata = []

f = open(title,'r')
fn = f.readlines()

for i in fn:
	match = re.findall(r'[0-9.-]+',i)
	xdata.append(float(match[1]))
	ydata.append(float(match[2]))

r1 = sg.correl(xdata,ydata)

X = sg.dft(xdata)
Y = sg.dft(ydata)
h = sg.filt1()
xd = sg.fir(h,xdata)
yd = sg.fir(h,ydata)
Xd = sg.dft(xd)
r2 = sg.correl(xd,yd)
#subplot(311)

plot(range(-1023,len(r1)/2 +1),r1)
plt.xlim([-1023,1024])
#xticks(numpy.linspace(0,2500,6),numpy.linspace(-1024,2500-1048,6))
"""
subplot(312)
plot(range(-1023,len(r2)/2 +1),r2)
plt.xlim([-1023,1024])