Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ This document explains the changes made to Iris for this release
#. `@trexfeathers`_ and `@pp-mo`_ made Iris' use of the `netCDF4`_ library
thread-safe. (:pull:`5095`)

#. `@ESadek-MO`_ removed check and error raise for saving
cubes with masked :class:`iris.coords.CellMeasure`.
(:issue:`5147`, :pull:`5181`)


💣 Incompatible Changes
=======================
Expand Down
10 changes: 0 additions & 10 deletions lib/iris/fileformats/netcdf/saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1933,16 +1933,6 @@ def _create_generic_cf_array_var(
# Check if this is a dim-coord.
is_dimcoord = cube is not None and element in cube.dim_coords

if isinstance(element, iris.coords.CellMeasure):
# Disallow saving of *masked* cell measures.
# NOTE: currently, this is the only functional difference in
# variable creation between an ancillary and a cell measure.
if iris.util.is_masked(data):
# We can't save masked points properly, as we don't maintain
# a fill_value. (Load will not record one, either).
msg = "Cell measures with missing data are not supported."
raise ValueError(msg)

if is_dimcoord:
# By definition of a CF-netCDF coordinate variable this
# coordinate must be 1-D and the name of the CF-netCDF variable
Expand Down
33 changes: 0 additions & 33 deletions lib/iris/tests/unit/fileformats/netcdf/test_Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,38 +1051,5 @@ def test_geo_cs(self):
self._test(coord_system, expected)


class Test__create_cf_cell_measure_variable(tests.IrisTest):
# Saving of masked data is disallowed.

# Attribute is substituted in test_Saver__lazy.
array_lib = np

def setUp(self):
self.cube = stock.lat_lon_cube()
self.names_map = ["latitude", "longitude"]
masked_array = self.array_lib.ma.masked_array(
[0, 1, 2], mask=[True, False, True]
)
self.cm = iris.coords.CellMeasure(masked_array, var_name="cell_area")
self.cube.add_cell_measure(self.cm, data_dims=0)
self.exp_emsg = "Cell measures with missing data are not supported."

def test_masked_data__insitu(self):
# Test that the error is raised in the right place.
with self.temp_filename(".nc") as nc_path:
saver = Saver(nc_path, "NETCDF4")
with self.assertRaisesRegex(ValueError, self.exp_emsg):
saver._create_generic_cf_array_var(
self.cube, self.names_map, self.cm
)

def test_masked_data__save_pipeline(self):
# Test that the right error is raised by the saver pipeline.
with self.temp_filename(".nc") as nc_path:
with Saver(nc_path, "NETCDF4") as saver:
with self.assertRaisesRegex(ValueError, self.exp_emsg):
saver.write(self.cube)


if __name__ == "__main__":
tests.main()
6 changes: 0 additions & 6 deletions lib/iris/tests/unit/fileformats/netcdf/test_Saver__lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ class Test_check_attribute_compliance__exception_handling(
pass


class Test__create_cf_cell_measure_variable(
LazyMixin, test_Saver.Test__create_cf_cell_measure_variable
):
pass


class TestStreamed(tests.IrisTest):
def setUp(self):
self.cube = stock.simple_2d()
Expand Down