[Git][debian-gis-team/python-geotiepoints][master] 7 commits: New upstream version 1.6.0

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sun Jun 11 16:59:55 BST 2023



Antonio Valentino pushed to branch master at Debian GIS Project / python-geotiepoints


Commits:
a3b07222 by Antonio Valentino at 2023-06-11T08:14:21+00:00
New upstream version 1.6.0
- - - - -
69e15e9a by Antonio Valentino at 2023-06-11T08:15:02+00:00
Update upstream source from tag 'upstream/1.6.0'

Update to upstream version '1.6.0'
with Debian dir 3863dfffb584e598ab038ad44cff480bac258dd6
- - - - -
96c31cfa by Antonio Valentino at 2023-06-11T08:30:20+00:00
Update dates in d/copyright

- - - - -
4761b1a5 by Antonio Valentino at 2023-06-11T08:32:08+00:00
Refresh all patches

- - - - -
75609cac by Antonio Valentino at 2023-06-11T08:42:00+00:00
Add pyresample to build-dependencies

- - - - -
29387e2b by Antonio Valentino at 2023-06-11T17:58:36+02:00
Bump debhelpar-compat version to 13

- - - - -
34e0b3aa by Antonio Valentino at 2023-06-11T17:58:37+02:00
Set distribution to unstable

- - - - -


15 changed files:

- .gitignore
- CHANGELOG.md
- continuous_integration/environment.yaml
- debian/changelog
- debian/control
- debian/copyright
- debian/patches/0001-Skip-tests-using-external-data.patch
- debian/tests/control
- geotiepoints/geointerpolator.py
- geotiepoints/interpolator.py
- geotiepoints/tests/test_geointerpolator.py
- geotiepoints/tests/test_interpolator.py
- geotiepoints/version.py
- geotiepoints/viiinterpolator.py
- setup.py


Changes:

=====================================
.gitignore
=====================================
@@ -6,6 +6,7 @@
 dist
 build
 eggs
+.eggs
 parts
 bin
 var
