diff --git a/lib/iris/fileformats/nimrod.py b/lib/iris/fileformats/nimrod.py index a24ef3c5c8..6fd53c3479 100644 --- a/lib/iris/fileformats/nimrod.py +++ b/lib/iris/fileformats/nimrod.py @@ -251,8 +251,8 @@ def to_cube(self): if self.tm_meridian_scaling != MISSING_INT: raise TranslationError("tm_meridian_scaling not yet handled") + # "NG" (British National Grid). if self.horizontal_grid_type == 0: - # "NG", means osgb grid. osgb_cs = iris.coord_systems.OSGB() cube.add_dim_coord( DimCoord(numpy.arange(self.num_cols) * self.column_step + self.x_origin, @@ -263,6 +263,21 @@ def to_cube(self): long_name="y", units="m", coord_system=osgb_cs), 0) else: raise TranslationError("Corner {0} not yet implemented".format(self.origin_corner)) + + # Latlon + elif self.horizontal_grid_type == 1: + # latlon + from iris.analysis.cartography import DEFAULT_SPHERICAL_EARTH_RADIUS + ll_cs = iris.coord_systems.GeogCS(DEFAULT_SPHERICAL_EARTH_RADIUS) + cube.add_dim_coord( + DimCoord(numpy.arange(self.num_cols) * self.column_step + self.x_origin, + standard_name="longitude", units="degrees", coord_system=ll_cs), 1) + if self.origin_corner == 0: # top left + cube.add_dim_coord( + DimCoord(numpy.arange(self.num_rows)[::-1] * -self.row_step + self.y_origin, + standard_name="latitude", units="degrees", coord_system=ll_cs), 0) + else: + raise TranslationError("Corner {0} not yet implemented".format(self.origin_corner)) else: raise TranslationError("Grid type %d not yet implemented" % self.horizontal_grid_type) @@ -276,6 +291,13 @@ def to_cube(self): standard_name="height", units="m")) else: raise TranslationError("Bounded vertical not yet implemented") + elif self.vertical_coord_type == 1: + if (self.reference_vertical_coord_type == MISSING_INT or + self.reference_vertical_coord == MISSING_FLOAT): + cube.add_aux_coord(DimCoord(self.vertical_coord, + standard_name="altitude", units="m")) + else: + raise TranslationError("Bounded vertical not yet implemented") else: raise TranslationError("Vertical coord type %d currently unhanded" % self.vertical_coord_type) diff --git a/lib/iris/tests/results/nimrod/korean.cml b/lib/iris/tests/results/nimrod/korean.cml new file mode 100644 index 0000000000..a60314b973 --- /dev/null +++ b/lib/iris/tests/results/nimrod/korean.cml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/iris/tests/test_nimrod.py b/lib/iris/tests/test_nimrod.py index 6b12059270..c82d1fece5 100644 --- a/lib/iris/tests/test_nimrod.py +++ b/lib/iris/tests/test_nimrod.py @@ -21,22 +21,32 @@ import matplotlib.pyplot as plt import numpy as np +import cartopy.crs as ccrs import iris import iris.plot as iplt +import iris.quickplot as qplt @iris.tests.skip_data -class TestGribLoad(tests.GraphicsTest): +class TestLoad(tests.GraphicsTest): - def test_load(self): - cube = iris.load(tests.get_data_path(('NIMROD', 'uk2km', 'WO0000000003452', - '201007020900_u1096_ng_ey00_visibility0180_screen_2km')))[0] - self.assertCML(cube, ("nimrod", "load.cml")) +# def test_load(self): +# cube = iris.load(tests.get_data_path(('NIMROD', 'uk2km', 'WO0000000003452', +# '201007020900_u1096_ng_ey00_visibility0180_screen_2km')))[0] +# self.assertCML(cube, ("nimrod", "load.cml")) +# +# c = plt.contourf(cube.data, levels=np.linspace(-25000, 6000, 10)) +# self.check_graphic() - c = plt.contourf(cube.data, levels=np.linspace(-25000, 6000, 10)) - self.check_graphic() + def test_korean(self): +# cubes = iris.load(tests.get_data_path(('NIMROD', 'Korea', '201210240000_k0880_ll_umqg_height0000_orography_2km'))) + cube = iris.load_cube('/data/local/dataZoo/NIMROD/Korea/201210240000_k0880_ll_umqg_height0000_orography_2km') + self.assertCML(cube, ("nimrod", "korean.cml")) + qplt.contourf(cube) + plt.gcs().coastlines() + self.check_graphic() if __name__ == "__main__": tests.main()