Python dask.array.from_zarr() Examples
The following are 8
code examples of dask.array.from_zarr().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
dask.array
, or try the search function
.
Example #1
Source File: starfm4py.py From starfm4py with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: zarr.py From intake with BSD 2-Clause "Simplified" License | 6 votes |
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)
Example #3
Source File: test_preprocessing_distributed.py From scanpy with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #4
Source File: zarr.py From intake with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #5
Source File: io.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #6
Source File: test_numpy_like.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #7
Source File: test_numpy_like.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #8
Source File: llcmodel.py From xmitgcm with MIT License | 5 votes |
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