[Git][debian-gis-team/pyresample][upstream] New upstream version 1.8.1

Antonio Valentino gitlab at salsa.debian.org
Sun Feb 25 12:06:50 UTC 2018


Antonio Valentino pushed to branch upstream at Debian GIS Project / pyresample


Commits:
b72681d2 by Antonio Valentino at 2018-02-25T10:08:11+00:00
New upstream version 1.8.1
- - - - -


10 changed files:

- .bumpversion.cfg
- README.md
- changelog.rst
- pyresample/data_reduce.py
- pyresample/geometry.py
- pyresample/kd_tree.py
- pyresample/test/__init__.py
- + pyresample/test/test_data_reduce.py
- pyresample/test/test_kd_tree.py
- pyresample/version.py


Changes:

=====================================
.bumpversion.cfg
=====================================
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 1.8.0
+current_version = 1.8.1
 commit = True
 tag = True
 


=====================================
README.md
=====================================
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Pyresample works with Numpy arrays including support for masked arrays.
 Support for parallel resampling using multiple processor cores.
 Plotting capablity using Basemap. As of v0.8.0 [pykdtree](https://github.com/storpipfugl/pykdtree) can be used to speed up processing.
 
-Pyresample is tested with Python 2.6, 2.7, 3.2, 3.3, and 3.4.
+Pyresample is tested with Python 2.7, 3.4, 3.5, and 3.6.
 
 Note: For numpy >= 1.6.2 use pyresample >= 0.7.13  
 


=====================================
changelog.rst
=====================================
--- a/changelog.rst
+++ b/changelog.rst
@@ -2,6 +2,41 @@ Changelog
 =========
 
 
+v1.8.1 (2018-02-22)
+-------------------
+- update changelog. [Martin Raspaud]
+- Bump version: 1.8.0 → 1.8.1. [Martin Raspaud]
+- Merge pull request #101 from floriankrb/master. [Martin Raspaud]
+
+  Update README to include correct versions of python tested
+- Update README.md. [Florian]
+- Update README.md. [Florian]
+- Merge pull request #99 from pytroll/feature-dynamic-projs. [Martin
+  Raspaud]
+
+  Add support for dynamic resampling for most projections
+- Do not overwrite provided lon_0 and lat_0. [Martin Raspaud]
+- Add support for dynamic resampling for most projections. [Martin
+  Raspaud]
+- Merge pull request #98 from pytroll/bugfix-data-reduce. [Martin
+  Raspaud]
+
+  Revert "Fix data reduction when poles are within area"
+- Add test for data reduction over the poles. [Martin Raspaud]
+- Make pep8 happy. [Martin Raspaud]
+- Revert "Fix data reduction when poles are within area" [Martin
+  Raspaud]
+
+  This reverts commit 1c9ac493aea549a354f384059e9aa6ad41558fd8.
+
+- Merge pull request #96 from pytroll/bugfix-partially-invalid-source-
+  data. [David Hoese]
+
+  Fix xarray resampling for partially invalid source datasets
+- Fix xarray resampling for partially invalid source datasets. [Martin
+  Raspaud]
+
+
 v1.8.0 (2018-02-02)
 -------------------
 - update changelog. [Martin Raspaud]


