Commit 9cc9083f authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

The output map of COREG_LOCAL.view_CoRegPoints() is now cropped nicely. Added...


The output map of COREG_LOCAL.view_CoRegPoints() is now cropped nicely. Added parameter 'figsize_multiplier'.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent f023e0c5
......@@ -498,6 +498,7 @@ class COREG_LOCAL(object):
backgroundIm: str = 'tgt',
hide_filtered: bool = True,
figsize: tuple = None,
figsize_multiplier: float = 1,
title: str = '',
vector_scale: float = 1.,
savefigPath: str = '',
......@@ -518,7 +519,8 @@ class COREG_LOCAL(object):
:param backgroundIm: whether to use the target or the reference image as map background. Possible
options are 'ref' and 'tgt' (default: 'tgt')
:param hide_filtered: hide all points that have been filtered out according to tie point filter level
:param figsize: size of the figure to be viewed, e.g. (10, 10)
:param figsize: size of the figure to be viewed, e.g. (10, 10); automatically estimated if not given
:param figsize_multiplier: if given, the figure size is multiplied with this value
:param title: plot title
:param vector_scale: scale factor for shift vector length (default: 1 -> no scaling)
:param savefigPath:
......@@ -534,20 +536,28 @@ class COREG_LOCAL(object):
from cartopy.crs import PlateCarree
from mpl_toolkits.axes_grid1 import make_axes_locatable
# get a map showing the reference or target image
# get background image (reference or target image)
if backgroundIm not in ['tgt', 'ref']:
raise ValueError('backgroundIm')
backgroundIm = self.im2shift if backgroundIm == 'tgt' else self.imref
# make sure the output figure has a reasonable size, also if figsize is not given
if not figsize:
r, c = backgroundIm.shape
figsize = (8, r / c * 8) if r > c else (c / r * 8, 8)
# apply figsize multiplier
if figsize_multiplier:
if figsize_multiplier < 0:
raise ValueError(figsize_multiplier, 'The figure size multiplier must be a positive finite number.')
figsize = (figsize[0] * figsize_multiplier, figsize[1] * figsize_multiplier)
# get a map showing the background image
fig, ax = backgroundIm.show_map(figsize=figsize,
nodataVal=self.nodata[1],
return_map=True,
band=self.COREG_obj.shift.band4match)
# make sure the output figure has a reasonable size, also if figsize is not given
if not figsize:
w, h = fig.get_size_inches()
fig.set_size_inches(w * 1.6, h * 1.6)
# set figure title
dict_attr_title = dict(
X_WIN_SIZE='size of the matching window in x-direction [pixels]',
......@@ -689,8 +699,11 @@ class COREG_LOCAL(object):
if not self.q:
warnings.warn(msg)
# remove white space around the figure
plt.subplots_adjust(top=.95, bottom=.05, right=.95, left=.05)
if savefigPath:
fig.savefig(savefigPath, dpi=savefigDPI)
fig.savefig(savefigPath, dpi=savefigDPI, pad_inches=0.1, bbox_inches='tight')
if return_map:
return fig, ax
......
Supports Markdown
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