This PR makes easier to implement user defined Ground motion databases for residuals computation (e.g. via SQL database) .
A new module rcrs is created, which implements ResidualsCompliantRecordSet: this is the abstract-like base interface for any database to be passed to gmpe_residuals.Residuals.get_residuals.
sm_database.GroundMotionDatabase and sm_table.GroundMotionTable were refactored to subclass ResidualsCompliantRecordSet
gmpe_residuals.Residuals.get_residuals has been slightly refactored to work with ResidualsCompliantRecordSetas input (minor stuff, most of the code was already implemented for that)
Refactored sm_table because of some unused / unstructured code (nothing to do with this PR, but while I was at it ...)
Fixed tests (with Python 3.8.1 and openquake 3.10.1)
============
Note: the context dicts (see method rcrs.ResidualsCompliantRecordSet.get_contexts) do not have anymore the 'EventIndex' key, which was mapped to the indices of the event's records. Let alone the naming ('RecordIndex' might be more suited) the key has been removed because it is not used anymore anywhere. Also, before being tempted to restore it, note that it assumed Ground motion databases storages to always be index-based, which is not true (it works for Python lists, but not for HDF table rows for instance)
This PR makes easier to implement user defined Ground motion databases for residuals computation (e.g. via SQL database) .
A new module
rcrs
is created, which implementsResidualsCompliantRecordSet
: this is the abstract-like base interface for any database to be passed togmpe_residuals.Residuals.get_residuals
.sm_database.GroundMotionDatabase
andsm_table.GroundMotionTable
were refactored to subclassResidualsCompliantRecordSet
gmpe_residuals.Residuals.get_residuals
has been slightly refactored to work withResidualsCompliantRecordSet
as input (minor stuff, most of the code was already implemented for that)Refactored
sm_table
because of some unused / unstructured code (nothing to do with this PR, but while I was at it ...)Fixed tests (with Python 3.8.1 and openquake 3.10.1)
============
Note: the
context
dicts (see methodrcrs.ResidualsCompliantRecordSet.get_contexts
) do not have anymore the 'EventIndex' key, which was mapped to the indices of the event's records. Let alone the naming ('RecordIndex' might be more suited) the key has been removed because it is not used anymore anywhere. Also, before being tempted to restore it, note that it assumed Ground motion databases storages to always be index-based, which is not true (it works for Python lists, but not for HDF table rows for instance)