Skip to content
Commits on Source (7)
[bumpversion]
current_version = 1.8.0
current_version = 1.8.1
commit = True
tag = True
......
......@@ -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
......
......@@ -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 (1.8.1-1) unstable; urgency=medium
* New upstream release
* Update copyright file
* debian/control
- remove unnecessary versioned dependency from pykdtree
* debian/rules
- remove unnecessary dh argument: --parallel
-- Antonio Valentino <antonio.valentino@tiscali.it> Sun, 25 Feb 2018 10:53:36 +0000
pyresample (1.8.0-1) unstable; urgency=medium
* New upstream release
......
......@@ -11,8 +11,8 @@ Build-Depends: debhelper (>= 11.0.0),
python3-setuptools,
python-numpy,
python3-numpy,
python-pykdtree (>= 1.1.1),
python3-pykdtree (>= 1.1.1),
python-pykdtree,
python3-pykdtree,
python-pyproj,
python3-pyproj,
python-configobj,
......@@ -45,7 +45,7 @@ Depends: ${misc:Depends},
python-numpy,
python-pyproj,
python-yaml,
python-pykdtree (>= 1.1.1),
python-pykdtree,
python-six,
python-pyresample-test
Recommends: python-numexpr,
......@@ -72,7 +72,7 @@ Depends: ${misc:Depends},
python3-numpy,
python3-pyproj,
python3-yaml,
python3-pykdtree (>= 1.1.1),
python3-pykdtree,
python3-six,
python-pyresample-test
Recommends: python3-numexpr,
......
......@@ -3,7 +3,8 @@ Upstream-Name: pyresample
Source: https://github.com/pytroll/pyresample
Files: *
Copyright: 2010-2016, Esben S. Nielsen <esn@dmi.dk>
Copyright: 2018, Pytroll Developers
2010-2016, Esben S. Nielsen <esn@dmi.dk>
2010-2016, Thomas Lavergne <t.lavergne@met.no>
2010, 2013-2015, Martin Raspaud <martin.raspaud@smhi.se
2010, 2014-2016, Adam Dybbroe
......
......@@ -11,7 +11,7 @@ export PYBUILD_NAME=pyresample
%:
dh $@ --parallel --with python2,python3,sphinxdoc --buildsystem=pybuild
dh $@ --with python2,python3,sphinxdoc --buildsystem=pybuild
override_dh_auto_build:
......
......@@ -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:
......
......@@ -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`.
......
......@@ -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,
......
......@@ -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, 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()
......@@ -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()
......@@ -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'