@@ -28,3 +29,9 @@ pip-log.txt
 
 # Don't include the C files in the repository
 geotiepoints/*.c
+
+# pycharm
+.idea
+
+# vscode
+.vscode
\ No newline at end of file


=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,19 @@
+## Version 1.6.0 (2023/03/17)
+
+
+### Pull Requests Merged
+
+#### Bugs fixed
+
+* [PR 45](https://github.com/pytroll/python-geotiepoints/pull/45) - Fix VII interpolator compatibility with future versions of xarray
+
+#### Features added
+
+* [PR 44](https://github.com/pytroll/python-geotiepoints/pull/44) - Add interpolators based on scipy's RegularGridInterpolator
+
+In this release 2 pull requests were closed.
+
+
 ## Version 1.5.1 (2022/12/09)
 
 ### Pull Requests Merged


=====================================
continuous_integration/environment.yaml
=====================================
@@ -18,3 +18,4 @@ dependencies:
   - pytest
   - pytest-cov
   - pyproj
+  - pyresample


=====================================
debian/changelog
=====================================
@@ -1,11 +1,18 @@
-python-geotiepoints (1.5.1-2) UNRELEASED; urgency=medium
+python-geotiepoints (1.6.0-1) unstable; urgency=medium
 
-  * Team upload.
+  [ Bas Couwenberg ]
   * Enable numpy3 dh helper.
   * Enable Salsa CI.
   * Bump Standards-Version to 4.6.2, no changes.
 
- -- Bas Couwenberg <sebastic at debian.org>  Thu, 22 Dec 2022 11:56:36 +0100
+  [ Antonio Valentino ]
+  * New upstream release.
+  * Update dates in d/copyright.
+  * Refresh all patches.
+  * Build-depend on pyresample.
+  * Bump debhelper-compat version to 13.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Sun, 11 Jun 2023 08:33:47 +0000
 
 python-geotiepoints (1.5.1-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -4,7 +4,7 @@ Uploaders: Antonio Valentino <antonio.valentino at tiscali.it>
 Section: python
 Priority: optional
 Rules-Requires-Root: no
-Build-Depends: debhelper-compat (= 12),
+Build-Depends: debhelper-compat (= 13),
                dh-python,
                cython3,
                pybuild-plugin-pyproject,
@@ -14,6 +14,7 @@ Build-Depends: debhelper-compat (= 12),
                python3-numpy,
                python3-pandas,
                python3-pyproj,
+               python3-pyresample,
                python3-pytest,
                python3-scipy,
                python3-setuptools,


=====================================
debian/copyright
=====================================
@@ -42,7 +42,7 @@ License: public-domain
  For more information, please refer to <http://unlicense.org/>
 
 Files: debian/*
-Copyright: 2018-2022, Antonio Valentino <antonio.valentino at tiscali.it>
+Copyright: 2018-2023, Antonio Valentino <antonio.valentino at tiscali.it>
 License: GPL-3+
 
 License: GPL-3+


=====================================
debian/patches/0001-Skip-tests-using-external-data.patch
=====================================
@@ -101,10 +101,10 @@ index 3af03ef..34ccc24 100644
      lon1, lat1 = load_1km_lonlat_as_xarray_dask()
      # remove 1 row from the end
 diff --git a/setup.py b/setup.py
-index 302aedb..78594f3 100644
+index 79c78dd..8dec19c 100644
 --- a/setup.py
 +++ b/setup.py
-@@ -114,7 +114,7 @@ if __name__ == "__main__":
+@@ -113,7 +113,7 @@ if __name__ == "__main__":
                         "Programming Language :: Cython",
                         "Topic :: Scientific/Engineering"],
            url="https://github.com/pytroll/python-geotiepoints",


=====================================
debian/tests/control
=====================================
@@ -1,2 +1,2 @@
 Tests: python3
-Depends: @, python3-all, python3-h5py, python3-pytest, python3-pyproj
+Depends: @, python3-all, python3-h5py, python3-pytest, python3-pyproj, python3-pyresample


=====================================
geotiepoints/geointerpolator.py
=====================================
@@ -18,7 +18,8 @@
 """Geographical interpolation (lon/lats)."""
 
 import numpy as np
-from geotiepoints.interpolator import Interpolator
+from geotiepoints.interpolator import Interpolator, MultipleGridInterpolator
+
 
 EARTH_RADIUS = 6370997.0
 
@@ -83,10 +84,34 @@ def xyz2lonlat(x__, y__, z__, radius=EARTH_RADIUS, thr=0.8, low_lat_z=True):
         # if we are at low latitudes - small z, then get the
         # latitudes only from z. If we are at high latitudes (close to the poles)
         # then derive the latitude using x and y:
-        lat_mask_cond = np.logical_and(
-            np.less(z__, thr * radius),
-            np.greater(z__, -1. * thr * radius))
-        lat_z_only = 90 - np.rad2deg(np.arccos(z__ / radius))
+        normalized_z = z__ / radius
+        lat_mask_cond = abs(normalized_z) < thr
+        lat_z_only = 90 - np.rad2deg(np.arccos(normalized_z))
         lats = np.where(lat_mask_cond, lat_z_only, lats)
 
     return lons, lats
+
+
+class GeoGridInterpolator(MultipleGridInterpolator):
+    """Interpolate geographical coordinates from a regular grid of tie points."""
+
+    def __init__(self, tie_points, *data, **kwargs):
+        """Set up the interpolator."""
+        if len(data) == 1:
+            xyz = data[0].get_cartesian_coords()
+            data = [xyz[:, :, 0], xyz[:, :, 1], xyz[:, :, 2]]
+        elif len(data) == 2:
+            data = lonlat2xyz(*data)
+        else:
+            raise ValueError("Either pass lon/lats or a pyresample definition.")
+        super().__init__(tie_points, *data, **kwargs)
+
+    def interpolate(self, fine_points, **kwargs):
+        """Interpolate to *fine_points*."""
+        x, y, z = super().interpolate(fine_points, **kwargs)
+        return xyz2lonlat(x, y, z)
+
+    def interpolate_to_shape(self, shape, **kwargs):
+        """Interpolate to a given *shape*."""
+        fine_points = [np.arange(size) for size in shape]
+        return self.interpolate(fine_points, **kwargs)


=====================================
geotiepoints/interpolator.py
=====================================
@@ -20,15 +20,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Generic interpolation routines.
-"""
+"""Generic interpolation routines."""
+
 import numpy as np
-from scipy.interpolate import RectBivariateSpline, splev, splrep
+from scipy.interpolate import RectBivariateSpline, splev, splrep, RegularGridInterpolator
 
 
 def generic_modis5kmto1km(*data5km):
-    """Getting 1km data for modis from 5km tiepoints.
-    """
+    """Get 1km data for modis from 5km tiepoints."""
     cols5km = np.arange(2, 1354, 5)
     cols1km = np.arange(1354)
     lines = data5km[0].shape[0] * 5
@@ -51,7 +50,7 @@ def generic_modis5kmto1km(*data5km):
 
 
 def _linear_extrapolate(pos, data, xev):
-    """
+    """Perform linear extrapolation.
 
     >>> import numpy as np
     >>> pos = np.array([1, 2])
@@ -69,27 +68,23 @@ def _linear_extrapolate(pos, data, xev):
         raise ValueError("len(pos) and the number of lines of data"
                          " must be 2.")
 
-    return data[1] + ((xev - pos[1]) / (1.0 * (pos[0] - pos[1])) *
-                      (data[0] - data[1]))
+    return data[1] + ((xev - pos[1]) / (1.0 * (pos[0] - pos[1])) * (data[0] - data[1]))
 
 
-class Interpolator(object):
+class Interpolator:
+    """Handles interpolation of data from a grid of tie points.
 
-    """
-    Handles interpolation of data from a grid of tie points.  It is preferable
-    to have tie-points out till the edges if the tiepoint grid, but a method is
-    provided to extrapolate linearly the tiepoints to the borders of the
+    It is preferable to have tie-points out till the edges if the tiepoint grid,
+    but a method is provided to extrapolate linearly the tiepoints to the borders of the
     grid. The extrapolation is done automatically if it seems necessary.
 
     Uses numpy and scipy.
 
-    The constructor takes in the tiepointed data as *data*, the
-    *tiepoint_grid* and the desired *final_grid*. As optional arguments, one
-    can provide *kx_* and *ky_* as interpolation orders (in x and y directions
-    respectively), and the *chunksize* if the data has to be handled by pieces
-    along the y axis (this affects how the extrapolator behaves). If
-    *chunksize* is set, don't forget to adjust the interpolation orders
-    accordingly: the interpolation is indeed done globaly (not chunkwise).
+    The constructor takes in the tiepointed data as *data*, the *tiepoint_grid* and the desired *final_grid*. As
+    optional arguments, one can provide *kx_* and *ky_* as interpolation orders (in x and y directions respectively),
+    and the *chunksize* if the data has to be handled by pieces along the y axis (this affects how the extrapolator
+    behaves). If *chunksize* is set, don't forget to adjust the interpolation orders accordingly: the interpolation
+    is indeed done globaly (not chunkwise).
     """
 
     def __init__(self, data, tiepoint_grid, final_grid,
@@ -108,10 +103,7 @@ class Interpolator(object):
         self.kx_, self.ky_ = kx_, ky_
 
     def fill_borders(self, *args):
-        """Extrapolate tiepoint lons and lats to fill in the border of the
-        chunks.
-        """
-
+        """Extrapolate tiepoint lons and lats to fill in the border of the chunks."""
         to_run = []
         cases = {"y": self._fill_row_borders,
                  "x": self._fill_col_borders}
@@ -125,11 +117,7 @@ class Interpolator(object):
             fun()
 
     def _extrapolate_cols(self, data, first=True, last=True):
-        """Extrapolate the column of data, to get the first and last together
-        with the data.
-
-        """
-
+        """Extrapolate the column of data, to get the first and last together with the data."""
         if first:
             pos = self.col_indices[:2]
             first_column = _linear_extrapolate(pos,
@@ -155,9 +143,7 @@ class Interpolator(object):
             return data
 
     def _fill_col_borders(self):
-        """Add the first and last column to the data by extrapolation.
-        """
-
+        """Add the first and last column to the data by extrapolation."""
         first = True
         last = True
         if self.col_indices[0] == self.hcol_indices[0]:
@@ -179,10 +165,7 @@ class Interpolator(object):
                                                np.array([self.hcol_indices[-1]])))
 
     def _extrapolate_rows(self, data, row_indices, first_index, last_index):
-        """Extrapolate the rows of data, to get the first and last together
-        with the data.
-        """
-
+        """Extrapolate the rows of data, to get the first and last together with the data."""
         pos = row_indices[:2]
         first_row = _linear_extrapolate(pos,
                                         (data[0, :], data[1, :]),
@@ -196,21 +179,19 @@ class Interpolator(object):
                           np.expand_dims(last_row, 0)))
 
     def _fill_row_borders(self):
-        """Add the first and last rows to the data by extrapolation.
-        """
+        """Add the first and last rows to the data by extrapolation."""
         lines = len(self.hrow_indices)
         chunk_size = self.chunk_size or lines
         factor = len(self.hrow_indices) / len(self.row_indices)
 
         tmp_data = []
-        for num in range(len(self.tie_data)):
+        for _num in range(len(self.tie_data)):
             tmp_data.append([])
         row_indices = []
 
         for index in range(0, lines, chunk_size):
             indices = np.logical_and(self.row_indices >= index / factor,
-                                     self.row_indices < (index
-                                                         + chunk_size) / factor)
+                                     self.row_indices < (index + chunk_size) / factor)
             ties = np.argwhere(indices).squeeze()
             tiepos = self.row_indices[indices].squeeze()
 
@@ -226,16 +207,14 @@ class Interpolator(object):
 
             row_indices.append(np.array([self.hrow_indices[index]]))
             row_indices.append(tiepos)
-            row_indices.append(np.array([self.hrow_indices[index
-                                                           + chunk_size - 1]]))
+            row_indices.append(np.array([self.hrow_indices[index + chunk_size - 1]]))
 
         for num in range(len(self.tie_data)):
             self.tie_data[num] = np.vstack(tmp_data[num])
         self.row_indices = np.concatenate(row_indices)
 
     def _interp(self):
-        """Interpolate the cartesian coordinates.
-        """
+        """Interpolate the cartesian coordinates."""
         if np.array_equal(self.hrow_indices, self.row_indices):
             return self._interp1d()
 
@@ -254,8 +233,7 @@ class Interpolator(object):
             self.new_data[num] = new_data_.reshape(xpoints.shape).T.copy(order='C')
 
     def _interp1d(self):
-        """Interpolate in one dimension.
-        """
+        """Interpolate in one dimension."""
         lines = len(self.hrow_indices)
 
         for num, data in enumerate(self.tie_data):
@@ -269,8 +247,104 @@ class Interpolator(object):
                     self.hcol_indices, tck, der=0)
 
     def interpolate(self):
-        """Do the interpolation, and return resulting longitudes and latitudes.
-        """
+        """Do the interpolation, and return resulting longitudes and latitudes."""
         self._interp()
 
         return self.new_data
+
+
+class SingleGridInterpolator:
+    """An interpolator for a single 2d data array."""
+
+    def __init__(self, points, values, **kwargs):
+        """Set up the interpolator.
+
+        *kwargs* are passed to the underlying RegularGridInterpolator instance.
+        So for example, to allow extrapolation, the kwargs can be `bounds_error=False, fill_value=None`.
+        """
+        self.interpolator = RegularGridInterpolator(points, values, **kwargs)
+        self.points = points
+        self.values = values
+
+    def interpolate(self, fine_points, method="linear", chunks=None):
+        """Interpolate the value points to the *fine_points* grid.
+
+        Args:
+            fine_points: the points on the target grid to use, as one dimensional vectors for each dimension.
+            method: the method to use for interpolation as described in RegularGridInterpolator's documentation.
+                    Default is "linear".
+            chunks: If not None, a lazy (dask-based) interpolation will be performed using the chunk sizes specified.
+                    The result will be a dask array in this case. Defaults to None.
+        """
+        if chunks is not None:
+            res = self.interpolate_dask(fine_points, method=method, chunks=chunks)
+        else:
+            res = self.interpolate_numpy(fine_points, method=method)
+
+        return res
+
+    def interpolate_dask(self, fine_points, method, chunks):
+        """Interpolate (lazily) to a dask array."""
+        from dask.base import tokenize
+        import dask.array as da
+        v_fine_points, h_fine_points = fine_points
+        shape = len(v_fine_points), len(h_fine_points)
+
+        try:
+            v_chunk_size, h_chunk_size = chunks
+        except TypeError:
+            v_chunk_size, h_chunk_size = chunks, chunks
+
+        vchunks = range(0, shape[0], v_chunk_size)
+        hchunks = range(0, shape[1], h_chunk_size)
+
+        token = tokenize(v_chunk_size, h_chunk_size, self.points, self.values, fine_points, method)
+        name = 'interpolate-' + token
+
+        dskx = {(name, i, j): (self.interpolate_slices,
+                               (slice(vcs, min(vcs + v_chunk_size, shape[0])),
+                                slice(hcs, min(hcs + h_chunk_size, shape[1]))),
+                               method
+                               )
+                for i, vcs in enumerate(vchunks)
+                for j, hcs in enumerate(hchunks)
+                }
+
+        res = da.Array(dskx, name, shape=list(shape),
+                       chunks=(v_chunk_size, h_chunk_size),
+                       dtype=self.values.dtype)
+        return res
+
+    def interpolate_numpy(self, fine_points, method="linear"):
+        """Interpolate to a numpy array."""
+        fine_x, fine_y = np.meshgrid(*fine_points, indexing='ij')
+        return self.interpolator((fine_x, fine_y), method=method)
+
+    def interpolate_slices(self, fine_points, method="linear"):
+        """Interpolate using slices.
+
+        *fine_points* are a tuple of slices for the y and x dimensions
+        """
+        slice_y, slice_x = fine_points
+        points_y = np.arange(slice_y.start, slice_y.stop)
+        points_x = np.arange(slice_x.start, slice_x.stop)
+        fine_points = points_y, points_x
+
+        return self.interpolate_numpy(fine_points, method=method)
+
+
+class MultipleGridInterpolator:
+    """Interpolator that works on multiple data arrays."""
+
+    def __init__(self, tie_points, *data, **kwargs):
+        """Set up the interpolator from the multiple `data` arrays."""
+        self.interpolators = []
+        for values in data:
+            self.interpolators.append(SingleGridInterpolator(tie_points, values, **kwargs))
+
+    def interpolate(self, fine_points, **kwargs):
+        """Interpolate the data.
+
+        The keyword arguments will be passed on to SingleGridInterpolator's interpolate function.
+        """
+        return (interpolator.interpolate(fine_points, **kwargs) for interpolator in self.interpolators)


=====================================
geotiepoints/tests/test_geointerpolator.py
=====================================
@@ -19,97 +19,95 @@
 import unittest
 
 import numpy as np
+import pytest
+from pyresample.geometry import SwathDefinition
 
-from geotiepoints.geointerpolator import GeoInterpolator
+from geotiepoints.geointerpolator import GeoInterpolator, GeoGridInterpolator
 
-TIES_EXP1 = np.array([[6384905.78040055,  6381081.08333225,  6371519.34066148,
-                       6328950.00792935,  6253610.69157758,  6145946.19489936,
+TIES_EXP1 = np.array([[6384905.78040055, 6381081.08333225, 6371519.34066148,
+                       6328950.00792935, 6253610.69157758, 6145946.19489936,
                        6124413.29556372],
-                      [6377591.95940176,  6370997.,  6354509.6014956,
-                       6305151.62592155,  6223234.99818839,  6109277.14889072,
+                      [6377591.95940176, 6370997., 6354509.6014956,
+                       6305151.62592155, 6223234.99818839, 6109277.14889072,
                        6086485.57903118],
-                      [6359307.40690478,  6345786.79166939,  6311985.2535809,
-                       6245655.67090206,  6147295.76471541,  6017604.5338691,
+                      [6359307.40690478, 6345786.79166939, 6311985.2535809,
+                       6245655.67090206, 6147295.76471541, 6017604.5338691,
                        5991666.28769983],
-                      [6351993.58590599,  6335702.70833714,  6294975.51441502,
-                       6221857.28889426,  6116920.07132621,  5980935.48786045,
+                      [6351993.58590599, 6335702.70833714, 6294975.51441502,
+                       6221857.28889426, 6116920.07132621, 5980935.48786045,
                        5953738.5711673],
-                      [6338032.26190294,  6320348.4990906,  6276139.09205974,
-                       6199670.56624433,  6091551.90273768,  5952590.38414781,
+                      [6338032.26190294, 6320348.4990906, 6276139.09205974,
+                       6199670.56624433, 6091551.90273768, 5952590.38414781,
                        5924798.08042984],
-                      [6290665.5946295,  6270385.16249031,  6219684.08214232,
-                       6137100.75832981,  6023313.2794414,  5879194.72399075,
+                      [6290665.5946295, 6270385.16249031, 6219684.08214232,
+                       6137100.75832981, 6023313.2794414, 5879194.72399075,
                        5850371.01290062],
-                      [6172248.92644589,  6145476.82098957,  6078546.55734877,
-                       5980676.23854351,  5852716.72120069,  5695705.57359808,
+                      [6172248.92644589, 6145476.82098957, 6078546.55734877,
+                       5980676.23854351, 5852716.72120069, 5695705.57359808,
                        5664303.34407756],
-                      [6124882.25917245,  6095513.48438928,  6022091.54743135,
-                       5918106.430629,  5784478.09790441,  5622309.91344102,
+                      [6124882.25917245, 6095513.48438928, 6022091.54743135,
+                       5918106.430629, 5784478.09790441, 5622309.91344102,
                        5589876.27654834]])
 
-TIES_EXP2 = np.array([[6372937.31273379,  6370997.,  6366146.21816553,
-                       6351605.98629588,  6327412.61244969,  6293626.50067273,
+TIES_EXP2 = np.array([[6372937.31273379, 6370997., 6366146.21816553,
+                       6351605.98629588, 6327412.61244969, 6293626.50067273,
                        6286869.27831734],
-                      [6353136.46335726,  6345786.79166939,  6327412.61244969,
-                       6299445.69529922,  6261968.60390423,  6215087.60607344,
+                      [6353136.46335726, 6345786.79166939, 6327412.61244969,
+                       6299445.69529922, 6261968.60390423, 6215087.60607344,
                        6205711.40650728]])
 
-TIES_EXP4 = np.array([[6381081.08333225,  6381639.66045187,  6372470.10269454,
-                       6353590.21586788,  6325042.05851245],
-                      [6370997.,  6366146.21816553,  6351605.98629588,
-                       6327412.61244969,  6293626.50067273],
-                      [6345786.79166939,  6327412.61244969,  6299445.69529922,
-                       6261968.60390423,  6215087.60607344],
-                      [6335702.70833714,  6311919.17016336,  6278581.57890056,
-                       6235791.00048604,  6183672.04823372]])
-
-TIES_EXP5 = np.array([[6381081.08333225,  6371519.34066148,  6328950.00792935,
-                       6253610.69157758,  6145946.19489936],
-                      [6370997.,  6354509.6014956,  6305151.62592155,
-                       6223234.99818839,  6109277.14889072],
-                      [6345786.79166939,  6311985.2535809,  6245655.67090206,
-                       6147295.76471541,  6017604.5338691],
-                      [6270385.16249031,  6219684.08214232,  6137100.75832981,
-                       6023313.2794414,  5879194.72399075],
-                      [6145476.82098957,  6078546.55734877,  5980676.23854351,
-                       5852716.72120069,  5695705.57359808],
-                      [6095513.48438928,  6022091.54743135,  5918106.430629,
-                       5784478.09790441,  5622309.91344102]])
-
-TIES_EXP6 = np.array([[6381081.08333225,  6371519.34066148,  6328950.00792935,
-                       6253610.69157758,  6145946.19489936],
-                      [6370997.,  6354509.6014956,  6305151.62592155,
-                       6223234.99818839,  6109277.14889072],
-                      [6345786.79166939,  6311985.2535809,  6245655.67090206,
-                       6147295.76471541,  6017604.5338691],
-                      [6335702.70833714,  6294975.51441502,  6221857.28889426,
-                       6116920.07132621,  5980935.48786045],
-                      [6320348.4990906,  6276139.09205974,  6199670.56624433,
-                       6091551.90273768,  5952590.38414781],
-                      [6270385.16249031,  6219684.08214232,  6137100.75832981,
-                       6023313.2794414,  5879194.72399075],
-                      [6145476.82098957,  6078546.55734877,  5980676.23854351,
-                       5852716.72120069,  5695705.57359808],
-                      [6095513.48438928,  6022091.54743135,  5918106.430629,
-                       5784478.09790441,  5622309.91344102]])
-
-TIES_EXP7 = np.array([[6372937.31273379,  6370997.,  6366146.21816553,
-                       6351605.98629588,  6327412.61244969,  6293626.50067273,
+TIES_EXP4 = np.array([[6381081.08333225, 6381639.66045187, 6372470.10269454,
+                       6353590.21586788, 6325042.05851245],
+                      [6370997., 6366146.21816553, 6351605.98629588,
+                       6327412.61244969, 6293626.50067273],
+                      [6345786.79166939, 6327412.61244969, 6299445.69529922,
+                       6261968.60390423, 6215087.60607344],
+                      [6335702.70833714, 6311919.17016336, 6278581.57890056,
+                       6235791.00048604, 6183672.04823372]])
+
+TIES_EXP5 = np.array([[6381081.08333225, 6371519.34066148, 6328950.00792935,
+                       6253610.69157758, 6145946.19489936],
+                      [6370997., 6354509.6014956, 6305151.62592155,
+                       6223234.99818839, 6109277.14889072],
+                      [6345786.79166939, 6311985.2535809, 6245655.67090206,
+                       6147295.76471541, 6017604.5338691],
+                      [6270385.16249031, 6219684.08214232, 6137100.75832981,
+                       6023313.2794414, 5879194.72399075],
+                      [6145476.82098957, 6078546.55734877, 5980676.23854351,
+                       5852716.72120069, 5695705.57359808],
+                      [6095513.48438928, 6022091.54743135, 5918106.430629,
+                       5784478.09790441, 5622309.91344102]])
+
+TIES_EXP6 = np.array([[6381081.08333225, 6371519.34066148, 6328950.00792935,
+                       6253610.69157758, 6145946.19489936],
+                      [6370997., 6354509.6014956, 6305151.62592155,
+                       6223234.99818839, 6109277.14889072],
+                      [6345786.79166939, 6311985.2535809, 6245655.67090206,
+                       6147295.76471541, 6017604.5338691],
+                      [6335702.70833714, 6294975.51441502, 6221857.28889426,
+                       6116920.07132621, 5980935.48786045],
+                      [6320348.4990906, 6276139.09205974, 6199670.56624433,
+                       6091551.90273768, 5952590.38414781],
+                      [6270385.16249031, 6219684.08214232, 6137100.75832981,
+                       6023313.2794414, 5879194.72399075],
+                      [6145476.82098957, 6078546.55734877, 5980676.23854351,
+                       5852716.72120069, 5695705.57359808],
+                      [6095513.48438928, 6022091.54743135, 5918106.430629,
+                       5784478.09790441, 5622309.91344102]])
+
+TIES_EXP7 = np.array([[6372937.31273379, 6370997., 6366146.21816553,
+                       6351605.98629588, 6327412.61244969, 6293626.50067273,
                        6286869.27831734],
-                      [6353136.46335726,  6345786.79166939,  6327412.61244969,
-                       6299445.69529922,  6261968.60390423,  6215087.60607344,
+                      [6353136.46335726, 6345786.79166939, 6327412.61244969,
+                       6299445.69529922, 6261968.60390423, 6215087.60607344,
                        6205711.40650728]])
 
 
 class TestGeoInterpolator(unittest.TestCase):
-
-    """Class for unit testing the ancillary interpolation functions
-    """
-
-    def setUp(self):
-        pass
+    """Class for unit testing the ancillary interpolation functions."""
 
     def test_fillborders(self):
+        """Test filling borders."""
         lons = np.arange(20).reshape((4, 5), order="F")
         lats = np.arange(20).reshape((4, 5), order="C")
         lines = np.array([2, 7, 12, 17]) / 5.0
@@ -122,11 +120,12 @@ class TestGeoInterpolator(unittest.TestCase):
 
         np.testing.assert_allclose(satint.tie_data[0], TIES_EXP1)
         np.testing.assert_allclose(satint.row_indices, np.array(
-            [0,  2,  7,  9, 10, 12, 17, 19]) / 5.0)
+            [0, 2, 7, 9, 10, 12, 17, 19]) / 5.0)
         self.assertTrue(
-            np.allclose(satint.col_indices, np.array([0,  2,  7, 12, 17, 22, 23])))
+            np.allclose(satint.col_indices, np.array([0, 2, 7, 12, 17, 22, 23])))
 
     def test_extrapolate_cols(self):
+        """Test extrapolating columns."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -139,6 +138,7 @@ class TestGeoInterpolator(unittest.TestCase):
                                     TIES_EXP2))
 
     def test_fill_col_borders(self):
+        """Test filling the column borders."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -149,9 +149,10 @@ class TestGeoInterpolator(unittest.TestCase):
         satint._fill_col_borders()
         np.testing.assert_allclose(satint.tie_data[0], TIES_EXP7)
         np.testing.assert_allclose(satint.col_indices,
-                                   np.array([0,  2,  7, 12, 17, 22, 23]))
+                                   np.array([0, 2, 7, 12, 17, 22, 23]))
 
     def test_extrapolate_rows(self):
+        """Test extrapolation of rows."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -164,6 +165,7 @@ class TestGeoInterpolator(unittest.TestCase):
                                    TIES_EXP4)
 
     def test_fill_row_borders(self):
+        """Test filling the row borders."""
         lons = np.arange(20).reshape((4, 5), order="F")
         lats = np.arange(20).reshape((4, 5), order="C")
         lines = np.array([2, 7, 12, 17]) / 5.0
@@ -175,11 +177,83 @@ class TestGeoInterpolator(unittest.TestCase):
         np.testing.assert_allclose(satint.tie_data[0],
                                    TIES_EXP5)
         np.testing.assert_allclose(satint.row_indices,
-                                   np.array([0,  2,  7, 12, 17, 19]) / 5.0)
+                                   np.array([0, 2, 7, 12, 17, 19]) / 5.0)
         satint = GeoInterpolator((lons, lats), (lines, cols),
                                  (hlines, hcols), chunk_size=10)
         satint._fill_row_borders()
         np.testing.assert_allclose(satint.tie_data[0],
                                    TIES_EXP6)
         np.testing.assert_allclose(satint.row_indices,
-                                   np.array([0,  2,  7,  9, 10, 12, 17, 19]) / 5.0)
+                                   np.array([0, 2, 7, 9, 10, 12, 17, 19]) / 5.0)
+
+
+TIE_LONS = np.array([[1, 2, 3, 4],
+                     [1, 2, 3, 4],
+                     [1, 2, 3, 4],
+                     [1, 2, 3, 4],
+                     [1, 2, 3, 4]])
+
+TIE_LATS = np.array([[1, 1, 1, 1],
+                     [2, 2, 2, 2],
+                     [3, 3, 3, 3],
+                     [4, 4, 4, 4],
+                     [5, 5, 5, 5]])
+
+
+class TestGeoGridInterpolator:
+    """Test the GeoGridInterpolator."""
+
+    @pytest.mark.parametrize("args", ((TIE_LONS, TIE_LATS),
+                                      [SwathDefinition(TIE_LONS, TIE_LATS)]
+                                      ))
+    def test_geogrid_interpolation(self, args):
+        """Test that the interpolator works with both explicit tie-point arrays and swath definition objects."""
+        x_points = np.array([0, 1, 3, 7])
+        y_points = np.array([0, 1, 3, 7, 15])
+
+        interpolator = GeoGridInterpolator((y_points, x_points), *args)
+
+        fine_x_points = np.arange(8)
+        fine_y_points = np.arange(16)
+
+        lons, lats = interpolator.interpolate((fine_y_points, fine_x_points))
+
+        lons_expected = np.array([1., 2., 2.5, 3., 3.25, 3.5, 3.75, 4.])
+        lats_expected = np.array([1., 2., 2.5, 3., 3.25, 3.5, 3.75, 4., 4.125,
+                                  4.25, 4.375, 4.5, 4.625, 4.75, 4.875, 5.])
+
+        np.testing.assert_allclose(lons[0, :], lons_expected, rtol=5e-5)
+        np.testing.assert_allclose(lats[:, 0], lats_expected, rtol=5e-5)
+
+    def test_geogrid_interpolation_counts_its_arguments(self):
+        """Test that an arbitrary number of argument is not allowed in the interpolator."""
+        with pytest.raises(ValueError):
+            _ = GeoGridInterpolator((None, None), None, None, None)
+
+    def test_geogrid_interpolation_to_shape(self):
+        """Test that the interpolator works with both explicit tie-point arrays and swath definition objects."""
+        x_points = np.array([0, 1, 3, 7])
+        y_points = np.array([0, 1, 3, 7, 15])
+
+        interpolator = GeoGridInterpolator((y_points, x_points), TIE_LONS, TIE_LATS)
+
+        lons, lats = interpolator.interpolate_to_shape((16, 8))
+
+        lons_expected = np.array([1., 2., 2.5, 3., 3.25, 3.5, 3.75, 4.])
+        lats_expected = np.array([1., 2., 2.5, 3., 3.25, 3.5, 3.75, 4., 4.125,
+                                  4.25, 4.375, 4.5, 4.625, 4.75, 4.875, 5.])
+
+        np.testing.assert_allclose(lons[0, :], lons_expected, rtol=5e-5)
+        np.testing.assert_allclose(lats[:, 0], lats_expected, rtol=5e-5)
+
+    def test_geogrid_interpolation_can_extrapolate(self):
+        """Test that the interpolator can also extrapolate given the right parameters."""
+        x_points = np.array([0, 1, 3, 7])
+        y_points = np.array([0, 1, 3, 7, 15])
+
+        interpolator = GeoGridInterpolator((y_points, x_points), TIE_LONS, TIE_LATS,
+                                           bounds_error=False, fill_value=None)
+
+        lons, lats = interpolator.interpolate_to_shape((16, 16), method="cubic")
+
+        assert lons.shape == (16, 16)


=====================================
geotiepoints/tests/test_interpolator.py
=====================================
@@ -18,36 +18,40 @@
 
 import unittest
 import numpy as np
+import pytest
+from unittest import mock
 
 from geotiepoints.interpolator import Interpolator
+from geotiepoints.interpolator import SingleGridInterpolator
 
-TIES_EXP1 = np.array([[-2.00000000e+00,  -4.00000000e-01,   3.60000000e+00,
-                       7.60000000e+00,   1.16000000e+01,   1.56000000e+01,
+TIES_EXP1 = np.array([[-2.00000000e+00, -4.00000000e-01, 3.60000000e+00,
+                       7.60000000e+00, 1.16000000e+01, 1.56000000e+01,
                        1.64000000e+01],
-                      [-1.60000000e+00,   0.00000000e+00,   4.00000000e+00,
-                       8.00000000e+00,   1.20000000e+01,   1.60000000e+01,
+                      [-1.60000000e+00, 0.00000000e+00, 4.00000000e+00,
+                       8.00000000e+00, 1.20000000e+01, 1.60000000e+01,
                        1.68000000e+01],
-                      [-6.00000000e-01,   1.00000000e+00,   5.00000000e+00,
-                       9.00000000e+00,   1.30000000e+01,   1.70000000e+01,
+                      [-6.00000000e-01, 1.00000000e+00, 5.00000000e+00,
+                       9.00000000e+00, 1.30000000e+01, 1.70000000e+01,
                        1.78000000e+01],
-                      [-2.00000000e-01,   1.40000000e+00,   5.40000000e+00,
-                       9.40000000e+00,   1.34000000e+01,   1.74000000e+01,
+                      [-2.00000000e-01, 1.40000000e+00, 5.40000000e+00,
+                       9.40000000e+00, 1.34000000e+01, 1.74000000e+01,
                        1.82000000e+01],
-                      [4.44089210e-16,   1.60000000e+00,   5.60000000e+00,
-                       9.60000000e+00,   1.36000000e+01,   1.76000000e+01,
+                      [4.44089210e-16, 1.60000000e+00, 5.60000000e+00,
+                       9.60000000e+00, 1.36000000e+01, 1.76000000e+01,
                        1.84000000e+01],
-                      [4.00000000e-01,   2.00000000e+00,   6.00000000e+00,
-                       1.00000000e+01,   1.40000000e+01,   1.80000000e+01,
+                      [4.00000000e-01, 2.00000000e+00, 6.00000000e+00,
+                       1.00000000e+01, 1.40000000e+01, 1.80000000e+01,
                        1.88000000e+01],
-                      [1.40000000e+00,   3.00000000e+00,   7.00000000e+00,
-                       1.10000000e+01,   1.50000000e+01,   1.90000000e+01,
+                      [1.40000000e+00, 3.00000000e+00, 7.00000000e+00,
+                       1.10000000e+01, 1.50000000e+01, 1.90000000e+01,
                        1.98000000e+01],
-                      [1.80000000e+00,   3.40000000e+00,   7.40000000e+00,
-                       1.14000000e+01,   1.54000000e+01,   1.94000000e+01,
+                      [1.80000000e+00, 3.40000000e+00, 7.40000000e+00,
+                       1.14000000e+01, 1.54000000e+01, 1.94000000e+01,
                        2.02000000e+01]])
 
 
 class TestInterpolator(unittest.TestCase):
+    """Test the interpolator."""
 
     # def test_fill_borders(self):
     #     lons = np.arange(20).reshape((4, 5), order="F")
@@ -67,6 +71,7 @@ class TestInterpolator(unittest.TestCase):
     #                                 np.array([0,  2,  7, 12, 17, 22, 23])))
 
     def test_extrapolate_cols(self):
+        """Test extrapolation of the columns."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -75,10 +80,11 @@ class TestInterpolator(unittest.TestCase):
         hcols = np.arange(24)
         satint = Interpolator((lons, lats), (lines, cols), (hlines, hcols))
         self.assertTrue(np.allclose(satint._extrapolate_cols(satint.tie_data[0]),
-                                    np.array([[-0.8,  0.,  2.,  4.,  6.,  8.,  8.4],
-                                              [0.2,  1.,  3.,  5.,  7.,  9.,  9.4]])))
+                                    np.array([[-0.8, 0., 2., 4., 6., 8., 8.4],
+                                              [0.2, 1., 3., 5., 7., 9., 9.4]])))
 
     def test_fill_col_borders(self):
+        """Test filling the column borders."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -88,12 +94,13 @@ class TestInterpolator(unittest.TestCase):
         satint = Interpolator((lons, lats), (lines, cols), (hlines, hcols))
         satint._fill_col_borders()
         self.assertTrue(np.allclose(satint.tie_data[0],
-                                    np.array([[-0.8,  0.,  2.,  4.,  6.,  8.,  8.4],
-                                              [0.2,  1.,  3.,  5.,  7.,  9.,  9.4]])))
+                                    np.array([[-0.8, 0., 2., 4., 6., 8., 8.4],
+                                              [0.2, 1., 3., 5., 7., 9., 9.4]])))
         self.assertTrue(np.allclose(satint.col_indices,
-                                    np.array([0,  2,  7, 12, 17, 22, 23])))
+                                    np.array([0, 2, 7, 12, 17, 22, 23])))
 
     def test_extrapolate_rows(self):
+        """Test extrapolation of rows."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -106,12 +113,13 @@ class TestInterpolator(unittest.TestCase):
         self.assertTrue(np.allclose(satint._extrapolate_rows(lons,
                                                              lines,
                                                              first_idx, last_idx),
-                                    np.array([[-0.4,  1.6,  3.6,  5.6,  7.6],
-                                              [0.,  2.,  4.,  6.,  8.],
-                                              [1.,  3.,  5.,  7.,  9.],
-                                              [1.4,  3.4,  5.4,  7.4,  9.4]])))
+                                    np.array([[-0.4, 1.6, 3.6, 5.6, 7.6],
+                                              [0., 2., 4., 6., 8.],
+                                              [1., 3., 5., 7., 9.],
+                                              [1.4, 3.4, 5.4, 7.4, 9.4]])))
 
     def test_results_in_c_order(self):
+        """Test that the results are in C order."""
         lons = np.arange(10).reshape((2, 5), order="F")
         lats = np.arange(10).reshape((2, 5), order="C")
         lines = np.array([2, 7])
@@ -122,37 +130,251 @@ class TestInterpolator(unittest.TestCase):
         interp_results = satint.interpolate()
         assert interp_results[0].flags['C_CONTIGUOUS'] is True
 
-    # def test_fill_row_borders(self):
-    #     lons = np.arange(20).reshape((4, 5), order="F")
-    #     lats = np.arange(20).reshape((4, 5), order="C")
-    #     lines = np.array([2, 7, 12, 17])
-    #     cols = np.array([2, 7, 12, 17, 22])
-    #     hlines = np.arange(20)
-    #     hcols = np.arange(24)
-    #     satint = Interpolator((lons, lats), (lines, cols), (hlines, hcols))
-    #     satint._fill_row_borders()
-    #     self.assertTrue(np.allclose(satint.tie_data[0],
-    #                                 np.array([[-0.4,   3.6,   7.6,  11.6,  15.6],
-    #                                           [0.,   4.,   8.,  12.,  16.],
-    #                                           [1.,   5.,   9.,  13.,  17.],
-    #                                           [2.,   6.,  10.,  14.,  18.],
-    #                                           [3.,   7.,  11.,  15.,  19.],
-    #                                           [3.4,   7.4,  11.4,  15.4,  19.4]])))
-    #     self.assertTrue(np.allclose(satint.row_indices,
-    #                                 np.array([0,  2,  7, 12, 17, 19])))
-    #     satint = Interpolator(
-    #         (lons, lats), (lines, cols), (hlines, hcols), chunk_size=10)
-    #     satint._fill_row_borders()
-    #     self.assertTrue(np.allclose(satint.tie_data[0],
-    #                                 np.array([[-0.4,   3.6,   7.6,  11.6,  15.6],
-    #                                           [0.,   4.,   8.,  12.,  16.],
-    #                                           [1.,   5.,   9.,  13.,  17.],
-    #                                           [1.4,   5.4,   9.4,
-    #                                               13.4,  17.4],
-    #                                           [1.6,   5.6,   9.6,
-    #                                               13.6,  17.6],
-    #                                           [2.,   6.,  10.,  14.,  18.],
-    #                                           [3.,   7.,  11.,  15.,  19.],
-    #                                           [3.4,   7.4,  11.4,  15.4,  19.4]])))
-    #     self.assertTrue(np.allclose(satint.row_indices,
-    # np.array([0,  2,  7,  9, 10, 12, 17, 19])))
+
+ at pytest.fixture
+def grid_interpolator():
+    """Return an instance of SingleGridInterpolator for testing."""
+    xpoints = np.array([0, 3, 7, 15])
+    ypoints = np.array([0, 3, 7, 15, 31])
+    data = np.array([[0, 1, 0, 1],
+                     [2, 2, 2, 1],
+                     [0, 3, 3, 3],
+                     [1, 2, 1, 2],
+                     [4, 4, 4, 4]])
+
+    return SingleGridInterpolator((ypoints, xpoints), data)
+
+
+class TestSingleGridInterpolator:
+    """Test for the SingleGridInterpolator."""
+
+    def setup_method(self):
+        """Set up the tests."""
+        self.expected = np.array([[0.00000000e+00, 5.91666667e-01, 9.09722222e-01,
+                                   1.00000000e+00, 9.08333333e-01, 6.80555556e-01,
+                                   3.62500000e-01, 1.11022302e-16, -3.61111111e-01,
+                                   -6.75000000e-01, -8.95833333e-01, -9.77777778e-01,
+                                   -8.75000000e-01, -5.41666667e-01, 6.80555556e-02,
+                                   1.00000000e+00],
+                                  [1.29188830e+00, 1.36660572e+00, 1.37255612e+00,
+                                   1.32180851e+00, 1.22643190e+00, 1.09849528e+00,
+                                   9.50067677e-01, 7.93218085e-01, 6.40015514e-01,
+                                   5.02528970e-01, 3.92827460e-01, 3.22979990e-01,
+                                   3.05055566e-01, 3.51123195e-01, 4.73251884e-01,
+                                   6.83510638e-01],
+                                  [1.90990691e+00, 1.81115953e+00, 1.72929138e+00,
+                                   1.66103090e+00, 1.60310651e+00, 1.55224664e+00,
+                                   1.50517970e+00, 1.45863412e+00, 1.40933833e+00,
+                                   1.35402074e+00, 1.28940979e+00, 1.21223389e+00,
+                                   1.11922148e+00, 1.00710096e+00, 8.72600776e-01,
+                                   7.12449341e-01],
+                                  [2.00000000e+00, 1.99166667e+00, 1.99305556e+00,
+                                   2.00000000e+00, 2.00833333e+00, 2.01388889e+00,
+                                   2.01250000e+00, 2.00000000e+00, 1.97222222e+00,
+                                   1.92500000e+00, 1.85416667e+00, 1.75555556e+00,
+                                   1.62500000e+00, 1.45833333e+00, 1.25138889e+00,
+                                   1.00000000e+00],
+                                  [1.70811170e+00, 1.97446571e+00, 2.17697619e+00,
+                                   2.32104863e+00, 2.41208851e+00, 2.45550132e+00,
+                                   2.45669253e+00, 2.42106763e+00, 2.35403210e+00,
+                                   2.26099144e+00, 2.14735111e+00, 2.01851661e+00,
+                                   1.87989341e+00, 1.73688701e+00, 1.59490288e+00,
+                                   1.45934650e+00],
+                                  [1.18018617e+00, 1.82589523e+00, 2.29418084e+00,
+                                   2.60650963e+00, 2.78434820e+00, 2.84916319e+00,
+                                   2.82242122e+00, 2.72558891e+00, 2.58013287e+00,
+                                   2.40751974e+00, 2.22921614e+00, 2.06668868e+00,
+                                   1.94140399e+00, 1.87482869e+00, 1.88842940e+00,
+                                   2.00367275e+00],
+                                  [5.62167553e-01, 1.61229380e+00, 2.35779706e+00,
+                                   2.83871581e+00, 3.09508855e+00, 3.16695379e+00,
+                                   3.09435002e+00, 2.91731573e+00, 2.67588943e+00,
+                                   2.41010961e+00, 2.16001476e+00, 1.96564339e+00,
+                                   1.86703400e+00, 1.90422507e+00, 2.11725511e+00,
+                                   2.54616261e+00],
+                                  [-5.55111512e-16, 1.40000000e+00, 2.38095238e+00,
+                                   3.00000000e+00, 3.31428571e+00, 3.38095238e+00,
+                                   3.25714286e+00, 3.00000000e+00, 2.66666667e+00,
+                                   2.31428571e+00, 2.00000000e+00, 1.78095238e+00,
+                                   1.71428571e+00, 1.85714286e+00, 2.26666667e+00,
+                                   3.00000000e+00],
+                                  [-3.87768035e-01, 1.24340379e+00, 2.37526033e+00,
+                                   3.07734929e+00, 3.41921836e+00, 3.47041522e+00,
+                                   3.30048758e+00, 2.97898313e+00, 2.57544955e+00,
+                                   2.15943455e+00, 1.80048581e+00, 1.56815104e+00,
+                                   1.53197791e+00, 1.76151412e+00, 2.32630738e+00,
+                                   3.29590536e+00],
+                                  [-5.92170878e-01, 1.14910071e+00, 2.34627828e+00,
+                                   3.07636778e+00, 3.41637520e+00, 3.44330649e+00,
+                                   3.23416762e+00, 2.86596457e+00, 2.41570330e+00,
+                                   1.96038977e+00, 1.57702995e+00, 1.34262982e+00,
+                                   1.33419533e+00, 1.62873246e+00, 2.30324718e+00,
+                                   3.43474544e+00],
+                                  [-6.31638547e-01, 1.11173771e+00, 2.29804954e+00,
+                                   3.00731383e+00, 3.31954746e+00, 3.31476733e+00,
+                                   3.07299031e+00, 2.67423329e+00, 2.19851317e+00,
+                                   1.72584681e+00, 1.33625112e+00, 1.10974297e+00,
+                                   1.12633925e+00, 1.46605685e+00, 2.20891265e+00,
+                                   3.43492354e+00],
+                                  [-5.24601064e-01, 1.12596172e+00, 2.23461746e+00,
+                                   2.88044580e+00, 3.14252639e+00, 3.09993890e+00,
+                                   2.83176297e+00, 2.41707827e+00, 1.93496443e+00,
+                                   1.46450113e+00, 1.08476800e+00, 8.74844707e-01,
+                                   9.13810903e-01, 1.28074624e+00, 2.05473038e+00,
+                                   3.31484296e+00],
+                                  [-2.89488447e-01, 1.18641968e+00, 2.16002535e+00,
+                                   2.70602204e+00, 2.89910321e+00, 2.81396236e+00,
+                                   2.52529294e+00, 2.10778846e+00, 1.63614237e+00,
+                                   1.18504816e+00, 8.29199299e-01, 6.43289272e-01,
+                                   7.02011552e-01, 1.08005962e+00, 1.85212694e+00,
+                                   3.09290701e+00],
+                                  [5.52692819e-02, 1.28775854e+00, 2.07831656e+00,
+                                   2.49430091e+00, 2.60306915e+00, 2.47197885e+00,
+                                   2.16838755e+00, 1.75965283e+00, 1.31313224e+00,
+                                   8.96183350e-01, 5.76163712e-01, 4.20430892e-01,
+                                   4.96342449e-01, 8.71255945e-01, 1.61252894e+00,
+                                   2.78751900e+00],
+                                  [4.91242104e-01, 1.42462522e+00, 1.99353441e+00,
+                                   2.25554078e+00, 2.26821545e+00, 2.08912953e+00,
+                                   1.77585413e+00, 1.38596036e+00, 9.77019326e-01,
+                                   6.06602149e-01, 3.32279936e-01, 2.11623798e-01,
+                                   3.02204847e-01, 6.61594194e-01, 1.34736295e+00,
+                                   2.41708223e+00],
+                                  [1.00000000e+00, 1.59166667e+00, 1.90972222e+00,
+                                   2.00000000e+00, 1.90833333e+00, 1.68055556e+00,
+                                   1.36250000e+00, 1.00000000e+00, 6.38888889e-01,
+                                   3.25000000e-01, 1.04166667e-01, 2.22222222e-02,
+                                   1.25000000e-01, 4.58333333e-01, 1.06805556e+00,
+                                   2.00000000e+00],
+                                  [1.56311295e+00, 1.78352982e+00, 1.83092334e+00,
+                                   1.73793693e+00, 1.53721403e+00, 1.26139808e+00,
+                                   9.43132501e-01, 6.15060731e-01, 3.09826203e-01,
+                                   6.00723485e-02, -1.01557398e-01, -1.42419605e-01,
+                                   -2.98708387e-02, 2.68732333e-01, 7.86033344e-01,
+                                   1.55467563e+00],
+                                  [2.16215093e+00, 1.99486162e+00, 1.76118108e+00,
+                                   1.47960993e+00, 1.16864878e+00, 8.46798254e-01,
+                                   5.32558960e-01, 2.44431516e-01, 9.16537382e-04,
+                                   -1.79485360e-01, -2.78273562e-01, -2.76947452e-01,
+                                   -1.57006415e-01, 1.00050164e-01, 5.12722901e-01,
+                                   1.09951241e+00],
+                                  [2.77868393e+00, 2.22030900e+00, 1.70453878e+00,
+                                   1.23527736e+00, 8.16428811e-01, 4.51897232e-01,
+                                   1.45586708e-01, -9.85986773e-02, -2.76754836e-01,
+                                   -3.84977682e-01, -4.19363128e-01, -3.76007089e-01,
+                                   -2.51005477e-01, -4.04542058e-02, 2.59550811e-01,
+                                   6.52913659e-01],
+                                  [3.39428191e+00, 2.45451890e+00, 1.66503977e+00,
+                                   1.01519757e+00, 4.94345351e-01, 9.18361693e-02,
+                                   -2.02976925e-01, -4.00740881e-01, -5.12102647e-01,
+                                   -5.47709170e-01, -5.18207399e-01, -4.34244283e-01,
+                                   -3.06466769e-01, -1.45521806e-01, 3.79436582e-02,
+                                   2.33282675e-01],
+                                  [3.99051488e+00, 2.69213826e+00, 1.64672737e+00,
+                                   8.29628926e-01, 2.16189635e-01, -2.18243782e-01,
+                                   -4.98324609e-01, -6.48706129e-01, -6.94041625e-01,
+                                   -6.58984380e-01, -5.68187679e-01, -4.46304804e-01,
+                                   -3.17989039e-01, -2.07893666e-01, -1.40671971e-01,
+                                   -1.40977235e-01],
+                                  [4.54895279e+00, 2.92781402e+00, 1.65364493e+00,
+                                   6.88829787e-01, -4.24710692e-03, -4.63201469e-01,
+                                   -7.25649013e-01, -8.29205452e-01, -8.11486499e-01,
+                                   -7.10107867e-01, -5.62685270e-01, -4.06834420e-01,
+                                   -2.80171032e-01, -2.20310818e-01, -2.64869492e-01,
+                                   -4.51462766e-01],
+                                  [5.05116564e+00, 3.15619312e+00, 1.68983575e+00,
+                                   6.03058511e-01, -1.53173643e-01, -6.27895738e-01,
+                                   -8.70142807e-01, -9.28949884e-01, -8.53351999e-01,
+                                   -6.92384185e-01, -4.95081475e-01, -3.10478902e-01,
+                                   -1.87611496e-01, -1.75514291e-01, -3.23222319e-01,
+                                   -6.79770612e-01],
+                                  [5.47872340e+00, 3.37192249e+00, 1.75934319e+00,
+                                   5.82573455e-01, -2.16798741e-01, -6.97185434e-01,
+                                   -9.16998661e-01, -9.34650456e-01, -8.08552854e-01,
+                                   -5.97117890e-01, -3.58757599e-01, -1.51884016e-01,
+                                   -3.49091764e-02, -6.62451151e-02, -3.04303867e-01,
+                                   -8.07497467e-01],
+                                  [5.81319606e+00, 3.56964908e+00, 1.86621056e+00,
+                                   6.37632979e-01, -1.81331170e-01, -6.55929406e-01,
+                                   -8.51409244e-01, -8.33018201e-01, -6.66003793e-01,
+                                   -4.15613535e-01, -1.47094943e-01, 7.43044672e-02,
+                                   1.83337180e-01, 1.14755679e-01, -1.96687551e-01,
+                                   -8.16240027e-01],
+                                  [6.03615359e+00, 3.74401982e+00, 2.01448119e+00,
+                                   7.78495441e-01, -3.29796987e-02, -4.88986498e-01,
+                                   -6.58567226e-01, -6.10764153e-01, -4.14619546e-01,
+                                   -1.39175676e-01, 1.46525189e-01, 3.73440779e-01,
+                                   4.72528826e-01, 3.74747061e-01, 1.10532133e-02,
+                                   -6.87594985e-01],
+                                  [6.12916597e+00, 3.88968165e+00, 2.20819842e+00,
+                                   1.01541920e+00, 2.42046904e-01, -1.81215558e-01,
+                                   -3.23665277e-01, -2.54599342e-01, -4.33148426e-02,
+                                   2.40891132e-01, 5.28721493e-01, 7.50879151e-01,
+                                   8.38067017e-01, 7.20988000e-01, 3.30345012e-01,
+                                   -4.03159036e-01],
+                                  [6.07380319e+00, 4.00128150e+00, 2.45140557e+00,
+                                   1.35866261e+00, 6.57539871e-01, 2.82524568e-01,
+                                   1.68103934e-01, 2.48765198e-01, 4.58995588e-01,
+                                   7.33282336e-01, 1.00611267e+00, 1.21197381e+00,
+                                   1.28535300e+00, 1.16073747e+00, 7.72614430e-01,
+                                   5.54711246e-02],
+                                  [5.85163522e+00, 4.07346633e+00, 2.74814597e+00,
+                                   1.81848404e+00, 1.22729043e+00, 9.17375033e-01,
+                                   8.31547737e-01, 9.12618434e-01, 1.10339702e+00,
+                                   1.34669338e+00, 1.58531741e+00, 1.76207900e+00,
+                                   1.81978804e+00, 1.70125443e+00, 1.34928805e+00,
+                                   7.06698803e-01],
+                                  [5.44423205e+00, 4.10088306e+00, 3.10246296e+00,
+                                   2.40514184e+00, 1.96508982e+00, 1.73847699e+00,
+                                   1.68147346e+00, 1.75024934e+00, 1.90097472e+00,
+                                   2.08981971e+00, 2.27295441e+00, 2.40654894e+00,
+                                   2.44677339e+00, 2.34979786e+00, 2.07179247e+00,
+                                   1.56892730e+00],
+                                  [4.83316365e+00, 4.07817864e+00, 3.51839986e+00,
+                                   3.12889438e+00, 2.88472927e+00, 2.76097160e+00,
+                                   2.73268844e+00, 2.77494687e+00, 2.86281395e+00,
+                                   2.97135677e+00, 3.07564238e+00, 3.15073786e+00,
+                                   3.17171029e+00, 3.11362673e+00, 2.95155425e+00,
+                                   2.66055994e+00],
+                                  [4.00000000e+00, 4.00000000e+00, 4.00000000e+00,
+                                   4.00000000e+00, 4.00000000e+00, 4.00000000e+00,
+                                   4.00000000e+00, 4.00000000e+00, 4.00000000e+00,
+                                   4.00000000e+00, 4.00000000e+00, 4.00000000e+00,
+                                   4.00000000e+00, 4.00000000e+00, 4.00000000e+00,
+                                   4.00000000e+00]])
+
+    def test_interpolate(self, grid_interpolator):
+        """Test that interpolation is working."""
+        fine_x = np.arange(16)
+        fine_y = np.arange(32)
+
+        res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic")
+        np.testing.assert_allclose(res, self.expected)
+
+    def test_interpolate_slices(self, grid_interpolator):
+        """Test that interpolation from slices is working."""
+        res = grid_interpolator.interpolate_slices((slice(0, 32), slice(0, 16)), method="cubic")
+        np.testing.assert_allclose(res, self.expected)
+
+    @pytest.mark.parametrize("chunks, expected_chunks", [(10, (10, 10)),
+                                                         ((10, 5), (10, 5))])
+    def test_interpolate_dask(self, grid_interpolator, chunks, expected_chunks):
+        """Test that interpolation with dask is working."""
+        da = pytest.importorskip("dask.array")
+
+        fine_x = np.arange(16)
+        fine_y = np.arange(32)
+
+        with mock.patch.object(grid_interpolator,
+                               "interpolate_numpy",
+                               wraps=grid_interpolator.interpolate_numpy) as interpolate:
+            res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic", chunks=chunks)
+            assert not interpolate.called
+
+            assert isinstance(res, da.Array)
+            v_chunk, h_chunk = expected_chunks
+            assert res.chunks[0][0] == v_chunk
+            assert res.chunks[1][0] == h_chunk
+
+            np.testing.assert_allclose(res, self.expected)
+            assert interpolate.called


=====================================
geotiepoints/version.py
=====================================
@@ -26,9 +26,9 @@ def get_keywords():
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (HEAD -> main, tag: v1.5.1)"
-    git_full = "751dd6291786045e221aebe3a91b92251be7d5e8"
-    git_date = "2022-12-09 09:36:09 -0600"
+    git_refnames = " (HEAD -> main, tag: v1.6.0)"
+    git_full = "4f3fd0b5b3d39987a6b17619287f761a04e01ea8"
+    git_date = "2023-03-17 14:32:34 +0100"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 


=====================================
geotiepoints/viiinterpolator.py
=====================================
@@ -65,18 +65,18 @@ def tie_points_interpolation(data_on_tie_points, scan_alt_tie_points, tie_points
     n_pixel_alt = (n_tie_alt - 1) * tie_points_factor
 
     # Create the grids used for interpolation across the track
-    tie_grid_act = da.arange(0, n_pixel_act + 1, tie_points_factor)
-    pixel_grid_act = da.arange(0, n_pixel_act)
+    tie_grid_act = np.arange(0, n_pixel_act + 1, tie_points_factor)
+    pixel_grid_act = np.arange(0, n_pixel_act)
 
     # Create the grids used for the interpolation along the track (must not include the spurious points between scans)
-    tie_grid_alt = da.arange(0, n_pixel_alt + 1, tie_points_factor)
+    tie_grid_alt = np.arange(0, n_pixel_alt + 1, tie_points_factor)
     n_pixel_alt_per_scan = (scan_alt_tie_points - 1) * tie_points_factor
     pixel_grid_alt = []
 
     for j_scan in range(n_scans):
         start_index_scan = j_scan * scan_alt_tie_points * tie_points_factor
-        pixel_grid_alt.append(da.arange(start_index_scan, start_index_scan + n_pixel_alt_per_scan))
-    pixel_grid_alt = da.concatenate(pixel_grid_alt)
+        pixel_grid_alt.append(np.arange(start_index_scan, start_index_scan + n_pixel_alt_per_scan))
+    pixel_grid_alt = np.concatenate(pixel_grid_alt)
 
     # Loop on all arrays
     data_on_pixel_points = []


=====================================
setup.py
=====================================
@@ -21,8 +21,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Setting up the geo_interpolator project.
-"""
+"""Setting up the geo_interpolator project."""
 
 import sys
 
@@ -33,7 +32,7 @@ from Cython.Build import build_ext
 from Cython.Distutils import Extension
 
 requirements = ['numpy', 'scipy', 'pandas']
-test_requires = ['pytest', 'pytest-cov', 'h5py', 'xarray', 'dask', 'pyproj']
+test_requires = ['pytest', 'pytest-cov', 'h5py', 'xarray', 'dask', 'pyproj', "pyresample"]
 
 if sys.platform.startswith("win"):
     extra_compile_args = []



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geotiepoints/-/compare/298366b8acb59b1997e95226e0de709143121f7a...34e0b3aa63d261162f21285f665376758977a400

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geotiepoints/-/compare/298366b8acb59b1997e95226e0de709143121f7a...34e0b3aa63d261162f21285f665376758977a400
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20230611/2ec2a156/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list