aimbat.core
Core logic for AIMBAT.
All functions take a SQLModel Session and work with the models in
aimbat.models. The main areas covered are:
- Active event — get and set the active event (
get_active_event,set_active_event). Only one event is processed at a time; switching clears the seismogram data cache. - Data — add data to the project, linking each source to its station,
event, and seismogram records (
add_data_to_project). - Events, seismograms, stations — query, update, and delete records; read and write parameters.
- ICCS / MCCC — run the Iterative Cross-Correlation and Stack (
run_iccs) and Multi-Channel Cross-Correlation (run_mccc) algorithms; update picks, time windows, and correlation thresholds. - Snapshots — save, restore, and delete parameter snapshots
(
create_snapshot,rollback_to_snapshot). - Project — create and delete the project database (
create_project,delete_project).
Classes:
| Name | Description |
|---|---|
BoundICCS |
An ICCS instance explicitly bound to a specific event. |
Functions:
| Name | Description |
|---|---|
add_data_to_project |
Add data sources to the AIMBAT database. |
create_iccs_instance |
Create a BoundICCS instance for the given event. |
create_project |
Initializes a new AIMBAT project database schema and triggers. |
create_snapshot |
Create a snapshot of the AIMBAT processing parameters. |
delete_event |
Delete an AimbatEvent from the database. |
delete_event_by_id |
Delete an AimbatEvent from the database by ID. |
delete_project |
Delete the AIMBAT project. |
delete_seismogram |
Delete an AimbatSeismogram from the database. |
delete_seismogram_by_id |
Delete an AimbatSeismogram from the database by ID. |
delete_snapshot |
Delete an AIMBAT parameter snapshot. |
delete_snapshot_by_id |
Delete an AIMBAT parameter snapshot. |
delete_station |
Delete an AimbatStation from the database. |
delete_station_by_id |
Delete an AimbatStation from the database by ID. |
dump_data_table_to_json |
Dump the table data to json. |
dump_event_parameter_table_to_json |
Dump the event parameter table data to json. |
dump_event_table_to_json |
Dump the table data to json. |
dump_seismogram_parameter_table_to_json |
Dump the seismogram parameter table data to json. |
dump_seismogram_table_to_json |
Create a JSON string from the AimbatSeismogram table data. |
dump_snapshot_tables_to_json |
Dump snapshot data as a dict of lists of dicts. |
dump_station_table_to_json |
Create a JSON string from the AimbatStation table data. |
dump_station_table_with_counts |
Dump station table with associated seismogram and event counts to a list of dicts. |
get_active_event |
Return the currently active event (i.e. the one being processed). |
get_completed_events |
Get the events marked as completed. |
get_data_for_event |
Returns the data sources belonging to the given event. |
get_event_parameter |
Get event parameter value for the given event. |
get_events_using_station |
Get all events that use a particular station. |
get_seismogram_parameter |
Get parameter value from an AimbatSeismogram instance. |
get_seismogram_parameter_by_id |
Get parameter value from an AimbatSeismogram by ID. |
get_selected_seismograms |
Get the selected seismograms for the given event. |
get_snapshots |
Get the snapshots for an event. |
get_stations_in_event |
Get the stations for a particular event. |
get_stations_with_event_and_seismogram_count |
Get stations along with the count of seismograms and events they are associated with. |
plot_all_seismograms |
Plot all seismograms for a particular event ordered by great circle distance. |
plot_iccs_seismograms |
Plot the ICCS seismograms as an image. |
plot_stack |
Plot the ICCS stack. |
reset_seismogram_parameters |
Reset an AimbatSeismogram's parameters to their default values. |
reset_seismogram_parameters_by_id |
Reset an AimbatSeismogram's parameters to their default values by ID. |
rollback_to_snapshot |
Rollback to an AIMBAT parameters snapshot. |
rollback_to_snapshot_by_id |
Rollback to an AIMBAT parameters snapshot. |
run_iccs |
Run ICCS algorithm. |
run_mccc |
Run MCCC algorithm. |
set_active_event |
Set the active event (i.e. the one being processed). |
set_active_event_by_id |
Set the currently selected event (i.e. the one being processed) by its ID. |
set_event_parameter |
Set event parameter value for the given event. |
set_seismogram_parameter |
Set parameter value for an AimbatSeismogram instance. |
set_seismogram_parameter_by_id |
Set parameter value for an AimbatSeismogram by ID. |
sync_iccs_parameters |
Sync an existing ICCS instance's parameters from the database. |
update_min_ccnorm |
Update the minimum cross correlation coefficient for the given event. |
update_pick |
Update the pick for the active event. |
update_timewindow |
Update the time window for the given event. |
BoundICCS
dataclass
An ICCS instance explicitly bound to a specific event.
Use is_stale to detect whether the event's parameters have been modified
(e.g. by a CLI command) since this instance was created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iccs
|
ICCS
|
|
required |
event_id
|
UUID
|
|
required |
created_at
|
Timestamp
|
|
required |
Methods:
| Name | Description |
|---|---|
is_stale |
Return True if the event has been modified since this ICCS was created. |
Source code in src/aimbat/core/_iccs.py
is_stale
is_stale(event: AimbatEvent) -> bool
Return True if the event has been modified since this ICCS was created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
AimbatEvent
|
The event to check against. |
required |
Source code in src/aimbat/core/_iccs.py
add_data_to_project
add_data_to_project(
session: Session,
data_sources: Sequence[str | PathLike],
data_type: DataType,
station_id: UUID | None = None,
event_id: UUID | None = None,
dry_run: bool = False,
disable_progress_bar: bool = True,
) -> None
Add data sources to the AIMBAT database.
What gets created depends on which capabilities data_type supports:
- Station + event + seismogram: all three records are created and linked,
and an
AimbatDataSourceentry is stored. - Station or event only (e.g.
JSON_STATION,JSON_EVENT): only the relevant metadata records are created; no seismogram or data source entry is stored.
Use station_id or event_id to skip extracting station or event metadata
from the data source and link to a pre-existing record instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The SQLModel database session. |
required |
data_sources
|
Sequence[str | PathLike]
|
List of data sources to add. |
required |
data_type
|
DataType
|
Type of data. |
required |
station_id
|
UUID | None
|
UUID of an existing station to use instead of extracting one from each data source. |
None
|
event_id
|
UUID | None
|
UUID of an existing event to use instead of extracting one from each data source. |
None
|
dry_run
|
bool
|
If True, do not commit changes to the database. |
False
|
disable_progress_bar
|
bool
|
Do not display progress bar. |
True
|
Source code in src/aimbat/core/_data.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
create_iccs_instance
create_iccs_instance(
session: Session, event: AimbatEvent
) -> BoundICCS
Create a BoundICCS instance for the given event.
Seismogram data is copied into MiniICCSSeismogram objects so the session does not need to remain open after this call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
Returns:
| Type | Description |
|---|---|
BoundICCS
|
BoundICCS instance tied to the given event. |
Source code in src/aimbat/core/_iccs.py
create_project
Initializes a new AIMBAT project database schema and triggers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine
|
Engine
|
The SQLAlchemy/SQLModel Engine instance connected to the target database. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a project schema already exists in the target database. |
Source code in src/aimbat/core/_project.py
create_snapshot
create_snapshot(
session: Session,
event: AimbatEvent,
comment: str | None = None,
) -> None
Create a snapshot of the AIMBAT processing parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
comment
|
str | None
|
Optional comment. |
None
|
Source code in src/aimbat/core/_snapshot.py
delete_event
delete_event(session: Session, event: AimbatEvent) -> None
Delete an AimbatEvent from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
Event to delete. |
required |
Source code in src/aimbat/core/_event.py
delete_event_by_id
delete_event_by_id(
session: Session, event_id: UUID
) -> None
Delete an AimbatEvent from the database by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event_id
|
UUID
|
Event ID. |
required |
Raises:
| Type | Description |
|---|---|
NoResultFound
|
If no AimbatEvent is found with the given ID. |
Source code in src/aimbat/core/_event.py
delete_project
Delete the AIMBAT project.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If unable to delete project. |
Source code in src/aimbat/core/_project.py
delete_seismogram
delete_seismogram(
session: Session, seismogram: AimbatSeismogram
) -> None
Delete an AimbatSeismogram from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
seismogram
|
AimbatSeismogram
|
Seismogram to delete. |
required |
Source code in src/aimbat/core/_seismogram.py
delete_seismogram_by_id
delete_seismogram_by_id(
session: Session, seismogram_id: UUID
) -> None
Delete an AimbatSeismogram from the database by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
seismogram_id
|
UUID
|
Seismogram ID. |
required |
Raises:
| Type | Description |
|---|---|
NoResultFound
|
If no AimbatSeismogram is found with the given ID. |
Source code in src/aimbat/core/_seismogram.py
delete_snapshot
delete_snapshot(
session: Session, snapshot: AimbatSnapshot
) -> None
Delete an AIMBAT parameter snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
snapshot
|
AimbatSnapshot
|
Snapshot. |
required |
Source code in src/aimbat/core/_snapshot.py
delete_snapshot_by_id
delete_snapshot_by_id(
session: Session, snapshot_id: UUID
) -> None
Delete an AIMBAT parameter snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
snapshot_id
|
UUID
|
Snapshot id. |
required |
Source code in src/aimbat/core/_snapshot.py
delete_station
delete_station(
session: Session, station: AimbatStation
) -> None
Delete an AimbatStation from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
station
|
AimbatStation
|
Station to delete. |
required |
Source code in src/aimbat/core/_station.py
delete_station_by_id
delete_station_by_id(
session: Session, station_id: UUID
) -> None
Delete an AimbatStation from the database by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
station_id
|
UUID
|
Station ID. |
required |
Raises:
| Type | Description |
|---|---|
NoResultFound
|
If no AimbatStation is found with the given ID. |
Source code in src/aimbat/core/_station.py
dump_data_table_to_json
dump_data_table_to_json(session: Session) -> str
Dump the table data to json.
Source code in src/aimbat/core/_data.py
dump_event_parameter_table_to_json
dump_event_parameter_table_to_json(
session: Session,
all_events: bool,
as_string: bool,
event: AimbatEvent | None = None,
) -> str | dict[str, Any] | list[dict[str, Any]]
Dump the event parameter table data to json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
all_events
|
bool
|
Include event parameter table data for all events. |
required |
as_string
|
bool
|
Whether to return the result as a string. |
required |
event
|
AimbatEvent | None
|
Event to dump parameter data for (only used when all_events is False). |
None
|
Source code in src/aimbat/core/_event.py
dump_event_table_to_json
Dump the table data to json.
Source code in src/aimbat/core/_event.py
dump_seismogram_parameter_table_to_json
dump_seismogram_parameter_table_to_json(
session: Session,
all_events: bool,
as_string: bool,
event: AimbatEvent | None = None,
) -> str | list[dict[str, Any]]
Dump the seismogram parameter table data to json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
all_events
|
bool
|
Include parameters for all events. |
required |
as_string
|
bool
|
Return as JSON string. |
required |
event
|
AimbatEvent | None
|
Event to dump parameters for (only used when all_events is False). |
None
|
Source code in src/aimbat/core/_seismogram.py
dump_seismogram_table_to_json
dump_seismogram_table_to_json(session: Session) -> str
Create a JSON string from the AimbatSeismogram table data.
Source code in src/aimbat/core/_seismogram.py
dump_snapshot_tables_to_json
dump_snapshot_tables_to_json(
session: Session,
all_events: bool,
as_string: bool,
event: AimbatEvent | None = None,
) -> str | dict[str, list[dict[str, Any]]]
Dump snapshot data as a dict of lists of dicts.
Returns a structure with three keys:
snapshots: flat list of snapshot metadata.event_parameters: flat list of event parameter snapshots.seismogram_parameters: flat list of seismogram parameter snapshots.
Each entry includes a snapshot_id for cross-referencing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
all_events
|
bool
|
Include snapshots for all events. |
required |
as_string
|
bool
|
Return a JSON string when True, otherwise a dict. |
required |
event
|
AimbatEvent | None
|
Event to dump snapshots for (only used when all_events is False). |
None
|
Source code in src/aimbat/core/_snapshot.py
dump_station_table_to_json
dump_station_table_to_json(session: Session) -> str
Create a JSON string from the AimbatStation table data.
Source code in src/aimbat/core/_station.py
dump_station_table_with_counts
Dump station table with associated seismogram and event counts to a list of dicts.
Each dict represents a station and includes additional keys for the seismogram and event counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
Returns: A list of dictionaries representing the stations with counts.
Source code in src/aimbat/core/_station.py
get_active_event
get_active_event(session: Session) -> AimbatEvent
Return the currently active event (i.e. the one being processed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
SQL session. |
required |
Returns:
| Type | Description |
|---|---|
AimbatEvent
|
Active Event |
Raises NoResultFound: When no event is active.
Source code in src/aimbat/core/_active_event.py
get_completed_events
get_completed_events(
session: Session,
) -> Sequence[AimbatEvent]
Get the events marked as completed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
SQL session. |
required |
Source code in src/aimbat/core/_event.py
get_data_for_event
get_data_for_event(
session: Session, event: AimbatEvent
) -> Sequence[AimbatDataSource]
Returns the data sources belonging to the given event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
Returns:
| Type | Description |
|---|---|
Sequence[AimbatDataSource]
|
Sequence of AimbatDataSource objects belonging to the event. |
Source code in src/aimbat/core/_data.py
get_event_parameter
get_event_parameter(
session: Session,
event: AimbatEvent,
name: EventParameter,
) -> Timedelta | bool | float
Get event parameter value for the given event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
name
|
EventParameter
|
Name of the parameter. |
required |
Source code in src/aimbat/core/_event.py
get_events_using_station
get_events_using_station(
session: Session, station: AimbatStation
) -> Sequence[AimbatEvent]
Get all events that use a particular station.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
station
|
AimbatStation
|
Station to return events for. |
required |
Returns: Events that use the station.
Source code in src/aimbat/core/_event.py
get_seismogram_parameter
get_seismogram_parameter(
seismogram: AimbatSeismogram, name: SeismogramParameter
) -> bool | Timestamp
Get parameter value from an AimbatSeismogram instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seismogram
|
AimbatSeismogram
|
Seismogram. |
required |
name
|
SeismogramParameter
|
Name of the parameter value to return. |
required |
Returns:
| Type | Description |
|---|---|
bool | Timestamp
|
Seismogram parameter value. |
Source code in src/aimbat/core/_seismogram.py
get_seismogram_parameter_by_id
get_seismogram_parameter_by_id(
session: Session,
seismogram_id: UUID,
name: SeismogramParameter,
) -> bool | Timestamp
Get parameter value from an AimbatSeismogram by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
seismogram_id
|
UUID
|
Seismogram ID. |
required |
name
|
SeismogramParameter
|
Name of the parameter value to return. |
required |
Returns:
| Type | Description |
|---|---|
bool | Timestamp
|
Seismogram parameter value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no AimbatSeismogram is found with the given ID. |
Source code in src/aimbat/core/_seismogram.py
get_selected_seismograms
get_selected_seismograms(
session: Session,
event: AimbatEvent | None = None,
all_events: bool = False,
) -> Sequence[AimbatSeismogram]
Get the selected seismograms for the given event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent | None
|
Event to return selected seismograms for. |
None
|
all_events
|
bool
|
Get the selected seismograms for all events. |
False
|
Returns: Selected seismograms.
Source code in src/aimbat/core/_seismogram.py
get_snapshots
get_snapshots(
session: Session,
event: AimbatEvent | None = None,
all_events: bool = False,
) -> Sequence[AimbatSnapshot]
Get the snapshots for an event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent | None
|
Event to return snapshots for. |
None
|
all_events
|
bool
|
Get the snapshots for all events. |
False
|
Returns: Snapshots.
Source code in src/aimbat/core/_snapshot.py
get_stations_in_event
get_stations_in_event(
session: Session,
event: AimbatEvent,
as_json: bool = False,
) -> Sequence[AimbatStation] | list[dict[str, Any]]
Get the stations for a particular event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
Event to return stations for. |
required |
as_json
|
bool
|
Whether to return the result as JSON. |
False
|
Returns: Stations in event.
Source code in src/aimbat/core/_station.py
get_stations_with_event_and_seismogram_count
get_stations_with_event_and_seismogram_count(
session: Session,
) -> Sequence[tuple[AimbatStation, int, int]]
Get stations along with the count of seismograms and events they are associated with.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
A sequence of tuples containing the station, count of seismograms
| Type | Description |
|---|---|
Sequence[tuple[AimbatStation, int, int]]
|
and count of events. |
Source code in src/aimbat/core/_station.py
plot_all_seismograms
plot_all_seismograms(
session: Session, event: AimbatEvent, return_fig: bool
) -> tuple[Figure, Axes] | None
Plot all seismograms for a particular event ordered by great circle distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
return_fig
|
bool
|
Whether to return the figure and axes objects instead of showing the plot. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes] | None
|
figure and axes objects if return_fig is True, otherwise None. |
Source code in src/aimbat/core/_seismogram.py
plot_iccs_seismograms
Plot the ICCS seismograms as an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iccs
|
ICCS
|
ICCS instance. |
required |
context
|
bool
|
Whether to use seismograms with extra context. |
required |
all
|
bool
|
Whether to plot all seismograms. |
required |
return_fig
|
bool
|
If True, return the figure and axes objects instead of showing the plot. |
required |
Returns:
| Type | Description |
|---|---|
tuple | None
|
A tuple of (Figure, Axes) if return_fig is True, otherwise None. |
Source code in src/aimbat/core/_iccs.py
plot_stack
Plot the ICCS stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iccs
|
ICCS
|
ICCS instance. |
required |
context
|
bool
|
Whether to use seismograms with extra context. |
required |
all
|
bool
|
Whether to plot all seismograms. |
required |
return_fig
|
bool
|
If True, return the figure and axes objects instead of showing the plot. |
required |
Returns:
| Type | Description |
|---|---|
tuple | None
|
A tuple of (Figure, Axes) if return_fig is True, otherwise None. |
Source code in src/aimbat/core/_iccs.py
reset_seismogram_parameters
reset_seismogram_parameters(
session: Session, seismogram: AimbatSeismogram
) -> None
Reset an AimbatSeismogram's parameters to their default values.
All fields defined on AimbatSeismogramParametersBase are reset to the values produced by a fresh default instance, so newly added fields are picked up automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
seismogram
|
AimbatSeismogram
|
Seismogram whose parameters should be reset. |
required |
Source code in src/aimbat/core/_seismogram.py
reset_seismogram_parameters_by_id
reset_seismogram_parameters_by_id(
session: Session, seismogram_id: UUID
) -> None
Reset an AimbatSeismogram's parameters to their default values by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
seismogram_id
|
UUID
|
Seismogram ID. |
required |
Raises:
| Type | Description |
|---|---|
NoResultFound
|
If no AimbatSeismogram is found with the given ID. |
Source code in src/aimbat/core/_seismogram.py
rollback_to_snapshot
rollback_to_snapshot(
session: Session, snapshot: AimbatSnapshot
) -> None
Rollback to an AIMBAT parameters snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
AimbatSnapshot
|
Snapshot. |
required |
Source code in src/aimbat/core/_snapshot.py
rollback_to_snapshot_by_id
rollback_to_snapshot_by_id(
session: Session, snapshot_id: UUID
) -> None
Rollback to an AIMBAT parameters snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
snapshot_id
|
UUID
|
Snapshot id. |
required |
Source code in src/aimbat/core/_snapshot.py
run_iccs
Run ICCS algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
iccs
|
ICCS
|
ICCS instance. |
required |
autoflip
|
bool
|
Whether to automatically flip seismograms. |
required |
autoselect
|
bool
|
Whether to automatically select seismograms. |
required |
Source code in src/aimbat/core/_iccs.py
run_mccc
run_mccc(
session: Session,
event: AimbatEvent,
iccs: ICCS,
all_seismograms: bool,
) -> None
Run MCCC algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
iccs
|
ICCS
|
ICCS instance. |
required |
all_seismograms
|
bool
|
Whether to include all seismograms in the MCCC processing, or just the selected ones. |
required |
Source code in src/aimbat/core/_iccs.py
set_active_event
set_active_event(
session: Session, event: AimbatEvent
) -> None
Set the active event (i.e. the one being processed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
SQL session. |
required |
event
|
AimbatEvent
|
AIMBAT Event to set as active. |
required |
Source code in src/aimbat/core/_active_event.py
set_active_event_by_id
set_active_event_by_id(
session: Session, event_id: UUID
) -> None
Set the currently selected event (i.e. the one being processed) by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
SQL session. |
required |
event_id
|
UUID
|
ID of AIMBAT Event to set as active one. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no event with the given ID is found. |
Source code in src/aimbat/core/_active_event.py
set_event_parameter
set_event_parameter(
session: Session,
event: AimbatEvent,
name: EventParameter,
value: Timedelta | bool | float | str,
) -> None
Set event parameter value for the given event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
name
|
EventParameter
|
Name of the parameter. |
required |
value
|
Timedelta | bool | float | str
|
Value to set. |
required |
Source code in src/aimbat/core/_event.py
set_seismogram_parameter
set_seismogram_parameter(
session: Session,
seismogram: AimbatSeismogram,
name: SeismogramParameter,
value: Timestamp | bool | str,
) -> None
Set parameter value for an AimbatSeismogram instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session |
required |
seismogram
|
AimbatSeismogram
|
Seismogram to set parameter for. |
required |
name
|
SeismogramParameter
|
Name of the parameter. |
required |
value
|
Timestamp | bool | str
|
Value to set parameter to. |
required |
Source code in src/aimbat/core/_seismogram.py
set_seismogram_parameter_by_id
set_seismogram_parameter_by_id(
session: Session,
seismogram_id: UUID,
name: SeismogramParameter,
value: Timestamp | bool | str,
) -> None
Set parameter value for an AimbatSeismogram by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session |
required |
seismogram_id
|
UUID
|
Seismogram id. |
required |
name
|
SeismogramParameter
|
Name of the parameter. |
required |
value
|
Timestamp | bool | str
|
Value to set. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no AimbatSeismogram is found with the given ID. |
Source code in src/aimbat/core/_seismogram.py
sync_iccs_parameters
sync_iccs_parameters(
session: Session, event: AimbatEvent, iccs: ICCS
) -> None
Sync an existing ICCS instance's parameters from the database.
Updates event-level and per-seismogram parameters without re-reading waveform data. Use this after operations that change parameters but not the seismogram list (e.g. rolling back to a snapshot).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
iccs
|
ICCS
|
ICCS instance to update in-place. |
required |
Source code in src/aimbat/core/_iccs.py
update_min_ccnorm
update_min_ccnorm(
session: Session,
event: AimbatEvent,
iccs: ICCS,
context: bool,
all: bool,
return_fig: bool,
) -> tuple | None
Update the minimum cross correlation coefficient for the given event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
iccs
|
ICCS
|
ICCS instance. |
required |
context
|
bool
|
Whether to use seismograms with extra context. |
required |
all
|
bool
|
Whether to plot all seismograms. |
required |
return_fig
|
bool
|
If True, return the figure and axes objects instead of showing the plot. |
required |
Returns:
| Type | Description |
|---|---|
tuple | None
|
A tuple of (Figure, Axes, widgets) if return_fig is True, otherwise None. |
Source code in src/aimbat/core/_iccs.py
update_pick
update_pick(
session: Session,
iccs: ICCS,
context: bool,
all: bool,
use_seismogram_image: bool,
return_fig: bool,
) -> tuple | None
Update the pick for the active event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iccs
|
ICCS
|
ICCS instance. |
required |
context
|
bool
|
Whether to use seismograms with extra context. |
required |
all
|
bool
|
Whether to plot all seismograms. |
required |
use_seismogram_image
|
bool
|
Whether to use the seismogram image to update pick. |
required |
return_fig
|
bool
|
If True, return the figure and axes objects instead of showing the plot. |
required |
Returns:
| Type | Description |
|---|---|
tuple | None
|
A tuple of (Figure, Axes, widgets) if return_fig is True, otherwise None. |
Source code in src/aimbat/core/_iccs.py
update_timewindow
update_timewindow(
session: Session,
event: AimbatEvent,
iccs: ICCS,
context: bool,
all: bool,
use_seismogram_image: bool,
return_fig: bool,
) -> tuple | None
Update the time window for the given event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
event
|
AimbatEvent
|
AimbatEvent. |
required |
iccs
|
ICCS
|
ICCS instance. |
required |
context
|
bool
|
Whether to use seismograms with extra context. |
required |
all
|
bool
|
Whether to plot all seismograms. |
required |
use_seismogram_image
|
bool
|
Whether to use the seismogram image to update pick. |
required |
return_fig
|
bool
|
If True, return the figure and axes objects instead of showing the plot. |
required |
Returns:
| Type | Description |
|---|---|
tuple | None
|
A tuple of (Figure, Axes, widgets) if return_fig is True, otherwise None. |