Fixed bug in plot_pdf: wrong input for _axes.plot, method instead of values of method!

This commit is contained in:
Ludger Küperkoch 2017-02-09 16:59:47 +01:00
parent a3d3c02773
commit 200695e7ca

View File

@ -9,6 +9,7 @@ import warnings
import copy import copy
import datetime import datetime
import numpy as np import numpy as np
import math
from matplotlib.figure import Figure from matplotlib.figure import Figure
from pylot.core.util.utils import find_horizontals from pylot.core.util.utils import find_horizontals
@ -50,7 +51,7 @@ def getDataType(parent):
def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None, def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
title=None): title=None):
_axes.plot(x, y) _axes.plot(x, y())
if title: if title:
_axes.set_title(title) _axes.set_title(title)
if xlabel: if xlabel:
@ -242,54 +243,55 @@ class ComparisonDialog(QDialog):
std=std, exp=exp) std=std, exp=exp)
bbox_props = dict(boxstyle='round', facecolor='lightgrey', alpha=.7) bbox_props = dict(boxstyle='round', facecolor='lightgrey', alpha=.7)
plot_pdf(_axes, x, y, annotation, bbox_props, 'time difference [s]', if math.isnan(std) == False:
'propability density [-]', phase) plot_pdf(_axes, x, y, annotation, bbox_props, 'time difference [s]',
'propability density [-]', phase)
pdf_a = copy.deepcopy(self.data.get('auto')[station][phase]) pdf_a = copy.deepcopy(self.data.get('auto')[station][phase])
pdf_m = copy.deepcopy(self.data.get('manu')[station][phase]) pdf_m = copy.deepcopy(self.data.get('manu')[station][phase])
xauto, yauto, stdauto, expauto, alim = pdf_a.axis, pdf_a.data, \ xauto, yauto, stdauto, expauto, alim = pdf_a.axis, pdf_a.data, \
pdf_a.standard_deviation(), \ pdf_a.standard_deviation(), \
pdf_a.expectation(), \ pdf_a.expectation(), \
pdf_a.limits() pdf_a.limits()
xmanu, ymanu, stdmanu, expmanu, mlim = pdf_m.axis, pdf_m.data, \ xmanu, ymanu, stdmanu, expmanu, mlim = pdf_m.axis, pdf_m.data, \
pdf_m.standard_deviation(), \ pdf_m.standard_deviation(), \
pdf_m.expectation(), \ pdf_m.expectation(), \
pdf_m.limits() pdf_m.limits()
# find common limits # find common limits
lims = clims(alim, mlim) lims = clims(alim, mlim)
# relative x axis # relative x axis
x0 = lims[0] x0 = lims[0]
xmanu -= x0 xmanu -= x0
xauto -= x0 xauto -= x0
lims = [lim - x0 for lim in lims] lims = [lim - x0 for lim in lims]
x0 = UTCDateTime(x0) x0 = UTCDateTime(x0)
# set annotation text # set annotation text
mannotation = "probability density for manual pick\n" \ mannotation = "probability density for manual pick\n" \
"expectation: {exp}\n" \ "expectation: {exp}\n" \
"std: {std}".format(std=stdmanu, "std: {std}".format(std=stdmanu,
exp=expmanu-x0.timestamp) exp=expmanu-x0.timestamp)
aannotation = "probability density for automatic pick\n" \ aannotation = "probability density for automatic pick\n" \
"expectation: {exp}\n" \ "expectation: {exp}\n" \
"std: {std}".format(std=stdauto, "std: {std}".format(std=stdauto,
exp=expauto-x0.timestamp) exp=expauto-x0.timestamp)
_ax1 = plot_pdf(_ax1, xmanu, ymanu, mannotation, _ax1 = plot_pdf(_ax1, xmanu, ymanu, mannotation,
bbox_props=bbox_props, xlabel='seconds since ' bbox_props=bbox_props, xlabel='seconds since '
'{0}'.format(x0), '{0}'.format(x0),
ylabel='probability density [-]') ylabel='probability density [-]')
_ax1.set_xlim(lims) _ax1.set_xlim(lims)
_ax2 = plot_pdf(_ax2, xauto, yauto, aannotation, _ax2 = plot_pdf(_ax2, xauto, yauto, aannotation,
bbox_props=bbox_props, xlabel='seconds since ' bbox_props=bbox_props, xlabel='seconds since '
'{0}'.format(x0)) '{0}'.format(x0))
_ax2.set_xlim(lims) _ax2.set_xlim(lims)
_gs.update(wspace=0.5, hspace=0.5) _gs.update(wspace=0.5, hspace=0.5)
self.canvas.draw() self.canvas.draw()
def plothist(self): def plothist(self):
name = self.sender().objectName() name = self.sender().objectName()