-
Notifications
You must be signed in to change notification settings - Fork 300
Moveplottests #2139
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
Moveplottests #2139
Changes from all commits
cc44b54
fc88776
5e543e7
eae2a17
b3b9b0a
2300ff7
3b658cf
c494b69
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # (C) British Crown Copyright 2013 - 2015, Met Office | ||
| # (C) British Crown Copyright 2013 - 2016, Met Office | ||
| # | ||
| # This file is part of Iris. | ||
| # | ||
|
|
@@ -32,20 +32,17 @@ | |
| from iris.cube import Cube | ||
| from iris.tests.stock import global_pp | ||
|
|
||
| # Run tests in no graphics mode if matplotlib is not available. | ||
| if tests.MPL_AVAILABLE: | ||
| import iris.quickplot as qplt | ||
|
|
||
|
|
||
| @tests.skip_data | ||
| @tests.skip_plot | ||
| class TestOSGBToLatLon(tests.GraphicsTest): | ||
| class TestOSGBToLatLon(tests.IrisTest): | ||
| def setUp(self): | ||
| path = tests.get_data_path( | ||
| ('NIMROD', 'uk2km', 'WO0000000003452', | ||
| '201007020900_u1096_ng_ey00_visibility0180_screen_2km')) | ||
| self.src = iris.load_cube(path)[0] | ||
| self.src.data = self.src.data.astype(np.float32) | ||
| # Cast up to float64, to work around numpy<=1.8 bug with means of | ||
| # arrays of 32bit floats. | ||
| self.src.data = self.src.data.astype(np.float64) | ||
| self.grid = Cube(np.empty((73, 96))) | ||
| cs = GeogCS(6370000) | ||
| lat = DimCoord(np.linspace(46, 65, 73), 'latitude', units='degrees', | ||
|
|
@@ -58,23 +55,25 @@ def setUp(self): | |
| def _regrid(self, method): | ||
| regridder = Regridder(self.src, self.grid, method, 'mask') | ||
| result = regridder(self.src) | ||
| qplt.pcolor(result, antialiased=False) | ||
| qplt.plt.gca().coastlines() | ||
| return result | ||
|
|
||
| def test_linear(self): | ||
| self._regrid('linear') | ||
| self.check_graphic() | ||
| res = self._regrid('linear') | ||
| self.assertArrayShapeStats(res, (73, 96), -16100.351951, 5603.850769) | ||
|
|
||
| def test_nearest(self): | ||
| self._regrid('nearest') | ||
| self.check_graphic() | ||
| res = self._regrid('nearest') | ||
| self.assertArrayShapeStats(res, (73, 96), -16095.965585, 5612.657155) | ||
|
|
||
|
|
||
| @tests.skip_data | ||
| @tests.skip_plot | ||
| class TestGlobalSubsample(tests.GraphicsTest): | ||
| class TestGlobalSubsample(tests.IrisTest): | ||
| def setUp(self): | ||
| self.src = global_pp() | ||
| _ = self.src.data | ||
|
Member
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.
Member
Author
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. it will, but it can make for messy output during debugging |
||
| # Cast up to float64, to work around numpy<=1.8 bug with means of | ||
| # arrays of 32bit floats. | ||
| self.src.data = self.src.data.astype(np.float64) | ||
| # Subsample and shift the target grid so that we can see a visual | ||
| # difference between regridding scheme methods. | ||
| grid = self.src[1::2, 1::3] | ||
|
|
@@ -85,16 +84,15 @@ def setUp(self): | |
| def _regrid(self, method): | ||
| regridder = Regridder(self.src, self.grid, method, 'mask') | ||
| result = regridder(self.src) | ||
| qplt.pcolormesh(result) | ||
| qplt.plt.gca().coastlines() | ||
| return result | ||
|
|
||
| def test_linear(self): | ||
| self._regrid('linear') | ||
| self.check_graphic() | ||
| res = self._regrid('linear') | ||
| self.assertArrayShapeStats(res, (36, 32), 280.35907, 15.997223) | ||
|
|
||
| def test_nearest(self): | ||
| self._regrid('nearest') | ||
| self.check_graphic() | ||
| res = self._regrid('nearest') | ||
| self.assertArrayShapeStats(res, (36, 32), 280.33726, 16.064001) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
@marqh Is this up-casting to avoid
numpy 1.8issues?If so, would you agree a comment might be handy? As for line +76 ...