lair.hrrr.get_value#

lair.hrrr.get_value(s3, zarr_id, chunk_id, nearest_point)[source]#

Get an array of values from am s3 zarr chunk.

Parameters:
  • s3 (boto3.resource) – s3 resource

  • zarr_id (ZarrId) – ZarrId instance

  • chunk_id (str) – Chunk id, for example "4.5".

  • nearest_point (xr.Dataset) – nearest point

Returns:

np.array – array of values

See also

retrieve_object

Gets the chunk’s bytes.

decompress_chunk

Turns them into an array.

get_nearest_point

Gives the chunk_id and nearest_point.

Examples

Winds does this for the 10 m u and v. For one hour of u at the nearest point (needs the internet; s3 and point are as in retrieve_object() and get_nearest_point()):

>>> import datetime as dt
>>> from lair.hrrr import ZarrId, get_value
>>> zarr_id = ZarrId(
...     dt.datetime(2024, 1, 15, 12), "sfc", "10m_above_ground", "UGRD", "anl"
... )
>>> u = get_value(s3, zarr_id, point.chunk_id.values, point)