Skip to content

Commit

Permalink
NetCDF _lazy_stream_data use np.squeeze to reduce dimensionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
trexfeathers committed Mar 2, 2022
1 parent 27677a8 commit d786c7a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2866,11 +2866,12 @@ def _increment_name(self, varname):
@staticmethod
def _lazy_stream_data(data, fill_value, fill_warn, cf_var):
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])
# Reduce dimensionality where the data array has an extra dimension
# versus the cf_var - to avoid a broadcasting ambiguity.
# Happens when bounds data is for a scalar point - array is 2D but
# contains just 1 row, so the cf_var is 1D.
data = data.squeeze()

if is_lazy_data(data):

Expand Down

0 comments on commit d786c7a

Please sign in to comment.