-
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
Merged
pp-mo
merged 5 commits into
SciTools:master
from
corinnebosley:hybrid_coords_round_trip
Jun 12, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
35a2763
first draft of tests, not currently passing
corinnebosley eb6e221
very much revised second draft of round trip testing
corinnebosley 55687a4
pep8 corrections and review suggestions implemented
corinnebosley e38527f
removed saved grib files
corinnebosley 1c9dcf8
added a few comments for explanation
corinnebosley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
74 changes: 74 additions & 0 deletions
74
iris_grib/tests/integration/round_trip/test_hybrid_coords_round_trip.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # (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 | ||
|
|
||
| import os | ||
|
|
||
| from iris import load_cube, load_cubes, save | ||
| from iris.experimental.equalise_cubes import equalise_attributes | ||
|
|
||
|
|
||
| class TestHybridHeightRoundTrip(tests.IrisGribTest): | ||
| def test_hh_round_trip(self): | ||
| filepath = self.get_testdata_path( | ||
| 'faked_sample_hh_grib_data.grib2') | ||
| # Load and save temperature cube and reference (orography) cube | ||
| # separately because this is the only way to save the hybrid height | ||
| # coordinate. | ||
| cube, ref_cube = load_cubes(filepath, | ||
| ('air_temperature', 'surface_altitude')) | ||
|
|
||
| with self.temp_filename() as tmp_save_path: | ||
| save([cube, ref_cube], tmp_save_path, saver='grib2') | ||
| # Only need to reload temperature cube to compare with unsaved | ||
| # temperature cube. | ||
| saved_cube = load_cube(tmp_save_path, 'air_temperature') | ||
| self.assertTrue(saved_cube == cube) | ||
|
|
||
|
|
||
| class TestHybridPressureRoundTrip(tests.IrisGribTest): | ||
| def test_hybrid_pressure(self): | ||
| filepath = self.get_testdata_path( | ||
| 'faked_sample_hp_grib_data.grib2') | ||
| # Load and save temperature cube and reference (air_pressure at | ||
| # surface) cube separately because this is the only way to save the | ||
| # hybrid pressure coordinate. | ||
| cube, ref_cube = load_cubes(filepath, | ||
| ('air_temperature', 'air_pressure')) | ||
|
|
||
| with self.temp_filename() as tmp_save_path: | ||
| save([cube, ref_cube], tmp_save_path, saver='grib2') | ||
| # Only need to reload temperature cube to compare with unsaved | ||
| # temperature cube. | ||
| saved_cube = load_cube(tmp_save_path, '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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.