Skip to content

Commit e809750

Browse files
committed
fix so that fillvalues get updated when encoding is used
1 parent e2aa0bb commit e809750

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

obsarray/templater/dswriter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import os
6-
6+
from obsarray.templater.template_util import DatasetUtil
77

88
__author__ = "Sam Hunt <sam.hunt@npl.co.uk>"
99

@@ -73,6 +73,9 @@ def _write_netcdf(ds, path, compression_level=None):
7373
for var_name in ds.data_vars:
7474
var_encoding = dict(comp)
7575
var_encoding.update(ds[var_name].encoding)
76+
if "dtype" in var_encoding.keys():
77+
var_encoding.update({"_FillValue": DatasetUtil.get_default_fill_value(var_encoding["dtype"])})
78+
ds[var_name].attrs.pop("_FillValue")
7679
encoding.update({var_name: var_encoding})
7780

7881
ds.to_netcdf(path, format="netCDF4", engine="netcdf4", encoding=encoding)

0 commit comments

Comments
 (0)