GEMScienceTools / gmpe-smtk

Python and OpenQuake-based Toolkit for Analysis of Strong Motions and Interpretation of GMPEs
GNU Affero General Public License v3.0
43 stars 33 forks source link

Refactor of Residuals object - merging all methods into one class #99

Closed g-weatherill closed 5 years ago

g-weatherill commented 5 years ago

Addresses https://github.com/GEMScienceTools/gmpe-smtk/issues/97 The use of subclasses for different tools to calculate the fit of ground motions to models (e.g. Likelihood, LLH, MultivariateLLH, EDR) meant that the user would need to re-calculate the residuals upon calling each tool. This PR merges the respective tools into the main Residuals class to avoid this. The changes (from the original classes to new methods in the Residuals class) are as follows: Likelihood now becomes .get_likelihood_values() LLH(...) now becomes .get_loglikelihood_values(imts) MultivariateLLH now becomes .get_multivariate_loglikelihood_values(sum_imts=bool) EDR now becomes .get_edr_values(bandwidth, multiplier)

Additionally, the methods are also added into a dictionary, allowing them to be called in sequence from an instantiated residuals object and a list of method names.

For backward compatibility the previous classes are retained, albeit now raising deprecation warnings upon instantiation.

Changes are propagated into the plotting tools.