Skip to content
Merged
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
10 changes: 9 additions & 1 deletion tests/test_efas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from itertools import product as cart_prod
from logging import getLogger
from pathlib import Path
from types import MappingProxyType
from unittest.mock import AsyncMock
from unittest.mock import patch
from zipfile import ZipFile
Expand Down Expand Up @@ -56,6 +57,8 @@ class EfasLikeFileGenerator:
the EFAS archive.
"""

COMPRESSION = MappingProxyType({"zlib": True, "complevel": 4})

def __init__(
self,
tmp_path: Path,
Expand Down Expand Up @@ -118,7 +121,12 @@ def create(self, output_file: Path):

dataset = xr.Dataset({"dis06": data})
nc_path = self._tmp_path / "data_operational-version-5.nc"
dataset.to_netcdf(nc_path)
dataset.to_netcdf(
nc_path,
encoding={
v: EfasLikeFileGenerator.COMPRESSION for v in dataset.data_vars
},
)

with ZipFile(output_file, "w") as zip_file:
zip_file.write(nc_path, arcname=nc_path.name)
Expand Down