Beispiel #1
0
    def _assert_expected_call(self, sample_points, sample_points_call,
                              cinterp_patch, linear_patch):
        linear_patch.return_value = self.scheme
        linear(self.cube, sample_points, self.extrapolation)

        linear_patch.assert_called_once_with(self.extrapolation)

        cinterp_patch.assert_called_once_with(sample_points_call, self.scheme)
Beispiel #2
0
 def test_multi(self):
     # Testing interpolation on specified points on cube with
     # multidimensional coordinates.
     interp_cube = linear(self.cube, {'latitude': 1.5, 'longitude': 1.5})
     self.assertCMLApproxData(interp_cube, ('experimental', 'analysis',
                                            'interpolate',
                                            'linear_nd_2_coords.cml'))
Beispiel #3
0
 def test_single(self):
     # Interpolation on the 1d coordinate.
     interp_cube = linear(self.cube, {'wibble': 20})
     self.assertArrayEqual(np.mean(self.cube.data, axis=0),
                           interp_cube.data)
     self.assertCMLApproxData(interp_cube, ('experimental', 'analysis',
                                            'interpolate', 'linear_nd.cml'))
Beispiel #4
0
 def test_mask_retention(self):
     cube = stock.realistic_4d_w_missing_data()
     interp_cube = linear(cube, [('pressure', [850, 950])])
     self.assertIsInstance(interp_cube.data, ma.MaskedArray)
     # this value is masked in the input
     self.assertTrue(cube.data.mask[0, 2, 2, 0])
     # and is still masked in the output
     self.assertTrue(interp_cube.data.mask[0, 1, 2, 0])
Beispiel #5
0
 def test_mask_retention(self):
     cube = stock.realistic_4d_w_missing_data()
     interp_cube = linear(cube, [('pressure', [850, 950])])
     self.assertIsInstance(interp_cube.data, ma.MaskedArray)
     # this value is masked in the input
     self.assertTrue(cube.data.mask[0, 2, 2, 0])
     # and is still masked in the output
     self.assertTrue(interp_cube.data.mask[0, 1, 2, 0])
Beispiel #6
0
 def test_positive(self):
     # Check we can interpolate from a Cube defined over [0, 360).
     cube = self._create_cube([0, 90, 180, 270])
     samples = [('longitude', range(-360, 720, 45))]
     result = interpolate.linear(cube, samples)
     self.assertCMLApproxData(result,
                              ('analysis', 'interpolation', 'linear',
                               'circular_wrapping', 'positive'))
Beispiel #7
0
 def test_positive(self):
     # Check we can interpolate from a Cube defined over [0, 360).
     cube = self._create_cube([0, 90, 180, 270])
     samples = [('longitude', range(-360, 720, 45))]
     result = interpolate.linear(cube, samples)
     self.assertCMLApproxData(result, ('analysis', 'interpolation',
                                       'linear', 'circular_wrapping',
                                       'positive'))
Beispiel #8
0
 def test_symmetric(self):
     # Check we can interpolate from a Cube defined over [-180, 180).
     cube = self._create_cube([-180, -90, 0, 90])
     samples = [('longitude', range(-360, 720, 45))]
     result = interpolate.linear(cube, samples)
     normalise_order(result)
     self.assertCMLApproxData(result,
                              ('analysis', 'interpolation', 'linear',
                               'circular_wrapping', 'symmetric'))
Beispiel #9
0
 def test_symmetric(self):
     # Check we can interpolate from a Cube defined over [-180, 180).
     cube = self._create_cube([-180, -90, 0, 90])
     samples = [('longitude', range(-360, 720, 45))]
     result = interpolate.linear(cube, samples)
     normalise_order(result)
     self.assertCMLApproxData(result, ('analysis', 'interpolation',
                                       'linear', 'circular_wrapping',
                                       'symmetric'))
Beispiel #10
0
 def test_single_extrapolation(self):
     # Interpolation on the 1d coordinate with extrapolation.
     interp_cube = linear(self.cube, {'wibble': np.float32(1.5)})
     expected = ('experimental', 'analysis', 'interpolate',
                 'linear_nd_with_extrapolation.cml')
     self.assertCMLApproxData(interp_cube, expected)