Open a EOPF Zarr product#

import xarray as xr

from xarray_eop.api import open_datatree
from xarray_eop.path import EOPath

Product stored in the filesystem#

import importlib.resources
SAMPLE_PATH = importlib.resources.files("tests.ut.data")
product = SAMPLE_PATH / "sample.zarr"

One can access the whole product using datatree

dt = open_datatree(product)
dt
<xarray.DatasetView> Size: 0B
Dimensions:  ()
Data variables:
    *empty*
Attributes:
    filename:        sample.zarr
    other_metadata:  {}
product = SAMPLE_PATH / "sample.zip"
dt = open_datatree("zip::"+str(product),engine="zarr")
dt
<xarray.DatasetView> Size: 0B
Dimensions:  ()
Data variables:
    *empty*
Attributes:
    filename:        sample.zip
    other_metadata:  {}

or a specific group by opening a xarray dataset

product = SAMPLE_PATH / "sample.zarr"
group = "measurements/fine"
# Open with xarray zarr engine
ds=xr.open_dataset(SAMPLE_PATH / product / group, engine="zarr",chunks={})
# Open with custom engine="eop"
ds=xr.open_dataset(SAMPLE_PATH / product, group=group, engine="eop")
ds
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/xarray/backends/api.py:571: RuntimeWarning: Failed to open Zarr store with consolidated metadata, but successfully read with non-consolidated metadata. This is typically much slower for opening a dataset. To silence this warning, consider:
1. Consolidating metadata in this existing store with zarr.consolidate_metadata().
2. Explicitly setting consolidated=False, to avoid trying to read consolidate metadata, or
3. Explicitly setting consolidated=True, to raise an error in this case instead of falling back to try reading non-consolidated metadata.
  backend_ds = backend.open_dataset(
<xarray.Dataset> Size: 152B
Dimensions:  (x: 3, y: 5)
Coordinates:
  * x        (x) int32 12B 10 15 20
  * y        (y) int32 20B 10 15 20 25 30
Data variables:
    var1     (x, y) float64 120B ...

Product stored in S3 bucket#

Products store in S3 object-storage can also be accessed.

Note: The credentials are tried to be retrieved automatically looking for AWS or S3 environment variables. It can alsso be explicitely passed to the function using the addition kwargs backend_kwargs, whose value is a dictionary in the form {“s3”:{“key”: access-key,”secret”: secret-key,”endpoint_url”: endpoint_url}}.

xarray-eop provide an EOPath classe derived from pathlib.Path which supports S3 paths and well as fsspec-like URL chain.

For instance:

buc_name = EOPath("zip::s3://buc-acaw-dpr")
product = buc_name / "Samples/Zarr/S03OLCEFR_20230506T015316_0180_B117_T229.zarr.zip"
dt = open_datatree(product)
dt
<xarray.DatasetView> Size: 0B
Dimensions:  ()
Data variables:
    *empty*
Attributes:
    other_metadata:  {'data_information': {'accuracy_reference': '0', 'earth_...
    stac_discovery:  {'assets': [], 'bbox': [132.954, 29.0715, 115.986, 41.97...