error_correction.py 文件源码

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

项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码
def _calc(self, data, ret_obj, **kwargs):

        self._inst_als = _AlsCvxopt(**kwargs)

        try:
            shp = data.shape[0:-2]
            total_num = _np.array(shp).prod()

            counter = 1
            for idx in _np.ndindex(shp):
                print('Detrended iteration {} / {}'.format(counter, total_num))
                ph = _np.unwrap(_np.angle(data[idx]))
                if self.rng is None:
                    err_phase = self._inst_als.calculate(ph)
                else:
                    err_phase = self._inst_als.calculate(ph[..., self.rng])

                h = _np.zeros(err_phase.shape)
                h += _hilbert(err_phase)

                correction_factor = 1/_np.exp(h) * _np.exp(-1j*err_phase)

                if self.rng is None:
                    ret_obj[idx] *= correction_factor
                else:
                    ret_obj[idx][..., self.rng] *= correction_factor
                counter += 1
        except:
            return False
        else:
#            print(self._inst_als.__dict__)
            return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号