Skip to content

Commit 481f3af

Browse files
authored
fix: Skip previous encoding workaround for fixed xarray versions (#401)
* fix: Skip previous encoding workaround for fixed xarray versions see reported issue pydata/xarray#7691 and pr pydata/xarray#8713 which was included into xarray v2024.03.0 * Replace workaround by a new xarray lower bound --------- Co-authored-by: Jonas Hoersch <[email protected]>
1 parent 8bdae17 commit 481f3af

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

atlite/datasets/era5.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,6 @@ def retrieve_data(product, chunks=None, tmpdir=None, lock=None, **updates):
361361
logger.debug(f"Adding finalizer for {target}")
362362
weakref.finalize(ds._file_obj._manager, noisy_unlink, target)
363363

364-
# Remove default encoding we get from CDSAPI, which can lead to NaN values after loading with subsequent
365-
# saving due to how xarray handles netcdf compression (only float encoded as short int seem affected)
366-
# Fixes issue by keeping "float32" encoded as "float32" instead of internally saving as "short int", see:
367-
# https://stackoverflow.com/questions/75755441/why-does-saving-to-netcdf-without-encoding-change-some-values-to-nan
368-
# and hopefully fixed soon (could then remove), see https://github.com/pydata/xarray/issues/7691
369-
for v in ds.data_vars:
370-
if ds[v].encoding["dtype"] == "int16":
371-
ds[v].encoding.clear()
372-
373364
return ds
374365

375366

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"pandas>=0.25",
3434
"bottleneck",
3535
"numexpr",
36-
"xarray>=0.20",
36+
"xarray>=2024.03.0",
3737
"netcdf4",
3838
"dask>=2021.10.0",
3939
"toolz",
@@ -116,4 +116,4 @@ ignore = [
116116
'D415', # First line should end with a period, question mark, or exclamation point
117117
'D417', # Missing argument descriptions in the docstring
118118

119-
]
119+
]

0 commit comments

Comments
 (0)