def test_cube__simple_3d(self): # Test that an 'index' coord is added to the resultant cube. cube = simple_3d() waypoints = [ { "latitude": 40, "longitude": 40 }, { "latitude": 0, "longitude": 0 }, ] sample_count = 3 new_coord_name = "index" trajectory = Trajectory(waypoints, sample_count=sample_count) result = trajectory.interpolate(cube) dim_names, named_dims, anon_dims = self._result_cube_metadata(result) new_coord = result.coord(new_coord_name) exp_named_dims = [0, 1] self.assertEqual(result.ndim, cube.ndim - 1) self.assertIn(new_coord_name, dim_names) self.assertEqual(named_dims, exp_named_dims) self.assertIsNone(anon_dims) self.assertEqual(len(new_coord.points), sample_count)
def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) col_span = self.representer.ndims self.row = self.representer._make_row('title', body='first', col_span=col_span)
def test_argument_is_basestring(self): cube_a = stock.simple_3d() cube_b = cube_a.copy() demote_dim_coord_to_aux_coord(cube_b, cube_b.coord("wibble")) self.assertEqual( cube_b.dim_coords, (cube_a.coord("latitude"), cube_a.coord("longitude")), )
def setUp(self): cube = stock.simple_3d()[:, :1, :1] #: The data from which to get the levels. self.src_levels = cube.copy() #: The data to interpolate. self.cube = cube.copy() self.cube.rename('foobar') self.cube *= 10 self.coord = self.src_levels.coord('wibble') self.axes = (self.coord, self.coord.name(), None, 0)
def setUp(self): cube = stock.simple_3d()[:, :1, :1] #: The data from which to get the levels. self.src_levels = cube.copy() #: The data to interpolate. self.cube = cube.copy() self.cube.rename("foobar") self.cube *= 10 self.coord = self.src_levels.coord("wibble") self.axes = (self.coord, self.coord.name(), None, 0)
def test_call(self): # Test that :func:`iris.analysis.trajectory.interpolate` is called by # `Trajectory.interpolate`. cube = simple_3d() to_patch = 'iris.analysis.trajectory.interpolate' waypoints = [{'latitude': 40, 'longitude': 40}, {'latitude': 0, 'longitude': 0}] sample_count = 3 trajectory = Trajectory(waypoints, sample_count=sample_count) with mock.patch(to_patch, return_value=cube) as mock_interpolate: trajectory.interpolate(cube) mock_interpolate.assert_called_once()
def test_cube__simple_3d(self): # Test that an 'index' coord is added to the resultant cube. cube = simple_3d() waypoints = [{'latitude': 40, 'longitude': 40}, {'latitude': 0, 'longitude': 0}] sample_count = 3 new_coord_name = 'index' trajectory = Trajectory(waypoints, sample_count=sample_count) result = trajectory.interpolate(cube) dim_names, named_dims, anon_dims = self._result_cube_metadata(result) new_coord = result.coord(new_coord_name) exp_named_dims = [0, 1] self.assertEqual(result.ndim, cube.ndim - 1) self.assertIn(new_coord_name, dim_names) self.assertEqual(named_dims, exp_named_dims) self.assertIsNone(anon_dims) self.assertEqual(len(new_coord.points), sample_count)
def setUp(self): path = tests.get_data_path(('NetCDF', 'unstructured_grid', 'theta_nodal_xios.nc')) self.src = iris.load_cube(path, 'Potential Temperature') self.grid = simple_3d()[0, :, :]
def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) self.header_emts = self.representer._make_header().split('\n')
def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube)
def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) self.result = self.representer._make_content()
def setUp(self): self.cube = stock.simple_3d() cm = CellMethod('mean', 'time', '6hr') self.cube.add_cell_method(cm) self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines())
def test_argument_is_basestring(self): cube_a = stock.simple_3d() cube_b = cube_a.copy() demote_dim_coord_to_aux_coord(cube_b, cube_b.coord('wibble')) self.assertEqual(cube_b.dim_coords, (cube_a.coord('latitude'), cube_a.coord('longitude')))
def setUp(self): self.cube = stock.simple_3d() coord = self.cube.coord('wibble') self.cube.remove_coord(coord) self.cube.add_aux_coord(coord, 0)
def test(self): cube = stock.simple_3d() self._check_copy(cube, cube.copy())
def setUp(self): self.cube = stock.simple_3d() representer = CubeRepresentation(self.cube) self.result = representer.repr_html()
def setUp(self): path = tests.get_data_path( ('NetCDF', 'unstructured_grid', 'theta_nodal_xios.nc')) self.src = iris.load_cube(path, 'Potential Temperature') self.grid = simple_3d()[0, :, :]
def setUp(self): self.cubes = CubeList([stock.simple_3d(), stock.lat_lon_cube()]) self.representer = CubeListRepresentation(self.cubes)
def setUp(self): path = tests.get_data_path( ("NetCDF", "unstructured_grid", "theta_nodal_xios.nc")) self.src = iris.load_cube(path, "Potential Temperature") self.grid = simple_3d()[0, :, :]
def setUp(self): self.cube = stock.simple_3d() self.representer = CubeRepresentation(self.cube) self.representer._get_bits(self.representer._get_lines()) self.result = self.representer._make_shapes_row().split('\n')
def setUp(self): self.cubes = CubeList([stock.simple_3d(), stock.lat_lon_cube()]) self.cubes[0].rename('name & <html>') self.representer = CubeListRepresentation(self.cubes) self.content = self.representer.make_content()
def test_find_discontiguities_1d_coord(self): # Check that an error is raised when we try and use # find_discontiguities on 1D coordinates: cube = simple_3d() with self.assertRaises(NotImplementedError): find_discontiguities(cube)
def test_compare_cubes_incompatible(self): test_case_a = stock.simple_2d() test_case_b = stock.simple_3d() test_cubes = [test_case_a, test_case_b] self.assertRaises(OSError, ch.compare_cubes, test_cubes)
def setUp(self): self.cube = stock.simple_3d() coord = self.cube.coord("wibble") self.cube.remove_coord(coord) self.cube.add_aux_coord(coord, 0)
def setUp(self): self.cube1 = stock.simple_3d() iris.analysis.clear_phenomenon_identity(self.cube1) self.cube2 = stock.simple_3d_w_multidim_coords() iris.analysis.clear_phenomenon_identity(self.cube2)