SChunk.postfilter#

SChunk.postfilter(input_dtype, output_dtype=None)#

Decorator to set a function as a postfilter.

The postfilter function will be executed each time after decompressing blocks of data. It will receive three parameters: the input ndarray from which to read, the output ndarray to fill and the offset inside the SChunk instance where the corresponding block begins (see example below).

Parameters:
  • input_dtype (np.dtype) – Data type of the input that will receive the postfilter function.

  • output_dtype (np.dtype) – Data type of the output that will receive and fill the postfilter function. If None (default) it will be set to input_dtype.

Returns:

out

Return type:

None

Notes

Examples

# Create SChunk
input_dtype = np.dtype(np.int64)
cparams = {"typesize": input_dtype.itemsize}
dparams = {"nthreads": 1}
storage = {"cparams": cparams, "dparams": dparams}
schunk = blosc2.SChunk(chunksize=20_000 * input_dtype.itemsize, **storage)

# Create postfilter and associate it to the schunk
@schunk.postfilter(input_dtype)
def postfilter(input, output, offset):
    output[:] = offset + np.arange(input.size)