From 6f335ce871672ecb84ead522f5f0055cf4083f19 Mon Sep 17 00:00:00 2001 From: Eirik Rolland Enger Date: Tue, 25 Jul 2023 10:37:30 +0200 Subject: [PATCH] fix(nc_savefile): open in lock=False mode (#16) Issue also described and tracked in https://github.com/pydata/xarray/issues/3961. --- src/cesm_helper_scripts/gen_agg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cesm_helper_scripts/gen_agg b/src/cesm_helper_scripts/gen_agg index 050d8c3..421a6b8 100755 --- a/src/cesm_helper_scripts/gen_agg +++ b/src/cesm_helper_scripts/gen_agg @@ -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: @@ -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):