In [1]:
from scipy import signal



f1 = 200
f2 = 700
sig_len = 20.

fs = 2.*((f1*f2/1000)**2)
print "samplingfreq:", fs/1000, "kHz"

per1 = 1/f1
per2 = 1/f2

flicker1 = concatenate((ones(fs/(2*f1)), zeros(fs/(2*f1))), axis=1)
flicker2 = concatenate((ones(fs/(2*f2)), zeros(fs/(2*f2))), axis=1)

sig1 = tile(flicker1, .5*f1)
sig2 = tile(flicker2, .5*f2) #beide signale auf 0.5s
sig = concatenate((sig1, sig2), axis=1) #ein flickerübergang

print sig1.size

data1 = (int(sqrt(sig.size)))**2 #flickerübergang auf 2er potenz

S = tile(sig, sig_len)-.5
n = (int(sqrt(S.size)))**2
S = S[:n]

FT = fft.fft(S)/S.size
faxis = fft.fftfreq(S.size, 1/fs)

plot(faxis[:1000], abs(FT[:1000]))
#plot(faxis[:1000], real(FT[:1000]))
#plot(faxis[:1000], imag(FT[:1000]))



lowpass = zeros(FT.size)
lowpass[:60*FT.size/fs] = FT[:60*FT.size/fs]
lowpass[(FT.size-60*FT.size/fs):] = FT[(FT.size-60*FT.size/fs):]

iFT = fft.ifft(lowpass*S.size)
xaxis = linspace(0, S.size/fs, S.size)

figure()
plot(xaxis, iFT)
plt.xlim(3.9, 4.6)

bpsize = (60*FT.size/fs)+(10*FT.size/fs)
bandpass = concatenate((signal.tukey(bpsize, sym=False), zeros(FT.size-2*bpsize)), axis=1)
bandpass = concatenate((bandpass, signal.tukey(bpsize, sym=False)), axis=1)
bandpass[0:(FT.size/fs*60)/3.] = 1.
bandpass[(FT.size-(FT.size/fs*60)/3.):] = 1.
bandpass = abs(FT)*bandpass
bandpass = fft.ifft(bandpass*S.size)

figure()
plot(xaxis, bandpass)
plt.xlim(3.9, 4.6)


-c:40: ComplexWarning: Casting complex values to real discards the imaginary part
-c:41: ComplexWarning: Casting complex values to real discards the imaginary part
/usr/lib/python2.7/dist-packages/numpy/core/numeric.py:460: ComplexWarning: Casting complex values to real discards the imaginary part
  return array(a, dtype, copy=False, order=order)
samplingfreq: 39.2 kHz
19600
Out[1]:
(3.9, 4.6)

In [65]:


In [ ]: