def test_tie_points_geo_interpolation(self): """# Test the coordinates interpolation routine with valid and invalid input.""" # Test the interpolation routine with valid input lon, lat = tie_points_geo_interpolation(self.longitude, self.latitude, TEST_SCAN_ALT_TIE_POINTS, TEST_TIE_POINTS_FACTOR) self.assertTrue(np.allclose(lon, TEST_LON_1)) self.assertTrue(np.allclose(lat, TEST_LAT_1)) lon, lat = tie_points_geo_interpolation(self.longitude_over360, self.latitude, TEST_SCAN_ALT_TIE_POINTS, TEST_TIE_POINTS_FACTOR) self.assertTrue(np.allclose(lon, TEST_LON_2)) self.assertTrue(np.allclose(lat, TEST_LAT_2)) lon, lat = tie_points_geo_interpolation(self.longitude, self.latitude_over60, TEST_SCAN_ALT_TIE_POINTS, TEST_TIE_POINTS_FACTOR) self.assertTrue(np.allclose(lon, TEST_LON_3)) self.assertTrue(np.allclose(lat, TEST_LAT_3)) # Test the interpolation routine with invalid input (different dimensions of the two arrays) with self.assertRaises(ValueError): tie_points_geo_interpolation(self.longitude, self.invalid_data_for_interpolation, TEST_SCAN_ALT_TIE_POINTS, TEST_TIE_POINTS_FACTOR)
def _perform_geo_interpolation(longitude, latitude): """Perform the interpolation of geographic coodinates from tie points to pixel points. Args: longitude: xarray DataArray containing the longitude dataset to interpolate. latitude: xarray DataArray containing the longitude dataset to interpolate. Returns: tuple of arrays containing the interpolate values, all the original metadata and the updated dimension names. """ interpolated_longitude, interpolated_latitude = tie_points_geo_interpolation( longitude, latitude, SCAN_ALT_TIE_POINTS, TIE_POINTS_FACTOR ) new_longitude = interpolated_longitude.rename( num_tie_points_act='num_pixels', num_tie_points_alt='num_lines' ) new_longitude.name = longitude.name new_longitude.attrs = longitude.attrs new_latitude = interpolated_latitude.rename( num_tie_points_act='num_pixels', num_tie_points_alt='num_lines' ) new_latitude.name = latitude.name new_latitude.attrs = latitude.attrs return new_longitude, new_latitude