當前位置: 首頁>>代碼示例>>Python>>正文


Python array.from_zarr方法代碼示例

本文整理匯總了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 
開發者ID:nmileva,項目名稱:starfm4py,代碼行數:21,代碼來源:starfm4py.py

示例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) 
開發者ID:intake,項目名稱:intake,代碼行數:27,代碼來源:zarr.py

示例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 
開發者ID:theislab,項目名稱:scanpy,代碼行數:16,代碼來源:test_preprocessing_distributed.py

示例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) 
開發者ID:intake,項目名稱:intake,代碼行數:14,代碼來源:zarr.py

示例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 
開發者ID:napari,項目名稱:napari,代碼行數:31,代碼來源:io.py

示例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) 
開發者ID:napari,項目名稱:napari,代碼行數:11,代碼來源:test_numpy_like.py

示例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) 
開發者ID:napari,項目名稱:napari,代碼行數:11,代碼來源:test_numpy_like.py

示例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 
開發者ID:MITgcm,項目名稱:xmitgcm,代碼行數:9,代碼來源:llcmodel.py


注:本文中的dask.array.from_zarr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。