-
Notifications
You must be signed in to change notification settings - Fork 44
Hybrid coords round trip #114
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
Changes from 2 commits
35a2763
eb6e221
55687a4
e38527f
1c9dcf8
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,21 @@ | ||
| # (C) British Crown Copyright 2018, Met Office | ||
| # | ||
| # This file is part of iris-grib. | ||
| # | ||
| # iris-grib 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-grib 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-grib. If not, see <http://www.gnu.org/licenses/>. | ||
| """Integration tests for the :mod:`iris_grib._load_convert` and | ||
| :mod:`iris_grib._save_rules` packages.""" | ||
|
|
||
| from __future__ import (absolute_import, division, print_function) | ||
| from six.moves import (filter, input, map, range, zip) # noqa |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # (C) British Crown Copyright 2018, Met Office | ||
| # | ||
| # This file is part of iris-grib. | ||
| # | ||
| # iris-grib 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-grib 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-grib. If not, see <http://www.gnu.org/licenses/>. | ||
| """ | ||
| Integration test for round-trip loading and saving of hybrid height and | ||
| hybrid pressure cubes. | ||
| """ | ||
|
|
||
| from __future__ import (absolute_import, division, print_function) | ||
| from six.moves import (filter, input, map, range, zip) # noqa | ||
|
|
||
| # import iris_grib.tests first so that some things can be initialised | ||
| # before importing anything else. | ||
| import iris_grib.tests as tests | ||
|
|
||
| from iris import load_cube, load_cubes, save | ||
| from iris.experimental.equalise_cubes import equalise_attributes | ||
|
|
||
|
|
||
| class TestHybridHeightRoundTrip(tests.IrisGribTest): | ||
| def setUp(self): | ||
| self.filepath = self.get_testdata_path( | ||
|
||
| 'faked_sample_hh_grib_data.grib2') | ||
| self.out_path = self.get_result_path( | ||
|
||
| '../results/integration/round_trips') | ||
| self.out_name = '/hybrid_height_cube.grib2' | ||
| self.outfile = self.out_path + self.out_name | ||
|
|
||
| def test_hybrid_height(self): | ||
| # Load air temperature cube. | ||
| cube, ref_cube = load_cubes(self.filepath, | ||
| ('air_temperature', 'surface_altitude')) | ||
| # Save cubes separately | ||
| save([cube, ref_cube], self.outfile) | ||
| saved_cube = load_cube(self.outfile, 'air_temperature') | ||
| self.assertTrue(saved_cube == cube) | ||
|
|
||
|
|
||
| class TestHybridPressureRoundTrip(tests.IrisGribTest): | ||
| def setUp(self): | ||
| self.filepath = self.get_testdata_path( | ||
| 'faked_sample_hp_grib_data.grib2') | ||
| self.out_path = self.get_result_path( | ||
| '../results/integration/round_trips') | ||
| self.out_name = '/hybrid_pressure_cube.grib2' | ||
| self.outfile = self.out_path + self.out_name | ||
|
|
||
| def test_hybrid_pressure(self): | ||
| # Load air temperature cube and surface air pressure reference cube | ||
| cube, ref_cube = load_cubes(self.filepath, | ||
| ('air_temperature', 'air_pressure')) | ||
| # Save cubes separately | ||
| save([cube, ref_cube], self.outfile) | ||
| saved_cube = load_cube(self.outfile, 'air_temperature') | ||
|
|
||
| # Currently all attributes are lost when saving to grib, so we must | ||
| # equalise them in order to successfully compare all other aspects. | ||
| equalise_attributes([saved_cube, cube]) | ||
|
|
||
| self.assertTrue(saved_cube == cube) | ||
|
|
||
|
|
||
|
|
||
|
|
||
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.
Whoops ?!?
Another reason to have more integration tests, if this could get missed.