Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Scheffler
arosics
Commits
16898c39
Commit
16898c39
authored
Nov 21, 2017
by
Daniel Scheffler
Browse files
Merge branch 'release/v0.8.0'
parents
89e17e1c
e8c41d9c
Pipeline
#1586
passed with stages
in 3 minutes and 23 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
arosics/CoReg_local.py
View file @
16898c39
...
...
@@ -335,11 +335,15 @@ class COREG_LOCAL(object):
footprints of the input images as well as the corresponding overlap area."""
return
self
.
COREG_obj
.
show_image_footprints
()
def
view_CoRegPoints
(
self
,
attribute2plot
=
'ABS_SHIFT'
,
cmap
=
None
,
exclude_fillVals
=
True
,
backgroundIm
=
'tgt'
,
hide_filtered
=
True
,
figsize
=
None
,
savefigPath
=
''
,
savefigDPI
=
96
,
showFig
=
True
,
vmin
=
None
,
vmax
=
None
,
return_map
=
False
,
zoomable
=
False
):
def
view_CoRegPoints
(
self
,
shapes2plot
=
'points'
,
attribute2plot
=
'ABS_SHIFT'
,
cmap
=
None
,
exclude_fillVals
=
True
,
backgroundIm
=
'tgt'
,
hide_filtered
=
True
,
figsize
=
None
,
title
=
''
,
vector_scale
=
1.
,
savefigPath
=
''
,
savefigDPI
=
96
,
showFig
=
True
,
vmin
=
None
,
vmax
=
None
,
return_map
=
False
,
zoomable
=
False
):
# type: (str, str, plt.cm, bool, str, bool, tuple, str, float, str, int, bool, float, float, bool) -> tuple
"""Shows a map of the calculated tie point grid with the target image as background.
:param shapes2plot: <str> 'points': plot points representing values of 'attribute2plot' onto the map
'vectors': plot shift vectors onto the map
:param attribute2plot: <str> the attribute of the tie point grid to be shown (default: 'ABS_SHIFT')
:param cmap: <plt.cm.<colormap>> a custom color map to be applied to the plotted grid points
(default: 'RdYlGn_r')
...
...
@@ -350,6 +354,8 @@ class COREG_LOCAL(object):
:param hide_filtered: <bool> hide all points that have been filtered out according to tie point filter
level
:param figsize: <tuple> size of the figure to be viewed, e.g. (10,10)
:param title: <str> plot title
:param vector_scale: <float> scale factor for shift vector length (default: 1 -> no scaling)
:param savefigPath:
:param savefigDPI:
:param showFig: <bool> whether to show or to hide the figure
...
...
@@ -371,7 +377,7 @@ class COREG_LOCAL(object):
# ax.tick_params(axis='both', which='minor', labelsize=8)
# fig, ax, map2show = backgroundIm.show_map_utm(figsize=(20,20), nodataVal=self.nodata[1], return_map=True)
plt
.
title
(
attribute2plot
)
plt
.
title
(
title
or
attribute2plot
)
# transform all points of tie point grid to LonLat
outlierCols
=
[
c
for
c
in
self
.
CoRegPoints_table
.
columns
if
'OUTLIER'
in
c
]
...
...
@@ -437,25 +443,45 @@ class COREG_LOCAL(object):
if
self
.
tieP_filter_level
>
0
:
plt
.
legend
(
loc
=
0
,
scatterpoints
=
1
)
# plot all points on top
# plot all points
or vectors
on top
if
not
GDF
.
empty
:
vmin_auto
,
vmax_auto
=
(
np
.
percentile
(
GDF
[
attribute2plot
],
0
),
np
.
percentile
(
GDF
[
attribute2plot
],
9
5
))
\
vmin_auto
,
vmax_auto
=
(
np
.
percentile
(
GDF
[
attribute2plot
],
0
),
np
.
percentile
(
GDF
[
attribute2plot
],
9
8
))
\
if
attribute2plot
!=
'ANGLE'
else
(
0
,
360
)
vmin
=
vmin
if
vmin
is
not
None
else
vmin_auto
vmax
=
vmax
if
vmax
is
not
None
else
vmax_auto
points
=
plt
.
scatter
(
GDF
[
'plt_X'
],
GDF
[
'plt_Y'
],
c
=
GDF
[
attribute2plot
],
lw
=
0
,
cmap
=
palette
,
marker
=
'o'
if
len
(
GDF
)
<
10000
else
'.'
,
s
=
50
,
alpha
=
1.0
,
vmin
=
vmin
,
vmax
=
vmax
)
if
shapes2plot
==
'vectors'
:
# plot shift vectors
# doc: https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.quiver.html
plt
.
quiver
(
GDF
[
'plt_X'
],
GDF
[
'plt_Y'
],
-
GDF
[
'X_SHIFT_M'
],
-
GDF
[
'Y_SHIFT_M'
],
# invert absolute shifts to make arrows point to tgt
GDF
[
attribute2plot
].
clip
(
vmin
,
vmax
),
# sets the colors
scale
=
1200
/
vector_scale
,
# larger values decrease the arrow length
width
=
.
0015
,
# arrow width (in relation to plot width)
# linewidth=1, # maybe use this to mark outliers instead of scatter points
cmap
=
palette
,
pivot
=
'middle'
# position the middle point of the arrows onto the tie point location
)
mappable
=
None
elif
shapes2plot
==
'points'
:
# plot tie points
points
=
plt
.
scatter
(
GDF
[
'plt_X'
],
GDF
[
'plt_Y'
],
c
=
GDF
[
attribute2plot
],
lw
=
0
,
cmap
=
palette
,
marker
=
'o'
if
len
(
GDF
)
<
10000
else
'.'
,
s
=
50
,
alpha
=
1.0
,
vmin
=
vmin
,
vmax
=
vmax
)
mappable
=
points
# plot shift vectors
# map2show.quiver(GDF['plt_X'], GDF['plt_Y'], GDF['X_SHIFT_M'], GDF['Y_SHIFT_M'])#, scale=700)
else
:
raise
ValueError
(
"The parameter 'shapes2plot' must be set to 'vectors' or 'points'. Received %s."
%
shapes2plot
)
# add colorbar
divider
=
make_axes_locatable
(
plt
.
gca
())
cax
=
divider
.
append_axes
(
"right"
,
size
=
"2%"
,
pad
=
0.1
)
# create axis on the right; size =2% of ax; padding = 0.1 inch
plt
.
colorbar
(
points
,
cax
=
cax
)
# create axis on the right; size =2% of ax; padding = 0.1 inch
cax
=
divider
.
append_axes
(
"right"
,
size
=
"2%"
,
pad
=
0.1
)
plt
.
colorbar
(
mappable
,
cax
=
cax
)
else
:
if
not
self
.
q
:
warnings
.
warn
(
'Cannot plot any tie point because none is left after tie point validation.'
)
...
...
arosics/__init__.py
View file @
16898c39
...
...
@@ -12,8 +12,8 @@ from arosics.Tie_Point_Grid import Tie_Point_Grid
__author__
=
"""Daniel Scheffler"""
__email__
=
'daniel.scheffler@gfz-potsdam.de'
__version__
=
'0.
7
.0'
__versionalias__
=
'2017-11-2
0
_01'
__version__
=
'0.
8
.0'
__versionalias__
=
'2017-11-2
1
_01'
__all__
=
[
'COREG'
,
'COREG_LOCAL'
,
'DESHIFTER'
,
...
...
setup.py
View file @
16898c39
...
...
@@ -28,7 +28,7 @@ test_requirements = requirements + ['coverage', 'nose', 'nose-htmloutput', 'redn
setup
(
name
=
'arosics'
,
version
=
'0.
7
.0'
,
version
=
'0.
8
.0'
,
description
=
"An Automated and Robust Open-Source Image Co-Registration Software for Multi-Sensor Satellite Data"
,
long_description
=
readme
+
'
\n\n
'
+
history
,
author
=
"Daniel Scheffler"
,
...
...
tests/test_COREG_LOCAL.py
View file @
16898c39
...
...
@@ -65,7 +65,9 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
# test tie point grid visualization
if
util
.
find_spec
(
'mpl_toolkits.basemap'
):
# only works if basemap is installed
CRL
.
view_CoRegPoints
()
CRL
.
view_CoRegPoints
(
hide_filtered
=
True
)
CRL
.
view_CoRegPoints
(
hide_filtered
=
False
)
CRL
.
view_CoRegPoints
(
shapes2plot
=
'vectors'
)
# test shift correction and output writer
CRL
.
correct_shifts
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment