functional_time_series.helpers
Utility functions for use across functional_time_series modules.
Module Attributes
A local path or web URL, represented as a string. |
Functions
|
Validate that the provided path is either a valid local path or a web URL. |
Assign CF grid-mapping and fill-value metadata to dataset variables. |
|
Assign the required GeoZarr attributes to a spatial coordinate. |
|
|
Convert a time coordinate to numeric epoch seconds with legacy CF metadata. |
|
Save dataset to GeoZarr adhering to CF conventions (https://cfconventions.org/). |
- type ZarrType
A local path or web URL, represented as a string.
Validated by
path_or_web_url_validator().
- path_or_web_url_validator(type_: object, path_or_url: Path | str) str
Validate that the provided path is either a valid local path or a web URL.
NOTE: Path(“”) resolves to the current directory (“.”) - which is considered a valid path.
- Parameters:
type (object) – The type of the argument being validated - unused, purely required for cyclopts validator compatibility.
path_or_url (Path | str) – The candidate path or URL to validate.
- Returns:
The validated path or URL as a string.
- Return type:
str
- Raises:
ValueError – If the provided path is neither a valid local path nor a web URL.
- prepare_cf_data_variable_arrays(ds: Dataset) Dataset
Assign CF grid-mapping and fill-value metadata to dataset variables.
- prepare_cf_spatial_data_array(spatial_data_array: DataArray, name: str, axis: str) DataArray
Assign the required GeoZarr attributes to a spatial coordinate.
- prepare_cf_time_data_array(time_data_array: DataArray) DataArray
Convert a time coordinate to numeric epoch seconds with legacy CF metadata.
- save_geo_zarr(ds: Dataset, zarr_path: Path | str, target_chunk_size: str = '1024MB') None
Save dataset to GeoZarr adhering to CF conventions (https://cfconventions.org/).
- Parameters:
ds (xr.Dataset) – The xarray dataset to save. This must follow the GeoZarr format, including having a spatial_ref attribute with a valid CRS.
zarr_path (Path | str) – Full path of the output .zarr file to be created.
target_chunk_size (str) – The target chunk size for the GeoZarr dataset, by default “1024MB”.