blosc2.open#
- blosc2.open(urlpath, mode='a', **kwargs)#
Open an already persistently stored SChunk.
- Parameters:
mode¶ (str, optional) – The open mode.
kwargs¶ (dict, optional) –
- Keyword arguments supported:
- cparams: dict
A dictionary with the compression parameters, which are the same that can be used in the
compress2()
function. Typesize and blocksize cannot be changed.- dparams: dict
A dictionary with the decompression parameters, which are the same that can be used in the
decompress2()
function.
Examples
>>> import blosc2 >>> import numpy as np >>> storage = {"contiguous": True, "urlpath": "b2frame", "cparams": {}, "dparams": {}} >>> nelem = 20 * 1000 >>> nchunks = 5 >>> chunksize = nelem * 4 // nchunks >>> data = np.arange(nelem, dtype="int32") >>> # Create SChunk and append data >>> schunk = blosc2.SChunk(chunksize=chunksize, data=data.tobytes(), mode="w", **storage) >>> # Open SChunk >>> sc_open = blosc2.open(urlpath=storage["urlpath"]) >>> for i in range(nchunks): ... dest = np.empty(nelem // nchunks, dtype=data.dtype) ... schunk.decompress_chunk(i, dest) ... dest1 = np.empty(nelem // nchunks, dtype=data.dtype) ... sc_open.decompress_chunk(i, dest1) ... np.array_equal(dest, dest1) True True True True True