From 5bbe26eb5b763013c41f53ad9b96edf2970241ee Mon Sep 17 00:00:00 2001 From: lbdreyer Date: Mon, 10 Oct 2016 15:27:12 +0100 Subject: [PATCH] Update laea test; remove rotated cs changes --- lib/iris/fileformats/netcdf.py | 3 -- .../test_LambertAzimuthalEqualArea.py | 6 +++ .../unit/fileformats/netcdf/test_Saver.py | 38 +++++++++++-------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/lib/iris/fileformats/netcdf.py b/lib/iris/fileformats/netcdf.py index 9a12be506b9..65af4eea85d 100644 --- a/lib/iris/fileformats/netcdf.py +++ b/lib/iris/fileformats/netcdf.py @@ -1328,9 +1328,6 @@ def _cf_coord_identity(coord): elif coord.standard_name == "longitude": units = 'degrees_east' - elif isinstance(coord.coord_system, iris.coord_systems.RotatedGeogCS): - units = 'degrees' - return coord.standard_name, coord.long_name, units def _ensure_valid_dtype(self, values, src_name, src_object): diff --git a/lib/iris/tests/unit/coord_systems/test_LambertAzimuthalEqualArea.py b/lib/iris/tests/unit/coord_systems/test_LambertAzimuthalEqualArea.py index ee44e491d5f..4629a40c4ac 100644 --- a/lib/iris/tests/unit/coord_systems/test_LambertAzimuthalEqualArea.py +++ b/lib/iris/tests/unit/coord_systems/test_LambertAzimuthalEqualArea.py @@ -36,10 +36,14 @@ def setUp(self): self.longitude_of_projection_origin = 0.0 self.semi_major_axis = 6377563.396 self.semi_minor_axis = 6356256.909 + self.false_easting = 0.0 + self.false_northing = 0.0 self.ellipsoid = GeogCS(self.semi_major_axis, self.semi_minor_axis) self.laea_cs = LambertAzimuthalEqualArea( self.latitude_of_projection_origin, self.longitude_of_projection_origin, + self.false_easting, + self.false_northing, ellipsoid=self.ellipsoid) def test_crs_creation(self): @@ -50,6 +54,8 @@ def test_crs_creation(self): expected = ccrs.LambertAzimuthalEqualArea( self.longitude_of_projection_origin, self.latitude_of_projection_origin, + self.false_easting, + self.false_northing, globe=globe) self.assertEqual(res, expected) diff --git a/lib/iris/tests/unit/fileformats/netcdf/test_Saver.py b/lib/iris/tests/unit/fileformats/netcdf/test_Saver.py index b2d1a52c4ff..00d535638aa 100644 --- a/lib/iris/tests/unit/fileformats/netcdf/test_Saver.py +++ b/lib/iris/tests/unit/fileformats/netcdf/test_Saver.py @@ -459,31 +459,35 @@ def test_valid_range_and_valid_min_valid_max_provided(self): class Test__cf_coord_identity(tests.IrisTest): - def check_call(self, coord_system, units, expected_units): - coord = iris.coords.DimCoord([30, 45], 'latitude', units=units, + def check_call(self, coord_name, coord_system, units, expected_units): + coord = iris.coords.DimCoord([30, 45], coord_name, units=units, coord_system=coord_system) result = Saver._cf_coord_identity(coord) self.assertEqual(result, (coord.standard_name, coord.long_name, expected_units)) - def test_geogcs(self): + def test_geogcs_latitude(self): crs = iris.coord_systems.GeogCS(60, 0) - self.check_call(coord_system=crs, units='degrees', + self.check_call('latitude', coord_system=crs, units='degrees', expected_units='degrees_north') - def test_no_coord_system(self): - self.check_call(coord_system=None, units='degrees', + def test_geogcs_longitude(self): + crs = iris.coord_systems.GeogCS(60, 0) + self.check_call('longitude', coord_system=crs, units='degrees', + expected_units='degrees_east') + + def test_no_coord_system_latitude(self): + self.check_call('latitude', coord_system=None, units='degrees', expected_units='degrees_north') - def test_rotatedgeogcs(self): - crs = iris.coord_systems.RotatedGeogCS(30, 175) - self.check_call(coord_system=crs, units='degrees', - expected_units='degrees') + def test_no_coord_system_longitude(self): + self.check_call('longitude', coord_system=None, units='degrees', + expected_units='degrees_east') - def test_crs_with_no_default_units(self): + def test_passthrough_units(self): crs = iris.coord_systems.LambertConformal(0, 20) - self.check_call(coord_system=crs, units='km', - expected_units='km') + self.check_call('projection_x_coordinate', coord_system=crs, + units='km', expected_units='km') class Test__create_cf_grid_mapping(tests.IrisTest): @@ -535,7 +539,7 @@ def _variable_attributes(self, coord_system): def _test(self, coord_system, expected): actual = self._variable_attributes(coord_system) - + print('actual', actual) # To see obvious differences, check that they keys are the same. self.assertEqual(sorted(actual.keys()), sorted(expected.keys())) # Now check that the values are equivalent. @@ -589,12 +593,16 @@ def test_laea_cs(self): latitude_of_projection_origin=52, longitude_of_projection_origin=10, false_easting=100, - false_northing=200) + false_northing=200, + ellipsoid=GeogCS(6377563.396, 6356256.909)) expected = {'grid_mapping_name': 'lambert_azimuthal_equal_area', 'latitude_of_projection_origin': 52, 'longitude_of_projection_origin': 10, 'false_easting': 100, 'false_northing': 200, + 'semi_major_axis': 6377563.396, + 'semi_minor_axis': 6356256.909, + 'longitude_of_prime_meridian': 0, } self._test(coord_system, expected)