本文整理匯總了Python中dask.array.from_zarr方法的典型用法代碼示例。如果您正苦於以下問題:Python array.from_zarr方法的具體用法?Python array.from_zarr怎麽用?Python array.from_zarr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dask.array
的用法示例。
在下文中一共展示了array.from_zarr方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: da_stack
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def da_stack(folder, shape):
da_list = []
full_path = path + folder
max_blocks = shape[0]//windowSize + 1
for block in range(1,max_blocks + 1):
for row in range(0,windowSize):
name = str(block) + 'r' + str(row)
full_name = full_path + name + '.zarr'
try:
da_array = da.from_zarr(full_name)
da_list.append(da_array)
except Exception:
continue
return da.rechunk(da.concatenate(da_list, axis=0), chunks = (shape[1],windowSize**2))
# Calculate the spectral distance
示例2: __init__
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def __init__(self, urlpath, storage_options=None, component=None,
metadata=None, **kwargs):
"""
The parameters dtype and shape will be determined from the first
file, if not given.
Parameters
----------
urlpath : str
Location of data file(s), possibly including protocol
information
storage_options : dict
Passed on to storage backend for remote files
component : str or None
If None, assume the URL points to an array. If given, assume
the URL points to a group, and descend the group to find the
array at this location in the hierarchy.
kwargs : passed on to dask.array.from_zarr
"""
self.urlpath = urlpath
self.storage_options = storage_options or {}
self.component = component
self.kwargs = kwargs
self._arr = None
super(ZarrArraySource, self).__init__(metadata=metadata)
示例3: adata_dist
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def adata_dist(self, request):
# regular anndata except for X, which we replace on the next line
a = ad.read_zarr(input_file)
input_file_X = input_file + "/X"
if request.param == "direct":
import zappy.direct
a.X = zappy.direct.from_zarr(input_file_X)
yield a
elif request.param == "dask":
import dask.array as da
a.X = da.from_zarr(input_file_X)
yield a
示例4: _get_schema
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def _get_schema(self):
import dask.array as da
if self._arr is None:
self._arr = da.from_zarr(self.urlpath, component=self.component,
storage_options=self.storage_options,
**self.kwargs)
self.chunks = self._arr.chunks
self.npartitions = self._arr.npartitions
return Schema(dtype=str(self.dtype), shape=self.shape,
extra_metadata=self.metadata,
npartitions=self.npartitions,
chunks=self.chunks)
示例5: read_zarr_dataset
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def read_zarr_dataset(path):
"""Read a zarr dataset, including an array or a group of arrays.
Parameters
--------
path : str
Path to directory ending in '.zarr'. Path can contain either an array
or a group of arrays in the case of multiscale data.
Returns
-------
image : array-like
Array or list of arrays
shape : tuple
Shape of array or first array in list
"""
if os.path.exists(os.path.join(path, '.zarray')):
# load zarr array
image = da.from_zarr(path)
shape = image.shape
elif os.path.exists(os.path.join(path, '.zgroup')):
# else load zarr all arrays inside file, useful for multiscale data
image = []
for subpath in sorted(os.listdir(path)):
if not subpath.startswith('.'):
image.append(read_zarr_dataset(os.path.join(path, subpath))[0])
shape = image[0].shape
else:
raise ValueError(f"Not a zarr dataset or group: {path}")
return image, shape
示例6: test_zarr_dask_2D
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def test_zarr_dask_2D(make_test_viewer):
"""Test adding 2D dask image."""
viewer = make_test_viewer()
data = zarr.zeros((200, 100), chunks=(40, 20))
data[53:63, 10:20] = 1
zdata = da.from_zarr(data)
viewer.add_image(zdata)
assert np.all(viewer.layers[0].data == zdata)
示例7: test_zarr_dask_nD
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def test_zarr_dask_nD(make_test_viewer):
"""Test adding nD zarr image."""
viewer = make_test_viewer()
data = zarr.zeros((200, 100, 50), chunks=(40, 20, 10))
data[53:63, 10:20, :] = 1
zdata = da.from_zarr(data)
viewer.add_image(zdata)
assert np.all(viewer.layers[0].data == zdata)
示例8: _get_masks
# 需要導入模塊: from dask import array [as 別名]
# 或者: from dask.array import from_zarr [as 別名]
def _get_masks(self):
masks = {}
zgroup = self.store.open_mask_group()
for point in ['c', 'w', 's']:
mask_faces = dsa.from_zarr(zgroup['mask_' + point]).astype('bool')
masks[point] = _faces_to_facets(mask_faces)
return masks