本文整理匯總了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