lair.hrrr.decompress_chunk#
- lair.hrrr.decompress_chunk(zarr_id, compressed_data)[source]#
Decompress s3 chunk data.
- Parameters:
- Returns:
np.array – decompressed chunk
See also
retrieve_objectGets the bytes it takes.
get_valueDoes both, and picks the point out of the chunk.
Examples
An analysis chunk is 150 by 150 half-precision numbers; here, a made-up one:
>>> import datetime as dt >>> import numcodecs >>> import numpy as np >>> from lair.hrrr import ZarrId, decompress_chunk >>> zarr_id = ZarrId( ... dt.datetime(2024, 1, 15, 12), "sfc", "10m_above_ground", "UGRD", "anl" ... ) >>> raw = np.arange(150 * 150, dtype="<f2").tobytes() >>> chunk = decompress_chunk( ... zarr_id, bytes(numcodecs.blosc.compress(raw, b"zstd", 5)) ... ) >>> chunk.shape, chunk[0, :3] ((150, 150), array([0., 1., 2.], dtype=float16))