Skip to content

Commit ab205df

Browse files
Tweak extract_point preprocessor: explain what it returns if one point coord outside cube and add explicit test (#1584)
* explicit test for full masked data * explicitly say cube fully masked data * fix docs * fix docstring
1 parent 9c5681f commit ab205df

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

doc/recipe/preprocessor.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,11 @@ match the respective latitude and longitude coordinate to those of the
16541654
input coordinates. If the input coordinate is a scalar, the dimension
16551655
will be missing in the output cube (that is, it will be a scalar).
16561656

1657+
If the point to be extracted has at least one of the coordinate point
1658+
values outside the interval of the cube's same coordinate values, then
1659+
no extrapolation will be performed, and the resulting extracted cube
1660+
will have fully masked data.
1661+
16571662
Parameters:
16581663
* ``cube``: the input dataset cube.
16591664
* ``latitude``, ``longitude``: coordinates (as floating point

esmvalcore/preprocessor/_regrid.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ def extract_point(cube, latitude, longitude, scheme):
387387
scalar, the dimension will be missing in the output cube (that is,
388388
it will be a scalar).
389389
390+
If the point to be extracted has at least one of the coordinate point
391+
values outside the interval of the cube's same coordinate values, then
392+
no extrapolation will be performed, and the resulting extracted cube
393+
will have fully masked data.
394+
390395
Parameters
391396
----------
392397
cube : cube
@@ -400,8 +405,11 @@ def extract_point(cube, latitude, longitude, scheme):
400405
401406
Returns
402407
-------
403-
Returns a cube with the extracted point(s), and with adjusted
404-
latitude and longitude coordinates (see above).
408+
:py:class:`~iris.cube.Cube`
409+
Returns a cube with the extracted point(s), and with adjusted
410+
latitude and longitude coordinates (see above). If desired point
411+
outside values for at least one coordinate, this cube will have fully
412+
masked data.
405413
406414
Raises
407415
------

tests/integration/preprocessor/_regrid/test_extract_point.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def test_extract_point__single_linear(self):
5151
self.assertEqual(point.shape, (3,))
5252
self.assert_array_equal(point.data, masked)
5353

54+
point = extract_point(self.cube, 30, 30, scheme='nearest')
55+
self.assertEqual(point.shape, (3,))
56+
# do it the proletarian way, back to basics is good sometimes
57+
assert np.ma.is_masked(point.data)
58+
assert point.data.mask.all()
59+
5460
def test_extract_point__single_nearest(self):
5561
"""Test nearest match when extracting a single point"""
5662

0 commit comments

Comments
 (0)