fir.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:pactools 作者: pactools 项目源码 文件源码
def _design(self):
        """Designs the FIR filter"""
        # the length of the filter
        order = self._get_order()
        half_order = (order - 1) // 2

        w = np.blackman(order)
        t = np.linspace(-half_order, half_order, order)
        phase = (2.0 * np.pi * self.fc / self.fs) * t

        car = np.cos(phase)
        fir = w * car

        # the filter must be symmetric, in order to be zero-phase
        assert np.all(np.abs(fir - fir[::-1]) < 1e-15)

        # remove the constant component by forcing fir.sum() = 0
        if self.zero_mean:
            fir -= fir.sum() / order

        gain = np.sum(fir * car)
        self.fir = fir * (1.0 / gain)

        # add the imaginary part to have a complex wavelet
        if self.extract_complex:
            car_imag = np.sin(phase)
            fir_imag = w * car_imag
            self.fir_imag = fir_imag * (1.0 / gain)
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号