MCPcopy Create free account
hub / github.com/bopen/xarray-sentinel / to_group_zarr

Function to_group_zarr

xarray_sentinel/reformat.py:8–27  ·  view source on GitHub ↗
(
    product_path: esa_safe.PathType,
    output_store: Any,
    groups: Dict[str, str] | None = None,
    **kwargs: Any,
)

Source from the content-addressed store, hash-verified

6
7
8def to_group_zarr(
9 product_path: esa_safe.PathType,
10 output_store: Any,
11 groups: Dict[str, str] | None = None,
12 **kwargs: Any,
13) -> None:
14 root = xr.open_dataset(product_path, engine="sentinel-1")
15 root.to_zarr(output_store, mode="w", **kwargs)
16
17 if groups is None:
18 groups = {g: g for g in root.attrs["subgroups"]}
19
20 for group_out, group_in in groups.items():
21 try:
22 group_ds = xr.open_dataset(
23 product_path, engine="sentinel-1", group=group_in
24 )
25 group_ds.to_zarr(output_store, mode="a", group=group_out, **kwargs)
26 except FileNotFoundError:
27 pass
28
29
30# Apparently there is no way to save SLC images because "netcdf4" doesn't support complex data

Callers

nothing calls this directly

Calls 1

open_datasetMethod · 0.80

Tested by

no test coverage detected