Exemple #1
0
    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)
Exemple #2
0
 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)
Exemple #3
0
 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")),
     )
Exemple #4
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)
Exemple #5
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)
Exemple #6
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()
Exemple #7
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()
Exemple #8
0
    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)
Exemple #9
0
 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')
Exemple #11
0
 def setUp(self):
     self.cube = stock.simple_3d()
     self.representer = CubeRepresentation(self.cube)
Exemple #12
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_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')))
Exemple #15
0
 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)
Exemple #16
0
 def test(self):
     cube = stock.simple_3d()
     self._check_copy(cube, cube.copy())
 def setUp(self):
     self.cube = stock.simple_3d()
     self.representer = CubeRepresentation(self.cube)
 def setUp(self):
     self.cube = stock.simple_3d()
     representer = CubeRepresentation(self.cube)
     self.result = representer.repr_html()
 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()
Exemple #20
0
 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, :, :]
Exemple #21
0
 def setUp(self):
     self.cubes = CubeList([stock.simple_3d(), stock.lat_lon_cube()])
     self.representer = CubeListRepresentation(self.cubes)
Exemple #22
0
 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, :, :]
Exemple #23
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')
Exemple #24
0
 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 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')
Exemple #26
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 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)
Exemple #28
0
 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())
Exemple #29
0
 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)
Exemple #30
0
 def setUp(self):
     self.cube = stock.simple_3d()
     representer = CubeRepresentation(self.cube)
     self.result = representer.repr_html()
Exemple #31
0
 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)
Exemple #32
0
 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)
Exemple #33
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)