Example #1
0
def lpFiltSpec(fp, fs, nyqf):
    nyqf = float(nyqf)
    ord, wn = filter_design.buttord(fp / nyqf, fs / nyqf, 1, 12, analog=0)
    b, a = butter(ord, wn, btype="lowpass", analog=0, output='ba')
    w, h = freqz(b, a)
    fig = _plt.figure()
    _plt.plot(w * (nyqf / _N.pi), _N.abs(h))
Example #2
0
def bpFilt(fpL, fpH, fsL, fsH, nyqf, y):
    nyqf = float(nyqf)
    ord, wn = filter_design.buttord((fpL / nyqf, fpH / nyqf),
                                    (fsL / nyqf, fsH / nyqf),
                                    1,
                                    12,
                                    analog=0)
    b, a = butter(ord, wn, btype="bandpass", analog=0, output='ba')
    fy = filtfilt(b, a, y)
    return fy
Example #3
0
def bpFiltSpec(fpL, fpH, fsL, fsH, nyqf):
    nyqf = float(nyqf)
    ord, wn = filter_design.buttord((fpL / nyqf, fpH / nyqf),
                                    (fsL / nyqf, fsH / nyqf),
                                    1,
                                    12,
                                    analog=0)
    b, a = butter(ord, wn, btype="bandpass", analog=0, output='ba')
    w, h = freqz(b, a)
    fig = _plt.figure()
    _plt.plot(w * (nyqf / _N.pi), _N.abs(h))
Example #4
0
 def low_filter(self, wavFile):
     rate, sound_samples = read(wavFile)
     sound_samples = np.float64(sound_samples / 32768.0)
     pass_freq = 0.2
     stop_freq = 0.3
     pass_gain = 0.5  # permissible loss (ripple) in passband (dB)
     stop_gain = 10.0  # attenuation required in stopband (dB)
     ord, wn = buttord(pass_freq, stop_freq, pass_gain, stop_gain)
     b, a = butter(ord, wn, btype='low')
     filtered = lfilter(b, a, sound_samples)
     filtered = np.int16(filtered * 32768 * 10)
     write(self.__filteredFile, rate, filtered)
     return self.__filteredFile
Example #5
0
def hpFilt(fp, fs, nyqf, y, disp=False):
    nyqf = float(nyqf)
    ord, wn = filter_design.buttord(fp / nyqf, fs / nyqf, 1, 12, analog=0)
    b, a = butter(ord, wn, btype="highpass", analog=0, output='ba')
    fy = filtfilt(b, a, y)
    return fy
Example #6
0
                    flash_read(k)
                else:
                    if((n-k)>= len(int_resp)):
                        temp += 0
                    else:
                        temp += data_buffer[k%64]*int_resp[n-k]
            data_dump[n%64] = temp;
                        
    
f = open('sample_vishwa.dat', 'r')
data = []
for i in f.readlines():
    data.append(int(i))
data_test = zeros(len(data))
data_test[0] = 1
order, Wn = fd.buttord(0.2, 0.3, 1, 10)
print order, Wn
b, a = fd.butter(order, Wn)
response = sg.lfilter(b, a, data_test)[:256]
int_resp = []
resp_file = open('impulse_response_integer.dat', 'r')
for i in resp_file.readlines():
    int_resp.append(int(i))
#op1 = conv(data[:1024], int_resp)
f.close()
op2 = range(1024)
conv(data)
op1 = convolve(int_resp, data)
clf()
plot(op1, 'r')
plot(op2)