Skip to content

Commit

Permalink
fix(nc_savefile): open in lock=False mode (#16)
Browse files Browse the repository at this point in the history
Issue also described and tracked in
pydata/xarray#3961.
  • Loading branch information
engeir authored Jul 25, 2023
1 parent 5585f19 commit 6f335ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cesm_helper_scripts/gen_agg
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _attr_present(attr) -> bool:
check_input = glob.glob(the_input)[0]
elif isinstance(the_input, list):
check_input = the_input[0]
ds = xr.open_mfdataset(check_input)
ds = xr.open_mfdataset(check_input, lock=False)
try:
_ = getattr(ds, attr)
except AttributeError as e:
Expand Down Expand Up @@ -151,7 +151,8 @@ if not attrs:
sys.exit("All attributes files already exist. Exiting...")

print("Creating aggregated dataset... ", end="", flush=True)
dataset = xr.open_mfdataset(the_input)
# See issue https://github.com/pydata/xarray/issues/3961
dataset = xr.open_mfdataset(the_input, lock=False)
dataset = xr.decode_cf(dataset)
print("Finished creating aggregated dataset.")
for i, a in enumerate(attrs):
Expand Down

0 comments on commit 6f335ce

Please sign in to comment.