From 1b4b7b1e424d608d559db0189dcd9c4f551f34d8 Mon Sep 17 00:00:00 2001 From: isilber Date: Wed, 11 Dec 2024 00:36:21 +0000 Subject: [PATCH 1/3] FIX: `read_arm_mmcr` fails when using a read-only input file --- act/io/arm.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/act/io/arm.py b/act/io/arm.py index 05c9201a87..f9a7fc0cdf 100644 --- a/act/io/arm.py +++ b/act/io/arm.py @@ -841,12 +841,11 @@ def read_arm_mmcr(filenames): # read it in with xarray multi_ds = [] for f in filenames: - nc = Dataset(f, 'a') - # Change heights name to range to read appropriately to xarray - if 'heights' in nc.dimensions: - nc.renameDimension('heights', 'range') + nc = Dataset(f, 'r') if nc is not None: ds = xr.open_dataset(xr.backends.NetCDF4DataStore(nc)) + # Change heights name to range to read appropriately to xarray + ds = ds.rename_dims({"heights": "range"}) multi_ds.append(ds) # Concatenate datasets together if len(multi_ds) > 1: From 8e37e2bcf133fa7ffdcd1ab717919399b58ce97c Mon Sep 17 00:00:00 2001 From: isilber Date: Wed, 11 Dec 2024 00:46:17 +0000 Subject: [PATCH 2/3] FIX: add condition on "heights" dimension --- act/io/arm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/act/io/arm.py b/act/io/arm.py index f9a7fc0cdf..14b4aaece3 100644 --- a/act/io/arm.py +++ b/act/io/arm.py @@ -845,7 +845,8 @@ def read_arm_mmcr(filenames): if nc is not None: ds = xr.open_dataset(xr.backends.NetCDF4DataStore(nc)) # Change heights name to range to read appropriately to xarray - ds = ds.rename_dims({"heights": "range"}) + if 'heights' in ds.dims: + ds = ds.rename_dims({"heights": "range"}) multi_ds.append(ds) # Concatenate datasets together if len(multi_ds) > 1: From 476f83494eb735b2b194e2e4b53cbd1c376b453a Mon Sep 17 00:00:00 2001 From: AdamTheisen Date: Tue, 17 Dec 2024 11:14:40 -0600 Subject: [PATCH 3/3] ENH: I think I have a fix to work for read only. The proposed method did not work on my mac after downloading data. --- act/io/arm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/act/io/arm.py b/act/io/arm.py index 14b4aaece3..f8dc8f9e7f 100644 --- a/act/io/arm.py +++ b/act/io/arm.py @@ -841,12 +841,12 @@ def read_arm_mmcr(filenames): # read it in with xarray multi_ds = [] for f in filenames: - nc = Dataset(f, 'r') + nc = Dataset(f, 'a', diskless=True) + # Change heights name to range to read appropriately to xarray + if 'heights' in nc.dimensions: + nc.renameDimension('heights', 'range') if nc is not None: ds = xr.open_dataset(xr.backends.NetCDF4DataStore(nc)) - # Change heights name to range to read appropriately to xarray - if 'heights' in ds.dims: - ds = ds.rename_dims({"heights": "range"}) multi_ds.append(ds) # Concatenate datasets together if len(multi_ds) > 1: