本文整理汇总了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()
示例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
示例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)
示例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