Skip to content

Commit deb7587

Browse files
committed
Explicity do I/O with netcdf4 engine
1 parent edf0be7 commit deb7587

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

compass/landice/tests/ismip6_GrIS_forcing/file_finders.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33

44
import xarray as xr
5+
from xarray.coders import CFDatetimeCoder
56

67
# create mapping dictionary of ISMIP6 variables to MALI variable names
78
{"thermal_forcing": "ismip6_2dThermalForcing",
@@ -82,6 +83,7 @@ def get_filename(self, GCM, scenario, variable, start=1950, end=2100):
8283
# get a list of all the yearly files within the period of intrest
8384
yearly_files = self.__find_yearly_files(GCM, scenario, variable,
8485
start, end)
86+
8587
# still need to make the output filename to write combined files to
8688
out_fn = f"MAR3.9_{GCM}_{scenario}_{variable}_{start}--{end}.nc"
8789
# relative to the workdir, which we've already checked if if existed
@@ -129,9 +131,12 @@ def __find_yearly_files(self, GCM, scenario, variable, start, end):
129131
def __combine_files(self, files, out_fn):
130132
"""
131133
"""
132-
ds = xr.open_mfdataset(files, concat_dim="time", combine="nested",
134+
decoder = CFDatetimeCoder(use_cftime=True)
135+
136+
ds = xr.open_mfdataset(files, decode_times=decoder,
137+
concat_dim="time", combine="nested",
133138
data_vars='minimal', coords='minimal',
134139
compat="broadcast_equals",
135-
combine_attrs="override")
140+
combine_attrs="override", engine='netcdf4')
136141

137-
ds.to_netcdf(out_fn)
142+
ds.to_netcdf(out_fn, engine='netcdf4')

0 commit comments

Comments
 (0)