linearfilters.py 文件源码

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

项目:oocgcm 作者: lesommer 项目源码 文件源码
def apply(self, mode='reflect', weights=None, compute=True):
        """
        Convolve the current window with the data
        """
        # Check if the data has more dimensions than the window and add
        # extra-dimensions to the window if it is the case
        mask = self.obj.notnull()
        if weights is None:
            weights = im.convolve(mask.astype(float), self.coefficients, mode=mode)
        filled_data = self.obj.fillna(0.).data

        def convolve(x):
            xf = im.convolve(x, self.coefficients, mode=mode)
            return xf

        data = filled_data.map_overlap(convolve, depth=self._depth,
                                       boundary=mode, trim=True)
        if compute:
            with ProgressBar():
                out = data.compute()
        else:
            out = data
        res = xr.DataArray(out, dims=self.obj.dims, coords=self.coords, name=self.obj.name) / weights

        return res.where(mask == 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号