def test_realization(self): """Test that a cube is created with the expected order for coordinates within the output cube, if the input cube has dimensions of realization, projection_y_coordinate and projection_x_coordinate.""" for sliced_cube in self.cube.slices([ "realization", "projection_y_coordinate", "projection_x_coordinate" ]): break data = sliced_cube.data coord_x = sliced_cube.coord("projection_x_coordinate") coord_y = sliced_cube.coord("projection_y_coordinate") new_cube = SquareNeighbourhood()._create_cube_with_new_data( sliced_cube, data, coord_x, coord_y) self.assertIsInstance(new_cube, Cube) self.assertArrayAlmostEqual(new_cube.data, data) self.assertEqual(new_cube.coord_dims("realization")[0], 0) self.assertEqual(new_cube.coord_dims("projection_y_coordinate")[0], 1) self.assertEqual(new_cube.coord_dims("projection_x_coordinate")[0], 2)
def test_no_y_dimension_coordinate(self): """Test that a cube is created with the expected y and x coordinates within the output cube, if the input cube only has a projection_y_coordinate dimension coordinate.""" for sliced_cube in self.cube.slices(["projection_x_coordinate"]): break data = sliced_cube.data coord_x = sliced_cube.coord("projection_x_coordinate") coord_y = sliced_cube.coord("projection_y_coordinate") new_cube = SquareNeighbourhood()._create_cube_with_new_data( sliced_cube, data, coord_x, coord_y) self.assertIsInstance(new_cube, Cube) self.assertArrayAlmostEqual(new_cube.data, data) self.assertEqual(new_cube.coord_dims("projection_x_coordinate")[0], 0) self.assertTrue( new_cube.coords("projection_y_coordinate", dim_coords=False))
def test_forecast_period(self): """Test that a cube is created with the expected order for coordinates within the output cube, if the input cube has dimensions of projection_y_coordinate and projection_x_coordinate, and where the input cube also has a forecast_period coordinate.""" for sliced_cube in self.cube.slices( ["projection_y_coordinate", "projection_x_coordinate"]): break fp_coord = DimCoord(np.array([10]), standard_name="forecast_period") sliced_cube.add_aux_coord(fp_coord) data = sliced_cube.data coord_x = sliced_cube.coord("projection_x_coordinate") coord_y = sliced_cube.coord("projection_y_coordinate") new_cube = SquareNeighbourhood()._create_cube_with_new_data( sliced_cube, data, coord_x, coord_y) self.assertIsInstance(new_cube, Cube) self.assertArrayAlmostEqual(new_cube.data, data) self.assertEqual(new_cube.coord("forecast_period").points, 10) self.assertEqual(new_cube.coord_dims("projection_y_coordinate")[0], 0) self.assertEqual(new_cube.coord_dims("projection_x_coordinate")[0], 1)