Esempio n. 1
0
 def test_volume_statistics_masked_level(self):
     """
     Test to take the volume weighted average of a (2,3,2,2) cube
     where the last depth level is fully masked.
     """
     self.grid_4d.data[:, -1, :, :] = np.ma.masked_all((2, 2, 2))
     result = volume_statistics(self.grid_4d, 'mean')
     expected = np.ma.array([1., 1.], mask=False)
     self.assert_array_equal(result.data, expected)
Esempio n. 2
0
 def test_volume_statistics_masked_timestep(self):
     """
     Test to take the volume weighted average of a (2,3,2,2) cube
     where the first timestep is fully masked.
     """
     self.grid_4d.data[0, :, :, :] = np.ma.masked_all((3, 2, 2))
     result = volume_statistics(self.grid_4d, 'mean')
     expected = np.ma.array([1., 1], mask=[True, False])
     self.assert_array_equal(result.data, expected)
Esempio n. 3
0
    def test_volume_statistics_long(self):
        """
        Test to take the volume weighted average of a (4,3,2,2) cube.

        This extra time is needed, as the volume average calculation uses
        different methods for small and large cubes.
        """
        result = volume_statistics(self.grid_4d_2, 'mean')
        expected = np.ma.array([1., 1., 1., 1.], mask=False)
        self.assert_array_equal(result.data, expected)
Esempio n. 4
0
 def test_volume_statistics_cell_measure(self):
     """
     Test to take the volume weighted average of a (2,3,2,2) cube.
     The volume measure is pre-loaded in the cube.
     """
     grid_volume = calculate_volume(self.grid_4d)
     measure = iris.coords.CellMeasure(grid_volume,
                                       standard_name='ocean_volume',
                                       units='m3',
                                       measure='volume')
     self.grid_4d.add_cell_measure(measure, range(0, measure.ndim))
     result = volume_statistics(self.grid_4d, 'mean')
     expected = np.ma.array([1., 1.], mask=False)
     self.assert_array_equal(result.data, expected)
Esempio n. 5
0
 def test_extract_volume_mean(self):
     """
     Test to extract the top two layers and compute the
     weighted average of a cube."""
     grid_volume = calculate_volume(self.grid_4d)
     measure = iris.coords.CellMeasure(grid_volume,
                                       standard_name='ocean_volume',
                                       units='m3',
                                       measure='volume')
     self.grid_4d.add_cell_measure(measure, range(0, measure.ndim))
     result = extract_volume(self.grid_4d, 0., 10.)
     expected = np.ma.ones((2, 2, 2, 2))
     self.assert_array_equal(result.data, expected)
     result_mean = volume_statistics(result, 'mean')
     expected_mean = np.ma.array([1., 1.], mask=False)
     self.assert_array_equal(result_mean.data, expected_mean)
Esempio n. 6
0
 def test_volume_statistics(self):
     """Test to take the volume weighted average of a (2,3,2,2) cube."""
     result = volume_statistics(self.grid_4d, 'mean')
     expected = np.ma.array([1., 1.], mask=False)
     self.assert_array_equal(result.data, expected)