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

Caught the no-tie-points-found-case in some methods of Tie_Point_Grid. Updated version info.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 3f177960
Pipeline #15625 passed with stages
in 2 minutes and 25 seconds
...@@ -437,6 +437,9 @@ class Tie_Point_Grid(object): ...@@ -437,6 +437,9 @@ class Tie_Point_Grid(object):
:param include_outliers: whether to include tie points that have been marked as false-positives (if present) :param include_outliers: whether to include tie points that have been marked as false-positives (if present)
""" """
if self.CoRegPoints_table.empty:
raise RuntimeError('Cannot compute the RMSE because no tie points were found at all.')
tbl = self.CoRegPoints_table tbl = self.CoRegPoints_table
tbl = tbl if include_outliers else tbl[tbl['OUTLIER'] == 0].copy() if 'OUTLIER' in tbl.columns else tbl tbl = tbl if include_outliers else tbl[tbl['OUTLIER'] == 0].copy() if 'OUTLIER' in tbl.columns else tbl
...@@ -452,6 +455,9 @@ class Tie_Point_Grid(object): ...@@ -452,6 +455,9 @@ class Tie_Point_Grid(object):
:param include_outliers: whether to include tie points that have been marked as false-positives :param include_outliers: whether to include tie points that have been marked as false-positives
:param after_correction: whether to compute median SSIM before correction or after :param after_correction: whether to compute median SSIM before correction or after
""" """
if self.CoRegPoints_table.empty:
raise RuntimeError('Cannot compute the overall SSIM because no tie points were found at all.')
tbl = self.CoRegPoints_table tbl = self.CoRegPoints_table
tbl = tbl if include_outliers else tbl[tbl['OUTLIER'] == 0].copy() tbl = tbl if include_outliers else tbl[tbl['OUTLIER'] == 0].copy()
...@@ -564,6 +570,9 @@ class Tie_Point_Grid(object): ...@@ -564,6 +570,9 @@ class Tie_Point_Grid(object):
return fig, ax return fig, ax
def dump_CoRegPoints_table(self, path_out=None): def dump_CoRegPoints_table(self, path_out=None):
if self.CoRegPoints_table.empty:
raise RuntimeError('Cannot dump tie points table because it is empty.')
path_out = path_out if path_out else \ path_out = path_out if path_out else \
get_generic_outpath(dir_out=self.dir_out, get_generic_outpath(dir_out=self.dir_out,
fName_out="CoRegPoints_table_grid%s_ws(%s_%s)__T_%s__R_%s.pkl" fName_out="CoRegPoints_table_grid%s_ws(%s_%s)__T_%s__R_%s.pkl"
...@@ -649,6 +658,9 @@ class Tie_Point_Grid(object): ...@@ -649,6 +658,9 @@ class Tie_Point_Grid(object):
:param skip_nodata_col: <str> determines which column of Tie_Point_Grid.CoRegPoints_table is used to :param skip_nodata_col: <str> determines which column of Tie_Point_Grid.CoRegPoints_table is used to
identify points where no valid match could be found identify points where no valid match could be found
""" """
if self.CoRegPoints_table.empty:
raise RuntimeError('Cannot save a point shapefile because no tie points were found at all.')
GDF = self.CoRegPoints_table GDF = self.CoRegPoints_table
if skip_nodata: if skip_nodata:
...@@ -677,6 +689,9 @@ class Tie_Point_Grid(object): ...@@ -677,6 +689,9 @@ class Tie_Point_Grid(object):
warnings.warn(DeprecationWarning( warnings.warn(DeprecationWarning(
"'_tiepoints_grid_to_PointShapefile' is deprecated." # TODO delete if other method validated "'_tiepoints_grid_to_PointShapefile' is deprecated." # TODO delete if other method validated
" 'tiepoints_grid_to_PointShapefile' is much faster.")) " 'tiepoints_grid_to_PointShapefile' is much faster."))
if self.CoRegPoints_table.empty:
raise RuntimeError('Cannot save a point shapefile because no tie points were found at all.')
GDF = self.CoRegPoints_table GDF = self.CoRegPoints_table
GDF2pass = \ GDF2pass = \
GDF if not skip_nodata else \ GDF if not skip_nodata else \
...@@ -711,6 +726,9 @@ class Tie_Point_Grid(object): ...@@ -711,6 +726,9 @@ class Tie_Point_Grid(object):
attr_b1 = 'X_SHIFT_M' if mode == 'uv' else 'ABS_SHIFT' attr_b1 = 'X_SHIFT_M' if mode == 'uv' else 'ABS_SHIFT'
attr_b2 = 'Y_SHIFT_M' if mode == 'uv' else 'ANGLE' attr_b2 = 'Y_SHIFT_M' if mode == 'uv' else 'ANGLE'
if self.CoRegPoints_table.empty:
raise RuntimeError('Cannot save the vector field because no tie points were found at all.')
xshift_arr, gt, prj = points_to_raster(points=self.CoRegPoints_table['geometry'], xshift_arr, gt, prj = points_to_raster(points=self.CoRegPoints_table['geometry'],
values=self.CoRegPoints_table[attr_b1], values=self.CoRegPoints_table[attr_b1],
tgt_res=self.shift.xgsd * self.grid_res, tgt_res=self.shift.xgsd * self.grid_res,
......
...@@ -22,5 +22,5 @@ ...@@ -22,5 +22,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '1.2.3' __version__ = '1.2.4'
__versionalias__ = '2020-11-12_01' __versionalias__ = '2020-11-12_02'
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