From 3568a8a59a613357db775db89402006232a8cb86 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Sat, 11 Jun 2016 08:03:16 +0200 Subject: [PATCH] [bugfix] changed the way the the expectation and the std array are calculated; not sure how to deal with values 'inf' --- pylot/core/pick/compare.py | 43 +++++++++++++------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/pylot/core/pick/compare.py b/pylot/core/pick/compare.py index 8c64db05..2d7b55da 100644 --- a/pylot/core/pick/compare.py +++ b/pylot/core/pick/compare.py @@ -140,41 +140,28 @@ class Comparison(object): plt.show() - def get_array(self, phase, method): + def get_all(self, phasename): pdf_dict = self.comparison - exp_array = list() - for station, phases in pdf_dict.items(): + rlist = list() + for phases in pdf_dict.values(): try: - exp_array.append(phases[phase].expectation()) - except KeyError as e: - print('{err_msg}; station = {station}, phase = {phase}'.format( - err_msg=str(e), station=station, phase=phase)) + rlist.append(phases[phasename]) + except KeyError: continue - return exp_array + return rlist + + def get_array(self, phase, method_name): + import operator + method = operator.methodcaller(method_name) + pdf_list = self.get_all(phase) + rarray = map(method, pdf_list) + return rarray def get_expectation_array(self, phase): - pdf_dict = self.comparison - exp_array = list() - for station, phases in pdf_dict.items(): - try: - exp_array.append(phases[phase].expectation()) - except KeyError as e: - print('{err_msg}; station = {station}, phase = {phase}'.format( - err_msg=str(e), station=station, phase=phase)) - continue - return exp_array + return self.get_array(phase, 'expectation') def get_std_array(self, phase): - pdf_dict = self.comparison - std_array = list() - for station, phases in pdf_dict.items(): - try: - std_array.append(phases[phase].standard_deviation()) - except KeyError as e: - print('{err_msg}; station = {station}, phase = {phase}'.format( - err_msg=str(e), station=station, phase=phase)) - continue - return std_array + return self.get_array(phase, 'standard_deviation') def hist_expectation(self, phases='all', bins=20, normed=False): phases.strip()