Skip to content

Commit

Permalink
Update laea test; remove rotated cs changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lbdreyer committed Oct 10, 2016
1 parent cde0ac4 commit 5bbe26e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
3 changes: 0 additions & 3 deletions lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down
38 changes: 23 additions & 15 deletions lib/iris/tests/unit/fileformats/netcdf/test_Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 5bbe26e

Please sign in to comment.