Skip to content
Commits on Source (3)
pyresample (1.13.2-2) UNRELEASED; urgency=medium
pyresample (1.13.2-2) unstable; urgency=medium
* Drop Provides: ${python3:Provides}.
* debian/patches:
- new 0007-Fix-pyproj-inf.patch, imported form
upstream to fix unittest failures
* debian/tests:
- replace the deprecated ADTTMP with AUTOPKGTEST_TMP
-- Antonio Valentino <antonio.valentino@tiscali.it> Thu, 07 Nov 2019 18:41:13 +0100
-- Antonio Valentino <antonio.valentino@tiscali.it> Tue, 03 Dec 2019 07:33:10 +0000
pyresample (1.13.2-1) unstable; urgency=medium
......
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Tue, 3 Dec 2019 07:10:43 +0000
Subject: Fix pyproj inf
See https://github.com/pytroll/pyresample/pull/236 and
https://github.com/pytroll/pyresample/issues/237.
---
pyresample/ewa/__init__.py | 4 ++--
pyresample/ewa/_ll2cr.pyx | 4 ++--
pyresample/geometry.py | 17 ++++++++++-------
pyresample/grid.py | 2 +-
pyresample/kd_tree.py | 12 +++++++-----
pyresample/spherical_geometry.py | 2 +-
pyresample/test/test_geometry.py | 22 +++++++++++-----------
pyresample/test/test_spherical.py | 6 +++---
pyresample/test/test_utils.py | 8 ++++----
pyresample/test/utils.py | 2 +-
10 files changed, 42 insertions(+), 37 deletions(-)
diff --git a/pyresample/ewa/__init__.py b/pyresample/ewa/__init__.py
index d6c1195..62f3f11 100644
--- a/pyresample/ewa/__init__.py
+++ b/pyresample/ewa/__init__.py
@@ -119,8 +119,8 @@ def ll2cr(swath_def, area_def, fill=np.nan, copy=True):
cw = area_def.pixel_size_x
# cell height must be negative for this to work as expected
ch = -abs(area_def.pixel_size_y)
- w = area_def.x_size
- h = area_def.y_size
+ w = area_def.width
+ h = area_def.height
ox = area_def.area_extent[0] + cw / 2.
oy = area_def.area_extent[3] + ch / 2.
swath_points_in_grid = _ll2cr.ll2cr_static(lons, lats, fill,
diff --git a/pyresample/ewa/_ll2cr.pyx b/pyresample/ewa/_ll2cr.pyx
index 883613a..34ef568 100644
--- a/pyresample/ewa/_ll2cr.pyx
+++ b/pyresample/ewa/_ll2cr.pyx
@@ -159,13 +159,13 @@ def ll2cr_dynamic(numpy.ndarray[cr_dtype, ndim=2] lon_arr, numpy.ndarray[cr_dtyp
continue
elif x_tmp < xmin or npy_isnan(xmin):
xmin = x_tmp
- elif x_tmp > xmax or npy_isnan(xmax) or xmax == 1e30:
+ elif x_tmp > xmax or npy_isnan(xmax) or xmax >= 1e30:
# Note: technically 2 valid points are required to get here if there are a lot of NaNs
xmax = x_tmp
if y_tmp < ymin or npy_isnan(ymin):
ymin = y_tmp
- elif y_tmp > ymax or npy_isnan(ymax) or ymax == 1e30:
+ elif y_tmp > ymax or npy_isnan(ymax) or ymax >= 1e30:
# Note: technically 2 valid points are required to get here if there are a lot of NaNs
ymax = y_tmp
diff --git a/pyresample/geometry.py b/pyresample/geometry.py
index 697e4ed..9ed645b 100644
--- a/pyresample/geometry.py
+++ b/pyresample/geometry.py
@@ -935,7 +935,7 @@ class DynamicAreaDefinition(object):
def invproj(data_x, data_y, proj_dict):
"""Perform inverse projection."""
# XXX: does pyproj copy arrays? What can we do so it doesn't?
- target_proj = Proj(**proj_dict)
+ target_proj = Proj(proj_dict)
return np.dstack(target_proj(data_x, data_y, inverse=True))
@@ -1591,7 +1591,7 @@ class AreaDefinition(BaseDefinition):
"""
lon, lat = self.get_lonlats(nprocs=None, data_slice=(row, col))
- return np.asscalar(lon), np.asscalar(lat)
+ return lon.item(), lat.item()
@staticmethod
def _do_rotation(xspan, yspan, rot_deg=0):
@@ -1803,18 +1803,19 @@ class AreaDefinition(BaseDefinition):
raise ValueError("Can't specify 'nprocs' and 'chunks' at the same time")
# Proj.4 definition of target area projection
+ proj_def = self.crs if hasattr(self, 'crs') else self.proj_dict
if hasattr(target_x, 'chunks'):
# we are using dask arrays, map blocks to th
from dask.array import map_blocks
res = map_blocks(invproj, target_x, target_y,
chunks=(target_x.chunks[0], target_x.chunks[1], 2),
- new_axis=[2], proj_dict=self.proj_dict)
+ new_axis=[2], proj_dict=proj_def)
return res[:, :, 0], res[:, :, 1]
if nprocs > 1:
- target_proj = Proj_MP(**self.proj_dict)
+ target_proj = Proj_MP(proj_def)
else:
- target_proj = Proj(**self.proj_dict)
+ target_proj = Proj(proj_def)
# Get corresponding longitude and latitude values
lons, lats = target_proj(target_x, target_y, inverse=True, nprocs=nprocs)
@@ -1841,10 +1842,12 @@ class AreaDefinition(BaseDefinition):
raise NotImplementedError('Only AreaDefinitions can be used')
# Intersection only required for two different projections
- if area_to_cover.proj_str == self.proj_str:
+ proj_def_to_cover = area_to_cover.crs if hasattr(area_to_cover, 'crs') else area_to_cover.proj_str
+ proj_def = self.crs if hasattr(self, 'crs') else self.proj_str
+ if proj_def_to_cover == proj_def:
logger.debug('Projections for data and slice areas are'
' identical: %s',
- area_to_cover.proj_dict.get('proj', area_to_cover.proj_dict.get('init')))
+ proj_def_to_cover)
# Get xy coordinates
llx, lly, urx, ury = area_to_cover.area_extent
x, y = self.get_xy_from_proj_coords([llx, urx], [lly, ury])
diff --git a/pyresample/grid.py b/pyresample/grid.py
index 05afb1e..3b21203 100644
--- a/pyresample/grid.py
+++ b/pyresample/grid.py
@@ -210,7 +210,7 @@ def get_resampled_image(target_area_def, source_area_def, source_image_data,
# Calculate number of segments if needed
if segments is None:
- rows = target_area_def.y_size
+ rows = target_area_def.height
cut_off = 500
if rows > cut_off:
segments = int(rows / cut_off)
diff --git a/pyresample/kd_tree.py b/pyresample/kd_tree.py
index c45c499..c3b0136 100644
--- a/pyresample/kd_tree.py
+++ b/pyresample/kd_tree.py
@@ -430,7 +430,7 @@ def _get_valid_input_index(source_geo_def,
source_lons, source_lats,
radius_of_influence)
- if (isinstance(valid_input_index, np.ma.core.MaskedArray)):
+ if isinstance(valid_input_index, np.ma.core.MaskedArray):
# Make sure valid_input_index is not a masked array
valid_input_index = valid_input_index.filled(False)
@@ -1003,7 +1003,7 @@ class XArrayResamplerNN(object):
def _create_resample_kdtree(self, chunks=CHUNK_SIZE):
"""Set up kd tree on input"""
- source_lons, source_lats = self.source_geo_def.get_lonlats_dask(
+ source_lons, source_lats = self.source_geo_def.get_lonlats(
chunks=chunks)
valid_input_idx = ((source_lons >= -180) & (source_lons <= 180) &
(source_lats <= 90) & (source_lats >= -90))
@@ -1058,7 +1058,8 @@ class XArrayResamplerNN(object):
self.valid_input_index = valid_input_idx
self.delayed_kdtree = resample_kdtree
- target_lons, target_lats = self.target_geo_def.get_lonlats_dask()
+ # TODO: Add 'chunks' keyword argument to this method and use it
+ target_lons, target_lats = self.target_geo_def.get_lonlats(chunks=CHUNK_SIZE)
valid_output_idx = ((target_lons >= -180) & (target_lons <= 180) &
(target_lats <= 90) & (target_lats >= -90))
@@ -1094,7 +1095,7 @@ class XArrayResamplerNN(object):
and/or pykdtree.
Args:
- data (dask.array.Array): Source data pixels to sample
+ data (xarray.DataArray): Source data pixels to sample
fill_value (float): Output fill value when no source data is
near the target pixel. When omitted, if the input data is an
integer array then the maximum value for that integer type is
@@ -1147,7 +1148,8 @@ class XArrayResamplerNN(object):
coords = {c: c_var for c, c_var in data.coords.items()
if not contain_coords(c_var, src_geo_dims + dst_geo_dims)}
try:
- coord_x, coord_y = self.target_geo_def.get_proj_vectors_dask()
+ # TODO: Add 'chunks' kwarg
+ coord_x, coord_y = self.target_geo_def.get_proj_vectors(chunks=CHUNK_SIZE)
coords['y'] = coord_y
coords['x'] = coord_x
except AttributeError:
diff --git a/pyresample/spherical_geometry.py b/pyresample/spherical_geometry.py
index 091c6d7..4e8eac7 100644
--- a/pyresample/spherical_geometry.py
+++ b/pyresample/spherical_geometry.py
@@ -24,7 +24,7 @@ import numpy as np
import warnings
warnings.warn("This module will be removed in pyresample 2.0, please use the "
- "`pyresample.spherical` module functions and classe instead.",
+ "`pyresample.spherical` module functions and class instead.",
DeprecationWarning)
try:
diff --git a/pyresample/test/test_geometry.py b/pyresample/test/test_geometry.py
index c30c392..d516cbb 100644
--- a/pyresample/test/test_geometry.py
+++ b/pyresample/test/test_geometry.py
@@ -849,7 +849,7 @@ class Test(unittest.TestCase):
@unittest.skipIf(not dask, 'dask not available')
def test_get_proj_coords_dask(self):
"""Test get_proj_coords usage with dask arrays."""
- from pyresample import utils
+ from pyresample import get_area_def
area_id = 'test'
area_name = 'Test area with 2x2 pixels'
proj_id = 'test'
@@ -857,9 +857,9 @@ class Test(unittest.TestCase):
y_size = 10
area_extent = [1000000, 0, 1050000, 50000]
proj_dict = {"proj": 'laea', 'lat_0': '60', 'lon_0': '0', 'a': '6371228.0', 'units': 'm'}
- area_def = utils.get_area_def(area_id, area_name, proj_id, proj_dict, x_size, y_size, area_extent)
+ area_def = get_area_def(area_id, area_name, proj_id, proj_dict, x_size, y_size, area_extent)
- xcoord, ycoord = area_def.get_proj_coords_dask()
+ xcoord, ycoord = area_def.get_proj_coords(chunks=4096)
xcoord = xcoord.compute()
ycoord = ycoord.compute()
self.assertTrue(np.allclose(xcoord[0, :],
@@ -1588,7 +1588,7 @@ class TestStackedAreaDefinition(unittest.TestCase):
(5567747.7409681147, 2787374.2399544837,
-1000.3358822065015, 2323311.9002169576))
- self.assertEqual(adef.y_size, 4 * 464)
+ self.assertEqual(adef.height, 4 * 464)
self.assertIsInstance(adef.squeeze(), geometry.StackedAreaDefinition)
adef2 = geometry.StackedAreaDefinition()
@@ -1600,7 +1600,7 @@ class TestStackedAreaDefinition(unittest.TestCase):
(5567747.7409681147, 2787374.2399544837,
-1000.3358822065015, 2323311.9002169576))
- self.assertEqual(adef2.y_size, 4 * 464)
+ self.assertEqual(adef2.height, 4 * 464)
def test_get_lonlats(self):
"""Test get_lonlats on StackedAreaDefinition."""
@@ -1659,12 +1659,12 @@ class TestStackedAreaDefinition(unittest.TestCase):
"""Fail appending areas."""
area1 = MagicMock()
area1.proj_dict = {"proj": 'A'}
- area1.x_size = 4
- area1.y_size = 5
+ area1.width = 4
+ area1.height = 5
area2 = MagicMock()
area2.proj_dict = {'proj': 'B'}
- area2.x_size = 4
- area2.y_size = 6
+ area2.width = 4
+ area2.height = 6
# res = combine_area_extents_vertical(area1, area2)
self.assertRaises(IncompatibleAreas,
concatenate_area_defs, area1, area2)
@@ -1851,8 +1851,8 @@ class TestDynamicAreaDefinition(unittest.TestCase):
np.testing.assert_allclose(result.area_extent,
[-336277.698941, 5513145.392745,
192456.651909, 7749649.63914])
- self.assertEqual(result.x_size, 4)
- self.assertEqual(result.y_size, 18)
+ self.assertEqual(result.width, 4)
+ self.assertEqual(result.height, 18)
# Test for properties and shape usage in freeze.
area = geometry.DynamicAreaDefinition('test_area', 'A test area', {'proj': 'merc'},
width=4, height=18)
diff --git a/pyresample/test/test_spherical.py b/pyresample/test/test_spherical.py
index bd7513f..f9aba63 100644
--- a/pyresample/test/test_spherical.py
+++ b/pyresample/test/test_spherical.py
@@ -37,7 +37,7 @@ class TestSCoordinate(unittest.TestCase):
"""Test Vincenty formula
"""
d = SCoordinate(0, 0).distance(SCoordinate(1, 1))
- self.assertEquals(d, 1.2745557823062943)
+ self.assertEqual(d, 1.2745557823062943)
def test_hdistance(self):
"""Test Haversine formula
@@ -185,7 +185,7 @@ class TestArc(unittest.TestCase):
lon, lat = arc1.intersection(arc2)
self.assertTrue(np.allclose(np.rad2deg(lon), 5))
- self.assertEquals(np.rad2deg(lat).round(7), round(5.0575148968282093, 7))
+ self.assertEqual(np.rad2deg(lat).round(7), round(5.0575148968282093, 7))
arc1 = Arc(SCoordinate(0, 0),
SCoordinate(np.deg2rad(10), np.deg2rad(10)))
@@ -202,7 +202,7 @@ class TestArc(unittest.TestCase):
np.deg2rad(50.935830837274324)))
inter = SCoordinate(np.deg2rad(20.165957021925202),
np.deg2rad(46.177022633103398))
- self.assertEquals(arc1.intersection(arc2), inter)
+ self.assertEqual(arc1.intersection(arc2), inter)
arc1 = Arc(SCoordinate(np.deg2rad(-2.4982818108326734),
np.deg2rad(48.596644847869655)),
diff --git a/pyresample/test/test_utils.py b/pyresample/test/test_utils.py
index 209e6c2..93104a4 100644
--- a/pyresample/test/test_utils.py
+++ b/pyresample/test/test_utils.py
@@ -324,10 +324,10 @@ class TestMisc(unittest.TestCase):
def test_unicode_proj4_string(self):
"""Test that unicode is accepted for area creation.
"""
- from pyresample import utils
- utils.get_area_def(u"eurol", u"eurol", u"bla",
- u'+proj=stere +a=6378273 +b=6356889.44891 +lat_0=90 +lat_ts=70 +lon_0=-45',
- 1000, 1000, (-1000, -1000, 1000, 1000))
+ from pyresample import get_area_def
+ get_area_def(u"eurol", u"eurol", u"bla",
+ u'+proj=stere +a=6378273 +b=6356889.44891 +lat_0=90 +lat_ts=70 +lon_0=-45',
+ 1000, 1000, (-1000, -1000, 1000, 1000))
def test_proj4_radius_parameters_provided(self):
"""Test proj4_radius_parameters with a/b."""
diff --git a/pyresample/test/utils.py b/pyresample/test/utils.py
index 74f7a21..7704004 100644
--- a/pyresample/test/utils.py
+++ b/pyresample/test/utils.py
@@ -107,7 +107,7 @@ def treat_deprecations_as_exceptions():
warnings.filterwarnings(
"ignore",
r"This module will be removed in pyresample 2\.0\, please use the"
- r"\`pyresample.spherical\` module functions and classe instead\.",
+ r"\`pyresample.spherical\` module functions and class instead\.",
DeprecationWarning)
if sys.version_info[:2] >= (3, 5):
......@@ -4,3 +4,4 @@
0004-Detect-broken-basemap.patch
0005-Comapt-with-dask-1.0.patch
0006-Skip-test-on-deprecatet-basemap.patch
0007-Fix-pyproj-inf.patch
......@@ -4,7 +4,7 @@ set -efu
PYS=${PYS:-"$(py3versions -r 2>/dev/null)"}
TESTPKG=${TESTPKG:-pyresample}
cd "$ADTTMP"
cd "$AUTOPKGTEST_TMP"
for py in $PYS; do
echo "=== $py ==="
......