seismometer.data.loader.SeismogramLoader¶
- class seismometer.data.loader.SeismogramLoader(config, prediction_fn=None, event_fn=None, post_predict_fn=None, post_event_fn=None, merge_fn=None, post_load_fn=None)¶
A data loading pipeline using three types of hooks:
load predictions [ConfigOnlyHook]
transform (type) the loaded predictions [ConfigFrameHook]
load events [ConfigOnlyHook]
transform (type) the loaded events [ConfigFrameHook]
merge events onto predictions [MergeFramesHook]
post load manipulations [ConfigFrameHook]
Each step is expected to return a dataframe, chaining the steps to get the frame driving a loaded Seismogram.
- Parameters:
config (ConfigProvider)
prediction_fn (Callable[[ConfigProvider], DataFrame] | None)
event_fn (Callable[[ConfigProvider], DataFrame] | None)
post_predict_fn (Callable[[ConfigProvider, DataFrame], DataFrame] | None)
post_event_fn (Callable[[ConfigProvider, DataFrame], DataFrame] | None)
merge_fn (Callable[[ConfigProvider, DataFrame, DataFrame], DataFrame] | None)
post_load_fn (Callable[[ConfigProvider, DataFrame], DataFrame] | None)
- __init__(config, prediction_fn=None, event_fn=None, post_predict_fn=None, post_event_fn=None, merge_fn=None, post_load_fn=None)¶
Initialize a data loading pipeline of functions returning a dataframe for a Seismogram session.
- Parameters:
config (ConfigProvider) – The loaded configuration object.
prediction_fn (ConfigOnlyHook) – A callable taking a ConfigProvider and returning a dataframe. Used to load a (predictions) dataframe based on configuration; skipped if prediction_obj is provided to load_data.
event_fn (ConfigOnlyHook, optional) – A callable taking a ConfigProvider and returning a dataframe. Used to load a (events) dataframe based on configuration; skipped if event_obj is provided to load_data.
post_predict_fn (ConfigFrameHook, optional) – A callable taking a ConfigProvider and a (predictions) dataframe and returning a dataframe. Used to do minor transforms of predictions such as type casting.
post_event_fn (ConfigFrameHook, optional) – A callable taking a ConfigProvider and a (events) dataframe and returning a dataframe. Used to do minor transforms of events such as type casting.
merge_fn (MergeFramesHook, optional) – A callable taking a ConfigProvider, a (events) dataframe, and a (predictions) dataframe and returning a dataframe. Used to merge events onto predictions based on configuration.
post_load_fn (ConfigFrameHook, optional) – A callable taking a ConfigProvider and the fully loaded dataframe and returning a dataframe. Used to allow any custom manipulations of the Seismogram dataframe during load. WARNING: This can completly overwrite/discard the daframe that was loaded.
Methods
__init__
(config[, prediction_fn, event_fn, ...])Initialize a data loading pipeline of functions returning a dataframe for a Seismogram session.
load_data
([prediction_obj, event_obj])Entry point for loading data for a Seismogram session.