Commit df88bfb9 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Implemented additional tests.

parent 95df7edf
Pipeline #411 passed with stages
in 8 minutes and 51 seconds
......@@ -57,4 +57,4 @@ def subplot_3dsurface(ims,shapetuple=None):
plt.tight_layout()
plt.show(block=True)
return fig
\ No newline at end of file
return fig
......@@ -16,9 +16,16 @@ test_cases = dict(
kwargs_global = dict(
path_out = os.path.join(tests_path, 'output/testcase_inter1_S2A_S2A/'
'tgt_S2A_20160529T153631_T33UUU_sub_CR_global.bsq'),
footprint_poly_ref= 'POLYGON ((340870 5862000, 354000 5862000, 354000 5830000, 331320 5830000, '
'340870 5862000))',
footprint_poly_tgt= 'POLYGON ((341890 5866490, 356180 5866490, 356180 5834970, 335440 5834970, '
'335490 5845270, 341890 5866490))',
progress = False,
v = 0),
wp_inside = (344720, 5848485),# (344932, 5842974), # inside of overlap
wp_inside = (344720, 5848485),# inside of overlap
wp_covering_nodata = (339611, 5856426), # close to the image edge of the input images -> win>64px covers nodata
wp_close_to_edge = (353810, 5840516), # close to the image edge of the input images -> win>64px covers nodata
wp_cloudy = (353308, 5859404), # at a cloudy position of the target image
wp_outside = (349533, 5818862), # outside of overlap
kwargs_local = dict(
grid_res = 100,
......
......@@ -80,27 +80,71 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
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."""
self.run_shift_detection_correction(self.ref_path, self.tgt_path, **self.coreg_kwargs)
CR = self.run_shift_detection_correction(self.ref_path, self.tgt_path,
**dict(self.coreg_kwargs,
footprint_poly_ref=None,
footprint_poly_tgt=None))
self.assertTrue(CR.success)
@unittest.skip
def test_shift_calculation_verboseMode(self):
"""Test the verbose mode - runs the functions of the plotting submodule."""
self.run_shift_detection_correction(self.ref_path, self.tgt_path,
**dict(self.coreg_kwargs,
v = True))
CR = self.run_shift_detection_correction(self.ref_path, self.tgt_path,
**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.
self.skipTest('Not yet implemented.')
Detected subpixel shifts (X/Y): 0.280572488796/-0.11016529071
Calculated map shifts (X,Y): -7.19427511207/-18.8983470928
"""
# 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)))
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.
self.skipTest('Not yet implemented.')
Detected subpixel shifts (X/Y): 0.34361492307/-0.320197995758
Calculated map shifts (X,Y): -6.56385076931/-16.7980200425
"""
# 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)))
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."""
with self.assertRaises(ValueError):
self.run_shift_detection_correction(self.ref_path, self.tgt_path,
**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.
"""
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)))
def test_shift_calculation_differentInputGrids(self):
......@@ -120,11 +164,14 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
self.skipTest('Not yet implemented.')
@unittest.skip
def test_plotting_after_shift_calculation(self):
""""""
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)
......@@ -132,9 +179,3 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
# CR.show_matchWin(interactive=True) # only works if test is started with ipython
# CR.show_matchWin(interactive=False, deshifted=True)
CR.show_image_footprints()
def test_if_shift_calculation_fails(self):
""""""
self.skipTest('Not yet implemented.')
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