From d2e29e140a15f4da22d8f4faf7890ee726a24e1d Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 27 Oct 2017 17:40:42 +0100 Subject: [PATCH 1/3] Add iris-grib as a testing dependency; Python 3 included. --- .travis.yml | 2 +- conda-requirements.txt | 3 +-- lib/iris/io/__init__.py | 2 +- .../format_interop/test_name_grib.py | 26 +++++++++---------- lib/iris/tests/integration/test_grib_load.py | 2 +- lib/iris/tests/test_grib_save.py | 15 ++++++----- lib/iris/tests/test_grib_save_rules.py | 2 +- 7 files changed, 25 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bcbf70e33..f61e086548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ install: conda install --quiet --file minimal-conda-requirements.txt; else if [[ "$TRAVIS_PYTHON_VERSION" == 3* ]]; then - sed -e '/ecmwf_grib/d' -e '/esmpy/d' -e 's/#.\+$//' conda-requirements.txt | xargs conda install --quiet; + sed -e '/esmpy/d' -e 's/#.\+$//' conda-requirements.txt | xargs conda install --quiet; else conda install --quiet --file conda-requirements.txt; fi diff --git a/conda-requirements.txt b/conda-requirements.txt index 0ba33e337b..061efbfc1d 100644 --- a/conda-requirements.txt +++ b/conda-requirements.txt @@ -25,7 +25,6 @@ imagehash requests # Optional iris dependencies -python-ecmwf_grib esmpy>=7.0 gdal libmo_unpack @@ -36,4 +35,4 @@ python-stratify pyugrid # Iris extensions (i.e. key tools that depend on Iris) -# iris_grib +iris_grib diff --git a/lib/iris/io/__init__.py b/lib/iris/io/__init__.py index 5f5ec0c3e8..a4e7a7d57e 100644 --- a/lib/iris/io/__init__.py +++ b/lib/iris/io/__init__.py @@ -330,7 +330,7 @@ def save(source, target, saver=None, **kwargs): * netCDF - the Unidata network Common Data Format: * see :func:`iris.fileformats.netcdf.save` * GRIB2 - the WMO GRIdded Binary data format: - * see :func:`iris.fileformats.grib.save_grib2`. + * see :func:`iris_grib.save_grib2`. * PP - the Met Office UM Post Processing Format: * see :func:`iris.fileformats.pp.save` diff --git a/lib/iris/tests/integration/format_interop/test_name_grib.py b/lib/iris/tests/integration/format_interop/test_name_grib.py index 192f0082b0..4bb567b2b4 100644 --- a/lib/iris/tests/integration/format_interop/test_name_grib.py +++ b/lib/iris/tests/integration/format_interop/test_name_grib.py @@ -72,21 +72,19 @@ def check_common(self, name_cube, grib_cube): def test_name2_field(self): filepath = tests.get_data_path(('NAME', 'NAMEII_field.txt')) name_cubes = iris.load(filepath) - # Check gribapi version, because we currently have a known load/save - # problem with gribapi 1v14 (at least). - gribapi_ver = gribapi.grib_get_api_version() - gribapi_fully_supported_version = \ - (StrictVersion(gribapi.grib_get_api_version()) < - StrictVersion('1.13')) + + # There is a known load/save problem with numerous + # gribapi/eccodes versions and + # zero only data, where min == max. + # This may be a problem with data scaling. for i, name_cube in enumerate(name_cubes): - if not gribapi_fully_supported_version: - data = name_cube.data - if np.min(data) == np.max(data): - msg = ('NAMEII cube #{}, "{}" has empty data : ' - 'SKIPPING test for this cube, as save/load will ' - 'not currently work with gribabi > 1v12.') - warnings.warn(msg.format(i, name_cube.name())) - continue + data = name_cube.data + if np.min(data) == np.max(data): + msg = ('NAMEII cube #{}, "{}" has empty data : ' + 'SKIPPING test for this cube, as save/load will ' + 'not currently work.') + warnings.warn(msg.format(i, name_cube.name())) + continue with self.temp_filename('.grib2') as temp_filename: iris.save(name_cube, temp_filename) diff --git a/lib/iris/tests/integration/test_grib_load.py b/lib/iris/tests/integration/test_grib_load.py index 64184a571c..2cf18154fc 100644 --- a/lib/iris/tests/integration/test_grib_load.py +++ b/lib/iris/tests/integration/test_grib_load.py @@ -22,7 +22,7 @@ The remainder of the old 'tests/test_grib_load.py' is now renamed as 'tests/test_grib_load_translations.py'. Those tests are implementation- -specific, and target the module 'iris.fileformats.grib'. +specific, and target the module 'iris_grib'. """ from __future__ import (absolute_import, division, print_function) diff --git a/lib/iris/tests/test_grib_save.py b/lib/iris/tests/test_grib_save.py index 53c14a169c..0befc8d56a 100644 --- a/lib/iris/tests/test_grib_save.py +++ b/lib/iris/tests/test_grib_save.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2016, Met Office +# (C) British Crown Copyright 2010 - 2017, Met Office # # This file is part of Iris. # @@ -34,6 +34,7 @@ if tests.GRIB_AVAILABLE: import gribapi + from iris_grib._load_convert import _MDI as MDI @tests.skip_data @@ -50,10 +51,10 @@ def test_latlon_forecast_plev(self): iris.save(cubes, temp_file_path) expect_diffs = {'totalLength': (4837, 4832), 'productionStatusOfProcessedData': (0, 255), - 'scaleFactorOfRadiusOfSphericalEarth': (4294967295, + 'scaleFactorOfRadiusOfSphericalEarth': (MDI, 0), 'shapeOfTheEarth': (0, 1), - 'scaledValueOfRadiusOfSphericalEarth': (4294967295, + 'scaledValueOfRadiusOfSphericalEarth': (MDI, 6367470), 'typeOfGeneratingProcess': (0, 255), 'generatingProcessIdentifier': (128, 255), @@ -70,10 +71,10 @@ def test_rotated_latlon(self): iris.save(cubes, temp_file_path) expect_diffs = {'totalLength': (648196, 648191), 'productionStatusOfProcessedData': (0, 255), - 'scaleFactorOfRadiusOfSphericalEarth': (4294967295, + 'scaleFactorOfRadiusOfSphericalEarth': (MDI, 0), 'shapeOfTheEarth': (0, 1), - 'scaledValueOfRadiusOfSphericalEarth': (4294967295, + 'scaledValueOfRadiusOfSphericalEarth': (MDI, 6367470), 'longitudeOfLastGridPoint': (392109982, 32106370), 'latitudeOfLastGridPoint': (19419996, 19419285), @@ -91,10 +92,10 @@ def test_time_mean(self): cubes = iris.load(source_grib) expect_diffs = {'totalLength': (21232, 21227), 'productionStatusOfProcessedData': (0, 255), - 'scaleFactorOfRadiusOfSphericalEarth': (4294967295, + 'scaleFactorOfRadiusOfSphericalEarth': (MDI, 0), 'shapeOfTheEarth': (0, 1), - 'scaledValueOfRadiusOfSphericalEarth': (4294967295, + 'scaledValueOfRadiusOfSphericalEarth': (MDI, 6367470), 'longitudeOfLastGridPoint': (356249908, 356249809), 'latitudeOfLastGridPoint': (-89999938, -89999944), diff --git a/lib/iris/tests/test_grib_save_rules.py b/lib/iris/tests/test_grib_save_rules.py index 3cae1e5e04..3f9a9eeded 100644 --- a/lib/iris/tests/test_grib_save_rules.py +++ b/lib/iris/tests/test_grib_save_rules.py @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU Lesser General Public License # along with Iris. If not, see . -"""Unit tests for :mod:`iris.fileformats.grib._save_rules`.""" +"""Integration tests for :mod:`iris_grib._save_rules`.""" from __future__ import (absolute_import, division, print_function) from six.moves import (filter, input, map, range, zip) # noqa From 56f1849d3a85d981b0d4b23fe481fea0cbc0a5c4 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Fri, 27 Oct 2017 19:26:53 +0100 Subject: [PATCH 2/3] Fix requirements for iris_grib>=0.12, assuming it will have eccodes + thus work with Python 3 --- .travis.yml | 6 ------ conda-requirements.txt | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f61e086548..4c6571a0d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,12 +65,6 @@ install: fi fi - # JUST FOR NOW : Install latest version of iris-grib. - # TODO : remove when this release is available on conda-forge. - - if [[ "$TEST_MINIMAL" != true ]]; then - pip install git+https://github.com/SciTools/iris-grib.git@v0.11.0 ; - fi - - PREFIX=$HOME/miniconda/envs/$ENV_NAME # Output debug info diff --git a/conda-requirements.txt b/conda-requirements.txt index 061efbfc1d..3792285fc0 100644 --- a/conda-requirements.txt +++ b/conda-requirements.txt @@ -35,4 +35,4 @@ python-stratify pyugrid # Iris extensions (i.e. key tools that depend on Iris) -iris_grib +iris_grib>=0.12 From 94ae63bd28950bf3b78c40146ee9c37a5625d578 Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Sat, 28 Oct 2017 05:56:59 +0100 Subject: [PATCH 3/3] Made the iris extensions not install by default. --- .travis.yml | 6 ++++++ conda-requirements.txt | 2 +- lib/iris/tests/integration/format_interop/test_name_grib.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c6571a0d2..f61e086548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,12 @@ install: fi fi + # JUST FOR NOW : Install latest version of iris-grib. + # TODO : remove when this release is available on conda-forge. + - if [[ "$TEST_MINIMAL" != true ]]; then + pip install git+https://github.com/SciTools/iris-grib.git@v0.11.0 ; + fi + - PREFIX=$HOME/miniconda/envs/$ENV_NAME # Output debug info diff --git a/conda-requirements.txt b/conda-requirements.txt index 3792285fc0..9ada018681 100644 --- a/conda-requirements.txt +++ b/conda-requirements.txt @@ -35,4 +35,4 @@ python-stratify pyugrid # Iris extensions (i.e. key tools that depend on Iris) -iris_grib>=0.12 +# iris_grib>=0.12 diff --git a/lib/iris/tests/integration/format_interop/test_name_grib.py b/lib/iris/tests/integration/format_interop/test_name_grib.py index 4bb567b2b4..6fd4ae4b41 100644 --- a/lib/iris/tests/integration/format_interop/test_name_grib.py +++ b/lib/iris/tests/integration/format_interop/test_name_grib.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2013 - 2016, Met Office +# (C) British Crown Copyright 2013 - 2017, Met Office # # This file is part of Iris. #