Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EnMAP
sensormapgeo
Commits
e7d507ae
Commit
e7d507ae
authored
Nov 26, 2021
by
Daniel Scheffler
Browse files
Simplified tests.
Signed-off-by:
Daniel Scheffler
<
danschef@gfz-potsdam.de
>
parent
59bfa1ba
Pipeline
#35325
failed with stage
in 1 minute and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/test_sensormapgeo.py
View file @
e7d507ae
...
...
@@ -139,23 +139,13 @@ class Test_SensorMapGeometryTransformer:
# GeoArray(dem_map_geo, dem_gt, dem_prj)\
# .save(os.path.join(tests_path, 'test_output', 'resampled_pyresample_ll.bsq'))
assert
isinstance
(
dem_map_geo
,
np
.
ndarray
)
assert
dem_map_geo
.
shape
==
(
SMGT
.
area_definition
.
height
,
SMGT
.
area_definition
.
width
)
xmin
,
xmax
,
ymin
,
ymax
=
\
corner_coord_to_minmax
(
get_corner_coordinates
(
gt
=
dem_gt
,
cols
=
dem_map_geo
.
shape
[
1
],
rows
=
dem_map_geo
.
shape
[
0
])
)
assert
np
.
allclose
(
np
.
array
([
xmin
,
ymin
,
xmax
,
ymax
]),
np
.
array
(
self
.
expected_dem_area_extent_lonlat
))
assert
not
np
.
array_equal
(
np
.
unique
(
dem_map_geo
),
np
.
array
([
0
]))
assert
np
.
isclose
(
np
.
mean
(
dem_map_geo
[
dem_map_geo
!=
0
]),
np
.
mean
(
self
.
dem_sensor_geo
),
rtol
=
0.01
)
assert
self
.
dem_sensor_geo
.
dtype
==
dem_map_geo
.
dtype
self
.
check_result_mapgeo
(
dem_map_geo
,
(
SMGT
.
area_definition
.
height
,
SMGT
.
area_definition
.
width
),
self
.
expected_dem_area_extent_lonlat
,
dem_gt
)
with
pytest
.
raises
(
ValueError
):
SMGT
.
to_map_geometry
(
self
.
dem_sensor_geo
[:
10
,
:
10
],
...
...
@@ -193,22 +183,32 @@ class Test_SensorMapGeometryTransformer:
# GeoArray(dem_map_geo, dem_gt, dem_prj)\
# .save(os.path.join(tests_path, 'test_output', 'resampled_pyresample_bilinear_16n.bsq'))
assert
isinstance
(
dem_map_geo
,
np
.
ndarray
)
assert
dem_map_geo
.
shape
==
(
366
,
976
)
xmin
,
xmax
,
ymin
,
ymax
=
\
corner_coord_to_minmax
(
get_corner_coordinates
(
gt
=
dem_gt
,
cols
=
dem_map_geo
.
shape
[
1
],
rows
=
dem_map_geo
.
shape
[
0
])
)
assert
np
.
allclose
(
np
.
array
([
xmin
,
ymin
,
xmax
,
ymax
]),
np
.
array
(
self
.
expected_dem_area_extent_utm_ongrid
))
assert
not
np
.
array_equal
(
np
.
unique
(
dem_map_geo
),
np
.
array
([
0
]))
assert
np
.
isclose
(
np
.
mean
(
dem_map_geo
[
dem_map_geo
!=
0
]),
np
.
mean
(
self
.
dem_sensor_geo
),
rtol
=
0.01
)
assert
self
.
dem_sensor_geo
.
dtype
==
dem_map_geo
.
dtype
self
.
check_result_mapgeo
(
dem_map_geo
,
(
366
,
976
),
self
.
expected_dem_area_extent_utm_ongrid
,
dem_gt
)
def
check_result_mapgeo
(
self
,
dem_map_geo
,
expected_shape
,
expected_extent
,
dem_gt
):
assert
isinstance
(
dem_map_geo
,
np
.
ndarray
)
assert
dem_map_geo
.
shape
==
expected_shape
xmin
,
xmax
,
ymin
,
ymax
=
\
corner_coord_to_minmax
(
get_corner_coordinates
(
gt
=
dem_gt
,
cols
=
dem_map_geo
.
shape
[
1
],
rows
=
dem_map_geo
.
shape
[
0
])
)
assert
np
.
allclose
(
np
.
array
([
xmin
,
ymin
,
xmax
,
ymax
]),
np
.
array
(
expected_extent
))
assert
not
np
.
array_equal
(
np
.
unique
(
dem_map_geo
),
np
.
array
([
0
]))
assert
np
.
isclose
(
np
.
mean
(
dem_map_geo
[
dem_map_geo
!=
0
]),
np
.
mean
(
self
.
dem_sensor_geo
),
rtol
=
0.01
)
assert
self
.
dem_sensor_geo
.
dtype
==
dem_map_geo
.
dtype
class
Test_SensorMapGeometryTransformer3D
:
...
...
@@ -227,7 +227,8 @@ class Test_SensorMapGeometryTransformer3D:
660473.864409047
,
# LL_x
5269351.40255343
# UR_y
)
# this differs from the 2D version because the geolayer in the second band has slightly different coordinates
# this differs from the 2D version because the geolayer
# in the second band has slightly different coordinates
expected_dem_area_extent_lonlat
=
(
10.685733901515151
,
# LL_x
47.44113415492957
,
# LL_y
...
...
@@ -240,7 +241,8 @@ class Test_SensorMapGeometryTransformer3D:
656188.928052
,
# UR_x
5267203.56579
# UR_y
)
# this differs from the 2D version because the geolayer in the second band has slightly different coordinates
# this differs from the 2D version because the geolayer
# in the second band has slightly different coordinates
expected_dem_area_extent_utm_ongrid
=
(
626910
,
# LL_x
5256240
,
# LL_y
...
...
@@ -273,26 +275,11 @@ class Test_SensorMapGeometryTransformer3D:
# GeoArray(data_mapgeo_3D, dem_gt, dem_prj)\
# .save(os.path.join(tests_path, 'test_output', 'resampled_3D_02_ll.bsq'))
assert
isinstance
(
data_mapgeo_3D
,
np
.
ndarray
)
# only validate number of bands (height and width are validated in 2D version
# fixed numbers may fail here due to float uncertainty errors
assert
np
.
dot
(
*
data_mapgeo_3D
.
shape
[:
2
])
>
\
np
.
dot
(
*
self
.
data_sensor_geo_3D
.
shape
[:
2
])
assert
data_mapgeo_3D
.
shape
[
2
]
==
2
xmin
,
xmax
,
ymin
,
ymax
=
\
corner_coord_to_minmax
(
get_corner_coordinates
(
gt
=
dem_gt
,
cols
=
data_mapgeo_3D
.
shape
[
1
],
rows
=
data_mapgeo_3D
.
shape
[
0
])
)
assert
np
.
allclose
(
np
.
array
([
xmin
,
ymin
,
xmax
,
ymax
]),
np
.
array
(
self
.
expected_dem_area_extent_lonlat
))
assert
np
.
isclose
(
np
.
mean
(
data_mapgeo_3D
[
data_mapgeo_3D
!=
0
]),
np
.
mean
(
self
.
data_sensor_geo_3D
),
rtol
=
0.01
)
assert
self
.
data_sensor_geo_3D
.
dtype
==
data_mapgeo_3D
.
dtype
self
.
check_result_mapgeo
(
data_mapgeo_3D
,
self
.
expected_dem_area_extent_lonlat
,
dem_gt
)
def
test_to_map_geometry_utm_3D_geolayer
(
self
,
subtests
):
for
rsp_alg
in
rsp_algs
:
...
...
@@ -322,26 +309,11 @@ class Test_SensorMapGeometryTransformer3D:
# GeoArray(data_mapgeo_3D, dem_gt, dem_prj)\
# .save(os.path.join(tests_path, 'test_output', 'resampled_3D_02_pyresample.bsq'))
assert
isinstance
(
data_mapgeo_3D
,
np
.
ndarray
)
# only validate number of bands (height and width are validated in 2D version
# fixed numbers may fail here due to float uncertainty errors
assert
np
.
dot
(
*
data_mapgeo_3D
.
shape
[:
2
])
>
\
np
.
dot
(
*
self
.
data_sensor_geo_3D
.
shape
[:
2
])
assert
data_mapgeo_3D
.
shape
[
2
]
==
2
xmin
,
xmax
,
ymin
,
ymax
=
\
corner_coord_to_minmax
(
get_corner_coordinates
(
gt
=
dem_gt
,
cols
=
data_mapgeo_3D
.
shape
[
1
],
rows
=
data_mapgeo_3D
.
shape
[
0
])
)
assert
np
.
allclose
(
np
.
array
([
xmin
,
ymin
,
xmax
,
ymax
]),
np
.
array
(
self
.
expected_dem_area_extent_utm_ongrid
))
assert
np
.
isclose
(
np
.
mean
(
data_mapgeo_3D
[
data_mapgeo_3D
!=
0
]),
np
.
mean
(
self
.
data_sensor_geo_3D
),
rtol
=
0.01
)
assert
self
.
data_sensor_geo_3D
.
dtype
==
data_mapgeo_3D
.
dtype
self
.
check_result_mapgeo
(
data_mapgeo_3D
,
self
.
expected_dem_area_extent_utm_ongrid
,
dem_gt
)
def
test_to_sensor_geometry
(
self
,
subtests
):
for
rsp_alg
in
rsp_algs
:
...
...
@@ -367,3 +339,28 @@ class Test_SensorMapGeometryTransformer3D:
assert
isinstance
(
dem_sensors_geo
,
np
.
ndarray
)
assert
dem_sensors_geo
.
shape
==
(
150
,
1000
,
2
)
assert
self
.
data_map_geo_3D
.
dtype
==
dem_sensors_geo
.
dtype
def
check_result_mapgeo
(
self
,
data_mapgeo_3D
,
expected_extent
,
dem_gt
):
assert
isinstance
(
data_mapgeo_3D
,
np
.
ndarray
)
# only validate number of bands (height and width are validated in 2D version
# fixed numbers may fail here due to float uncertainty errors
assert
np
.
dot
(
*
data_mapgeo_3D
.
shape
[:
2
])
>
\
np
.
dot
(
*
self
.
data_sensor_geo_3D
.
shape
[:
2
])
assert
data_mapgeo_3D
.
shape
[
2
]
==
2
xmin
,
xmax
,
ymin
,
ymax
=
\
corner_coord_to_minmax
(
get_corner_coordinates
(
gt
=
dem_gt
,
cols
=
data_mapgeo_3D
.
shape
[
1
],
rows
=
data_mapgeo_3D
.
shape
[
0
])
)
assert
np
.
allclose
(
np
.
array
([
xmin
,
ymin
,
xmax
,
ymax
]),
np
.
array
(
expected_extent
))
assert
np
.
isclose
(
np
.
mean
(
data_mapgeo_3D
[
data_mapgeo_3D
!=
0
]),
np
.
mean
(
self
.
data_sensor_geo_3D
),
rtol
=
0.01
)
assert
self
.
data_sensor_geo_3D
.
dtype
==
data_mapgeo_3D
.
dtype
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment