-
Notifications
You must be signed in to change notification settings - Fork 300
NEMO Ocean Data Gallery Example #3398
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5454ff9
Time series example added
jonseddon 264cf8d
Added a Whats New enrty
jonseddon 6536705
Corrected directory structure
jonseddon 19f09b2
stickler-ci formatting fixes
jonseddon 9df20bf
added test_load_nemo.py
bjlittle 0140c78
update imagerepo.json
bjlittle 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| """ | ||
| Load a time series of data from the NEMO model | ||
| ============================================== | ||
|
|
||
| This example demonstrates how to load multiple files containing data output by | ||
| the NEMO model and combine them into a time series in a single cube. The | ||
| different time dimensions in these files can prevent Iris from concatenating | ||
| them without the intervention shown here. | ||
| """ | ||
| from __future__ import unicode_literals | ||
|
|
||
| import iris | ||
| import iris.plot as iplt | ||
| import iris.quickplot as qplt | ||
| import matplotlib.pyplot as plt | ||
| from iris.util import promote_aux_coord_to_dim_coord | ||
|
|
||
|
|
||
| def main(): | ||
| # Load the three files of sample NEMO data. | ||
| fname = iris.sample_data_path('NEMO/nemo_1m_*.nc') | ||
| cubes = iris.load(fname) | ||
|
|
||
| # Some attributes are unique to each file and must be blanked | ||
| # to allow concatenation. | ||
| differing_attrs = ['file_name', 'name', 'timeStamp', 'TimeStamp'] | ||
| for cube in cubes: | ||
| for attribute in differing_attrs: | ||
| cube.attributes[attribute] = '' | ||
|
|
||
| # The cubes still cannot be concatenated because their time dimension is | ||
| # time_counter rather than time. time needs to be promoted to allow | ||
| # concatenation. | ||
| for cube in cubes: | ||
| promote_aux_coord_to_dim_coord(cube, 'time') | ||
|
|
||
| # The cubes can now be concatenated into a single time series. | ||
| cube = cubes.concatenate_cube() | ||
|
|
||
| # Generate a time series plot of a single point | ||
| plt.figure() | ||
| y_point_index = 100 | ||
| x_point_index = 100 | ||
| qplt.plot(cube[:, y_point_index, x_point_index], 'o-') | ||
|
|
||
| # Include the point's position in the plot's title | ||
| lat_point = cube.coord('latitude').points[y_point_index, x_point_index] | ||
| lat_string = '{:.3f}\u00B0 {}'.format(abs(lat_point), | ||
| 'N' if lat_point > 0. else 'S') | ||
| lon_point = cube.coord('longitude').points[y_point_index, x_point_index] | ||
| lon_string = '{:.3f}\u00B0 {}'.format(abs(lon_point), | ||
| 'E' if lon_point > 0. else 'W') | ||
| plt.title('{} at {} {}'.format(cube.long_name.capitalize(), | ||
| lat_string, lon_string)) | ||
| iplt.show() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
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,41 @@ | ||
| # (C) British Crown Copyright 2019, 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/>. | ||
|
|
||
| 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 | ||
|
|
||
| from .extest_util import (add_examples_to_path, | ||
| show_replaced_by_check_graphic, | ||
| fail_any_deprecation_warnings) | ||
|
|
||
|
|
||
| class TestLoadNemo(tests.GraphicsTest): | ||
| """Test the load_nemo example code.""" | ||
| def test_load_nemo(self): | ||
| with fail_any_deprecation_warnings(): | ||
| with add_examples_to_path(): | ||
| import load_nemo | ||
| with show_replaced_by_check_graphic(self): | ||
| load_nemo.main() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| tests.main() |
1 change: 1 addition & 0 deletions
1
docs/iris/src/whatsnew/contributions_2.3.0/docchange_2019-Sep-13_nemo_gallery_example.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 @@ | ||
| Added a gallery example showing how to concatenate NEMO ocean model data. |
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
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.
I003 isort expected 1 blank line in imports, found 0