当前位置: 首页>>代码示例>>Python>>正文


Python xarray.zeros_like方法代码示例

本文整理汇总了Python中xarray.zeros_like方法的典型用法代码示例。如果您正苦于以下问题:Python xarray.zeros_like方法的具体用法?Python xarray.zeros_like怎么用?Python xarray.zeros_like使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xarray的用法示例。


在下文中一共展示了xarray.zeros_like方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import xarray [as 别名]
# 或者: from xarray import zeros_like [as 别名]
def __init__(self, shiftds, sampling=2, pct_thres=99.9, on=0):
        self.shiftds = shiftds
        self.temps = shiftds['temps']
        self.on = on
        self.pct_thres = pct_thres
        self.hh = self.temps.sizes['height']
        self.ww = self.temps.sizes['width']
        self.mask = xr.zeros_like(self.temps, dtype=bool)
        self.ls_anm = np.unique(shiftds.coords['animal'].values)
        self.ls_ss = np.unique(shiftds.coords['session'].values)
        Selection = Stream.define(
            'selection',
            anm=param.Selector(self.ls_anm),
            ss=param.Selector(self.ls_ss))
        self.str_sel = Selection(anm=self.ls_anm[0], ss=self.ls_ss[0])
        # self.sampling = sampling
        self.str_box = BoxEdit()
        self.box = hv.DynamicMap(self._box, streams=[self.str_box])
        self.box = self.box.opts(
            style=dict(fill_alpha=0.3, line_color='white'))
        self.wgts = self._widgets()
        self.hvobjs = self._get_objs() 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:24,代码来源:visualization.py

示例2: compute_by_block

# 需要导入模块: import xarray [as 别名]
# 或者: from xarray import zeros_like [as 别名]
def compute_by_block(dsx):
    """
    
    """
    
    # determine index key for each chunk
    slices = []
    for chunks in dsx.chunks:
        L  = [0,] + list(np.cumsum(chunks))
        slices.append( [slice(a, b) 
                        for a,b in (zip(L[:-1], L[1:]))]  )
    indexes = list(product(*slices))
    
    # allocate memory to receive result
    if isinstance(dsx, xr.DataArray):
        result = xr.zeros_like(dsx).load()
    else:
        result = np.zeros(dsx.shape)
    
    #evaluate each chunk one at a time
    for index in tqdm_notebook(indexes, leave=False):
        block = dsx.__getitem__(index).compute()
        result.__setitem__(index, block)
    
    return result 
开发者ID:COSIMA,项目名称:cosima-cookbook,代码行数:27,代码来源:distributed.py

示例3: test_dimension_mismatch

# 需要导入模块: import xarray [as 别名]
# 或者: from xarray import zeros_like [as 别名]
def test_dimension_mismatch(function):
    darr = xr.DataArray([[1, 2], [3, 4]], dims=['x', 'y'])
    w = xr.zeros_like(darr)
    res = function(darr, dim=['x', 'z'], weights=w)
    xr.testing.assert_equal(res, darr) 
开发者ID:NCAR,项目名称:esmlab,代码行数:7,代码来源:test_statistics.py

示例4: update_spatial_perpx

# 需要导入模块: import xarray [as 别名]
# 或者: from xarray import zeros_like [as 别名]
def update_spatial_perpx(y, alpha, sub, C):
    res = np.zeros_like(sub, dtype=y.dtype)
    if np.sum(sub) > 0:
        C = C[:, sub]
        clf = LassoLars(alpha=alpha, positive=True)
        coef = clf.fit(C, y).coef_
        res[np.where(sub)[0]] = coef
    return res 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:10,代码来源:cnmf.py


注:本文中的xarray.zeros_like方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。