Beispiel #1
0
    def setUp(self):
        """Set up a weights cube and default plugin to use in unittests."""
        weights_data = np.array([[[0.8, 0.7, 0.0, 0.0, 0.0],
                                  [0.7, 0.3, 0.0, 0.0, 0.0],
                                  [0.3, 0.1, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0]],
                                 [[0.2, 0.3, 1.0, 1.0, 1.0],
                                  [0.3, 0.7, 1.0, 1.0, 1.0],
                                  [0.7, 0.9, 1.0, 1.0, 1.0],
                                  [1.0, 1.0, 1.0, 0.9, 0.5],
                                  [1.0, 1.0, 1.0, 0.6, 0.2]],
                                 [[0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.1, 0.5],
                                  [0.0, 0.0, 0.0, 0.4, 0.8]]])
        topographic_zone_points = [50, 150, 250]
        topographic_zone_bounds = [[0, 100], [100, 200], [200, 300]]

        weights_cubes = iris.cube.CubeList([])
        for data, point, bounds in zip(weights_data, topographic_zone_points,
                                       topographic_zone_bounds):
            weights_cubes.append(
                set_up_topographic_zone_cube(
                    data, point, bounds, num_grid_points=5))
        self.weights_cube = weights_cubes.merge_cube()
        nbhood_data = np.ones((3, 5, 5))
        nbhood_data[0] = nbhood_data[0]*0.1
        nbhood_data[1] = nbhood_data[1]*0.2
        nbhood_data[2] = nbhood_data[2]*0.1
        self.nbhooded_cube = self.weights_cube.copy(nbhood_data)
        self.plugin = CollapseMaskedNeighbourhoodCoordinate("topographic_zone",
                                                            self.weights_cube)
Beispiel #2
0
    def setUp(self):
        """Set up a weights cube and default plugin instance."""
        self.mask = np.array([[[1, 1, 1, 0, 0],
                               [1, 1, 0, 0, 0],
                               [1, 0, 0, 0, 0],
                               [1, 0, 0, 0, 0],
                               [1, 1, 1, 1, 1]],
                              [[1, 1, 1, 0, 0],
                               [1, 1, 0, 0, 0],
                               [1, 0, 0, 0, 0],
                               [1, 0, 0, 0, 0],
                               [1, 1, 1, 1, 1]],
                              [[1, 1, 1, 0, 0],
                               [1, 1, 0, 0, 0],
                               [1, 0, 0, 0, 0],
                               [1, 0, 0, 0, 0],
                               [1, 1, 1, 1, 1]]])
        weights_data = np.array([[[0.8, 0.7, 0.0, 0.0, 0.0],
                                  [0.7, 0.3, 0.0, 0.0, 0.0],
                                  [0.3, 0.1, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0]],
                                 [[0.2, 0.3, 1.0, 1.0, 1.0],
                                  [0.3, 0.7, 1.0, 1.0, 1.0],
                                  [0.7, 0.9, 1.0, 1.0, 1.0],
                                  [1.0, 1.0, 1.0, 0.9, 0.5],
                                  [1.0, 1.0, 1.0, 0.6, 0.2]],
                                 [[0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.0, 0.1, 0.5],
                                  [0.0, 0.0, 0.0, 0.4, 0.8]]])
        topographic_zone_points = [50, 150, 250]
        topographic_zone_bounds = [[0, 100], [100, 200], [200, 300]]

        weights_cubes = iris.cube.CubeList([])
        for data, point, bounds in zip(weights_data, topographic_zone_points,
                                       topographic_zone_bounds):
            weights_cubes.append(
                set_up_topographic_zone_cube(
                    data, point, bounds, num_grid_points=5))
        self.weights_cube = weights_cubes.merge_cube()
        self.plugin = CollapseMaskedNeighbourhoodCoordinate("topographic_zone",
                                                            self.weights_cube)