abstract_als.py 文件源码

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

项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码
def calculate(self, signal):
        sig_shape = signal.shape  # Shape of input signal
        sig_size = signal.shape[-1]  # Length of spectral axis

        # N signals to detrend
        sig_n_to_detrend = int(signal.size/signal.shape[-1])

        tmr = _timeit.default_timer()
        if self.redux == 1:
            output = self._calc(signal)
        else:  # Sub-sample
            # Dummy indep variable
            x = _np.arange(sig_size)
            x_sub = _np.linspace(x[0], x[-1], _np.round(x.size / 
                                 self.redux).astype(_np.integer))

            sub_shape = list(sig_shape)
            sub_shape[-1] = x_sub.size

            signal_sampled = _np.zeros(sub_shape)

            # Spline interpolation/sub-sampling
            for coords in _np.ndindex(signal.shape[0:-1]):
                spl = _USpline(x,signal[coords],s=0)
                signal_sampled[coords] = spl(x_sub)

            # Baseline from sub-sampled signal
            output_sampled = self._calc(signal_sampled)

            output = _np.zeros(signal.shape)
            # Spline interpolation/super-sampling
            for coords in _np.ndindex(output_sampled.shape[0:-1]):
                spl2 = _USpline(x_sub,output_sampled[coords],s=0)
                output[coords] = spl2(x)

        tmr -= _timeit.default_timer()
        self.t = -tmr
        self.t_per_iter = self.t/sig_n_to_detrend

        return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号