[adresses #195] comparison dictionaries can now be compiled from QuakeML files

This commit is contained in:
Sebastian Wehling-Benatelli 2016-03-31 14:29:29 +02:00
parent 5fcaddb028
commit a475b366d4
2 changed files with 21 additions and 3 deletions

View File

@ -49,4 +49,13 @@ def compare_picksets(a, b):
compare_pdfs = dict() compare_pdfs = dict()
for station, phases in pdf_a.items():
if station in pdf_b.keys():
compare_pdf = dict()
for phase in phases:
if phase in pdf_b[station].keys():
compare_pdf[phase] = phases[phase] - pdf_b[station][phase]
if compare_pdf is not None:
compare_pdfs[station] = compare_pdf
return compare_pdfs return compare_pdfs

View File

@ -270,12 +270,21 @@ class ProbabilityDensityFunction(object):
def prob_lt_val(self, value): def prob_lt_val(self, value):
if value <= self.axis[0] or value > self.axis[-1]: if value <= self.axis[0] or value > self.axis[-1]:
raise ValueError('value out of bounds: {0}'.format(value)) raise ValueError('value out of bounds: {0}'.format(value))
return self.data[self.axis <= value].sum() * self.incr return self.prob_limits((self.axis[0], value))
def prob_gt_val(self, value): def prob_gt_val(self, value):
if value < self.axis[0] or value >= self.axis[-1]: if value < self.axis[0] or value >= self.axis[-1]:
raise ValueError('value out of bounds: {0}'.format(value)) raise ValueError('value out of bounds: {0}'.format(value))
return self.data[self.axis >= value].sum() * self.incr return self.prob_limits((value, self.axis[-1]))
def prob_limits(self, limits):
lim_ind = np.logical_and(limits[0] <= self.axis, self.axis <= limits[1])
data = self.data[lim_ind]
min_est, max_est = 0., 0.
for n in range(len(data) - 1):
min_est += min(data[n], data[n + 1])
max_est += max(data[n], data[n + 1])
return (min_est + max_est) / 2. * self.incr
def prob_val(self, value): def prob_val(self, value):
if not (self.axis[0] <= value <= self.axis[-1]): if not (self.axis[0] <= value <= self.axis[-1]):