-
Notifications
You must be signed in to change notification settings - Fork 300
Provide info on pp-field indices in the file for structured um loads. #2977
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
DPeterK
merged 5 commits into
SciTools:master
from
pp-mo:structured_load_field_locations
Oct 8, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
8 changes: 8 additions & 0 deletions
8
docs/iris/src/whatsnew/contributions_2.1/newfeature_2018-Apr-12_fast_load_file_indices.txt
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,8 @@ | ||
| * The :class:`iris.fileformats.um.FieldCollation` objects, which are passed | ||
| into load callbacks when using | ||
| :func:`iris.fileformats.um.structured_um_loading`, now | ||
| have the additional properties : | ||
| :data:`iris.fileformats.um.FieldCollation.data_filepath` and | ||
| :data:`iris.fileformats.um.FieldCollation.data_field_indices`. | ||
| These provide the file locations of the original data fields, which are | ||
| otherwise lost in the structured loading process. |
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
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
82 changes: 82 additions & 0 deletions
82
lib/iris/tests/unit/fileformats/um/fast_load/test_FieldCollation.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,82 @@ | ||
| # (C) British Crown Copyright 2018, 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/>. | ||
| """ | ||
| Unit tests for the class | ||
| :class:`iris.fileformats.um._fast_load.FieldCollation`. | ||
| This only tests the additional functionality for recording file locations of | ||
| PPFields that make loaded cubes. | ||
| The original class is the baseclass of this, now renamed 'BasicFieldCollation'. | ||
| """ | ||
|
|
||
| from __future__ import (absolute_import, division, print_function) | ||
| from six.moves import (filter, input, map, range, zip) # noqa | ||
|
|
||
| # 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 | ||
|
|
||
| from iris.tests.integration.fast_load.test_fast_load import Mixin_FieldTest | ||
|
|
||
|
|
||
| class TestFastCallbackLocationInfo(Mixin_FieldTest, tests.IrisTest): | ||
| do_fast_loads = True | ||
|
|
||
| def setUp(self): | ||
| # Call parent setup. | ||
| super(TestFastCallbackLocationInfo, self).setUp() | ||
|
|
||
| # Create a basic load test case. | ||
| self.callback_collations = [] | ||
| self.callback_filepaths = [] | ||
|
|
||
| def fast_load_callback(cube, collation, filename): | ||
| self.callback_collations.append(collation) | ||
| self.callback_filepaths.append(filename) | ||
|
|
||
| flds = self.fields(c_t='11112222', c_h='11221122', phn='01010101') | ||
| self.test_filepath = self.save_fieldcubes(flds) | ||
| iris.load(self.test_filepath, callback=fast_load_callback) | ||
|
|
||
| def test_callback_collations_filepaths(self): | ||
| self.assertEqual(len(self.callback_collations), 2) | ||
| self.assertEqual(self.callback_collations[0].data_filepath, | ||
| self.test_filepath) | ||
| self.assertEqual(self.callback_collations[1].data_filepath, | ||
| self.test_filepath) | ||
|
|
||
| def test_callback_collations_field_indices(self): | ||
| self.assertEqual( | ||
| self.callback_collations[0].data_field_indices.dtype, np.int64) | ||
| self.assertArrayEqual( | ||
| self.callback_collations[0].data_field_indices, | ||
| [[1, 3], [5, 7]]) | ||
DPeterK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| self.assertEqual( | ||
| self.callback_collations[1].data_field_indices.dtype, np.int64) | ||
| self.assertArrayEqual( | ||
| self.callback_collations[1].data_field_indices, | ||
| [[0, 2], [4, 6]]) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| tests.main() | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.