Skip to content
Commits on Source (6)
language: python
env:
global:
- PYTHON_VERSION=$PYTHON_VERSION
- PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
- NUMPY_VERSION=stable
- MAIN_CMD='python setup.py'
- CONDA_DEPENDENCIES='xarray dask toolz Cython pykdtree sphinx cartopy rasterio pillow matplotlib
......@@ -10,7 +10,7 @@ env:
- EVENT_TYPE='push pull_request'
- SETUP_CMD='test'
- CONDA_CHANNELS='conda-forge'
- CONDA_CHANNEL_PRIORITY='True'
- CONDA_CHANNEL_PRIORITY='strict'
matrix:
include:
- env: PYTHON_VERSION=2.7
......@@ -18,19 +18,25 @@ matrix:
- env: PYTHON_VERSION=2.7
os: osx
language: generic
- env: PYTHON_VERSION=3.6
- env: PYTHON_VERSION=3.7
os: linux
- env: PYTHON_VERSION=3.6
- env: PYTHON_VERSION=3.7
os: osx
language: generic
- env: PYTHON_VERSION=3.7
os: windows
language: c
allow_failures:
- os: windows
install:
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
# - git clone --depth 1 git://github.com/astropy/ci-helpers.git
- git clone --depth 1 -b all-the-fixes git://github.com/djhoese/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
script:
- coverage run --source=pyresample setup.py test
- cd docs && mkdir doctest && sphinx-build -E -n -b doctest ./source ./doctest && cd ..
after_success:
- if [[ $PYTHON_VERSION == 3.6 ]]; then coveralls; codecov; fi
- if [[ $PYTHON_VERSION == 3.7 ]]; then coveralls; codecov; fi
deploy:
- provider: pypi
user: dhoese
......
## Version 1.13.0 (2019/09/13)
### Issues Closed
* [Issue 210](https://github.com/pytroll/pyresample/issues/210) - Incompatibility with new proj/pyproj versions
In this release 1 issue was closed.
### Pull Requests Merged
#### Bugs fixed
* [PR 213](https://github.com/pytroll/pyresample/pull/213) - Remove extra conversion to dask array
* [PR 208](https://github.com/pytroll/pyresample/pull/208) - Bugfix bilinear resampler masking ([735](https://github.com/pytroll/satpy/issues/735))
* [PR 207](https://github.com/pytroll/pyresample/pull/207) - Make output index tiling in bilinear interpolation work with dask
* [PR 205](https://github.com/pytroll/pyresample/pull/205) - Exclude NaNs from Bucket Average
* [PR 197](https://github.com/pytroll/pyresample/pull/197) - Fix to_cartopy_crs for latlong projections
* [PR 196](https://github.com/pytroll/pyresample/pull/196) - Improve handling of EPSG codes with pyproj 2.0+
#### Features added
* [PR 212](https://github.com/pytroll/pyresample/pull/212) - Use slices in bilinear resampler
* [PR 203](https://github.com/pytroll/pyresample/pull/203) - Add Numpy version limitation for Python 2
* [PR 198](https://github.com/pytroll/pyresample/pull/198) - Clarify warning if no overlap data and projection
* [PR 196](https://github.com/pytroll/pyresample/pull/196) - Improve handling of EPSG codes with pyproj 2.0+
* [PR 192](https://github.com/pytroll/pyresample/pull/192) - Add bucket resampling
#### Documentation changes
* [PR 204](https://github.com/pytroll/pyresample/pull/204) - Add Example for Regular Lat-Lon Grid
* [PR 201](https://github.com/pytroll/pyresample/pull/201) - fix bug in plot example code
* [PR 198](https://github.com/pytroll/pyresample/pull/198) - Clarify warning if no overlap data and projection
* [PR 195](https://github.com/pytroll/pyresample/pull/195) - Update docs for create_area_def and improve AreaDefinition property consistency
In this release 15 pull requests were closed.
## Version 1.12.3 (2019/05/17)
### Pull Requests Merged
......
......@@ -14,10 +14,9 @@ environment:
NUMPY_VERSION: "stable"
install:
- "git clone --depth 1 git://github.com/astropy/ci-helpers.git"
- "git clone --depth 1 -b all-the-fixes git://github.com/djhoese/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "activate test"
- "conda activate test"
build: false # Not a C# project, build stuff at the test step instead.
......
pyresample (1.13.0-1) unstable; urgency=medium
* New upstream release.
* debian/patches:
- refresh all patches
- new 0005-Comapt-with-dask-1.0.patch and
0006-Skip-test-on-deprecatet-basemap.patch
-- Antonio Valentino <antonio.valentino@tiscali.it> Sat, 14 Sep 2019 17:36:42 +0000
pyresample (1.12.3-6) unstable; urgency=medium
* Team upload.
......
......@@ -21,10 +21,10 @@ index 063264d..620e665 100644
YSIZE: 480
AREA_EXTENT: (-20037508.342789244, -10018754.171394622, 20037508.342789244, 10018754.171394622)
diff --git a/pyresample/test/test_geometry.py b/pyresample/test/test_geometry.py
index 267232c..a3f99ea 100644
index ba3341e..7a9630b 100644
--- a/pyresample/test/test_geometry.py
+++ b/pyresample/test/test_geometry.py
@@ -548,7 +548,7 @@ class Test(unittest.TestCase):
@@ -560,7 +560,7 @@ class Test(unittest.TestCase):
swath_def = geometry.SwathDefinition(lons, lats)
filter_area = geometry.AreaDefinition('test', 'test', 'test',
{'proj': 'eqc', 'lon_0': 0.0,
......@@ -33,7 +33,7 @@ index 267232c..a3f99ea 100644
8, 8,
(-20037508.34, -10018754.17, 20037508.34, 10018754.17))
filter = np.array([[1, 1, 1, 1, 0, 0, 0, 0],
@@ -573,7 +573,7 @@ class Test(unittest.TestCase):
@@ -585,7 +585,7 @@ class Test(unittest.TestCase):
data = np.array([1, 2, 3, 4])
filter_area = geometry.AreaDefinition('test', 'test', 'test',
{'proj': 'eqc', 'lon_0': 0.0,
......@@ -42,7 +42,7 @@ index 267232c..a3f99ea 100644
8, 8,
(-20037508.34, -10018754.17, 20037508.34, 10018754.17))
filter = np.array([[1, 1, 1, 1, 0, 0, 0, 0],
@@ -608,7 +608,7 @@ class Test(unittest.TestCase):
@@ -620,7 +620,7 @@ class Test(unittest.TestCase):
data = np.dstack((data1, data2, data3))
filter_area = geometry.AreaDefinition('test', 'test', 'test',
{'proj': 'eqc', 'lon_0': 0.0,
......@@ -51,7 +51,7 @@ index 267232c..a3f99ea 100644
8, 8,
(-20037508.34, -10018754.17, 20037508.34, 10018754.17))
filter = np.array([[1, 1, 1, 1, 0, 0, 0, 0],
@@ -677,7 +677,7 @@ class Test(unittest.TestCase):
@@ -689,7 +689,7 @@ class Test(unittest.TestCase):
def test_latlong_area(self):
area_def = geometry.AreaDefinition('', '', '',
......
......@@ -9,7 +9,7 @@ Subject: Skip dask-related tests if dask is not available
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/pyresample/test/test_geometry.py b/pyresample/test/test_geometry.py
index a3f99ea..931a13f 100644
index 7a9630b..0cd6ed2 100644
--- a/pyresample/test/test_geometry.py
+++ b/pyresample/test/test_geometry.py
@@ -9,7 +9,8 @@ import numpy as np
......@@ -34,7 +34,7 @@ index a3f99ea..931a13f 100644
class Test(unittest.TestCase):
@@ -823,6 +829,7 @@ class Test(unittest.TestCase):
@@ -835,6 +841,7 @@ class Test(unittest.TestCase):
np.array([-675286.976033, -682358.043845, -689429.111657, -696500.179469,
-703571.247281]))
......@@ -42,7 +42,7 @@ index a3f99ea..931a13f 100644
def test_get_proj_coords_dask(self):
"""Test get_proj_coords usage with dask arrays."""
from pyresample import utils
@@ -1389,6 +1396,8 @@ class TestSwathDefinition(unittest.TestCase):
@@ -1424,6 +1431,8 @@ class TestSwathDefinition(unittest.TestCase):
assert_np_dict_allclose(res.proj_dict, proj_dict)
self.assertEqual(res.shape, (6, 3))
......@@ -51,7 +51,7 @@ index a3f99ea..931a13f 100644
def test_aggregation(self):
"""Test aggregation on SwathDefinitions."""
if (sys.version_info < (3, 0)):
@@ -1406,6 +1415,7 @@ class TestSwathDefinition(unittest.TestCase):
@@ -1441,6 +1450,7 @@ class TestSwathDefinition(unittest.TestCase):
np.testing.assert_allclose(res.lons, [[179, -179]])
np.testing.assert_allclose(res.lats, [[0.5, 0.5]], atol=2e-5)
......@@ -84,12 +84,12 @@ index b3ef1a2..30108ca 100644
"""Test the XArrayResamplerNN class."""
diff --git a/setup.py b/setup.py
index cb098f7..15db3f5 100644
index abb8217..063d6d0 100644
--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ extras_require = {'numexpr': ['numexpr'],
'rasterio': ['rasterio'],
'dask': ['dask>=0.16.1']}
@@ -39,7 +39,7 @@ else:
setup_requires = ['numpy>=1.10.0,<1.17.0']
requirements.append('numpy>=1.10.0,<1.17.0')
-test_requires = ['rasterio', 'dask', 'xarray', 'cartopy', 'pillow', 'matplotlib', 'scipy']
+test_requires = ['rasterio', 'xarray', 'cartopy', 'pillow', 'matplotlib', 'scipy']
......
......@@ -9,7 +9,7 @@ Subject: Make xarray optional for testing
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/pyresample/test/test_geometry.py b/pyresample/test/test_geometry.py
index 931a13f..0ee95be 100644
index 0cd6ed2..de5fd7e 100644
--- a/pyresample/test/test_geometry.py
+++ b/pyresample/test/test_geometry.py
@@ -24,6 +24,11 @@ if sys.version_info < (2, 7):
......@@ -24,7 +24,7 @@ index 931a13f..0ee95be 100644
try:
import dask
except ImportError:
@@ -1301,6 +1306,7 @@ class TestSwathDefinition(unittest.TestCase):
@@ -1330,6 +1335,7 @@ class TestSwathDefinition(unittest.TestCase):
self.assertFalse(
swath_def == swath_def2, 'swath_defs are not expected to be equal')
......@@ -32,15 +32,15 @@ index 931a13f..0ee95be 100644
def test_compute_omerc_params(self):
"""Test omerc parameters computation."""
lats = np.array([[85.23900604248047, 62.256004333496094, 35.58000183105469],
@@ -1372,6 +1378,7 @@ class TestSwathDefinition(unittest.TestCase):
@@ -1401,6 +1407,7 @@ class TestSwathDefinition(unittest.TestCase):
np.testing.assert_allclose(lats, [80., 80., 80., 80., 80., 80., 80.,
80., 80., 80., 80., 80.])
+ @unittest.skipIf(xarray is None, 'xarray is not available')
def test_compute_optimal_bb(self):
"""Test computing the bb area."""
import xarray as xr
@@ -1396,6 +1403,7 @@ class TestSwathDefinition(unittest.TestCase):
from pyresample.utils import is_pyproj2
@@ -1431,6 +1438,7 @@ class TestSwathDefinition(unittest.TestCase):
assert_np_dict_allclose(res.proj_dict, proj_dict)
self.assertEqual(res.shape, (6, 3))
......@@ -48,7 +48,7 @@ index 931a13f..0ee95be 100644
@unittest.skipIf(not hasattr(DataArray, 'coarsen'), 'DataArray.coarsen not available')
@unittest.skipIf(not dask, 'dask not available')
def test_aggregation(self):
@@ -1415,6 +1423,7 @@ class TestSwathDefinition(unittest.TestCase):
@@ -1450,6 +1458,7 @@ class TestSwathDefinition(unittest.TestCase):
np.testing.assert_allclose(res.lons, [[179, -179]])
np.testing.assert_allclose(res.lats, [[0.5, 0.5]], atol=2e-5)
......@@ -56,14 +56,14 @@ index 931a13f..0ee95be 100644
@unittest.skipIf(not dask, 'dask not available')
def test_striding(self):
"""Test striding."""
@@ -1726,6 +1735,7 @@ class TestDynamicAreaDefinition(unittest.TestCase):
self.assertEqual(result.x_size, 395)
self.assertEqual(result.y_size, 539)
@@ -1776,6 +1785,7 @@ class TestDynamicAreaDefinition(unittest.TestCase):
self.assertEqual(result.width, 395)
self.assertEqual(result.height, 539)
+ @unittest.skipIf(xarray is None, 'xarray is not available')
def test_freeze_with_bb(self):
"""Test freezing the area with bounding box computation."""
area = geometry.DynamicAreaDefinition('test_area', 'A test area',
area = geometry.DynamicAreaDefinition('test_area', 'A test area', {'proj': 'omerc'},
diff --git a/pyresample/test/test_kd_tree.py b/pyresample/test/test_kd_tree.py
index 30108ca..1dc8f74 100644
--- a/pyresample/test/test_kd_tree.py
......@@ -89,12 +89,12 @@ index 30108ca..1dc8f74 100644
class TestXArrayResamplerNN(unittest.TestCase):
"""Test the XArrayResamplerNN class."""
diff --git a/setup.py b/setup.py
index 15db3f5..e7901bf 100644
index 063d6d0..b377068 100644
--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ extras_require = {'numexpr': ['numexpr'],
'rasterio': ['rasterio'],
'dask': ['dask>=0.16.1']}
@@ -39,7 +39,7 @@ else:
setup_requires = ['numpy>=1.10.0,<1.17.0']
requirements.append('numpy>=1.10.0,<1.17.0')
-test_requires = ['rasterio', 'xarray', 'cartopy', 'pillow', 'matplotlib', 'scipy']
+test_requires = ['rasterio', 'cartopy', 'pillow', 'matplotlib', 'scipy']
......
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sat, 14 Sep 2019 17:15:02 +0000
Subject: Comapt with dask 1.0
---
pyresample/bucket/__init__.py | 5 +++--
pyresample/test/test_bilinear.py | 30 +++++++++++++++---------------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/pyresample/bucket/__init__.py b/pyresample/bucket/__init__.py
index 9e87678..de6b74b 100644
--- a/pyresample/bucket/__init__.py
+++ b/pyresample/bucket/__init__.py
@@ -130,11 +130,12 @@ class BucketResampler(object):
x_res = (adef.area_extent[2] - adef.area_extent[0]) / adef.width
y_res = (adef.area_extent[3] - adef.area_extent[1]) / adef.height
x_vect = da.arange(adef.area_extent[0] + x_res / 2.,
- adef.area_extent[2] - x_res / 2., x_res)
+ adef.area_extent[2] - x_res / 2., x_res,
+ chunks=-1)
# Orient so that 0-meridian is pointing down
y_vect = da.arange(adef.area_extent[3] - y_res / 2.,
adef.area_extent[1] + y_res / 2.,
- -y_res)
+ -y_res, chunks=-1)
result = da.map_blocks(self._get_proj_coordinates, lons,
lats, x_res, y_res,
diff --git a/pyresample/test/test_bilinear.py b/pyresample/test/test_bilinear.py
index 85ba623..2cf0683 100644
--- a/pyresample/test/test_bilinear.py
+++ b/pyresample/test/test_bilinear.py
@@ -356,7 +356,7 @@ class TestXarrayBilinear(unittest.TestCase):
# Input data around the target pixel at 0.63388324, 55.08234642,
in_shape = (100, 100)
- self.data1 = DataArray(da.ones((in_shape[0], in_shape[1])), dims=('y', 'x'))
+ self.data1 = DataArray(da.ones((in_shape[0], in_shape[1]), chunks='auto'), dims=('y', 'x'))
self.data2 = 2. * self.data1
self.data3 = self.data1 + 9.5
lons, lats = np.meshgrid(np.linspace(-25., 40., num=in_shape[0]),
@@ -549,7 +549,7 @@ class TestXarrayBilinear(unittest.TestCase):
resampler = XArrayResamplerBilinear(self.source_def, self.target_def,
self.radius)
bands = ['R', 'G', 'B']
- data = DataArray(da.ones((3, 10, 10)), dims=('bands', 'y', 'x'),
+ data = DataArray(da.ones((3, 10, 10), chunks='auto'), dims=('bands', 'y', 'x'),
coords={'bands': bands,
'y': np.arange(10), 'x': np.arange(10)})
resampler._add_missing_coordinates(data)
@@ -571,12 +571,12 @@ class TestXarrayBilinear(unittest.TestCase):
self.radius)
# Too many dimensions
- data = DataArray(da.ones((1, 3, 10, 10)))
+ data = DataArray(da.ones((1, 3, 10, 10), chunks='auto'))
with self.assertRaises(ValueError):
_ = resampler._slice_data(data, np.nan)
# 2D data
- data = DataArray(da.ones((10, 10)))
+ data = DataArray(da.ones((10, 10), chunks='auto'))
resampler.slices_x = np.random.randint(0, 10, (100, 4))
resampler.slices_y = np.random.randint(0, 10, (100, 4))
resampler.mask_slices = np.zeros((100, 4), dtype=np.bool)
@@ -593,7 +593,7 @@ class TestXarrayBilinear(unittest.TestCase):
np.all(np.isnan(p_3)) and np.all(np.isnan(p_4)))
# 3D data
- data = DataArray(da.ones((3, 10, 10)))
+ data = DataArray(da.ones((3, 10, 10), chunks='auto'))
resampler.slices_x = np.random.randint(0, 10, (100, 4))
resampler.slices_y = np.random.randint(0, 10, (100, 4))
resampler.mask_slices = np.zeros((100, 4), dtype=np.bool)
@@ -686,8 +686,8 @@ class TestXarrayBilinear(unittest.TestCase):
proj = Proj(self.target_def.proj_str)
in_x, in_y = _get_input_xy_dask(self.source_def, proj,
- da.from_array(self.valid_input_index),
- da.from_array(self.index_array))
+ da.from_array(self.valid_input_index, chunks='auto'),
+ da.from_array(self.index_array, chunks='auto'))
self.assertTrue(in_x.shape, (self.target_def.size, 32))
self.assertTrue(in_y.shape, (self.target_def.size, 32))
@@ -700,8 +700,8 @@ class TestXarrayBilinear(unittest.TestCase):
from pyresample.bilinear.xarr import _mask_coordinates_dask
lons, lats = _mask_coordinates_dask(
- da.from_array([-200., 0., 0., 0., 200.]),
- da.from_array([0., -100., 0, 100., 0.]))
+ da.from_array([-200., 0., 0., 0., 200.], chunks='auto'),
+ da.from_array([0., -100., 0, 100., 0.], chunks='auto'))
lons, lats = da.compute(lons, lats)
self.assertTrue(lons[2] == lats[2] == 0.0)
self.assertEqual(np.sum(np.isnan(lons)), 4)
@@ -720,12 +720,12 @@ class TestXarrayBilinear(unittest.TestCase):
out_x = da.ravel(out_x)
out_y = da.ravel(out_y)
in_x, in_y = _get_input_xy_dask(self.source_def, proj,
- da.from_array(self.valid_input_index),
- da.from_array(self.index_array))
+ da.from_array(self.valid_input_index, chunks='auto'),
+ da.from_array(self.index_array, chunks='auto'))
pt_1, pt_2, pt_3, pt_4, ia_ = _get_bounding_corners_dask(
in_x, in_y, out_x, out_y,
self.neighbours,
- da.from_array(self.index_array))
+ da.from_array(self.index_array, chunks='auto'))
self.assertTrue(pt_1.shape == pt_2.shape ==
pt_3.shape == pt_4.shape ==
@@ -747,8 +747,8 @@ class TestXarrayBilinear(unittest.TestCase):
proj = Proj(self.target_def.proj_str)
in_x, in_y = _get_input_xy_dask(self.source_def, proj,
- da.from_array(self.valid_input_index),
- da.from_array(self.index_array))
+ da.from_array(self.valid_input_index, chunks='auto'),
+ da.from_array(self.index_array, chunks='auto'))
out_x, out_y = self.target_def.get_proj_coords(chunks=CHUNK_SIZE)
out_x = da.ravel(out_x)
out_y = da.ravel(out_y)
@@ -765,7 +765,7 @@ class TestXarrayBilinear(unittest.TestCase):
# Use lower left source pixels for testing
valid = (x_diff > 0) & (y_diff > 0)
x_3, y_3, idx_3 = _get_corner_dask(stride, valid, in_x, in_y,
- da.from_array(self.index_array))
+ da.from_array(self.index_array, chunks='auto'))
self.assertTrue(x_3.shape == y_3.shape == idx_3.shape ==
(self.target_def.size, ))
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sat, 14 Sep 2019 17:20:06 +0000
Subject: Skip test on deprecatet basemap
---
pyresample/test/test_plot.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/pyresample/test/test_plot.py b/pyresample/test/test_plot.py
index bc446e3..02728cd 100644
--- a/pyresample/test/test_plot.py
+++ b/pyresample/test/test_plot.py
@@ -57,6 +57,7 @@ class Test(unittest.TestCase):
self.assertAlmostEqual(b, 6356752.3142451793,
msg='Failed to get semi-minor axis of ellipsis')
+ @unittest.skip('deprecated interface')
@unittest.skipIf(Basemap is None, "basemap is not available")
def test_area_def2basemap(self):
from pyresample import plot
......@@ -2,3 +2,5 @@
0002-Skip-dask-related-tests-if-dask-is-not-available.patch
0003-Make-xarray-optional-for-testing.patch
0004-Detect-broken-basemap.patch
0005-Comapt-with-dask-1.0.patch
0006-Skip-test-on-deprecatet-basemap.patch
......@@ -31,6 +31,11 @@ pyresample.utils
.. automodule:: pyresample.utils
:members:
pyresample.area_config
----------------------
.. automodule:: pyresample.area_config
:members:
pyresample.data_reduce
----------------------
.. automodule:: pyresample.data_reduce
......@@ -45,3 +50,8 @@ pyresample.ewa
--------------
.. automodule:: pyresample.ewa
:members:
pyresample.bucket
-----------------
.. automodule:: pyresample.bucket
:members:
......@@ -237,5 +237,5 @@ intersphinx_mapping = {
'pyresample': ('https://pyresample.readthedocs.io/en/stable', None),
'trollsift': ('https://trollsift.readthedocs.io/en/stable', None),
'trollimage': ('https://trollimage.readthedocs.io/en/stable', None),
'proj4': ('https://proj4.org', None),
'proj4': ('https://proj.org', None),
}
......@@ -51,60 +51,48 @@ where
* **upper_right_x**: projection x coordinate of upper right corner of upper right pixel
* **upper_right_y**: projection y coordinate of upper right corner of upper right pixel
Below are three examples of creating an ``AreaDefinition``:
Example:
.. doctest::
>>> from pyresample.geometry import AreaDefinition
>>> # a) Using a projection dictionary
>>> area_id = 'ease_sh'
>>> description = 'Antarctic EASE grid'
>>> proj_id = 'ease_sh'
>>> proj_dict = {'proj': 'laea', 'lat_0': -90, 'lon_0': 0, 'a': 6371228.0, 'units': 'm'}
>>> projection = {'proj': 'laea', 'lat_0': -90, 'lon_0': 0, 'a': 6371228.0, 'units': 'm'}
>>> width = 425
>>> height = 425
>>> area_extent = (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
>>> area_def = AreaDefinition(area_id, description, proj_id, proj_dict,
>>> area_def = AreaDefinition(area_id, description, proj_id, projection,
... width, height, area_extent)
>>> print(area_def)
>>> area_def
Area ID: ease_sh
Description: Antarctic EASE grid
Projection ID: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
>>> # b) Using an explicit proj4 string
>>> proj_string = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
>>> area_def = AreaDefinition(area_id, description, proj_id, proj_string,
You can also specify the projection using a PROJ.4 string
.. doctest::
>>> projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
>>> area_def = AreaDefinition(area_id, description, proj_id, projection,
... width, height, area_extent)
>>> print(area_def)
Area ID: ease_sh
Description: Antarctic EASE grid
Projection ID: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
>>> # c) Using an EPSG code in a proj4 string
>>> proj_string = '+init=EPSG:3409' # Use 'EPSG:3409' with pyproj 2.0+
>>> area_def = AreaDefinition(area_id, description, proj_id, proj_string,
or an `EPSG code <https://www.epsg-registry.org/>`_:
.. doctest::
>>> projection = '+init=EPSG:3409' # Use 'EPSG:3409' with pyproj 2.0+
>>> area_def = AreaDefinition(area_id, description, proj_id, projection,
... width, height, area_extent)
>>> print(area_def)
Area ID: ease_sh
Description: Antarctic EASE grid
Projection ID: ease_sh
Projection: {'init': 'EPSG:3409'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
.. note::
When using pyproj 2.0+, please use the new ``'EPSG:XXXX'`` syntax
With pyproj 2.0+ please use the new ``'EPSG:XXXX'`` syntax
as the old ``'+init=EPSG:XXXX'`` is no longer supported.
Creating an ``AreaDefinition`` can be complex if you don't know everything
......
......@@ -11,7 +11,7 @@ AreaDefinition Creation
The main utility function for creating
:class:`~pyresample.geometry.AreaDefinition` objects is the
:func:`~pyresample.utils.create_area_def` function. This function will take
:func:`~pyresample.area_config.create_area_def` function. This function will take
whatever information can be provided to describe a geographic region and
create a valid ``AreaDefinition`` object if possible. If it can't make
a fully specified ``AreaDefinition`` then it will provide a
......@@ -46,17 +46,17 @@ and optional arguments:
.. doctest::
>>> from pyresample import utils
>>> from pyresample import create_area_def
>>> area_id = 'ease_sh'
>>> proj_dict = {'proj': 'laea', 'lat_0': -90, 'lon_0': 0, 'a': 6371228.0, 'units': 'm'}
>>> center = (0, 0)
>>> radius = (5326849.0625, 5326849.0625)
>>> resolution = (25067.525, 25067.525)
>>> area_def = utils.create_area_def(area_id, proj_dict, center=center, radius=radius, resolution=resolution)
>>> area_def = create_area_def(area_id, proj_dict, center=center, radius=radius, resolution=resolution)
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -68,12 +68,12 @@ keyword arguments can be specified with one value if ``dx == dy``:
.. doctest::
>>> proj_string = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
>>> area_def = utils.create_area_def(area_id, proj_string, center=center,
>>> area_def = create_area_def(area_id, proj_string, center=center,
... radius=5326849.0625, resolution=25067.525)
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -85,25 +85,44 @@ the mercator projection with radius and resolution defined in degrees.
.. doctest::
>>> proj_dict = {'proj': 'merc', 'lat_0': 0, 'lon_0': 0, 'a': 6371228.0, 'units': 'm'}
>>> area_def = utils.create_area_def(area_id, proj_dict, center=(0, 0),
>>> area_def = create_area_def(area_id, proj_dict, center=(0, 0),
... radius=(47.90379019311, 43.1355420077),
... resolution=(0.22542960090875294, 0.22542901929487608),
... units='degrees', description='Antarctic EASE grid')
>>> print(area_def)
Area ID: ease_sh
Description: Antarctic EASE grid
Projection: {'a': '6371228.0', 'lat_0': '0.0', 'lon_0': '0.0', 'proj': 'merc', 'units': 'm'}
Projection: {'a': '6371228.0', 'lat_0': '0', 'lon_0': '0', 'proj': 'merc', 'type': 'crs', 'units': 'm'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
The area definition corresponding to a given lat-lon grid (defined by area extent and resolution)
can be obtained as follows:
.. doctest::
>>> area_def = create_area_def('my_area',
... {'proj': 'latlong', 'lon_0': 0},
... area_extent=[-180, -90, 180, 90],
... resolution=1,
... units='degrees',
... description='Global 1x1 degree lat-lon grid')
>>> print(area_def)
Area ID: my_area
Description: Global 1x1 degree lat-lon grid
Projection: {'lon_0': '0', 'proj': 'latlong', 'type': 'crs'}
Number of columns: 360
Number of rows: 180
Area extent: (-180.0, -90.0, 180.0, 90.0)
If only one of **area_extent** or **shape** can be computed from the
information provided by the user, a
:class:`~pyresample.geometry.DynamicAreaDefinition` object is returned:
.. doctest::
>>> area_def = utils.create_area_def(area_id, proj_string, radius=radius, resolution=resolution)
>>> area_def = create_area_def(area_id, proj_string, radius=radius, resolution=resolution)
>>> print(type(area_def))
<class 'pyresample.geometry.DynamicAreaDefinition'>
......@@ -118,7 +137,7 @@ AreaDefinition Class Methods
There are four class methods available on the
:class:`~pyresample.geometry.AreaDefinition` class utilizing
:func:`~pyresample.utils.create_area_def` providing a simpler interface to the
:func:`~pyresample.area_config.create_area_def` providing a simpler interface to the
functionality described in the previous section.
Hence each argument used below is the same as the ``create_area_def`` arguments
described above and can be used in the same way (i.e. units). The following
......@@ -132,7 +151,6 @@ from_extent
.. doctest::
>>> from pyresample import utils
>>> from pyresample.geometry import AreaDefinition
>>> area_id = 'ease_sh'
>>> proj_string = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
......@@ -142,7 +160,7 @@ from_extent
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -161,7 +179,7 @@ from_circle
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -173,7 +191,7 @@ from_circle
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -189,7 +207,7 @@ from_area_of_interest
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -204,7 +222,7 @@ from_ul_corner
>>> print(area_def)
Area ID: ease_sh
Description: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -374,7 +392,7 @@ read a single ``AreaDefinition`` named ``corner`` by doing:
>>> print(area_def)
Area ID: corner
Description: Example of making an area definition using shape, upper_left_extent, and resolution
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -388,7 +406,7 @@ series of arguments:
>>> print(boundary)
Area ID: ease_sh
Description: Example of making an area definition using shape and area_extent
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -429,7 +447,7 @@ An area definition dict can be read using
Area ID: ease_nh
Description: Arctic EASE grid
Projection ID: ease_nh
Projection: {'a': '6371228.0', 'lat_0': '90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -445,7 +463,7 @@ Several area definitions can be read at once using the region names in an argume
Area ID: ease_sh
Description: Antarctic EASE grid
Projection ID: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90.0', 'lon_0': '0.0', 'proj': 'laea', 'units': 'm'}
Projection: {'R': '6371228', 'lat_0': '-90', 'lon_0': '0', 'no_defs': 'None', 'proj': 'laea', 'type': 'crs', 'units': 'm', 'x_0': '0', 'y_0': '0'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)
......@@ -16,6 +16,7 @@ Pyresample offers multiple resampling algorithms including:
- Nearest Neighbor
- Elliptical Weighted Average (EWA)
- Bilinear
- Bucket resampling (count hits per bin, averaging, ratios)
For nearest neighbor and bilinear interpolation pyresample uses a kd-tree
approach by using the fast KDTree implementation provided by the
......
......@@ -130,7 +130,7 @@ Cartopy CRS object.
>>> ax = plt.axes(projection=crs)
>>> ax.coastlines()
>>> ax.set_global()
>>> plt.imshow(data, transform=crs, extent=crs.bounds, origin='upper')
>>> plt.imshow(result, transform=crs, extent=crs.bounds, origin='upper')
>>> plt.colorbar()
>>> plt.savefig('viirs_i04_cartopy.png')
......
......@@ -459,3 +459,12 @@ Example
>>> rows_per_scan = 5
>>> # fornav resamples the swath data to the gridded area
>>> num_valid_points, gridded_data = fornav(cols, rows, area_def, data, rows_per_scan=rows_per_scan)
pyresample.bucket
-----------------
.. autoclass:: pyresample.bucket.BucketResampler
:noindex:
See :class:`~pyresample.bucket.BucketResampler` API documentation for
the details of method parameters.
......@@ -110,36 +110,15 @@ class cKDTree_MP(object):
class BaseProj(pyproj.Proj):
"""Helper class for easier backwards compatibility."""
def __init__(self, projparams=None, preserve_units=True, **kwargs):
# Copy dict-type arguments as they will be modified in-place
if isinstance(projparams, dict):
projparams = projparams.copy()
# Pyproj<2 uses __new__ to initiate data and does not define its own __init__ method.
if is_pyproj2():
# If init is found in any of the data, override any other area parameters.
if 'init' in kwargs:
warnings.warn('init="EPSG:XXXX" is no longer supported. Use "EPSG:XXXX" as a proj string instead')
projparams = kwargs.pop('init')
# Proj takes params in projparams over the params in kwargs.
if isinstance(projparams, (dict, str)) and 'init' in projparams:
warn_msg = '{"init": "EPSG:XXXX"} is no longer supported. Use "EPSG:XXXX" as a proj string instead'
if isinstance(projparams, str):
warn_msg = '"+init=EPSG:XXXX" is no longer supported. Use "EPSG:XXXX" as a proj string instead'
# Proj-dicts are cleaner to parse than strings.
projparams = proj4_str_to_dict(projparams)
warnings.warn(warn_msg)
projparams = projparams.pop('init')
# New syntax 'EPSG:XXXX'
if 'EPSG' in kwargs or (isinstance(projparams, dict) and 'EPSG' in projparams):
if 'EPSG' in kwargs:
epsg_code = kwargs.pop('EPSG')
else:
epsg_code = projparams.pop('EPSG')
projparams = 'EPSG:{}'.format(epsg_code)
super(BaseProj, self).__init__(projparams=projparams, preserve_units=preserve_units, **kwargs)
# have to have this because pyproj uses __new__
# subclasses would fail when calling __init__ otherwise
super(BaseProj, self).__init__(projparams=projparams,
preserve_units=preserve_units,
**kwargs)
def is_latlong(self):
if is_pyproj2():
......@@ -148,6 +127,7 @@ class BaseProj(pyproj.Proj):
class Proj(BaseProj):
"""Helper class to skip transforming lon/lat projection coordinates."""
def __call__(self, data1, data2, inverse=False, radians=False,
errcheck=False, nprocs=1):
......
......@@ -335,8 +335,9 @@ def _get_proj4_args(proj4_args):
"""Create dict from proj4 args."""
from pyresample.utils._proj4 import convert_proj_floats
if isinstance(proj4_args, (str, six.text_type)):
proj_config = proj4_str_to_dict(str(proj4_args))
else:
# float conversion is done in `proj4_str_to_dict` already
return proj4_str_to_dict(str(proj4_args))
from configobj import ConfigObj
proj_config = ConfigObj(proj4_args)
return convert_proj_floats(proj_config.items())
......@@ -417,12 +418,17 @@ def create_area_def(area_id, projection, width=None, height=None, area_extent=No
description = kwargs.pop('description', area_id)
proj_id = kwargs.pop('proj_id', None)
# convert EPSG dictionaries to projection string
# (hold on to EPSG code as much as possible)
if isinstance(projection, dict) and 'EPSG' in projection:
projection = "EPSG:{}".format(projection['EPSG'])
# Get a proj4_dict from either a proj4_dict or a proj4_string.
proj_dict = _get_proj_data(projection)
try:
p = Proj(proj_dict, preserve_units=True)
p = Proj(projection, preserve_units=True)
except RuntimeError:
return _make_area(area_id, description, proj_id, proj_dict, shape, area_extent, **kwargs)
return _make_area(area_id, description, proj_id, projection, shape, area_extent, **kwargs)
# If no units are provided, try to get units used in proj_dict. If still none are provided, use meters.
if units is None:
......@@ -457,7 +463,7 @@ def create_area_def(area_id, projection, width=None, height=None, area_extent=No
_extrapolate_information(area_extent, shape, center, radius,
resolution, upper_left_extent, units,
p, proj_dict)
return _make_area(area_id, description, proj_id, proj_dict, shape,
return _make_area(area_id, description, proj_id, projection, shape,
area_extent, resolution=resolution, **kwargs)
......@@ -482,7 +488,23 @@ def _make_area(area_id, description, proj_id, proj_dict, shape, area_extent, **k
def _get_proj_data(projection):
"""Takes a proj4_dict or proj4_string and returns a proj4_dict and a Proj function."""
"""Takes a proj4_dict or proj4_string and returns a proj4_dict and a Proj function.
There is special handling for the "EPSG:XXXX" case where "XXXX" is an
EPSG number code. It can be provided as a string `"EPSG:XXXX"` or as a
dictionary (when provided via YAML) as `{'EPSG': XXXX}`.
If it is passed as a string ("EPSG:XXXX") then the rules of
:func:`~pyresample.utils._proj.proj4_str_to_dict` are followed.
If a dictionary and pyproj 2.0+ is installed then the string
`"EPSG:XXXX"` is passed to ``proj4_str_to_dict``. If pyproj<2.0
is installed then the string ``+init=EPSG:XXXX`` is passed to
``proj4_str_to_dict`` which provides limited information to area
config operations.
"""
if isinstance(projection, dict) and 'EPSG' in projection:
projection = "EPSG:{}".format(projection['EPSG'])
if isinstance(projection, str):
proj_dict = proj4_str_to_dict(projection)
elif isinstance(projection, dict):
......
This diff is collapsed.