Ejemplo n.º 1
0
    def test_ok_for_diff_percentile_coord(self):
        """Test the plugin succeeds if percentile coord is different"""
        data = np.array([[[[4.75, 5.375, 6.], [6.625, 7.25, 7.875],
                           [8.5, 9.125, 9.75]]],
                         [[[6., 6.625, 7.25], [7.875, 8.5, 9.125],
                           [9.75, 10.375, 11.]]],
                         [[[7.25, 7.875, 8.5], [9.125, 9.75, 10.375],
                           [11., 11.625, 12.25]]]])

        cube = self.percentile_cube_mismatch
        plugin = Plugin()
        result = plugin.process(cube)
        self.assertArrayAlmostEqual(result.data, data)
Ejemplo n.º 2
0
    def test_check_data_not_specifying_percentiles(self):
        """
        Test that the plugin returns an Iris.cube.Cube with the expected
        data values without specifying the number of percentiles.
        """
        data = np.array([[[[4.75, 5.375, 6.], [6.625, 7.25, 7.875],
                           [8.5, 9.125, 9.75]]],
                         [[[6., 6.625, 7.25], [7.875, 8.5, 9.125],
                           [9.75, 10.375, 11.]]],
                         [[[7.25, 7.875, 8.5], [9.125, 9.75, 10.375],
                           [11., 11.625, 12.25]]]])

        cube = self.percentile_cube
        plugin = Plugin()
        result = plugin.process(cube)
        self.assertArrayAlmostEqual(result.data, data)
Ejemplo n.º 3
0
    def test_check_data_specifying_percentiles(self):
        """
        Test that the plugin returns an Iris.cube.Cube with the expected
        data values for a specific number of percentiles.
        """
        data = np.array([
            [[[4.75, 5.375, 6.0], [6.625, 7.25, 7.875], [8.5, 9.125, 9.75]]],
            [[[6.0, 6.625, 7.25], [7.875, 8.5, 9.125], [9.75, 10.375, 11.0]]],
            [[[7.25, 7.875, 8.5], [9.125, 9.75, 10.375], [11.0, 11.625,
                                                          12.25]]],
        ])

        cube = self.percentile_cube
        percentiles = [25, 50, 75]
        plugin = Plugin()
        result = plugin.process(cube, no_of_percentiles=len(percentiles))
        self.assertArrayAlmostEqual(result.data, data)