From 9b0a9cccb6247fa8c5a6df6efc3b187e75d4fa38 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Mon, 1 Oct 2018 17:58:06 +0100 Subject: [PATCH] Fix for netcdf4 returning masked array with no masked points. --- lib/iris/fileformats/netcdf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/iris/fileformats/netcdf.py b/lib/iris/fileformats/netcdf.py index 8c965ef1a5..ffd10ea379 100644 --- a/lib/iris/fileformats/netcdf.py +++ b/lib/iris/fileformats/netcdf.py @@ -393,6 +393,10 @@ def __getitem__(self, keys): variable = dataset.variables[self.variable_name] # Get the NetCDF variable data and slice. var = variable[keys] + # Make into a 'plain' array if no masked points, + # for compatibility with netcdf <= 1.3. + if isinstance(var, np.ma.MaskedArray) and not np.ma.is_masked(var): + var = var.data finally: dataset.close() return np.asanyarray(var)