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 to be read from * the output ndarray to be filled out * 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)