Commit 7d49da60 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

catched an error within COREG_LOCAL due 100% cloud cover

- components.Geom_Quality_Grid: refactored to components.Tie_Point_Grid

components.Tie_Point_Grid:
- Geom_Quality_Grid: refactored to Tie_Point_Grid
- Tie_Point_Grid.get_CoRegPoints_table(): catched empty GDF after excluding bad XY positions

- updated __version__
parent 36fd8288
from .components.CoReg import COREG
from .components.CoReg_local import COREG_LOCAL
from .components.DeShifter import DESHIFTER
from .components.Geom_Quality_Grid import Geom_Quality_Grid
from .components.Tie_Point_Grid import Tie_Point_Grid
from .components import io
from .components import plotting
......@@ -9,12 +9,12 @@ from .components import utilities
from .components import geometry
__author__ = 'Daniel Scheffler'
__version__= '2017-02-13_01'
__version__= '2017-02-16_01'
__all__=['COREG',
'COREG_LOCAL',
'DESHIFTER',
'Geom_Quality_Grid',
'Tie_Point_Grid',
'io',
'utilities',
'geometry',
......
......@@ -17,7 +17,7 @@ import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from .Geom_Quality_Grid import Geom_Quality_Grid
from .Tie_Point_Grid import Tie_Point_Grid
from .CoReg import COREG
from .DeShifter import DESHIFTER
from py_tools_ds.ptds.geo.coord_trafo import transform_any_prj, reproject_shapelyGeometry
......@@ -260,7 +260,7 @@ class COREG_LOCAL(object):
if self._quality_grid:
return self._quality_grid
else:
self._quality_grid = Geom_Quality_Grid(self.COREG_obj, self.grid_res,
self._quality_grid = Tie_Point_Grid(self.COREG_obj, self.grid_res,
max_points = self.max_points,
outFillVal = self.outFillVal,
resamp_alg_calc = self.rspAlg_calc,
......
......@@ -32,8 +32,8 @@ global_shared_imref = None
global_shared_im2shift = None
class Geom_Quality_Grid(object):
"""See help(Geom_Quality_Grid) for documentation!"""
class Tie_Point_Grid(object):
"""See help(Tie_Point_Grid) for documentation!"""
def __init__(self, COREG_obj, grid_res, max_points=None, outFillVal=-9999, resamp_alg_calc='cubic',
tieP_filter_level=2, dir_out=None, CPUs=None, progress=True, v=False, q=False):
......@@ -41,7 +41,7 @@ class Geom_Quality_Grid(object):
"""Applies the algorithm to detect spatial shifts to the whole overlap area of the input images. Spatial shifts
are calculated for each point in grid of which the parameters can be adjusted using keyword arguments. Shift
correction performs a polynomial transformation using te calculated shifts of each point in the grid as GCPs.
Thus 'Geom_Quality_Grid' can be used to correct for locally varying geometric distortions of the target image.
Thus 'Tie_Point_Grid' can be used to correct for locally varying geometric distortions of the target image.
:param COREG_obj(object): an instance of COREG class
:param grid_res: grid resolution in pixels of the target image (x-direction)
......@@ -244,6 +244,9 @@ class Geom_Quality_Grid(object):
# exclude offsite points and points on bad data mask
GDF = self._exclude_bad_XYpos(GDF)
if GDF.empty:
self.CoRegPoints_table = GDF
return self.CoRegPoints_table
# choose a random subset of points if a maximum number has been given
if self.max_points and len(GDF) > self.max_points:
......@@ -334,7 +337,7 @@ class Geom_Quality_Grid(object):
if self.tieP_filter_level>0:
if not self.q:
print('Performing validity checks...')
TPR = TiePoint_Refiner(GDF[GDF.ABS_SHIFT != self.outFillVal], q=self.q)
TPR = Tie_Point_Refiner(GDF[GDF.ABS_SHIFT != self.outFillVal], q=self.q)
GDF_filt, new_columns = TPR.run_filtering(level=self.tieP_filter_level)
GDF = GDF.merge(GDF_filt[ ['POINT_ID']+new_columns], on='POINT_ID', how="outer")
GDF = GDF.fillna(int(self.outFillVal))
......@@ -418,11 +421,11 @@ class Geom_Quality_Grid(object):
def to_PointShapefile(self, path_out=None, skip_nodata=True, skip_nodata_col ='ABS_SHIFT'):
# type: (str, bool, str) -> None
"""Writes the calculated geometric quality grid to a point shapefile containing
Geom_Quality_Grid.CoRegPoints_table as attribute table. This shapefile can easily be displayed using GIS software.
Tie_Point_Grid.CoRegPoints_table as attribute table. This shapefile can easily be displayed using GIS software.
:param path_out: <str> the output path. If not given, it is automatically defined.
:param skip_nodata: <bool> whether to skip all points where no valid match could be found
:param skip_nodata_col: <str> determines which column of Geom_Quality_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
"""
GDF = self.CoRegPoints_table
......@@ -564,7 +567,7 @@ class Geom_Quality_Grid(object):
class TiePoint_Refiner(object):
class Tie_Point_Refiner(object):
def __init__(self, GDF, q=False):
self.GDF = GDF.copy()
self.q = q
......
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