Commit 41a82832 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'enhancement/minor_fixes' into 'master'

Enhancement/minor fixes

Closes #17

See merge request danschef/arosics!8
parents 0d83bd9e f2991b45
Pipeline #11767 passed with stages
in 8 minutes and 17 seconds
......@@ -13,7 +13,7 @@ test_arosics:
script:
- source /root/miniconda3/bin/activate ci_env
- pip install "py_tools_ds>=0.14.28" # FIXME remove as soon as docker runner has been updated
- pip install "geoarray>=0.8.29" # FIXME remove as soon as docker runner has been updated
- pip install "geoarray>=0.8.30" # FIXME remove as soon as docker runner has been updated
# run tests
- make nosetests
......
......@@ -52,7 +52,7 @@ from py_tools_ds.geo.coord_calc import get_corner_coordinates
from py_tools_ds.geo.vector.topology import get_overlap_polygon, get_smallest_boxImYX_that_contains_boxMapYX
from py_tools_ds.geo.projection import prj_equal, get_proj4info
from py_tools_ds.geo.vector.geometry import boxObj, round_shapelyPoly_coords
from py_tools_ds.geo.coord_grid import move_shapelyPoly_to_image_grid
from py_tools_ds.geo.coord_grid import move_shapelyPoly_to_image_grid, is_coord_grid_equal
from py_tools_ds.geo.coord_trafo import reproject_shapelyGeometry, mapXY2imXY, imXY2mapXY
from py_tools_ds.geo.raster.reproject import warp_ndarray
from py_tools_ds.geo.map_info import geotransform2mapinfo
......@@ -463,7 +463,8 @@ class COREG(object):
def equalize_pixGrids(self):
"""Equalize image grids and projections of reference and target image (align target to reference)."""
if not (prj_equal(self.ref.prj, self.shift.prj) and self.ref.xygrid_specs == self.shift.xygrid_specs):
if not (prj_equal(self.ref.prj, self.shift.prj) and
is_coord_grid_equal(self.ref.gt, *self.shift.xygrid_specs)):
if not self.q:
print("Equalizing pixel grids and projections of reference and target image...")
......@@ -528,7 +529,7 @@ class COREG(object):
raise ImportError(
"This method requires the library 'holoviews'. It can be installed for Anaconda with "
"the shell command 'conda install -c ioam holoviews bokeh'.")
warnings.filterwarnings('ignore')
hv.notebook_extension('matplotlib')
hv.Store.add_style_opts(hv.Image, ['vmin', 'vmax'])
......@@ -581,7 +582,6 @@ class COREG(object):
# Construct a HoloMap by defining the sampling on the Dimension
# dmap = hv.DynamicMap(image_slice, kdims=[hv.Dimension('z_axis', values=keys)])
warnings.filterwarnings('default')
return hmap
......@@ -648,7 +648,7 @@ class COREG(object):
wp = (wp[0] if wp[0] else overlap_center_pos_x[0]), (wp[1] if wp[1] else overlap_center_pos_y[0])
# validate window position
if not self.overlap_poly.contains(Point(wp)):
if not self.overlap_poly.buffer(1e-5).contains(Point(wp)):
# in case the centroid point is not within overlap area
if not self.q:
warnings.warn("The centroid point of the two input images could not be used as matching window "
......@@ -660,11 +660,11 @@ class COREG(object):
overlap_center_pos_x, overlap_center_pos_y = self.overlap_poly.representative_point().coords.xy
wp = overlap_center_pos_x[0], overlap_center_pos_y[0]
assert self.overlap_poly.contains(Point(wp))
assert self.overlap_poly.buffer(1e-5).contains(Point(wp))
else:
# validate window position
if not self.overlap_poly.contains(Point(wp)):
if not self.overlap_poly.buffer(1e-5).contains(Point(wp)):
self._handle_error(ValueError('The provided window position %s/%s is outside of the overlap '
'area of the two input images. Check the coordinates.' % wp))
......@@ -767,7 +767,9 @@ class COREG(object):
if self.success is not False:
# check result -> ProgrammingError if not fulfilled
def within_equal(inner, outer): return inner.within(outer) or inner.equals(outer)
def within_equal(inner, outer):
return inner.within(outer.buffer(1e-5)) or inner.equals(outer)
assert within_equal(matchBox.mapPoly, otherBox.mapPoly)
assert within_equal(otherBox.mapPoly, overlapWin.mapPoly)
......@@ -1249,9 +1251,6 @@ class COREG(object):
if self.success is False:
return 'fail'
if self.q:
warnings.simplefilter('ignore')
# set self.matchWin and self.otherWin (GeoArray instances)
self._get_image_windows_to_match() # 45-90ms
......@@ -1274,7 +1273,6 @@ class COREG(object):
if scps is None:
self.success = False
warnings.simplefilter('default')
return 'fail'
......@@ -1364,8 +1362,6 @@ class COREG(object):
self._validate_ssim_improvement() # FIXME uses the not updated matchWin size
self.shift_reliability = self._calc_shift_reliability(scps)
warnings.simplefilter('default')
return 'success'
def _get_updated_map_info(self):
......
......@@ -548,7 +548,9 @@ class COREG_LOCAL(object):
image=image2plot, bounds=[[lat_min, lon_min], [lat_max, lon_max]],
).add_to(map_osm)
folium.GeoJson(self.CoRegPoints_table.loc[:, ['geometry', attribute2plot]]).add_to(map_osm)
points_values = self.CoRegPoints_table[['geometry', attribute2plot]]
points_values.geometry.crs = points_values.crs
folium.GeoJson(points_values).add_to(map_osm)
# add overlap polygon
overlapPoly = reproject_shapelyGeometry(self.COREG_obj.overlap_poly, self.im2shift.epsg, 4326)
......
......@@ -40,7 +40,7 @@ with open("arosics/version.py") as version_file:
exec(version_file.read(), version)
requirements = ['numpy', 'gdal', 'shapely', 'scikit-image', 'matplotlib', 'geopandas', 'pandas',
'geoarray>=0.8.17', 'py_tools_ds>=0.14.28', 'plotly', 'cmocean', 'six', 'folium>=0.6.0', 'geojson'
'geoarray>=0.8.30', 'py_tools_ds>=0.14.28', 'plotly', 'cmocean', 'six', 'folium>=0.6.0', 'geojson'
# 'pykrige' # conda install --yes -c conda-forge pykrige
# 'pyfftw', # conda install --yes -c conda-forge pyfftw=0.10.4 ; \
# 'basemap', # conda install --yes -c conda-forge basemap; \
......
......@@ -45,5 +45,5 @@ dependencies:
- coverage
- rednose
- plotly
- geoarray>=0.8.17
- geoarray>=0.8.30
- py_tools_ds>=0.14.28
......@@ -105,6 +105,7 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
def test_shift_calculation_with_image_coords_only(self):
"""Test with default parameters - should compute X/Y shifts properly and write the de-shifted target image."""
# FIXME fails when executed alone
# overwrite gt and prj
ref = GeoArray(self.ref_path)
......
......@@ -106,15 +106,18 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
ref = GeoArray(self.ref_path)
ref.to_mem()
ref.filePath = None
ref.gt = [330000.19999996503, 0.6, 0.0, 5862000.7999997628, 0.0, -0.6]
# ref.gt = [330000.1, 10.1, 0.0, 5862000.1, 0.0, -10.1]
tgt = GeoArray(self.tgt_path)
tgt.to_mem()
tgt.filePath = None
tgt.gt = [330000.19999996503, 0.6, 0.0, 5862000.7999997628, 0.0, -0.6]
ref.gt = [330000.19999996503, 10.00000001, 0.0, 5862000.7999997628, 0.0, -10.00000001]
# ref.gt = [330000.1, 10.1, 0.0, 5862000.1, 0.0, -10.1]
tgt.gt = [335440.19999996503, 10.00000001, 0.0, 5866490.7999997628, 0.0, -10.00000001]
# tgt.gt = [330000.1, 10.1, 0.0, 5862000.1, 0.0, -10.1]
# get instance of COREG_LOCAL object
CRL = COREG_LOCAL(ref, tgt, **dict(**self.coreg_kwargs))
CRL = COREG_LOCAL(ref, tgt, **dict(CPUs=32,
**self.coreg_kwargs))
# use the getter of the CoRegPoints_table to calculate tie point grid
# noinspection PyStatementEffect
......
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