Skip to content

Commit d786c7a

Browse files
committed
NetCDF _lazy_stream_data use np.squeeze to reduce dimensionality.
1 parent 27677a8 commit d786c7a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/iris/fileformats/netcdf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,11 +2866,12 @@ def _increment_name(self, varname):
28662866
@staticmethod
28672867
def _lazy_stream_data(data, fill_value, fill_warn, cf_var):
28682868
if hasattr(data, "shape") and data.shape == (1,) + cf_var.shape:
2869-
# Reduce dimensionality where bounds data is for a scalar point -
2870-
# bounds data is 2D but contains just 1 row, which causes
2871-
# broadcast ambiguity between the data and its 1D cf_var.
28722869
# (Don't do this check for string data).
2873-
data = np.atleast_1d(data[0])
2870+
# Reduce dimensionality where the data array has an extra dimension
2871+
# versus the cf_var - to avoid a broadcasting ambiguity.
2872+
# Happens when bounds data is for a scalar point - array is 2D but
2873+
# contains just 1 row, so the cf_var is 1D.
2874+
data = data.squeeze()
28742875

28752876
if is_lazy_data(data):
28762877

0 commit comments

Comments
 (0)