Commit 2aeed839 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'disable_bilinear_for_map2sensor' into 'master'

Disable bilinear resampling when transforming map to sensor geometry

Closes #7

See merge request !7
parents 0d7331fa 240bd229
Pipeline #35274 canceled with stage
in 20 minutes and 1 second
......@@ -2,10 +2,13 @@
History
=======
0.5.1 (coming soon)
-------------------
0.5.1 (2021-11-26)
------------------
* Replaced deprecated gdalnumeric import.
* Disabled bilinear resampling for map to sensor geometry transformation due to upstream incompatibility
(https://git.gfz-potsdam.de/EnMAP/sensormapgeo/-/issues/7).
* Removed pyresample version pinning which fixes multiple DeprecationWarnings.
0.5.0 (2021-09-27)
......
......@@ -47,6 +47,8 @@ from pyresample.geometry import AreaDefinition, SwathDefinition, create_area_def
from pyresample.bilinear import resample_bilinear
from pyresample.kd_tree import resample_nearest, resample_gauss, resample_custom
from .version import __version__ as _libver
class SensorMapGeometryTransformer(object):
def __init__(self,
......@@ -386,12 +388,20 @@ class SensorMapGeometryTransformer(object):
def to_sensor_geometry(self, data: np.ndarray,
src_prj: Union[str, int],
src_extent: Tuple[float, float, float, float]) -> np.ndarray:
"""Transform the input map geometry array into sensor geometry
"""Transform the input map geometry array into sensor geometry.
:param data: numpy array (representing map geometry) to be warped to sensor geometry
:param src_prj: projection of the input map geometry array (WKT or 'epsg:1234' or <EPSG_int>)
:param src_extent: extent coordinates of input map geometry array (LL_x, LL_y, UR_x, UR_y) in the src_prj
"""
# reject bilinear resampling due to https://git.gfz-potsdam.de/EnMAP/sensormapgeo/-/issues/7
if self.resamp_alg == 'bilinear':
warnings.warn(f"Bilinear resampling is not available in sensormapgeo {_libver} when transforming map "
f"geometry to sensor geometry due to changes in upstream packages. Using 'gauss' instead. "
f"Note that bilinear resampling works in sensormapgeo<=0.5.0.", RuntimeWarning)
self.resamp_alg = 'gauss'
self.opts['radius_of_influence'] = self.opts.pop('radius')
# get area_definition
self.area_definition = AreaDefinition('', '', '', CRS(src_prj), data.shape[1], data.shape[0],
list(src_extent))
......
......@@ -35,12 +35,13 @@ import platform
from pebble import ProcessPool, ProcessExpired
import numpy as np
from pyproj import CRS
from pyresample import AreaDefinition
from py_tools_ds.geo.coord_trafo import transform_any_prj
from .transformer_2d import \
SensorMapGeometryTransformer, _corner_coords_lonlat_to_extent, \
_move_extent_to_coordgrid, _get_validated_tgt_res
from pyresample import AreaDefinition
from .version import __version__ as _libver
class SensorMapGeometryTransformer3D(object):
......@@ -282,12 +283,21 @@ class SensorMapGeometryTransformer3D(object):
src_prj: Union[str, int],
src_extent: Tuple[float, float, float, float]
) -> np.ndarray:
"""Transform the input map geometry array into sensor geometry
"""Transform the input map geometry array into sensor geometry.
:param data: 3D numpy array (representing map geometry) to be warped to sensor geometry
:param src_prj: projection of the input map geometry array (WKT or 'epsg:1234' or <EPSG_int>)
:param src_extent: extent coordinates of input map geometry array (LL_x, LL_y, UR_x, UR_y) in the src_prj
"""
# reject bilinear resampling due to https://git.gfz-potsdam.de/EnMAP/sensormapgeo/-/issues/7
if self.resamp_alg == 'bilinear':
warn(f"Bilinear resampling is not available in sensormapgeo {_libver} when transforming map geometry to "
f"sensor geometry due to changes in upstream packages. Using 'gauss' instead. "
"Note that bilinear resampling works in sensormapgeo<=0.5.0.", RuntimeWarning)
self.resamp_alg = 'gauss'
# self.opts.pop('radius', None)
# self.opts['radius_of_influence'] = 30 # default
if data.ndim != 3:
raise ValueError(data.ndim, "'data' must have 3 dimensions.")
......
......@@ -24,6 +24,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = '0.5.0'
__versionalias__ = '20210927.01'
__version__ = '0.5.1'
__versionalias__ = '20211126.01'
__author__ = 'Daniel Scheffler'
......@@ -39,7 +39,7 @@ version = {}
with open("sensormapgeo/version.py") as version_file:
exec(version_file.read(), version)
requirements = ['numpy', 'gdal', 'pyresample>=1.11.0,<1.17.0', 'py_tools_ds>=0.18.0', 'pyproj>=2.2', 'pebble']
requirements = ['numpy', 'gdal', 'pyresample>=1.11.0', 'py_tools_ds>=0.18.0', 'pyproj>=2.2', 'pebble']
setup_requirements = []
......
......@@ -11,7 +11,7 @@ dependencies:
- numpy
- py-tools-ds>=0.18.0
- pyproj>=2.2
- pyresample>=1.11.0,<1.17.0 # below 1.17.0 due to https://github.com/pytroll/pyresample/issues/325
- pyresample>=1.11.0
- pip:
- pebble
......
......@@ -277,5 +277,5 @@ class Test_SensorMapGeometryTransformer3D(TestCase):
src_prj=32632,
src_extent=self.dem_area_extent_coarse_subset_utm)
self.assertIsInstance(dem_sensors_geo, np.ndarray)
self.assertEqual(dem_sensors_geo.shape, (150, 1000, 2))
self.assertEqual(dem_sensors_geo.shape, (150, 1000, 2))
self.assertEqual(self.data_map_geo_3D.dtype, dem_sensors_geo.dtype)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment