Exemple #1
0
def nearest_neighbour_data_value(cube, sample_points):
    msg = (_INTERPOLATE_DEPRECATION_WARNING + '\n' +
           'Please replace usage of '
           'iris.analysis.interpolate.nearest_neighbour_data_value() with '
           'iris.cube.Cube.interpolate(..., scheme=iris.analysis.Nearest()).')
    _warn_deprecated(msg)
    return oldinterp.nearest_neighbour_data_value(cube, sample_points)
Exemple #2
0
 def test_nearest_neighbour_over_specification_which_is_consistent(self):
     # latitude 40 is the 20th point
     point_spec = [('latitude', 40), ('i', 20), ('longitude', 38)]
     
     indices = iintrp.nearest_neighbour_indices(self.cube, point_spec)
     self.assertEqual(indices, (20, 10))
     
     b = iintrp.extract_nearest_neighbour(self.cube, point_spec) 
     self.assertCML(b, ('analysis', 'interpolation', 'nearest_neighbour_extract_latitude_longitude.cml'))
     
     value = iintrp.nearest_neighbour_data_value(self.cube, point_spec)
     # Check that the value back is that which was returned by the extract method
     self.assertEqual(value, b.data)
 def test_nearest_neighbour_over_specification_which_is_consistent(self):
     # latitude 40 is the 20th point
     point_spec = [('latitude', 40), ('i', 20), ('longitude', 38)]
     
     indices = iintrp.nearest_neighbour_indices(self.cube, point_spec)
     self.assertEqual(indices, (20, 10))
     
     b = iintrp.extract_nearest_neighbour(self.cube, point_spec) 
     self.assertCML(b, ('analysis', 'interpolation', 'nearest_neighbour_extract_latitude_longitude.cml'))
     
     value = iintrp.nearest_neighbour_data_value(self.cube, point_spec)
     # Check that the value back is that which was returned by the extract method
     self.assertEqual(value, b.data)
Exemple #4
0
    def test_nearest_neighbour(self):
        point_spec = [('latitude', 40), ('longitude', 39)]
        
        indices = iintrp.nearest_neighbour_indices(self.cube, point_spec)
        self.assertEqual(indices, (20, 10))
        
        b = iintrp.extract_nearest_neighbour(self.cube, point_spec) 

        # Check that the data has not been loaded on either the original cube,
        # nor the interpolated one.
        self.assertTrue(b.has_lazy_data())
        self.assertTrue(self.cube.has_lazy_data())
        self.assertCML(b, ('analysis', 'interpolation', 'nearest_neighbour_extract_latitude_longitude.cml'))
        
        value = iintrp.nearest_neighbour_data_value(self.cube, point_spec)
        self.assertEqual(value, np.array(285.98785, dtype=np.float32))

        # Check that the value back is that which was returned by the extract method
        self.assertEqual(value, b.data)
    def test_nearest_neighbour(self):
        point_spec = [('latitude', 40), ('longitude', 39)]
        
        indices = iintrp.nearest_neighbour_indices(self.cube, point_spec)
        self.assertEqual(indices, (20, 10))
        
        b = iintrp.extract_nearest_neighbour(self.cube, point_spec) 

        # Check that the data has not been loaded on either the original cube,
        # nor the interpolated one.
        self.assertTrue(b.has_lazy_data())
        self.assertTrue(self.cube.has_lazy_data())
        self.assertCML(b, ('analysis', 'interpolation', 'nearest_neighbour_extract_latitude_longitude.cml'))
        
        value = iintrp.nearest_neighbour_data_value(self.cube, point_spec)
        self.assertEqual(value, np.array(285.98785, dtype=np.float32))

        # Check that the value back is that which was returned by the extract method
        self.assertEqual(value, b.data)
def nearest_neighbour_data_value(cube, sample_points):
    msg = (_INTERPOLATE_DEPRECATION_WARNING + '\n' + 'Please replace usage of '
           'iris.analysis.interpolate.nearest_neighbour_data_value() with '
           'iris.cube.Cube.interpolate(..., scheme=iris.analysis.Nearest()).')
    _warn_deprecated(msg)
    return oldinterp.nearest_neighbour_data_value(cube, sample_points)