Commit 024e35a4 authored by Daniel Scheffler's avatar Daniel Scheffler

Fixed incompatibility of SensorMapGeometryTransformer with 3D input arrays. Updated version info.

Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 1c81181c
Pipeline #5059 passed with stage
in 1 minute
......@@ -795,7 +795,7 @@ class SensorMapGeometryTransformer(object):
% (str((self.area_definition.height, self.area_definition.width)),
str(data_mapgeo.shape[:2])))
if data.ndim > 2 and data_mapgeo.ndim == 2:
raise RuntimeError('The computed map geometry output only one band instead of the expected %d bands.'
raise RuntimeError('The computed map geometry output has only one band instead of the expected %d bands.'
% data.shape[2])
return data_mapgeo, out_gt, out_prj # type: Tuple[np.ndarray, tuple, str]
......@@ -818,11 +818,15 @@ class SensorMapGeometryTransformer(object):
data_sensorgeo = self._resample(data, self.area_definition, self.swath_definition)
# output validation
if not data_sensorgeo.shape == self.lats.shape:
raise RuntimeError('The computed sensor geometry output does not have the same size like the coordinates '
'array. Coordinates array: %s; output array: %s.'
if not data_sensorgeo.shape[:2] == self.lats.shape[:2]:
raise RuntimeError('The computed sensor geometry output does not have the same X/Y dimension like the '
'coordinates array. Coordinates array: %s; output array: %s.'
% (self.lats.shape, data_sensorgeo.shape))
if data.ndim > 2 and data_sensorgeo.ndim == 2:
raise RuntimeError('The computed sensor geometry output has only one band instead of the expected %d bands.'
% data.shape[2])
return data_sensorgeo
......
......@@ -19,5 +19,5 @@
# 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__ = '0.14.21'
__versionalias__ = '20190814_01'
__version__ = '0.14.22'
__versionalias__ = '20191016_01'
......@@ -74,6 +74,17 @@ class Test_SensorMapGeometryTransformer(TestCase):
self.assertFalse(np.array_equal(np.unique(dem_sensors_geo), np.array([0])))
self.assertEquals(dem_sensors_geo.shape, (150, 1000))
def test_to_sensor_geometry_3DInput(self):
SMGT = SensorMapGeometryTransformer(lons=self.lons,
lats=self.lats,
resamp_alg='nearest')
dem_sensors_geo = SMGT.to_sensor_geometry(np.dstack([self.dem_map_geo] * 2),
src_prj=32632, src_extent=self.dem_area_extent_coarse_subset_utm)
self.assertIsInstance(dem_sensors_geo, np.ndarray)
self.assertFalse(np.array_equal(np.unique(dem_sensors_geo), np.array([0])))
self.assertEquals(dem_sensors_geo.shape, (150, 1000, 2))
self.assertTrue(np.array_equal(dem_sensors_geo[:, :, 0], dem_sensors_geo[:, :, 1]))
def test_to_map_geometry_lonlat(self):
SMGT = SensorMapGeometryTransformer(lons=self.lons,
lats=self.lats,
......
Markdown is supported
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