Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/iris/fileformats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ def _load_grib(*args, **kwargs):
)


#
# Zarr files.
#
FORMAT_AGENT.add_spec(
FormatSpecification(
"zarr",
FileExtension(requires_fh=False),
".zarr#mode=nczarr,file",
netcdf.load_cubes,
priority=3,
)
)


#
# UM Fieldsfiles.
#
Expand Down
6 changes: 5 additions & 1 deletion lib/iris/fileformats/netcdf/saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ def __init__(self, filename, netcdf_format, compute=True):
else:
# Given a filepath string/path : create a dataset from that
try:
self.filepath = Path(filename).absolute()
filepath = Path(filename)
if ".zarr" not in filepath.suffix:
self.filepath = filepath.absolute()
else:
self.filepath = filepath
self._dataset = _thread_safe_nc.DatasetWrapper(
self.filepath, mode="w", format=netcdf_format
)
Expand Down
5 changes: 4 additions & 1 deletion lib/iris/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def decode_uri(uri, default="file"):
# put - last in the brackets so it refers to the character, not a range
# reference on valid schemes: https://tools.ietf.org/html/std66#section-3.1
match = re.match(r"^([a-zA-Z][a-zA-Z0-9+.-]+):(.+)", uri)
if match:
if ".zarr" in uri:
scheme = "zarr"
part = uri
elif match:
scheme = match.group(1)
part = match.group(2)
else:
Expand Down
4 changes: 4 additions & 0 deletions lib/iris/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def _generate_cubes(uris, callback, constraints):
urls = [":".join(x) for x in groups]
for cube in iris.io.load_http(urls, callback):
yield cube
elif scheme == "zarr":
urls = [x[1] for x in groups]
for cube in iris.io.load_http(urls, callback):
yield cube
elif scheme == "data":
data_objects = [x[1] for x in groups]
for cube in iris.io.load_data_objects(data_objects, callback):
Expand Down
1 change: 1 addition & 0 deletions lib/iris/tests/results/file_load/known_loaders.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
* UM Fieldsfile (FF) converted with ieee to 32 bit (priority 3)
* UM Fieldsfile (FF) pre v3.1 (priority 3)
* UM Post Processing file (PP) little-endian (priority 3)
* zarr (priority 3)
* GRIB (priority 1)
Loading