@@ -26,6 +26,7 @@ def open_source_datatree(
2626 storage_options : S3FsOptions | dict [str , Any ] | None = None ,
2727 cache_dir : str | None = None ,
2828 engine : str = "zarr" ,
29+ mask_and_scale : bool = True ,
2930) -> xr .DataTree :
3031 """Open a source datatree with dask chunks matching the native zarr chunks.
3132
@@ -46,6 +47,10 @@ def open_source_datatree(
4647 ephemeral directory.
4748 engine : str
4849 xarray backend engine, default ``"zarr"``.
50+ mask_and_scale : bool
51+ Forwarded to ``xr.open_datatree``. Pass ``False`` to keep variables
52+ packed (e.g. uint16 with CF scale_factor/add_offset in ``.attrs``)
53+ instead of CF-decoding to floats, as the OLCI converter requires.
4954
5055 Returns
5156 -------
@@ -61,6 +66,7 @@ def open_source_datatree(
6166 engine = engine ,
6267 chunks = {},
6368 storage_options = storage_options ,
69+ mask_and_scale = mask_and_scale ,
6470 )
6571 # Imported lazily: CacheStore is zarr's experimental API, so a relocation
6672 # in a future zarr release must not break importing this package.
@@ -87,4 +93,9 @@ def open_source_datatree(
8793 cached = CacheStore (source , cache_store = LocalStore (source_cache ))
8894 # xarray's open_datatree accepts a zarr store at runtime, but its stub does
8995 # not list Store among the accepted input types.
90- return xr .open_datatree (cached , engine = engine , chunks = {}) # pyright: ignore[reportArgumentType]
96+ return xr .open_datatree (
97+ cached , # pyright: ignore[reportArgumentType]
98+ engine = engine ,
99+ chunks = {},
100+ mask_and_scale = mask_and_scale ,
101+ )
0 commit comments