def setUp(self):
        """Set up cubes."""

        temp_vals = [278.0, 280.0, 285.0, 286.0]
        pressure_vals = [93856.0, 95034.0, 96216.0, 97410.0]

        data = np.ones((2, 1, 3, 3))
        relh_data = np.ones((2, 1, 3, 3)) * 0.65

        temperature = set_up_cube(data,
                                  'air_temperature',
                                  'K',
                                  realizations=np.array([0, 1]))
        relative_humidity = set_up_cube(relh_data,
                                        'relative_humidity',
                                        '%',
                                        realizations=np.array([0, 1]))
        pressure = set_up_cube(data,
                               'air_pressure',
                               'Pa',
                               realizations=np.array([0, 1]))
        self.height_points = np.array([5., 195., 200.])
        self.temperature_cube = set_up_height_cube(self.height_points,
                                                   cube=temperature)
        self.relative_humidity_cube = (set_up_height_cube(
            self.height_points, cube=relative_humidity))
        self.pressure_cube = set_up_height_cube(self.height_points,
                                                cube=pressure)
        for i in range(0, 3):
            self.temperature_cube.data[i, ::] = temp_vals[i + 1]
            self.pressure_cube.data[i, ::] = pressure_vals[i + 1]
            # Add hole in middle of data.
            self.temperature_cube.data[i, :, :, 1, 1] = temp_vals[i]
            self.pressure_cube.data[i, :, :, 1, 1] = pressure_vals[i]

        x_coord = iris.coords.DimCoord(np.linspace(-2000, 2000, 3),
                                       'projection_x_coordinate',
                                       units='m')
        y_coord = iris.coords.DimCoord(np.linspace(-2000, 2000, 3),
                                       'projection_y_coordinate',
                                       units='m')
        self.orog = iris.cube.Cube(np.ones((3, 3)),
                                   standard_name='surface_altitude',
                                   units='m')
        self.land_sea = iris.cube.Cube(np.ones((3, 3)),
                                       standard_name='land_binary_mask',
                                       units='m')
        cubes = [
            self.temperature_cube, self.relative_humidity_cube,
            self.pressure_cube
        ]
        for cube in cubes:
            cube.remove_coord("latitude")
            cube.remove_coord("longitude")
            cube.add_dim_coord(x_coord, 3)
            cube.add_dim_coord(y_coord, 4)
        cubes = [self.orog, self.land_sea]
        for cube in cubes:
            cube.add_dim_coord(x_coord, 0)
            cube.add_dim_coord(y_coord, 1)
 def setUp(self):
     """Set up cubes."""
     temperature, pressure, relative_humidity, _ = (
         set_up_cubes_for_wet_bulb_temperature())
     self.height_points = np.array([5., 10., 20.])
     self.temperature_cube = set_up_height_cube(self.height_points,
                                                cube=temperature)
     self.relative_humidity_cube = (set_up_height_cube(
         self.height_points, cube=relative_humidity))
     self.pressure_cube = set_up_height_cube(self.height_points,
                                             cube=pressure)
예제 #3
0
    def setUp(self):
        """Set up cubes."""

        temp_vals = [278.0, 280.0, 285.0, 286.0]
        pressure_vals = [93856.0, 95034.0, 96216.0, 97410.0]

        data = np.ones((2, 1, 3, 3))
        relh_data = np.ones((2, 1, 3, 3)) * 0.65

        temperature = set_up_cube(data,
                                  'air_temperature',
                                  'K',
                                  realizations=np.array([0, 1]))
        relative_humidity = set_up_cube(relh_data,
                                        'relative_humidity',
                                        '%',
                                        realizations=np.array([0, 1]))
        pressure = set_up_cube(data,
                               'air_pressure',
                               'Pa',
                               realizations=np.array([0, 1]))
        self.height_points = np.array([5., 195., 200.])
        self.temperature_cube = set_up_height_cube(self.height_points,
                                                   cube=temperature)
        self.relative_humidity_cube = (set_up_height_cube(
            self.height_points, cube=relative_humidity))
        self.pressure_cube = set_up_height_cube(self.height_points,
                                                cube=pressure)
        for i in range(0, 3):
            self.temperature_cube.data[i, ::] = temp_vals[i + 1]
            self.pressure_cube.data[i, ::] = pressure_vals[i + 1]
            # Add hole in middle of data.
            self.temperature_cube.data[i, :, :, 1, 1] = temp_vals[i]
            self.pressure_cube.data[i, :, :, 1, 1] = pressure_vals[i]

        self.orog = iris.cube.Cube(np.ones((3, 3)),
                                   standard_name='surface_altitude',
                                   units='m')
        self.orog.add_dim_coord(
            iris.coords.DimCoord(np.linspace(-45.0, 45.0, 3),
                                 'latitude',
                                 units='degrees'), 0)
        self.orog.add_dim_coord(
            iris.coords.DimCoord(np.linspace(120, 180, 3),
                                 'longitude',
                                 units='degrees'), 1)
예제 #4
0
 def setUp(self):
     """Set up a cube."""
     self.ascending_height_points = np.array([5., 10., 20.])
     cube = set_up_height_cube(self.ascending_height_points)[:, 0, :, :, :]
     data = np.zeros(cube.shape)
     data[0] = np.ones(cube[0].shape, dtype=np.int32)
     data[1] = np.full(cube[1].shape, 2, dtype=np.int32)
     data[2] = np.full(cube[2].shape, 3, dtype=np.int32)
     cube.data = data
     self.ascending_cube = cube
     descending_cube = cube.copy()
     self.descending_height_points = np.array([20., 10., 5.])
     descending_cube.coord("height").points = self.descending_height_points
     self.descending_cube = descending_cube