我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用scipy.fftpack.irfft()。
def istft(X, fftsize=128, step="half", wsola=False, mean_normalize=True, real=False, compute_onesided=True): """ Compute ISTFT for STFT transformed X """ if real: local_ifft = fftpack.irfft X_pad = np.zeros((X.shape[0], X.shape[1] + 1)) + 0j X_pad[:, :-1] = X X = X_pad else: local_ifft = fftpack.ifft if compute_onesided: X_pad = np.zeros((X.shape[0], 2 * X.shape[1])) + 0j X_pad[:, :fftsize // 2 + 1] = X X_pad[:, fftsize // 2 + 1:] = 0 X = X_pad X = local_ifft(X).astype("float64") if step == "half": X = invert_halfoverlap(X) else: X = overlap_add(X, step, wsola=wsola) if mean_normalize: X -= np.mean(X) return X
def istft(X, fftsize=128, step="half", wsola=False, mean_normalize=True, real=False, compute_onesided=True): """ Compute ISTFT for STFT transformed X """ if real: local_ifft = fftpack.irfft X_pad = np.zeros((X.shape[0], X.shape[1] + 1)) + 0j X_pad[:, :-1] = X X = X_pad else: local_ifft = fftpack.ifft if compute_onesided: X_pad = np.zeros((X.shape[0], 2 * X.shape[1])) + 0j X_pad[:, :fftsize // 2] = X X_pad[:, fftsize // 2:] = 0 X = X_pad X = local_ifft(X).astype("float64") if step == "half": X = invert_halfoverlap(X) else: X = overlap_add(X, step, wsola=wsola) if mean_normalize: X -= np.mean(X) return X
def bandpass(data_list, min_hz, max_hz): fft_list = rfft(data_list) # Filter for i in range(len(fft_list)): if not (min_hz < i/2+1 < max_hz): fft_list[i] = 0 result_vals = irfft(fft_list) return result_vals
def remove_freq_range(data_list, min_hz, max_hz): fft_list = rfft(data_list) # Filter for i in range(len(fft_list)): if (min_hz < i / 2 + 1 < max_hz): fft_list[i] = 0 result_vals = irfft(fft_list) return result_vals
def calc_ifft(data): return irfft(data)
def high_filter(data, sample_rate=1000): f_signal = rfft(data) l = int(len(f_signal)*50.0/sample_rate); cut_f_signal = f_signal.copy() cut_f_signal[l:len(f_signal)-1] = 0 cut_signal = irfft(cut_f_signal) return cut_signal
def low_filter(data, sample_rate=1000): f_signal = rfft(data) l = int(len(f_signal)*5.0/sample_rate); cut_f_signal = f_signal.copy() cut_f_signal[0:l+1] = 0 cut_f_signal[len(f_signal) + 1 - l :] = 0 cut_signal = irfft(cut_f_signal) return cut_signal
def simple_lf_filter(signal, sample_rate=1000): W = fftfreq(signal.size, d=1/float(sample_rate)) f_signal = rfft(signal) cut_f_signal = f_signal.copy() cut_f_signal[(W<5)] = 0 return irfft(cut_f_signal).astype('int16')
def simple_hf_filter(signal, sample_rate=1000): W = fftfreq(signal.size, d=1/float(sample_rate)) f_signal = rfft(signal) cut_f_signal = f_signal.copy() cut_f_signal[(W>70)] = 0 return irfft(cut_f_signal).astype('int16')