Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Scheffler
arosics
Commits
d6c8e5bb
Commit
d6c8e5bb
authored
Apr 18, 2018
by
Daniel Scheffler
Browse files
Updated test_COREG.py.
parent
3b09778f
Pipeline
#2912
failed with stages
in 41 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/test_COREG.py
View file @
d6c8e5bb
...
...
@@ -3,12 +3,10 @@
"""Tests for the global co-registration module of AROSICS."""
import
unittest
import
shutil
import
os
# custom
from
.cases
import
test_cases
from
arosics
import
COREG
...
...
@@ -24,7 +22,6 @@ class COREG_GLOBAL_init(unittest.TestCase):
self
.
coreg_kwargs
=
test_cases
[
'INTER1'
][
'kwargs_global'
]
self
.
coreg_kwargs
[
'wp'
]
=
test_cases
[
'INTER1'
][
'wp_inside'
]
def
test_coreg_init_from_disk
(
self
):
self
.
CRL
=
COREG
(
self
.
ref_path
,
self
.
tgt_path
,
**
self
.
coreg_kwargs
)
...
...
@@ -41,7 +38,6 @@ class COREG_GLOBAL_init(unittest.TestCase):
self
.
CRL
=
COREG
(
self
.
ref_gA
,
self
.
tgt_gA
,
**
self
.
coreg_kwargs
)
class
CompleteWorkflow_INTER1_S2A_S2A
(
unittest
.
TestCase
):
"""Test case for the complete workflow of global co-registration based on two Sentinel-2 datasets, one with
~25% cloud cover, the other one without any clouds. The subsets cover the S2A tiles only partly (nodata areas
...
...
@@ -53,14 +49,12 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
self
.
tgt_path
=
test_cases
[
'INTER1'
][
'tgt_path'
]
self
.
coreg_kwargs
=
test_cases
[
'INTER1'
][
'kwargs_global'
]
def
tearDown
(
self
):
"""Delete output."""
dir_out
=
os
.
path
.
dirname
(
self
.
coreg_kwargs
[
'path_out'
])
if
os
.
path
.
isdir
(
dir_out
):
shutil
.
rmtree
(
dir_out
)
def
run_shift_detection_correction
(
self
,
ref
,
tgt
,
**
params
):
# get instance of COREG_LOCAL object
CR
=
COREG
(
ref
,
tgt
,
**
params
)
...
...
@@ -77,7 +71,6 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
return
CR
def
test_shift_calculation_with_default_params
(
self
):
"""Test with default parameters - should compute X/Y shifts properly ad write the de-shifted target image."""
...
...
@@ -87,7 +80,29 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
footprint_poly_tgt
=
None
))
self
.
assertTrue
(
CR
.
success
)
#@unittest.SkipTest
def
test_shift_calculation_with_image_coords_only
(
self
):
"""Test with default parameters - should compute X/Y shifts properly ad write the de-shifted target image."""
# overwrite gt and prj
ref
=
GeoArray
(
self
.
ref_path
)
ref
.
to_mem
()
ref
.
filePath
=
None
ref
.
gt
=
[
0
,
1
,
0
,
0
,
0
,
-
1
]
ref
.
prj
=
''
tgt
=
GeoArray
(
self
.
tgt_path
)
tgt
.
to_mem
()
tgt
.
filePath
=
None
tgt
.
gt
=
[
0
,
1
,
0
,
0
,
0
,
-
1
]
tgt
.
prj
=
''
CR
=
self
.
run_shift_detection_correction
(
ref
,
tgt
,
**
dict
(
self
.
coreg_kwargs
,
wp
=
(
1200
,
-
1600
),
footprint_poly_ref
=
None
,
footprint_poly_tgt
=
None
))
self
.
assertTrue
(
CR
.
success
)
# @unittest.SkipTest
def
test_shift_calculation_verboseMode
(
self
):
"""Test the verbose mode - runs the functions of the plotting submodule."""
...
...
@@ -95,7 +110,6 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
**
dict
(
self
.
coreg_kwargs
,
v
=
True
))
self
.
assertTrue
(
CR
.
success
)
def
test_shift_calculation_windowCoveringNodata
(
self
):
"""Test shift detection in case the given matching window (defined by 'wp' and 'ws' covers the nodata area
of an input image.
...
...
@@ -107,11 +121,10 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
# TODO compare to expected results
CR
=
self
.
run_shift_detection_correction
(
self
.
ref_path
,
self
.
tgt_path
,
**
dict
(
self
.
coreg_kwargs
,
wp
=
test_cases
[
'INTER1'
][
'wp_covering_nodata'
],
ws
=
(
256
,
256
)))
wp
=
test_cases
[
'INTER1'
][
'wp_covering_nodata'
],
ws
=
(
256
,
256
)))
self
.
assertTrue
(
CR
.
success
)
def
test_shift_calculation_windowAtImageEdge
(
self
):
"""Test shift detection in case the given matching window is close to an image edge without covering any nodata
area.
...
...
@@ -123,10 +136,9 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
# TODO compare to expected results
CR
=
self
.
run_shift_detection_correction
(
self
.
ref_path
,
self
.
tgt_path
,
**
dict
(
self
.
coreg_kwargs
,
wp
=
test_cases
[
'INTER1'
][
'wp_close_to_edge'
],
ws
=
(
256
,
256
)))
wp
=
test_cases
[
'INTER1'
][
'wp_close_to_edge'
],
ws
=
(
256
,
256
)))
self
.
assertTrue
(
CR
.
success
)
def
test_shift_calculation_windowOutside
(
self
):
"""Test if shift computation properly raises a ValueError if the given window position is outside of the image
overlap."""
...
...
@@ -136,7 +148,6 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
**
dict
(
self
.
coreg_kwargs
,
wp
=
test_cases
[
'INTER1'
][
'wp_outside'
]))
def
test_shift_calculation_windowAtClouds
(
self
):
"""Test if shift computation properly raises a RunTimeError if the matching window is centered at a cloudy
image position.
...
...
@@ -145,42 +156,40 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
with
self
.
assertRaises
(
RuntimeError
):
self
.
run_shift_detection_correction
(
self
.
ref_path
,
self
.
tgt_path
,
**
dict
(
self
.
coreg_kwargs
,
wp
=
test_cases
[
'INTER1'
][
'wp_cloudy'
],
ws
=
(
256
,
256
)))
wp
=
test_cases
[
'INTER1'
][
'wp_cloudy'
],
ws
=
(
256
,
256
)))
def
test_shift_calculation_differentInputGrids
(
self
):
""""""
self
.
skipTest
(
'Not yet implemented.'
)
def
test_shift_calculation_withoutPyFFTW
(
self
):
""""""
self
.
skipTest
(
'Not yet implemented.'
)
def
test_shift_calculation_SSIMdecreases
(
self
):
""""""
self
.
skipTest
(
'Not yet implemented.'
)
#@unittest.SkipTest
def
test_plotting_after_shift_calculation
(
self
):
#
, mock_show):
""""""
#mock_show.return_value = None # probably not necessary here in your case
#
@unittest.SkipTest
def
test_plotting_after_shift_calculation
(
self
):
#
, mock_show):
"""
Test plotting functionality.
"""
#
mock_show.return_value = None # probably not necessary here in your case
CR
=
self
.
run_shift_detection_correction
(
self
.
ref_path
,
self
.
tgt_path
,
**
self
.
coreg_kwargs
)
self
.
assertTrue
(
CR
.
success
)
# test all the visualization functions
CR
.
show_cross_power_spectrum
()
CR
.
show_cross_power_spectrum
(
interactive
=
True
)
CR
.
show_matchWin
(
interactive
=
False
)
CR
.
show_matchWin
(
interactive
=
False
,
after_correction
=
None
)
CR
.
show_matchWin
(
interactive
=
False
,
after_correction
=
True
)
# CR.show_matchWin(interactive=True) # only works if test is started with ipython
# CR.show_matchWin(interactive=False, deshifted=True)
CR
.
show_matchWin
(
interactive
=
False
,
after_correction
=
False
)
CR
.
show_matchWin
(
interactive
=
True
,
after_correction
=
None
)
# only works if test is started with ipython
CR
.
show_matchWin
(
interactive
=
True
,
after_correction
=
True
)
CR
.
show_matchWin
(
interactive
=
True
,
after_correction
=
False
)
CR
.
show_image_footprints
()
#if __name__ == '__main__':
# if __name__ == '__main__':
# unittest.main(argv=['first-arg-is-ignored'],exit=False, verbosity=2)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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