Skip to content

Commit 5992a92

Browse files
sloosvelbouweandela
authored andcommitted
Remove coord discontinuity check in regrid (#2119)
1 parent a0dcfe8 commit 5992a92

File tree

3 files changed

+0
-88
lines changed

3 files changed

+0
-88
lines changed

doc/recipe/preprocessor.rst

-7
Original file line numberDiff line numberDiff line change
@@ -1015,13 +1015,6 @@ scheme available in :doc:`iris-esmf-regrid:index`:
10151015
reference: esmf_regrid.schemes:regrid_rectilinear_to_rectilinear
10161016
mdtol: 0.7
10171017
1018-
Since version 0.6 of :doc:`iris-esmf-regrid:index`, the regridder is able
1019-
to ignore discontinuities in the source grids if the data defined in the
1020-
discontiguous points is masked.
1021-
The :func:`~esmvalcore.preprocessor.regrid` preprocessor automatically detects
1022-
if discontinuities are present, and configures the regridding scheme in order to take
1023-
into account the mask of the source grid to ignore them.
1024-
10251018
.. _ensemble statistics:
10261019

10271020
Ensemble statistics

esmvalcore/preprocessor/_regrid.py

-23
Original file line numberDiff line numberDiff line change
@@ -384,21 +384,6 @@ def extract_location(cube, location, scheme):
384384
scheme)
385385

386386

387-
def _check_grid_discontiguities(cube, scheme):
388-
"""Check if there are grid discontiguities and set use_src_mask to True."""
389-
scheme = dict(scheme)
390-
try:
391-
discontiguities = iris.util.find_discontiguities(cube)
392-
except NotImplementedError:
393-
pass
394-
else:
395-
if discontiguities.any():
396-
scheme['use_src_mask'] = True
397-
logger.debug('Grid discontinuities were found in the source grid. '
398-
'Setting scheme argument `use_src_mask` to True.')
399-
return scheme
400-
401-
402387
def extract_point(cube, latitude, longitude, scheme):
403388
"""Extract a point, with interpolation.
404389
@@ -577,12 +562,6 @@ def regrid(cube, target_grid, scheme, lat_offset=True, lon_offset=True):
577562
scheme:
578563
reference: esmf_regrid.schemes:ESMFAreaWeighted
579564
580-
Since version 0.6 of :doc:`iris-esmf-regrid:index`, the regridder is able
581-
to ignore discontinuities in the source grids if the data defined in the
582-
discontiguous points is masked.
583-
The preprocessor automatically detects if discontinuities are present,
584-
and configures the regridding scheme in order to take into account
585-
the mask of the source grid to ignore them.
586565
"""
587566
if is_dataset(target_grid):
588567
target_grid = target_grid.copy()
@@ -637,8 +616,6 @@ def regrid(cube, target_grid, scheme, lat_offset=True, lon_offset=True):
637616
scheme['src_cube'] = cube
638617
if 'grid_cube' in scheme_args:
639618
scheme['grid_cube'] = target_grid
640-
if 'use_src_mask' in scheme_args:
641-
scheme = _check_grid_discontiguities(cube, scheme)
642619

643620
loaded_scheme = obj(**scheme)
644621
else:

tests/unit/preprocessor/_regrid/test_regrid.py

-58
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Unit tests for the :func:`esmvalcore.preprocessor.regrid.regrid`
22
function."""
33

4-
import logging
54
import unittest
65
from unittest import mock
76

@@ -16,7 +15,6 @@
1615
from esmvalcore.preprocessor._regrid import (
1716
_CACHE,
1817
HORIZONTAL_SCHEMES,
19-
_check_grid_discontiguities,
2018
_horizontal_grid_is_close,
2119
_rechunk,
2220
)
@@ -269,62 +267,6 @@ def test_regrid_is_skipped_if_grids_are_the_same():
269267
assert expected_different_cube is not cube
270268

271269

272-
def test_no_discontiguities_in_coords():
273-
"""Test that no mask is used if there are no discontinuities in coords."""
274-
cube = _make_cube(lat=LAT_SPEC1, lon=LON_SPEC1)
275-
scheme = {}
276-
scheme = _check_grid_discontiguities(cube, scheme)
277-
assert scheme == {}
278-
279-
280-
def test_use_mask_if_discontiguities_in_coords(caplog):
281-
"""Test use_src_mask is added to the scheme."""
282-
lat_bounds = np.array(
283-
[[[-43.48076211, -34.01923789, -22.00961894, -31.47114317],
284-
[-34.01923789, -10.0, 2.00961894, -22.00961894],
285-
[-10.0, -0.53847577, 11.47114317, 2.00961894]],
286-
[[-31.47114317, -22.00961894, -10.0, -19.46152423],
287-
[-22.00961894, 2.00961894, 14.01923789, -10.0],
288-
[2.00961894, 11.47114317, 23.48076211, 14.01923789]]])
289-
lat_coord = iris.coords.AuxCoord(
290-
[[-40.0, -20.0, 0.0], [-20.0, 0.0, 20.0]],
291-
var_name='lat',
292-
standard_name='latitude',
293-
units='degrees_north',
294-
bounds=lat_bounds,
295-
)
296-
lon_bounds = np.array([[[140.625, 99.375, 99.375, 140.625],
297-
[99.375, 140.625, 140.625, 99.375],
298-
[140.625, 99.375, 99.375, 140.625]],
299-
[[140., 99.375, 99.375, 140.],
300-
[99.375, 140.625, 140.625, 99.375],
301-
[140., 99.375, 99.375, 140.]]])
302-
lon_coord = iris.coords.AuxCoord(
303-
[[100.0, 140.0, 180.0], [80.0, 100.0, 120.0]],
304-
var_name='lon',
305-
standard_name='longitude',
306-
units='degrees_east',
307-
bounds=lon_bounds,
308-
)
309-
data = np.ma.array(
310-
[[-40.0, -20.0, 0.0], [-20.0, 0.0, 20.0]],
311-
mask=[[True, False, True], [False, True, False]],
312-
)
313-
cube = iris.cube.Cube(
314-
data,
315-
aux_coords_and_dims=[(lat_coord, (0, 1)), (lon_coord, (0, 1))],
316-
)
317-
318-
scheme = {}
319-
with caplog.at_level(logging.DEBUG):
320-
scheme = _check_grid_discontiguities(cube, scheme)
321-
assert scheme == {'use_src_mask': True}
322-
323-
msg = ('Grid discontinuities were found in the source grid. '
324-
'Setting scheme argument `use_src_mask` to True.')
325-
assert msg in caplog.text
326-
327-
328270
def make_test_cube(shape):
329271
data = da.empty(shape, dtype=np.float32)
330272
cube = iris.cube.Cube(data)

0 commit comments

Comments
 (0)