Commit 3bf5d02b authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'feature/add_quiverplot' into develop

parents 81a7761f f197b750
......@@ -19,8 +19,8 @@ stages:
test_arosics:
stage: test
script:
- source /root/anaconda3/bin/activate
- export GDAL_DATA=/root/anaconda3/share/gdal
- source /root/miniconda3/bin/activate
- export GDAL_DATA=/root/miniconda3/share/gdal
- export PYTHONPATH=$PYTHONPATH:/root # /root <- directory needed later
- make nosetests
- make docs
......@@ -36,8 +36,8 @@ test_arosics:
test_styles:
stage: test
script:
- source /root/anaconda3/bin/activate
- export GDAL_DATA=/root/anaconda3/share/gdal
- source /root/miniconda3/bin/activate
- export GDAL_DATA=/root/miniconda3/share/gdal
- export PYTHONPATH=$PYTHONPATH:/root # /root <- directory needed later
- make lint
artifacts:
......@@ -51,8 +51,8 @@ test_styles:
test_arosics_install:
stage: test
script:
- source /root/anaconda3/bin/activate
- export GDAL_DATA=/root/anaconda3/share/gdal
- source /root/miniconda3/bin/activate
- export GDAL_DATA=/root/miniconda3/share/gdal
- conda create -y -q --name arosics python=3
- source activate arosics
# resolve some requirements with conda
......@@ -106,7 +106,7 @@ deploy_pypi:
dependencies:
- test_arosics
script: # Configure the PyPI credentials, then push the package, and cleanup the creds.
- source /root/anaconda3/bin/activate
- source /root/miniconda3/bin/activate
- mkdir -p public/images/
- cp -r docs/images/* public/images/
- printf "[distutils]\nindex-servers =\n pypi\n\n" >> ~/.pypirc
......
......@@ -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], 95)) \
vmin_auto, vmax_auto = (np.percentile(GDF[attribute2plot], 0), np.percentile(GDF[attribute2plot], 98)) \
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.')
......
......@@ -12,8 +12,8 @@ from arosics.Tie_Point_Grid import Tie_Point_Grid
__author__ = """Daniel Scheffler"""
__email__ = 'daniel.scheffler@gfz-potsdam.de'
__version__ = '0.6.9'
__versionalias__ = '2017-11-16_02'
__version__ = '0.7.0'
__versionalias__ = '2017-11-20_01'
__all__ = ['COREG',
'COREG_LOCAL',
'DESHIFTER',
......
......@@ -28,7 +28,7 @@ test_requirements = requirements + ['coverage', 'nose', 'nose-htmloutput', 'redn
setup(
name='arosics',
version='0.6.9',
version='0.7.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",
......
......@@ -2,7 +2,7 @@
context_dir="./context"
dockerfile="arosics_ci.docker"
tag="arosics_ci:0.6.9"
tag="arosics_ci:0.6.10"
gitlab_runner="arosics_gitlab_CI_runner"
echo "#### Build runner docker image"
......
FROM centos:7
# matplotlib requires freetype, freetype-devel, libpng-devel under centos
# scikit-image requires blas-devel, lapack-devel, atlas-devel under centos
RUN yum update -y && \
yum install -y wget vim bzip2 gcc gcc-c++ make libgl1-mesa-glx mesa-libGL qt5-qtbase-gui git freetype \
freetype-devel libpng-devel blas-devel lapack-devel atlas-devel
ENV anaconda_dl 'Anaconda3-5.0.0-Linux-x86_64.sh'
RUN /bin/bash -i -c "cd /root; wget https://repo.continuum.io/archive/$anaconda_dl ; \
bash -i /root/$anaconda_dl -b ; \
rm -f /root/$anaconda_dl"
# 'conda install --yes -c conda-forge 'icu=58.*' lxml' fixing a bug for conda-forge gdal build, as of 06/2017
# holoviews and bokeh is only needed for geoarray because its not installable via pip during geoarray.setup.py
RUN /bin/bash -i -c "source /root/anaconda3/bin/activate ; \
conda install --yes pyqt; \
conda install --yes -c conda-forge pyfftw=0.10.4 ; \
conda install --yes -c ioam holoviews bokeh ; \
conda install --yes -c conda-forge numpy gdal scikit-image matplotlib pyproj rasterio shapely basemap pykrige geopandas; \
conda install --yes -c conda-forge 'icu=58.*' lxml ; \
pip install dicttoxml jsmin cerberus pyprind pint iso8601 tqdm mpld3 sphinx-argparse \
geoarray>=0.6.12 py_tools_ds>=0.12.1 plotly flake8 pycodestyle pylint pydocstyle coverage nose nose2 \
nose-htmloutput rednose" # must include all the requirements needed to build the docs!
FROM gms_base_centos:pinned_v0.1
# copy some needed stuff to /root
#COPY *.pkl /root/ # EXAMPLE
#COPY *.h5 /root/ # EXAMPLE
# install git lfs
RUN /bin/bash -i -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | bash"
# installing git large file support, see here: https://git-lfs.github.com/ , change version number below for future upgrades
ENV git_lfs_v='2.1.1'
RUN /bin/bash -i -c "wget https://github.com/git-lfs/git-lfs/releases/download/v${git_lfs_v}/git-lfs-linux-amd64-${git_lfs_v}.tar.gz; \
tar -zxvf git-lfs-linux-amd64-${git_lfs_v}.tar.gz; \
cd git-lfs-${git_lfs_v}; \
bash ./install.sh"
COPY *.yml /root/
# set matplotlib backend to Agg as default, Qt won't work in headless docker containers
RUN bash -i -c 'source /root/anaconda3/bin/activate; \
sed -i "/backend : tkagg/c\backend : Agg" $(python -c "import matplotlib; print(matplotlib.matplotlib_fname())"); \
sed -i "/backend : Qt4Agg/c\backend : Agg" $(python -c "import matplotlib; print(matplotlib.matplotlib_fname())"); \
sed -i "/backend : qt5agg/c\backend : Agg" $(python -c "import matplotlib; print(matplotlib.matplotlib_fname())")'
RUN /bin/bash -i -c "\
source /root/miniconda3/bin/activate ; \
conda env update -n root -f /root/environment_arosics.yml"
name: arosics
channels: &id1
- http://conda.anaconda.org/ioam # only for holoviews
- http://conda.anaconda.org/conda-forge
dependencies:
- python=3.*.*
- pyqt
- numpy
- gdal
- scikit-image
- rasterio
- pyproj
- lxml
- geopandas
- ipython
- shapely
- matplotlib
- basemap
- holoviews
- bokeh
- pykrige
- pip:
- dicttoxml
- jsmin
- cerberus
- pyprind
- pint
- iso8601
- tqdm
- mpld3
- sphinx-argparse
- six
- spectral
- flake8
- pycodestyle
- pylint
- pydocstyle
- nose
- nose2
- nose-htmloutput
- coverage
- rednose
- cmocean
- plotly
- geoarray>=0.6.16
- py_tools_ds>=0.12.1
......@@ -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()
......
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