diff --git a/.travis.yml b/.travis.yml index b6bb7b0c42..f7f24f2bc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ install: - export IRIS_TEST_DATA_REF="3378fe68c00ca7f31895ab6630a59a39ccef94e3" - export IRIS_TEST_DATA_SUFFIX=$(echo "${IRIS_TEST_DATA_REF}" | sed "s/^v//") - - export IRIS_SAMPLE_DATA_REF="2e7c73504e3d675d97dc8a2c2939f9fd2cfe51f1" + - export IRIS_SAMPLE_DATA_REF="1ed3e26606366717e2053bacc12bf5e8d8fa2704" - export IRIS_SAMPLE_DATA_SUFFIX=$(echo "${IRIS_SAMPLE_DATA_REF}" | sed "s/^v//") # Switch off virtualenv so we can use apt-get for Python packages. diff --git a/docs/iris/example_code/graphics/orca_projection.py b/docs/iris/example_code/graphics/orca_projection.py new file mode 100644 index 0000000000..bf231bedb5 --- /dev/null +++ b/docs/iris/example_code/graphics/orca_projection.py @@ -0,0 +1,58 @@ +""" +Tru-Polar Grid Projected Ploting +================================ + +This example demonstrates cell plots of data on the semi-structured ORCA2 model +grid. + +First, the data is projected into the PlateCarree coordinate reference system. + +Second four pcolormesh plots are created from this projected dataset, +using different projections for the output image. + +""" + +import matplotlib +import matplotlib.pyplot as plt + +import cartopy.crs as ccrs +import iris +import iris.analysis.cartography +import iris.quickplot as qplt + + +def main(): + # Load data + filepath = iris.sample_data_path('orca2_votemper.nc') + cube = iris.load_cube(filepath) + + # Choose plot projections + projections = {} + projections['Mollweide'] = ccrs.Mollweide() + projections['PlateCarree'] = ccrs.PlateCarree() + projections['NorthPolarStereo'] = ccrs.NorthPolarStereo() + projections['Orthographic'] = ccrs.Orthographic(central_longitude=-90, + central_latitude=45) + + pcarree = projections['PlateCarree'] + # Transform cube to target projection + new_cube, extent = iris.analysis.cartography.project(cube, pcarree, + nx=400, ny=200) + + # Plot data in each projection + for name in sorted(projections): + fig = plt.figure() + fig.suptitle('ORCA2 Data Projected to {}'.format(name)) + # Set up axes and title + ax = plt.subplot(projection=projections[name]) + # Set limits + ax.set_global() + # plot with Iris quickplot pcolormesh + qplt.pcolormesh(new_cube) + # Draw coastlines + ax.coastlines() + + plt.show() + +if __name__ == '__main__': + main() diff --git a/docs/iris/example_tests/test_orca_projection.py b/docs/iris/example_tests/test_orca_projection.py new file mode 100644 index 0000000000..b841975aff --- /dev/null +++ b/docs/iris/example_tests/test_orca_projection.py @@ -0,0 +1,37 @@ +# (C) British Crown Copyright 2014, 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 . + + +# Import Iris tests first so that some things can be initialised before +# importing anything else. +import iris.tests as tests + +import extest_util + +with extest_util.add_examples_to_path(): + import orca_projection + + +class TestOrcaProjection(tests.GraphicsTest): + """Test the orca projection example code.""" + def test_orca_projection(self): + with extest_util.show_replaced_by_check_graphic(self): + orca_projection.main() + + +if __name__ == '__main__': + tests.main() diff --git a/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.0.png b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.0.png new file mode 100644 index 0000000000..a0b4d907e5 Binary files /dev/null and b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.0.png differ diff --git a/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.1.png b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.1.png new file mode 100644 index 0000000000..b1acdd24d7 Binary files /dev/null and b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.1.png differ diff --git a/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.2.png b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.2.png new file mode 100644 index 0000000000..ee8ccf40a4 Binary files /dev/null and b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.2.png differ diff --git a/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.3.png b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.3.png new file mode 100644 index 0000000000..73c20a77f1 Binary files /dev/null and b/lib/iris/tests/results/visual_tests/test_orca_projection.TestOrcaProjection.test_orca_projection.3.png differ