From 27677a80cc7cdc53e73780bd55131ab2423fe9b8 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 1 Mar 2022 18:25:31 +0000 Subject: [PATCH] NetCDF saving avoid dimensionality reduction for string coords. --- lib/iris/fileformats/netcdf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/iris/fileformats/netcdf.py b/lib/iris/fileformats/netcdf.py index 59d6fcffe8..94395386b7 100644 --- a/lib/iris/fileformats/netcdf.py +++ b/lib/iris/fileformats/netcdf.py @@ -2865,10 +2865,11 @@ def _increment_name(self, varname): @staticmethod def _lazy_stream_data(data, fill_value, fill_warn, cf_var): - if data.shape == (1,) + cf_var.shape: + if hasattr(data, "shape") and data.shape == (1,) + cf_var.shape: # Reduce dimensionality where bounds data is for a scalar point - # bounds data is 2D but contains just 1 row, which causes # broadcast ambiguity between the data and its 1D cf_var. + # (Don't do this check for string data). data = np.atleast_1d(data[0]) if is_lazy_data(data):