SChunk.postfilter#

SChunk.postfilter(input_dtype: dtype, output_dtype: dtype = None) 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 = blosc2.CParams(typesize=input_dtype.itemsize)
dparams = blosc2.DParams(nthreads=1)
schunk = blosc2.SChunk(
    chunksize=20_000 * input_dtype.itemsize, cparams=cparams, dparams=dparams
)

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