def test_interp_from_xy_grid_to_points_nearest(self): """Ensures correct output from interp_from_xy_grid_to_points. In this case, doing interpolation with nearest-neighbour method. """ these_query_values = interp.interp_from_xy_grid_to_points( INPUT_MATRIX_FOR_SPATIAL_INTERP, sorted_grid_point_x_metres=GRID_POINT_X_METRES, sorted_grid_point_y_metres=GRID_POINT_Y_METRES, query_x_metres=QUERY_X_FOR_NEAREST_NEIGH_METRES, query_y_metres=QUERY_Y_FOR_NEAREST_NEIGH_METRES, method_string=interp.NEAREST_INTERP_METHOD) self.assertTrue( numpy.allclose(these_query_values, EXPECTED_QUERY_VALUES_FOR_NEAREST_NEIGH, atol=TOLERANCE))
def test_interp_from_xy_grid_to_points_nearest(self): """Ensures correct output from interp_from_xy_grid_to_points. In this case, interpolation method is nearest-neighbour. """ these_interp_values = interp.interp_from_xy_grid_to_points( input_matrix=INPUT_MATRIX_FOR_SPATIAL_INTERP, sorted_grid_point_x_metres=GRID_POINT_X_METRES, sorted_grid_point_y_metres=GRID_POINT_Y_METRES, query_x_coords_metres=QUERY_X_FOR_NEAREST_NEIGH_METRES, query_y_coords_metres=QUERY_Y_FOR_NEAREST_NEIGH_METRES, method_string=interp.NEAREST_NEIGHBOUR_METHOD_STRING, extrapolate=False) self.assertTrue( numpy.allclose(these_interp_values, INTERP_VALUES_NEAREST_NEIGH, atol=TOLERANCE))
def test_interp_from_xy_grid_to_points_spline_interp(self): """Ensures correct output from interp_from_xy_grid_to_points. In this case, doing interpolation with linear spline. """ these_query_values = interp.interp_from_xy_grid_to_points( INPUT_MATRIX_FOR_SPATIAL_INTERP, sorted_grid_point_x_metres=GRID_POINT_X_METRES, sorted_grid_point_y_metres=GRID_POINT_Y_METRES, query_x_metres=QUERY_X_FOR_SPLINE_INTERP_METRES, query_y_metres=QUERY_Y_FOR_SPLINE_INTERP_METRES, method_string=interp.SPLINE_INTERP_METHOD, spline_degree=SPLINE_DEGREE) self.assertTrue( numpy.allclose(these_query_values, QUERY_VALUES_FOR_SPLINE_INTERP, atol=TOLERANCE))
def test_interp_from_xy_grid_to_points_spline(self): """Ensures correct output from interp_from_xy_grid_to_points. In this case, interpolation method is linear spline. """ these_interp_values = interp.interp_from_xy_grid_to_points( input_matrix=INPUT_MATRIX_FOR_SPATIAL_INTERP, sorted_grid_point_x_metres=GRID_POINT_X_METRES, sorted_grid_point_y_metres=GRID_POINT_Y_METRES, query_x_coords_metres=QUERY_X_FOR_SPLINE_METRES, query_y_coords_metres=QUERY_Y_FOR_SPLINE_METRES, method_string=interp.SPLINE_METHOD_STRING, spline_degree=SPLINE_DEGREE, extrapolate=False) self.assertTrue( numpy.allclose(these_interp_values, INTERP_VALUES_SPLINE, atol=TOLERANCE))