def test__fail_unsupported_coord_system(self): cs = LambertConformal() test_cube = self._make_test_cube(cs=cs) with self.assertRaisesRegexp( ValueError, 'Grib saving is not supported for coordinate system:'): grid_definition_section(test_cube, self.mock_grib)
def test__fail_irregular_latlon(self): test_cube = self._make_test_cube(x_points=(1, 2, 11, 12), y_points=(4, 5, 6)) with self.assertRaisesRegexp( TranslationError, 'irregular latlon grid .* not yet supported'): grid_definition_section(test_cube, self.mock_grib)
def test_grid_definition_template_12(self): # Transverse Mercator grid. x_points = np.arange(3) y_points = np.arange(3) coord_units = 'm' cs = TransverseMercator(0, 0, 0, 0, 1, ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 12)
def test_grid_definition_template_5(self): # Irregular (variable resolution) rotated lat/lon grid. x_points = np.array([0, 2, 7]) y_points = np.array([1, 3, 6]) coord_units = '1' cs = RotatedGeogCS(34.0, 117.0, ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 5)
def test_grid_definition_template_1(self): # Rotated lat/lon (Plate Carree). x_points = np.arange(3) y_points = np.arange(3) coord_units = 'degrees' cs = RotatedGeogCS(34.0, 117.0, ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 1)
def test_grid_definition_template_0(self): # Regular lat/lon (Plate Carree). x_points = np.arange(3) y_points = np.arange(3) coord_units = 'degrees' cs = self.ellipsoid test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 0)
def test_grid_definition_template_30(self): # Lambert Conformal grid. x_points = np.arange(3) y_points = np.arange(3) coord_units = 'm' cs = LambertConformal(ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 30)
def test_grid_definition_template_12(self): # Transverse Mercator grid. x_points = np.arange(3) y_points = np.arange(3) coord_units = 'm' cs = TransverseMercator(0, 0, 0, 0, 1, ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 12)
def test_grid_definition_template_5(self): # Irregular (variable resolution) rotated lat/lon grid. x_points = np.array([0, 2, 7]) y_points = np.array([1, 3, 6]) coord_units = '1' cs = RotatedGeogCS(34.0, 117.0, ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 5)
def test_grid_definition_template_1(self): # Rotated lat/lon (Plate Carree). x_points = np.arange(3) y_points = np.arange(3) coord_units = 'degrees' cs = RotatedGeogCS(34.0, 117.0, ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 1)
def test_grid_definition_template_0(self): # Regular lat/lon (Plate Carree). x_points = np.arange(3) y_points = np.arange(3) coord_units = 'degrees' cs = self.ellipsoid test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 0)
def test_grid_definition_template_30(self): # Lambert Conformal grid. x_points = np.arange(3) y_points = np.arange(3) coord_units = 'm' cs = LambertConformal(ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) grid_definition_section(test_cube, self.mock_grib) self._check_key('gridDefinitionTemplateNumber', 30)
def test_coord_system_not_supported(self): # Test an unsupported grid - let's choose Albers Equal Area. x_points = np.arange(3) y_points = np.arange(3) coord_units = '1' cs = AlbersEqualArea(ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) exp_name = cs.grid_mapping_name.replace('_', ' ').title() exp_emsg = 'not supported for coordinate system {!r}'.format(exp_name) with self.assertRaisesRegexp(ValueError, exp_emsg): grid_definition_section(test_cube, self.mock_grib)
def test_coord_system_not_supported(self): # Test an unsupported grid - let's choose Albers Equal Area. x_points = np.arange(3) y_points = np.arange(3) coord_units = '1' cs = AlbersEqualArea(ellipsoid=self.ellipsoid) test_cube = self._make_test_cube(cs, x_points, y_points, coord_units) exp_name = cs.grid_mapping_name.replace('_', ' ').title() exp_emsg = 'not supported for coordinate system {!r}'.format(exp_name) with self.assertRaisesRegexp(ValueError, exp_emsg): grid_definition_section(test_cube, self.mock_grib)