diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-08 08:22:03 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-08 08:22:03 +0200 |
commit | 3a02d19162975b619ea11259ce763c1902837b81 (patch) | |
tree | 76a99ec0cdf6b67d14f249bdf7729cdff2aeaf81 /lib | |
parent | 3b0db299a77956ddaa1c9734e56d31eb3b245253 (diff) |
dfatool: refactor get_static
Diffstat (limited to 'lib')
-rw-r--r--[-rwxr-xr-x] | lib/dfatool.py | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py index cc07026..8b0ff09 100755..100644 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -1206,31 +1206,23 @@ class AnalyticModel: return self.parameters[param_index] return str(param_index) - def get_static(self): + def get_static(self, use_mean=False): """ Get static model function: name, attribute -> model value. Uses the median of by_name for modeling. """ - static_model = self._get_model_from_dict(self.by_name, np.median) - - def static_median_getter(name, key, **kwargs): - return static_model[name][key] + getter_function = np.median - return static_median_getter + if use_mean: + getter_function = np.mean - def get_static_using_mean(self): - """ - Get static model function: name, attribute -> model value. - - Uses the mean of by_name for modeling. - """ - static_model = self._get_model_from_dict(self.by_name, np.mean) + static_model = self._get_model_from_dict(self.by_name, getter_function) - def static_mean_getter(name, key, **kwargs): + def static_model_getter(name, key, **kwargs): return static_model[name][key] - return static_mean_getter + return static_model_getter def get_param_lut(self, fallback = False): """ @@ -1561,31 +1553,23 @@ class PTAModel: vprint(self.verbose, '[W] Got no data for {} {}: {}'.format(name, key, fpe)) return model - def get_static(self): + def get_static(self, use_mean=False): """ Get static model function: name, attribute -> model value. Uses the median of by_name for modeling. """ - static_model = self._get_model_from_dict(self.by_name, np.median) - - def static_median_getter(name, key, **kwargs): - return static_model[name][key] + getter_function = np.median - return static_median_getter + if use_mean: + getter_function = np.mean - def get_static_using_mean(self): - """ - Get static model function: name, attribute -> model value. - - Uses the mean of by_name for modeling. - """ - static_model = self._get_model_from_dict(self.by_name, np.mean) + static_model = self._get_model_from_dict(self.by_name, getter_function) - def static_mean_getter(name, key, **kwargs): + def static_model_getter(name, key, **kwargs): return static_model[name][key] - return static_mean_getter + return static_model_getter def get_param_lut(self, fallback = False): """ |