Skip to content

smart_geocubes.core.storage

Local zarr-storage related functions.

Classes:

  • CoordEncoding

    TypedDict for the encoding of regularly spaced coordinates.

Functions:

CoordEncoding

Bases: TypedDict

TypedDict for the encoding of regularly spaced coordinates.

optimize_coord_encoding

optimize_coord_encoding(
    values: ndarray, dx: int
) -> CoordEncoding

Optimize zarr encoding of regularly spaced coordinates.

Taken from https://github.com/earth-mover/serverless-datacube-demo/blob/a15423b9734898f52468bebc441e29ccf3789410/src/lib.py#L280

Parameters:

  • values

    (ndarray) –

    The coordinates to encode

  • dx

    (int) –

    The spacing between the coordinates

Returns:

  • CoordEncoding ( CoordEncoding ) –

    A dictionary containing the zarr compressors and filters to use for encoding the coordinates.

Source code in src/smart_geocubes/core/storage.py
def optimize_coord_encoding(values: np.ndarray, dx: int) -> CoordEncoding:
    """Optimize zarr encoding of regularly spaced coordinates.

    Taken from https://github.com/earth-mover/serverless-datacube-demo/blob/a15423b9734898f52468bebc441e29ccf3789410/src/lib.py#L280

    Args:
        values (np.ndarray): The coordinates to encode
        dx (int): The spacing between the coordinates

    Returns:
        CoordEncoding: A dictionary containing the zarr compressors and filters to use for encoding the coordinates.

    """
    compressor = BloscCodec()
    return {"compressors": [compressor]}

optimize_temporal_encoding

optimize_temporal_encoding(
    temporal_extent: DatetimeIndex,
) -> dict

Optimize the encoding of temporal data.

Parameters:

  • temporal_extent

    (DatetimeIndex) –

    The temporal extent to encode.

Returns:

  • dict ( dict ) –

    A dictionary containing the zarr compressors and filters to use for encoding the temporal data.

Source code in src/smart_geocubes/core/storage.py
def optimize_temporal_encoding(temporal_extent: pd.DatetimeIndex) -> dict:
    """Optimize the encoding of temporal data.

    Args:
        temporal_extent (pd.DatetimeIndex): The temporal extent to encode.

    Returns:
        dict: A dictionary containing the zarr compressors and filters to use for encoding the temporal data.

    """
    compressor = BloscCodec()
    return {"compressors": [compressor]}