-
Notifications
You must be signed in to change notification settings - Fork 283
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
Basic support for varying longitude ranges. #350
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# (C) British Crown Copyright 2013, Met Office | ||
# | ||
# This file is part of Iris. | ||
# | ||
# Iris is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by the | ||
# Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Iris is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with Iris. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
Package for testing the iris.analysis package. | ||
|
||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# (C) British Crown Copyright 2013, Met Office | ||
# | ||
# This file is part of Iris. | ||
# | ||
# Iris is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by the | ||
# Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Iris is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with Iris. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
Test the iris.analysis.interpolate module. | ||
|
||
""" | ||
# Import iris tests first so that some things can be initialised before | ||
# importing anything else. | ||
import iris.tests as tests | ||
|
||
import numpy as np | ||
|
||
import iris.analysis.interpolate as interpolate | ||
from iris.coords import DimCoord | ||
from iris.cube import Cube | ||
|
||
|
||
class Test_linear__circular_wrapping(tests.IrisTest): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There must be other interpolation tests somewhere? Is it worth putting this with those? Or moving those to here (in a separate PR?). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Indeed there are. And yes, it would be good to move them here in a separate PR (I've deliberately not done that in this PR to keep it obvious what is going on). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a follow-on issue to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is now ... #353 😉 |
||
def _create_cube(self, longitudes): | ||
# Return a Cube with circular longitude with the given values. | ||
data = np.arange(12).reshape((3, 4)) * 0.1 | ||
cube = Cube(data) | ||
lon = DimCoord(longitudes, standard_name='longitude', | ||
units='degrees', circular=True) | ||
cube.add_dim_coord(lon, 1) | ||
return cube | ||
|
||
def test_symmetric(self): | ||
# Check we can interpolate from a Cube defined over [-180, 180). | ||
cube = self._create_cube([-180, -90, 0, 90]) | ||
samples = [('longitude', range(-360, 720, 45))] | ||
result = interpolate.linear(cube, samples) | ||
self.assertCMLApproxData(result, ('analysis', 'interpolation', | ||
'linear', 'circular_wrapping', | ||
'symmetric')) | ||
|
||
def test_positive(self): | ||
# Check we can interpolate from a Cube defined over [0, 360). | ||
cube = self._create_cube([0, 90, 180, 270]) | ||
samples = [('longitude', range(-360, 720, 45))] | ||
result = interpolate.linear(cube, samples) | ||
self.assertCMLApproxData(result, ('analysis', 'interpolation', | ||
'linear', 'circular_wrapping', | ||
'positive')) | ||
|
||
|
||
if __name__ == "__main__": | ||
tests.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" ?> | ||
<cubes xmlns="urn:x-iris:cubeml-0.2"> | ||
<cube units="unknown"> | ||
<coords> | ||
<coord datadims="[1]"> | ||
<dimCoord id="a523d045" points="[-360.0, -315.0, -270.0, -225.0, -180.0, -135.0, | ||
-90.0, -45.0, 0.0, 45.0, 90.0, 135.0, 180.0, | ||
225.0, 270.0, 315.0, 360.0, 405.0, 450.0, 495.0, | ||
540.0, 585.0, 630.0, 675.0]" shape="(24,)" standard_name="longitude" units="Unit('degrees')" value_type="float64"/> | ||
</coord> | ||
</coords> | ||
<cellMethods/> | ||
<data dtype="float64" shape="(3, 24)" state="loaded"/> | ||
</cube> | ||
</cubes> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" ?> | ||
<cubes xmlns="urn:x-iris:cubeml-0.2"> | ||
<cube units="unknown"> | ||
<coords> | ||
<coord datadims="[1]"> | ||
<dimCoord id="a523d045" points="[-360.0, -315.0, -270.0, -225.0, -180.0, -135.0, | ||
-90.0, -45.0, 0.0, 45.0, 90.0, 135.0, 180.0, | ||
225.0, 270.0, 315.0, 360.0, 405.0, 450.0, 495.0, | ||
540.0, 585.0, 630.0, 675.0]" shape="(24,)" standard_name="longitude" units="Unit('degrees')" value_type="float64"/> | ||
</coord> | ||
</coords> | ||
<cellMethods/> | ||
<data dtype="float64" shape="(3, 24)" state="loaded"/> | ||
</cube> | ||
</cubes> |
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'm not sure what impact having a sub-folder will have our visual testing. I know cartopy can handle it, but not 100% that the standard mpl image testing functionality can. We can cross that bridge when we get to it though.