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
12 changes: 12 additions & 0 deletions xbout/boutdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,12 +999,24 @@ def to_restart(
self.data, variables, savepath, nxpe, nype, tind, prefix, overwrite
)

# Xarray sets _FillValue=NaN by default for floating-point variables,
# but BOUT++ rewrites restart-file attributes after writing data, which
# NetCDF does not allow for _FillValue. Disable that default here.
restart_encoding = {}
if restart_datasets:
restart_encoding = {
name: {"_FillValue": None}
for name, variable in restart_datasets[0].variables.items()
if np.issubdtype(variable.dtype, np.floating)
}

with ProgressBar():
xr.save_mfdataset(
restart_datasets,
paths,
compute=True,
engine=_check_filetype(paths[0]),
encoding=restart_encoding,
)

def animate_list(
Expand Down
Loading