diff --git a/doc/recipe/preprocessor.rst b/doc/recipe/preprocessor.rst index 1c91408684..44eb9d0dd4 100644 --- a/doc/recipe/preprocessor.rst +++ b/doc/recipe/preprocessor.rst @@ -1015,13 +1015,6 @@ scheme available in :doc:`iris-esmf-regrid:index`: reference: esmf_regrid.schemes:regrid_rectilinear_to_rectilinear mdtol: 0.7 -Since version 0.6 of :doc:`iris-esmf-regrid:index`, the regridder is able -to ignore discontinuities in the source grids if the data defined in the -discontiguous points is masked. -The :func:`~esmvalcore.preprocessor.regrid` preprocessor automatically detects -if discontinuities are present, and configures the regridding scheme in order to take -into account the mask of the source grid to ignore them. - .. _ensemble statistics: Ensemble statistics diff --git a/esmvalcore/preprocessor/_regrid.py b/esmvalcore/preprocessor/_regrid.py index daa6b6acfd..1008cf67ad 100644 --- a/esmvalcore/preprocessor/_regrid.py +++ b/esmvalcore/preprocessor/_regrid.py @@ -384,21 +384,6 @@ def extract_location(cube, location, scheme): scheme) -def _check_grid_discontiguities(cube, scheme): - """Check if there are grid discontiguities and set use_src_mask to True.""" - scheme = dict(scheme) - try: - discontiguities = iris.util.find_discontiguities(cube) - except NotImplementedError: - pass - else: - if discontiguities.any(): - scheme['use_src_mask'] = True - logger.debug('Grid discontinuities were found in the source grid. ' - 'Setting scheme argument `use_src_mask` to True.') - return scheme - - def extract_point(cube, latitude, longitude, scheme): """Extract a point, with interpolation. @@ -577,12 +562,6 @@ def regrid(cube, target_grid, scheme, lat_offset=True, lon_offset=True): scheme: reference: esmf_regrid.schemes:ESMFAreaWeighted - Since version 0.6 of :doc:`iris-esmf-regrid:index`, the regridder is able - to ignore discontinuities in the source grids if the data defined in the - discontiguous points is masked. - The preprocessor automatically detects if discontinuities are present, - and configures the regridding scheme in order to take into account - the mask of the source grid to ignore them. """ if is_dataset(target_grid): target_grid = target_grid.copy() @@ -637,8 +616,6 @@ def regrid(cube, target_grid, scheme, lat_offset=True, lon_offset=True): scheme['src_cube'] = cube if 'grid_cube' in scheme_args: scheme['grid_cube'] = target_grid - if 'use_src_mask' in scheme_args: - scheme = _check_grid_discontiguities(cube, scheme) loaded_scheme = obj(**scheme) else: diff --git a/tests/unit/preprocessor/_regrid/test_regrid.py b/tests/unit/preprocessor/_regrid/test_regrid.py index 780c0a1db3..b6334d0340 100644 --- a/tests/unit/preprocessor/_regrid/test_regrid.py +++ b/tests/unit/preprocessor/_regrid/test_regrid.py @@ -1,7 +1,6 @@ """Unit tests for the :func:`esmvalcore.preprocessor.regrid.regrid` function.""" -import logging import unittest from unittest import mock @@ -16,7 +15,6 @@ from esmvalcore.preprocessor._regrid import ( _CACHE, HORIZONTAL_SCHEMES, - _check_grid_discontiguities, _horizontal_grid_is_close, _rechunk, ) @@ -269,62 +267,6 @@ def test_regrid_is_skipped_if_grids_are_the_same(): assert expected_different_cube is not cube -def test_no_discontiguities_in_coords(): - """Test that no mask is used if there are no discontinuities in coords.""" - cube = _make_cube(lat=LAT_SPEC1, lon=LON_SPEC1) - scheme = {} - scheme = _check_grid_discontiguities(cube, scheme) - assert scheme == {} - - -def test_use_mask_if_discontiguities_in_coords(caplog): - """Test use_src_mask is added to the scheme.""" - lat_bounds = np.array( - [[[-43.48076211, -34.01923789, -22.00961894, -31.47114317], - [-34.01923789, -10.0, 2.00961894, -22.00961894], - [-10.0, -0.53847577, 11.47114317, 2.00961894]], - [[-31.47114317, -22.00961894, -10.0, -19.46152423], - [-22.00961894, 2.00961894, 14.01923789, -10.0], - [2.00961894, 11.47114317, 23.48076211, 14.01923789]]]) - lat_coord = iris.coords.AuxCoord( - [[-40.0, -20.0, 0.0], [-20.0, 0.0, 20.0]], - var_name='lat', - standard_name='latitude', - units='degrees_north', - bounds=lat_bounds, - ) - lon_bounds = np.array([[[140.625, 99.375, 99.375, 140.625], - [99.375, 140.625, 140.625, 99.375], - [140.625, 99.375, 99.375, 140.625]], - [[140., 99.375, 99.375, 140.], - [99.375, 140.625, 140.625, 99.375], - [140., 99.375, 99.375, 140.]]]) - lon_coord = iris.coords.AuxCoord( - [[100.0, 140.0, 180.0], [80.0, 100.0, 120.0]], - var_name='lon', - standard_name='longitude', - units='degrees_east', - bounds=lon_bounds, - ) - data = np.ma.array( - [[-40.0, -20.0, 0.0], [-20.0, 0.0, 20.0]], - mask=[[True, False, True], [False, True, False]], - ) - cube = iris.cube.Cube( - data, - aux_coords_and_dims=[(lat_coord, (0, 1)), (lon_coord, (0, 1))], - ) - - scheme = {} - with caplog.at_level(logging.DEBUG): - scheme = _check_grid_discontiguities(cube, scheme) - assert scheme == {'use_src_mask': True} - - msg = ('Grid discontinuities were found in the source grid. ' - 'Setting scheme argument `use_src_mask` to True.') - assert msg in caplog.text - - def make_test_cube(shape): data = da.empty(shape, dtype=np.float32) cube = iris.cube.Cube(data)