From 19ced8b8c5fcad4c4578bf6745f94cbb975c2bc6 Mon Sep 17 00:00:00 2001 From: sebastianp Date: Thu, 28 Jul 2016 13:42:50 +0200 Subject: [PATCH] [task] plot routine for quantile distance quotients --- pylot/core/pick/compare.py | 43 +++++++++++++++++++++++++++----------- pylot/core/util/pdf.py | 6 ++---- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/pylot/core/pick/compare.py b/pylot/core/pick/compare.py index c779c11f..e78e7fd8 100644 --- a/pylot/core/pick/compare.py +++ b/pylot/core/pick/compare.py @@ -405,25 +405,44 @@ class PDFstatistics(object): - def histplot(self ,array , bins = 100, label=None): + def histplot(self, array, label=None): # baustelle + binlist = [] + if array[-1] == '5': + bfactor = 0.001 + badd = 0 + elif array[-1] == '1': + bfactor = 0.003 + badd = 0 + else: + bfactor = 0.006 + badd = 0.4 + + for i in range(100): + binlist.append(badd+bfactor*i) import matplotlib.pyplot as plt - plt.hist(self.axis, self.data()) - plt.xlabel('x') - plt.ylabel('f(x)') - plt.autoscale(axis='x', tight=True) - if self: - title_str = 'Probability density function ' - if label: - title_str += label - title_str.strip() - else: - title_str = 'Function not suitable as probability density function' + plt.hist(eval('self.'+array),bins = binlist) + plt.xlabel('Values') + plt.ylabel('Frequency') + #plt.autoscale(axis='x', tight=True) + title_str = 'Quantile distance quotient distribution' + if label: + title_str += ' (' + label + ')' plt.title(title_str) plt.show() + def getTheta(self,number): + if number == 0: + return self.theta015 + elif number == 1: + return self.theta1 + elif number == 2: + return self.theta2 + + + def getPDFDict(self, month, evt): self.pdfdict = PDFDictionary.from_quakeml(os.path.join(self.directory,month,evt)) diff --git a/pylot/core/util/pdf.py b/pylot/core/util/pdf.py index 7c26b2be..94c847ce 100644 --- a/pylot/core/util/pdf.py +++ b/pylot/core/util/pdf.py @@ -326,7 +326,7 @@ class ProbabilityDensityFunction(object): raise ValueError('value out of bounds: {0}'.format(value)) return self.prob_limits((value, self.axis[-1])) - def prob_limits(self, limits, oversampling=1.): + def prob_limits(self, limits, oversampling=10.): sampling = self.incr / oversampling lim = np.arange(limits[0], limits[1], sampling) data = self.data(lim) @@ -353,7 +353,6 @@ class ProbabilityDensityFunction(object): r = self.axis[-1] m = (r + l) / 2 diff = prob_value - self.prob_lt_val(m) - while abs(diff) > eps and ((r - l) > self.incr): if diff > 0: l = m @@ -366,12 +365,11 @@ class ProbabilityDensityFunction(object): def quantile_distance(self, prob_value): ql = self.quantile(prob_value) qu = self.quantile(1 - prob_value) - return qu - ql def qtile_dist_quot(self,x): - if x < 0 or x > 0.5: + if x <= 0 or x >= 0.5: raise ValueError('Value out of range.') return self.quantile_distance(0.5-x)/self.quantile_distance(x)