Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed cell measure mask check and error #5181

Merged
merged 7 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 4 additions & 12 deletions lib/iris/tests/unit/fileformats/netcdf/test_Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,20 +1068,12 @@ def setUp(self):
self.exp_emsg = "Cell measures with missing data are not supported."
pp-mo marked this conversation as resolved.
Show resolved Hide resolved

def test_masked_data__insitu(self):
# Test that the error is raised in the right place.
# Test that the error is not being raised.
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):
pp-mo marked this conversation as resolved.
Show resolved Hide resolved
# 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)
saver._create_generic_cf_array_var(
pp-mo marked this conversation as resolved.
Show resolved Hide resolved
self.cube, self.names_map, self.cm
)


if __name__ == "__main__":
Expand Down