-
Notifications
You must be signed in to change notification settings - Fork 38
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
regridding regular grids with similar coordinates #1567
Conversation
…oints are close enough
Codecov Report
@@ Coverage Diff @@
## main #1567 +/- ##
=======================================
Coverage 90.99% 91.00%
=======================================
Files 201 201
Lines 10676 10679 +3
=======================================
+ Hits 9715 9718 +3
Misses 961 961
Continue to review full report at Codecov.
|
Thanks, @tomaslovato. Perhaps we should add a test for this functionality? |
@zklaus maybe something like this could do the job ... diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py
index 7a6b87e1a..a156bfb6f 100644
--- a/tests/integration/preprocessor/_regrid/test_regrid.py
+++ b/tests/integration/preprocessor/_regrid/test_regrid.py
@@ -92,6 +92,24 @@ class Test(tests.Test):
expected = np.array([[[1.5]], [[5.5]], [[9.5]]])
self.assert_array_equal(result.data, expected)
+ def test_regrid__regular_coordinates(self):
+ data = np.ones((1, 1))
+ lons = iris.coords.DimCoord([1.50000000000001],
+ standard_name='longitude',
+ bounds=[[1, 2]],
+ units='degrees_east',
+ coord_system=self.cs)
+ lats = iris.coords.DimCoord([1.50000000000001],
+ standard_name='latitude',
+ bounds=[[1, 2]],
+ units='degrees_north',
+ coord_system=self.cs)
+ coords_spec = [(lats, 0), (lons, 1)]
+ regular_grid = iris.cube.Cube(data, dim_coords_and_dims=coords_spec)
+ result = regrid(regular_grid, self.grid_for_linear, 'linear')
+ expected = np.array([[[1.5]], [[1.5]], [[1.]]])
+ self.assert_array_equal(result.data, expected)
+
def test_regrid__linear_do_not_preserve_dtype(self):
self.cube.data = self.cube.data.astype(int)
result = regrid(self.cube, self.grid_for_linear, 'linear') |
@zklaus I added the test for the regular grid coordinate ... let me know if it works for you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say the changes are fine, but it would be good people from @ESMValGroup/esmvaltool-coreteam who have followed the issue closer double checked.
Description
Regridding regular grid needs to produce an exact matching of the source lat/lon coordinates with those of the target cube.
Closes #1551
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.