=====================================
pyresample/data_reduce.py
=====================================
--- a/pyresample/data_reduce.py
+++ b/pyresample/data_reduce.py
@@ -289,14 +289,14 @@ def _get_valid_index(lons_side1, lons_side2, lons_side3, lons_side4,
 
     # From the winding number theorem follows:
     # angle_sum possiblilities:
-    # 360: area covers north pole
-    #-360: area covers south pole
+    # -360: area covers north pole
+    # 360: area covers south pole
     #   0: area covers no poles
     # else: area covers both poles
-    if round(angle_sum) == 360:
+    if round(angle_sum) == -360:
         # Covers NP
         valid_index = (lats >= lat_min_buffered)
-    elif round(angle_sum) == -360:
+    elif round(angle_sum) == 360:
         # Covers SP
         valid_index = (lats <= lat_max_buffered)
     elif round(angle_sum) == 0:


=====================================
pyresample/geometry.py
=====================================
--- a/pyresample/geometry.py
+++ b/pyresample/geometry.py
@@ -186,7 +186,8 @@ class BaseDefinition(object):
         side2 = self.get_lonlats(data_slice=(slice(None), -1))
         side3 = self.get_lonlats(data_slice=(-1, slice(None)))
         side4 = self.get_lonlats(data_slice=(slice(None), 0))
-        return Boundary(side1[0], side2[0], side3[0][::-1], side4[0][::-1]), Boundary(side1[1], side2[1], side3[1][::-1], side4[1][::-1])
+        return (Boundary(side1[0], side2[0], side3[0][::-1], side4[0][::-1]),
+                Boundary(side1[1], side2[1], side3[1][::-1], side4[1][::-1]))
 
     def get_cartesian_coords(self, nprocs=None, data_slice=None, cache=False):
         """Retrieve cartesian coordinates of geometry definition
@@ -528,6 +529,14 @@ class SwathDefinition(CoordinateDefinition):
                 'lat_0': float(lat0),  'lonc': float(lonc),
                 'no_rot': True, 'ellps': ellipsoid}
 
+    def _compute_generic_parameters(self, projection, ellipsoid):
+        """Compute the projection bb parameters for most projections."""
+        lines, cols = self.lons.shape
+        lat_0 = self.lats[int(lines / 2), int(cols / 2)]
+        lon_0 = self.lons[int(lines / 2), int(cols / 2)]
+        return {'proj': projection, 'ellps': ellipsoid,
+                'lat_0': lat_0, 'lon_0': lon_0}
+
     def get_edge_lonlats(self):
         """Get the concatenated boundary of the current swath."""
         lons, lats = self.get_boundary_lonlats()
@@ -543,7 +552,9 @@ class SwathDefinition(CoordinateDefinition):
         if projection == 'omerc':
             return self._compute_omerc_parameters(ellipsoid)
         else:
-            raise NotImplementedError('Only omerc supported for now.')
+            new_proj = self._compute_generic_parameters(projection, ellipsoid)
+            new_proj.update(proj_dict)
+            return new_proj
 
     def compute_optimal_bb_area(self, proj_dict=None):
         """Compute the "best" bounding box area for this swath with `proj_dict`.


=====================================
pyresample/kd_tree.py
=====================================
--- a/pyresample/kd_tree.py
+++ b/pyresample/kd_tree.py
@@ -1012,13 +1012,10 @@ class XArrayResamplerNN(object):
             # which is an invalid index, we mask those out so -1 represents
             # invalid values
             # voi is 2D, index_array is 1D
-            bad_mask = index_array >= resample_kdtree.n
-            voi[bad_mask.reshape(shape)] = False
+            good_pixels = index_array < resample_kdtree.n
+            voi[voi] = good_pixels
             res_ia = np.full(shape, fill_value=-1, dtype=np.int)
-            res_ia[voi] = index_array[~bad_mask]
-            # res_ia[voi >= resample_kdtree.n] = -1
-            # res_ia[voi] = index_array
-            # res_ia[voi >= resample_kdtree.n] = -1
+            res_ia[voi] = index_array[good_pixels]
             return res_ia
 
         res = da.map_blocks(query_no_distance, target_lons, target_lats,


=====================================
pyresample/test/__init__.py
=====================================
--- a/pyresample/test/__init__.py
+++ b/pyresample/test/__init__.py
@@ -36,6 +36,7 @@ from pyresample.test import (
     test_ewa_ll2cr,
     test_ewa_fornav,
     test_bilinear,
+    test_data_reduce,
 )
 
 import unittest
@@ -57,7 +58,7 @@ def suite():
     mysuite.addTests(test_ewa_ll2cr.suite())
     mysuite.addTests(test_ewa_fornav.suite())
     mysuite.addTests(test_bilinear.suite())
-
+    mysuite.addTests(test_data_reduce.suite())
     return mysuite
 
 


=====================================
pyresample/test/test_data_reduce.py
=====================================
--- /dev/null
+++ b/pyresample/test/test_data_reduce.py
@@ -0,0 +1,172 @@
+# pyresample, Resampling of remote sensing image data in python
+#
+# Copyright (C) 2018  Pytroll Developers
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""Testing the data_reduce module."""
+
+import unittest
+import numpy as np
+from pyresample import geometry
+from pyresample.data_reduce import (get_valid_index_from_cartesian_grid,
+                                    swath_from_lonlat_grid,
+                                    swath_from_lonlat_boundaries,
+                                    swath_from_cartesian_grid,
+                                    get_valid_index_from_lonlat_grid)
+
+
+class Test(unittest.TestCase):
+    """Unit testing the data_reduce module."""
+
+    @classmethod
+    def setUpClass(cls):
+        """Get ready for testing."""
+        cls.area_def = geometry.AreaDefinition('areaD',
+                                               'Europe (3km, HRV, VTC)',
+                                               'areaD',
+                                               {'a': '6378144.0',
+                                                'b': '6356759.0',
+                                                'lat_0': '50.00',
+                                                'lat_ts': '50.00',
+                                                'lon_0': '8.00',
+                                                'proj': 'stere'},
+                                               800,
+                                               800,
+                                               [-1370912.72,
+                                                   -909968.64000000001,
+                                                   1029087.28,
+                                                   1490031.3600000001])
+
+    def test_reduce(self):
+        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
+        lons = np.fromfunction(
+            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
+        lats = np.fromfunction(
+            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
+        grid_lons, grid_lats = self.area_def.get_lonlats()
+        lons, lats, data = swath_from_lonlat_grid(grid_lons, grid_lats,
+                                                  lons, lats, data,
+                                                  7000)
+        cross_sum = data.sum()
+        expected = 20514375.0
+        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
+
+    def test_reduce_boundary(self):
+        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
+        lons = np.fromfunction(
+            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
+        lats = np.fromfunction(
+            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
+        boundary_lonlats = self.area_def.get_boundary_lonlats()
+        lons, lats, data = swath_from_lonlat_boundaries(boundary_lonlats[0],
+                                                        boundary_lonlats[1],
+                                                        lons, lats, data, 7000)
+        cross_sum = data.sum()
+        expected = 20514375.0
+        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
+
+    def test_cartesian_reduce(self):
+        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
+        lons = np.fromfunction(
+            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
+        lats = np.fromfunction(
+            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
+        grid = self.area_def.get_cartesian_coords()
+        lons, lats, data = swath_from_cartesian_grid(grid, lons, lats, data,
+                                                     7000)
+        cross_sum = data.sum()
+        expected = 20514375.0
+        self.assertAlmostEqual(
+            cross_sum, expected, msg='Cartesian reduce data failed')
+
+    def test_area_con_reduce(self):
+        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
+        lons = np.fromfunction(
+            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
+        lats = np.fromfunction(
+            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
+        grid_lons, grid_lats = self.area_def.get_lonlats()
+        valid_index = get_valid_index_from_lonlat_grid(grid_lons, grid_lats,
+                                                       lons, lats, 7000)
+        data = data[valid_index]
+        cross_sum = data.sum()
+        expected = 20514375.0
+        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
+
+    def test_area_con_cartesian_reduce(self):
+        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
+        lons = np.fromfunction(
+            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
+        lats = np.fromfunction(
+            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
+        cart_grid = self.area_def.get_cartesian_coords()
+        valid_index = get_valid_index_from_cartesian_grid(cart_grid,
+                                                          lons, lats, 7000)
+        data = data[valid_index]
+        cross_sum = data.sum()
+        expected = 20514375.0
+        self.assertAlmostEqual(
+            cross_sum, expected, msg='Cartesian reduce data failed')
+
+    def test_reduce_north_pole(self):
+        """Test reducing around the poles."""
+
+        from pyresample import utils
+        area_id = 'ease_sh'
+        description = 'Antarctic EASE grid'
+        proj_id = 'ease_sh'
+        projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
+        x_size = 425
+        y_size = 425
+        area_extent = (-5326849.0625, -5326849.0625,
+                       5326849.0625, 5326849.0625)
+        area_def = utils.get_area_def(area_id, description, proj_id,
+                                      projection, x_size, y_size, area_extent)
+
+        grid_lons, grid_lats = area_def.get_lonlats()
+
+        area_id = 'ease_sh'
+        description = 'Antarctic EASE grid'
+        proj_id = 'ease_sh'
+        projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
+        x_size = 1000
+        y_size = 1000
+        area_extent = (-532684.0625, -532684.0625, 532684.0625, 532684.0625)
+        smaller_area_def = utils.get_area_def(area_id, description, proj_id,
+                                              projection, x_size, y_size,
+                                              area_extent)
+
+        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
+        lons, lats = smaller_area_def.get_lonlats()
+
+        lons, lats, data = swath_from_lonlat_grid(grid_lons, grid_lats,
+                                                  lons, lats, data, 7000)
+
+        cross_sum = data.sum()
+        expected = 999000000.0
+        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
+
+
+def suite():
+    """The test suite.
+    """
+    loader = unittest.TestLoader()
+    mysuite = unittest.TestSuite()
+    mysuite.addTest(loader.loadTestsFromTestCase(Test))
+
+    return mysuite
+
+
+if __name__ == '__main__':
+    unittest.main()


=====================================
pyresample/test/test_kd_tree.py
=====================================
--- a/pyresample/test/test_kd_tree.py
+++ b/pyresample/test/test_kd_tree.py
@@ -5,7 +5,7 @@ import sys
 
 import numpy
 
-from pyresample import data_reduce, geometry, kd_tree, utils
+from pyresample import geometry, kd_tree, utils
 from pyresample.test.utils import catch_warnings
 
 if sys.version_info < (2, 7):
@@ -135,7 +135,7 @@ class Test(unittest.TestCase):
         mask = numpy.ones_like(lons, dtype=numpy.bool)
         mask[::2, ::2] = False
         swath_def = geometry.SwathDefinition(
-            lons=numpy.ma.masked_array(lons, mask=mask), # numpy.ones_like(lons, dtype=numpy.bool)),
+            lons=numpy.ma.masked_array(lons, mask=mask),
             lats=numpy.ma.masked_array(lats, mask=False)
         )
         res = kd_tree.resample_nearest(swath_def, data.ravel(),
@@ -501,80 +501,6 @@ class Test(unittest.TestCase):
         self.assertAlmostEqual(cross_sum, expected,
                                msg='Swath multi channel custom resampling failed')
 
-    def test_reduce(self):
-        data = numpy.fromfunction(lambda y, x: (y + x), (1000, 1000))
-        lons = numpy.fromfunction(
-            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
-        lats = numpy.fromfunction(
-            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
-        grid_lons, grid_lats = self.area_def.get_lonlats()
-        lons, lats, data = data_reduce.swath_from_lonlat_grid(grid_lons, grid_lats,
-                                                              lons, lats, data,
-                                                              7000)
-        cross_sum = data.sum()
-        expected = 20514375.0
-        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
-
-    def test_reduce_boundary(self):
-        data = numpy.fromfunction(lambda y, x: (y + x), (1000, 1000))
-        lons = numpy.fromfunction(
-            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
-        lats = numpy.fromfunction(
-            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
-        boundary_lonlats = self.area_def.get_boundary_lonlats()
-        lons, lats, data = data_reduce.swath_from_lonlat_boundaries(boundary_lonlats[0],
-                                                                    boundary_lonlats[
-                                                                        1],
-                                                                    lons, lats, data,
-                                                                    7000)
-        cross_sum = data.sum()
-        expected = 20514375.0
-        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
-
-    def test_cartesian_reduce(self):
-        data = numpy.fromfunction(lambda y, x: (y + x), (1000, 1000))
-        lons = numpy.fromfunction(
-            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
-        lats = numpy.fromfunction(
-            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
-        #grid = utils.generate_cartesian_grid(self.area_def)
-        grid = self.area_def.get_cartesian_coords()
-        lons, lats, data = data_reduce.swath_from_cartesian_grid(grid, lons, lats, data,
-                                                                 7000)
-        cross_sum = data.sum()
-        expected = 20514375.0
-        self.assertAlmostEqual(
-            cross_sum, expected, msg='Cartesian reduce data failed')
-
-    def test_area_con_reduce(self):
-        data = numpy.fromfunction(lambda y, x: (y + x), (1000, 1000))
-        lons = numpy.fromfunction(
-            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
-        lats = numpy.fromfunction(
-            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
-        grid_lons, grid_lats = self.area_def.get_lonlats()
-        valid_index = data_reduce.get_valid_index_from_lonlat_grid(grid_lons, grid_lats,
-                                                                   lons, lats, 7000)
-        data = data[valid_index]
-        cross_sum = data.sum()
-        expected = 20514375.0
-        self.assertAlmostEqual(cross_sum, expected, msg='Reduce data failed')
-
-    def test_area_con_cartesian_reduce(self):
-        data = numpy.fromfunction(lambda y, x: (y + x), (1000, 1000))
-        lons = numpy.fromfunction(
-            lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
-        lats = numpy.fromfunction(
-            lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
-        cart_grid = self.area_def.get_cartesian_coords()
-        valid_index = data_reduce.get_valid_index_from_cartesian_grid(cart_grid,
-                                                                      lons, lats, 7000)
-        data = data[valid_index]
-        cross_sum = data.sum()
-        expected = 20514375.0
-        self.assertAlmostEqual(
-            cross_sum, expected, msg='Cartesian reduce data failed')
-
     def test_masked_nearest(self):
         data = numpy.ones((50, 10))
         data[:, 5:] = 2
@@ -849,5 +775,6 @@ def suite():
 
     return mysuite
 
+
 if __name__ == '__main__':
     unittest.main()


=====================================
pyresample/version.py
=====================================
--- a/pyresample/version.py
+++ b/pyresample/version.py
@@ -15,4 +15,4 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-__version__ = '1.8.0'
+__version__ = '1.8.1'



View it on GitLab: https://salsa.debian.org/debian-gis-team/pyresample/commit/b72681d2de72de3fba9edd4c7cbed9ba9e43709d

---
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyresample/commit/b72681d2de72de3fba9edd4c7cbed9ba9e43709d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-grass-devel/attachments/20180225/61827dfd/attachment-0001.html>


More information about the Pkg-grass-devel mailing list