Commit 9d1e8644 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed issue #23 ('TypeError in case COREG or COREG_LOCAL is called with an...

Fixed issue #23 ('TypeError in case COREG or COREG_LOCAL is called with an in-memory reference or target image and path_out is set to 'auto'.').
parent a0c02f8d
Pipeline #3298 failed with stages
in 3 minutes and 31 seconds
......@@ -337,11 +337,23 @@ class COREG(object):
'COREG._set_outpathes() expects two file pathes (string) or two instances of the ' \
'GeoArray class. Received %s and %s.' % (type(im_ref), type(im_tgt))
def get_baseN(path): return os.path.splitext(os.path.basename(path))[0]
def get_baseN(path):
return os.path.splitext(os.path.basename(path))[0]
# get input paths
def get_input_path(im):
if isinstance(im, GeoArray):
if not im.is_inmem:
return im.filePath
else:
raise ValueError(self.path_out, "The output path must be explicitly set in case the input "
"reference or target image is in-memory (without a reference to a "
"physical file on disk). Received path_out='%s'." % self.path_out)
else:
return im
# get input pathes
path_im_ref = im_ref.filePath if isinstance(im_ref, GeoArray) else im_ref
path_im_tgt = im_tgt.filePath if isinstance(im_tgt, GeoArray) else im_tgt
path_im_ref = get_input_path(im_ref) if self.path_out else None
path_im_tgt = get_input_path(im_tgt) if self.path_out else None
if self.path_out: # this also applies to self.path_out='auto'
......
......@@ -21,7 +21,7 @@ test_cases = dict(
footprint_poly_tgt='POLYGON ((341890 5866490, 356180 5866490, 356180 5834970, 335440 5834970, '
'335490 5845270, 341890 5866490))',
progress=False,
v=0),
v=False),
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
......
......@@ -6,6 +6,7 @@
import unittest
import shutil
import os
import numpy as np
# custom
from .cases import test_cases
......@@ -102,6 +103,18 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
footprint_poly_tgt=None))
self.assertTrue(CR.success)
def test_shift_calculation_inmem_gAs_path_out_auto(self):
"""Test input parameter path_out='auto' in case input reference/ target image are in-memory GeoArrays."""
ref = GeoArray(np.random.randint(1, 100, (1000, 1000)))
tgt = GeoArray(np.random.randint(1, 100, (1000, 1000)))
with self.assertRaises(ValueError):
self.run_shift_detection_correction(ref, tgt,
**dict(self.coreg_kwargs,
path_out='auto',
fmt_out='ENVI',
v=True))
# @unittest.SkipTest
def test_shift_calculation_verboseMode(self):
"""Test the verbose mode - runs the functions of the plotting submodule."""
......
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