subtract_baseline.py 文件源码

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

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

        self._inst_als = _AlsCvxopt(**kwargs)

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

            # Iterate over the sub-array -- super slick way of doing it
            for num, idx in enumerate(_np.ndindex(shp)):
                print('Detrended iteration {} / {}'.format(num+1, total_num))
                # Imaginary portion set
                if self.use_imag and _np.iscomplexobj(data):
                    if self.rng is None:
                        ret_obj[idx] -= 1j*self._inst_als.calculate(data[idx].imag)
                    else:
                        ret_obj[idx][..., self.rng] -= 1j*self._inst_als.calculate(data[idx][..., self.rng].imag)
                else:  # Real portion set or real object
                    if self.rng is None:
                        ret_obj[idx] -= self._inst_als.calculate(data[idx].real)
                    else:
                        ret_obj[idx][..., self.rng] -= self._inst_als.calculate(data[idx][..., self.rng].real)
        except:
            return False
        else:
#            print(self._inst_als.__dict__)
            return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号