aimbat.lib
Modules:
| Name | Description |
|---|---|
common |
Common functions for AIMBAT. |
data |
|
db |
Module to define the AIMBAT project file and create the database engine. |
event |
Module to manage and view events in AIMBAT. |
iccs |
Processing of data for AIMBAT. |
io |
Functions to read and write data files used with AIMBAT |
models |
This module defines the "Aimbat" classes. |
project |
|
seismogram |
|
snapshot |
|
station |
|
typing |
Custom types used in AIMBAT. |
utils |
|
common
Common functions for AIMBAT.
Classes:
| Name | Description |
|---|---|
CliHints |
Hints for error messages. |
TableStyling |
This class is to set the colour of the table columns and elements. |
Functions:
| Name | Description |
|---|---|
string_to_uuid |
Determine a UUID from a string containing the first few characters. |
CliHints
dataclass
TableStyling
dataclass
This class is to set the colour of the table columns and elements.
Source code in src/aimbat/lib/common.py
string_to_uuid
string_to_uuid(
session: Session,
id: str,
aimbat_class: type[
AimbatDataSource
| AimbatStation
| AimbatEvent
| AimbatEventParameters
| AimbatSeismogram
| AimbatSeismogramParameters
| AimbatSnapshot
| AimbatEventParametersSnapshot
| AimbatSeismogramParametersSnapshot
],
custom_error: str | None = None,
) -> UUID
Determine a UUID from a string containing the first few characters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
id
|
str
|
Input string to find UUID for. |
required |
aimbat_class
|
type[AimbatDataSource | AimbatStation | AimbatEvent | AimbatEventParameters | AimbatSeismogram | AimbatSeismogramParameters | AimbatSnapshot | AimbatEventParametersSnapshot | AimbatSeismogramParametersSnapshot]
|
Aimbat class to use to find UUID. |
required |
custom_error
|
str | None
|
Overrides the default error message. |
None
|
Returns:
| Type | Description |
|---|---|
UUID
|
The full UUID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the UUID could not be determined. |
Source code in src/aimbat/lib/common.py
data
Functions:
| Name | Description |
|---|---|
add_files_to_project |
Add files to the AIMBAT database. |
dump_data_table |
Dump the table data to json. |
get_data_for_active_event |
Returns the AimbatFiles belonging to the active event. |
print_data_table |
Print a pretty table with AIMBAT data. |
add_files_to_project
add_files_to_project(
datasources: Sequence[str | PathLike],
datatype: DataType,
disable_progress_bar: bool = True,
) -> None
Add files to the AIMBAT database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasources
|
Sequence[str | PathLike]
|
List of data sources to add. |
required |
datatype
|
DataType
|
Type of data. |
required |
disable_progress_bar
|
bool
|
Do not display progress bar. |
True
|
Source code in src/aimbat/lib/data.py
dump_data_table
Dump the table data to json.
Source code in src/aimbat/lib/data.py
get_data_for_active_event
get_data_for_active_event(
session: Session,
) -> Sequence[AimbatDataSource]
Returns the AimbatFiles belonging to the active event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
Sequence[AimbatDataSource]
|
List of AimbatFiles. |
Source code in src/aimbat/lib/data.py
print_data_table
Print a pretty table with AIMBAT data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short
|
bool
|
Shorten UUIDs and format data. |
required |
all_events
|
bool
|
Print all files instead of limiting to the active event. |
False
|
Source code in src/aimbat/lib/data.py
db
Module to define the AIMBAT project file and create the database engine.
Attributes:
| Name | Type | Description |
|---|---|---|
engine |
AIMBAT database engine. |
event
Module to manage and view events in AIMBAT.
Functions:
| Name | Description |
|---|---|
delete_event |
Delete an AimbatEvent from the database. |
delete_event_by_id |
Delete an AimbatEvent from the database by ID. |
dump_event_table |
Dump the table data to json. |
get_active_event |
Return the currently active event (i.e. the one being processed). |
get_completed_events |
Get the events marked as completed. |
get_event_parameter |
Get event parameter value for the active event. |
get_events_using_station |
Get all events that use a particular station. |
print_event_table |
Print a pretty table with AIMBAT events. |
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 active event. |
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/lib/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/lib/event.py
dump_event_table
Dump the table data to json.
Source code in src/aimbat/lib/event.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/lib/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/lib/event.py
get_event_parameter
get_event_parameter(
session: Session, name: EventParameter
) -> timedelta | bool | float
Get event parameter value for the active event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
name
|
EventParameter
|
Name of the parameter. |
required |
Source code in src/aimbat/lib/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/lib/event.py
print_event_table
print_event_table(short: bool = True) -> None
Print a pretty table with AIMBAT events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short
|
bool
|
Shorten and format the output to be more human-readable. |
True
|
Source code in src/aimbat/lib/event.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/lib/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/lib/event.py
set_event_parameter
set_event_parameter(
session: Session,
name: EventParameter,
value: timedelta | bool | float | str,
) -> None
Set event parameter value for the active event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
name
|
EventParameter
|
Name of the parameter. |
required |
value
|
timedelta | bool | float | str
|
Value to set. |
required |
Source code in src/aimbat/lib/event.py
iccs
Processing of data for AIMBAT.
Functions:
| Name | Description |
|---|---|
create_iccs_instance |
Create an ICCS instance for the active event. |
plot_seismograms |
Plot the ICCS seismograms as an image. |
plot_stack |
Plot the ICCS stack. |
run_iccs |
Run ICCS algorithm. |
update_min_ccnorm |
Update the minimum cross correlation coefficient for the active event. |
update_pick |
Update the pick for the active event. |
update_timewindow |
Update the time window for the active event. |
create_iccs_instance
create_iccs_instance(session: Session) -> ICCS
Create an ICCS instance for the active event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ICCS
|
ICCS instance. |
Source code in src/aimbat/lib/iccs.py
plot_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 |
Source code in src/aimbat/lib/iccs.py
plot_stack
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/lib/iccs.py
update_min_ccnorm
Update the minimum cross correlation coefficient 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 |
Source code in src/aimbat/lib/iccs.py
update_pick
update_pick(
session: Session,
iccs: ICCS,
context: bool,
all: bool,
use_seismogram_image: bool,
) -> 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 |
Source code in src/aimbat/lib/iccs.py
update_timewindow
update_timewindow(
session: Session,
iccs: ICCS,
context: bool,
all: bool,
use_seismogram_image: bool,
) -> None
Update the time window 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 |
Source code in src/aimbat/lib/iccs.py
io
Functions to read and write data files used with AIMBAT
Classes:
| Name | Description |
|---|---|
DataType |
Valid AIMBAT data types. |
Functions:
| Name | Description |
|---|---|
create_event |
Read event data from a data source and create an AimbatEvent. |
create_seismogram |
Read seismogram data from a data source and create an AimbatSeismogram. |
create_station |
Read station data from a data source and create an AimbatStation. |
read_seismogram_data |
Read seismogram data from a data source. |
write_seismogram_data |
Write seismogram data to a data source. |
DataType
create_event
create_event(
datasource: str | PathLike, datatype: DataType
) -> AimbatEvent
Read event data from a data source and create an AimbatEvent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike
|
Name of the data source. |
required |
datatype
|
DataType
|
AIMBAT compatible datatype. |
required |
Returns:
| Type | Description |
|---|---|
AimbatEvent
|
AimbatEvent instance. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the datatype is not supported. |
Source code in src/aimbat/lib/io/_io.py
create_seismogram
create_seismogram(
datasource: str | PathLike, datatype: DataType
) -> AimbatSeismogram
Read seismogram data from a data source and create an AimbatSeismogram.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike
|
Name of the data source. |
required |
datatype
|
DataType
|
AIMBAT compatible datatype. |
required |
Returns:
| Type | Description |
|---|---|
AimbatSeismogram
|
AimbatSeismogram instance. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the datatype is not supported. |
Source code in src/aimbat/lib/io/_io.py
create_station
create_station(
datasource: str | PathLike, datatype: DataType
) -> AimbatStation
Read station data from a data source and create an AimbatStation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike
|
Name of the data source. |
required |
datatype
|
DataType
|
AIMBAT compatible datatype. |
required |
Returns:
| Type | Description |
|---|---|
AimbatStation
|
AimbatStation instance. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the datatype is not supported. |
Source code in src/aimbat/lib/io/_io.py
read_seismogram_data
Read seismogram data from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike
|
Name of the data source. |
required |
datatype
|
DataType
|
AIMBAT compatible filetype. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Seismogram data. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the datatype is not supported. |
Source code in src/aimbat/lib/io/_io.py
write_seismogram_data
write_seismogram_data(
datasource: str | PathLike,
datatype: DataType,
data: NDArray[float64],
) -> None
Write seismogram data to a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike
|
Name of the data source. |
required |
datatype
|
DataType
|
AIMBAT compatible filetype. |
required |
data
|
NDArray[float64]
|
Seismogram data |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the datatype is not supported. |
Source code in src/aimbat/lib/io/_io.py
models
This module defines the "Aimbat" classes.
These classes are ORMs that present data stored in a database as classes to use with python in AIMBAT.
Classes:
| Name | Description |
|---|---|
AimbatDataSource |
Class to store data source information. |
AimbatDataSourceCreate |
Class to store data source information. |
AimbatEvent |
Store event information. |
AimbatEventParameters |
Processing parameters common to all seismograms of a particular event. |
AimbatEventParametersBase |
Base class that defines the event parameters used in AIMBAT. |
AimbatEventParametersSnapshot |
Event parameter snapshot. |
AimbatSeismogram |
Class to store seismogram data |
AimbatSeismogramParameters |
Class to store ICCS processing parameters of a single seismogram. |
AimbatSeismogramParametersBase |
Base class that defines the seismogram parameters used in AIMBAT. |
AimbatSeismogramParametersSnapshot |
Class to store a snapshot of ICCS processing parameters of a single seismogram. |
AimbatSnapshot |
Class to store AIMBAT snapshots. |
AimbatStation |
Class to store station information. |
Attributes:
| Name | Type | Description |
|---|---|---|
AimbatTypes |
Union of all AIMBAT models that exist in the database. |
AimbatTypes
module-attribute
AimbatTypes = (
AimbatDataSource
| AimbatStation
| AimbatEvent
| AimbatEventParameters
| AimbatSeismogram
| AimbatSeismogramParameters
| AimbatSnapshot
| AimbatEventParametersSnapshot
| AimbatSeismogramParametersSnapshot
)
Union of all AIMBAT models that exist in the database.
AimbatDataSource
Bases: SQLModel
Class to store data source information.
Source code in src/aimbat/lib/models.py
AimbatDataSourceCreate
AimbatEvent
Bases: SQLModel
Store event information.
Attributes:
| Name | Type | Description |
|---|---|---|
active |
bool | None
|
Indicates if an event is the active event. |
depth |
float | None
|
Event depth. |
id |
UUID
|
Unique ID. |
latitude |
float
|
Event latitude. |
longitude |
float
|
Event longitude. |
parameters |
AimbatEventParameters
|
Event parameters. |
seismograms |
list[AimbatSeismogram]
|
List of seismograms of this event. |
snapshots |
list[AimbatSnapshot]
|
List of snapshots. |
time |
datetime
|
Event time. |
Source code in src/aimbat/lib/models.py
active
class-attribute
instance-attribute
active: bool | None = Field(default=None, unique=True)
Indicates if an event is the active event.
id
class-attribute
instance-attribute
Unique ID.
parameters
class-attribute
instance-attribute
parameters: AimbatEventParameters = Relationship(
back_populates="event", cascade_delete=True
)
Event parameters.
seismograms
class-attribute
instance-attribute
seismograms: list[AimbatSeismogram] = Relationship(
back_populates="event", cascade_delete=True
)
List of seismograms of this event.
snapshots
class-attribute
instance-attribute
snapshots: list[AimbatSnapshot] = Relationship(
back_populates="event", cascade_delete=True
)
List of snapshots.
time
class-attribute
instance-attribute
time: datetime = Field(
unique=True, sa_type=_DateTimeUTC, allow_mutation=False
)
Event time.
AimbatEventParameters
Bases: AimbatEventParametersBase, EventParametersValidatorMixin
Processing parameters common to all seismograms of a particular event.
Attributes:
| Name | Type | Description |
|---|---|---|
bandpass_apply |
bool
|
Whether to apply bandpass filter to seismograms. |
bandpass_fmax |
float
|
Maximum frequency for bandpass filter (ignored if |
bandpass_fmin |
float
|
Minimum frequency for bandpass filter (ignored if |
completed |
bool
|
Mark an event as completed. |
event |
AimbatEvent
|
Event these parameters are associated with. |
event_id |
UUID
|
Event ID these parameters are associated with. |
id |
UUID
|
Unique ID. |
min_ccnorm |
float
|
Minimum cross-correlation used when automatically de-selecting seismograms. |
snapshots |
list[AimbatEventParametersSnapshot]
|
Snapshots these parameters are associated with. |
window_post |
timedelta
|
Post-pick window length. |
window_pre |
timedelta
|
Pre-pick window length. |
Source code in src/aimbat/lib/models.py
bandpass_apply
class-attribute
instance-attribute
bandpass_apply: bool = Field(
default_factory=lambda: bandpass_apply
)
Whether to apply bandpass filter to seismograms.
bandpass_fmax
class-attribute
instance-attribute
bandpass_fmax: float = Field(
default_factory=lambda: bandpass_fmax, gt=0
)
Maximum frequency for bandpass filter (ignored if bandpass_apply is False).
bandpass_fmin
class-attribute
instance-attribute
bandpass_fmin: float = Field(
default_factory=lambda: bandpass_fmin, ge=0
)
Minimum frequency for bandpass filter (ignored if bandpass_apply is False).
event
class-attribute
instance-attribute
event: AimbatEvent = Relationship(
back_populates="parameters"
)
Event these parameters are associated with.
event_id
class-attribute
instance-attribute
event_id: UUID = Field(
default=None,
foreign_key="aimbatevent.id",
ondelete="CASCADE",
)
Event ID these parameters are associated with.
id
class-attribute
instance-attribute
Unique ID.
min_ccnorm
class-attribute
instance-attribute
min_ccnorm: float = Field(
ge=0.0, le=1.0, default_factory=lambda: min_ccnorm
)
Minimum cross-correlation used when automatically de-selecting seismograms.
snapshots
class-attribute
instance-attribute
snapshots: list[AimbatEventParametersSnapshot] = (
Relationship(
back_populates="parameters", cascade_delete=True
)
)
Snapshots these parameters are associated with.
window_post
class-attribute
instance-attribute
window_post: timedelta = Field(
gt=0, default_factory=lambda: window_post
)
Post-pick window length.
window_pre
class-attribute
instance-attribute
window_pre: timedelta = Field(
lt=0, default_factory=lambda: window_pre
)
Pre-pick window length.
AimbatEventParametersBase
Bases: SQLModel
Base class that defines the event parameters used in AIMBAT.
This class serves as a base that is inherited by the actual classes that create the database tables. The attributes in this class correspond exactl to the AIMBAT event parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
bandpass_apply |
bool
|
Whether to apply bandpass filter to seismograms. |
bandpass_fmax |
float
|
Maximum frequency for bandpass filter (ignored if |
bandpass_fmin |
float
|
Minimum frequency for bandpass filter (ignored if |
completed |
bool
|
Mark an event as completed. |
min_ccnorm |
float
|
Minimum cross-correlation used when automatically de-selecting seismograms. |
window_post |
timedelta
|
Post-pick window length. |
window_pre |
timedelta
|
Pre-pick window length. |
Source code in src/aimbat/lib/models.py
bandpass_apply
class-attribute
instance-attribute
bandpass_apply: bool = Field(
default_factory=lambda: bandpass_apply
)
Whether to apply bandpass filter to seismograms.
bandpass_fmax
class-attribute
instance-attribute
bandpass_fmax: float = Field(
default_factory=lambda: bandpass_fmax, gt=0
)
Maximum frequency for bandpass filter (ignored if bandpass_apply is False).
bandpass_fmin
class-attribute
instance-attribute
bandpass_fmin: float = Field(
default_factory=lambda: bandpass_fmin, ge=0
)
Minimum frequency for bandpass filter (ignored if bandpass_apply is False).
min_ccnorm
class-attribute
instance-attribute
min_ccnorm: float = Field(
ge=0.0, le=1.0, default_factory=lambda: min_ccnorm
)
Minimum cross-correlation used when automatically de-selecting seismograms.
window_post
class-attribute
instance-attribute
window_post: timedelta = Field(
gt=0, default_factory=lambda: window_post
)
Post-pick window length.
window_pre
class-attribute
instance-attribute
window_pre: timedelta = Field(
lt=0, default_factory=lambda: window_pre
)
Pre-pick window length.
AimbatEventParametersSnapshot
Bases: AimbatEventParametersBase
Event parameter snapshot.
Attributes:
| Name | Type | Description |
|---|---|---|
bandpass_apply |
bool
|
Whether to apply bandpass filter to seismograms. |
bandpass_fmax |
float
|
Maximum frequency for bandpass filter (ignored if |
bandpass_fmin |
float
|
Minimum frequency for bandpass filter (ignored if |
completed |
bool
|
Mark an event as completed. |
min_ccnorm |
float
|
Minimum cross-correlation used when automatically de-selecting seismograms. |
window_post |
timedelta
|
Post-pick window length. |
window_pre |
timedelta
|
Pre-pick window length. |
Source code in src/aimbat/lib/models.py
bandpass_apply
class-attribute
instance-attribute
bandpass_apply: bool = Field(
default_factory=lambda: bandpass_apply
)
Whether to apply bandpass filter to seismograms.
bandpass_fmax
class-attribute
instance-attribute
bandpass_fmax: float = Field(
default_factory=lambda: bandpass_fmax, gt=0
)
Maximum frequency for bandpass filter (ignored if bandpass_apply is False).
bandpass_fmin
class-attribute
instance-attribute
bandpass_fmin: float = Field(
default_factory=lambda: bandpass_fmin, ge=0
)
Minimum frequency for bandpass filter (ignored if bandpass_apply is False).
min_ccnorm
class-attribute
instance-attribute
min_ccnorm: float = Field(
ge=0.0, le=1.0, default_factory=lambda: min_ccnorm
)
Minimum cross-correlation used when automatically de-selecting seismograms.
window_post
class-attribute
instance-attribute
window_post: timedelta = Field(
gt=0, default_factory=lambda: window_post
)
Post-pick window length.
window_pre
class-attribute
instance-attribute
window_pre: timedelta = Field(
lt=0, default_factory=lambda: window_pre
)
Pre-pick window length.
AimbatSeismogram
Bases: SQLModel
Class to store seismogram data
Attributes:
| Name | Type | Description |
|---|---|---|
begin_time |
datetime
|
Begin time of seismogram. |
delta |
timedelta
|
Sampling interval. |
id |
UUID
|
Unique ID. |
t0 |
datetime
|
Initial pick. |
Source code in src/aimbat/lib/models.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 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 | |
begin_time
class-attribute
instance-attribute
begin_time: datetime = Field(sa_type=_DateTimeUTC)
Begin time of seismogram.
id
class-attribute
instance-attribute
Unique ID.
AimbatSeismogramParameters
Bases: AimbatSeismogramParametersBase
Class to store ICCS processing parameters of a single seismogram.
Attributes:
| Name | Type | Description |
|---|---|---|
flip |
bool
|
Whether or not the seismogram should be flipped. |
select |
bool
|
Whether or not this seismogram should be used for processing. |
t1 |
datetime | None
|
Working pick. |
Source code in src/aimbat/lib/models.py
flip
class-attribute
instance-attribute
flip: bool = False
Whether or not the seismogram should be flipped.
select
class-attribute
instance-attribute
select: bool = True
Whether or not this seismogram should be used for processing.
t1
class-attribute
instance-attribute
t1: datetime | None = Field(
default=None, sa_type=_DateTimeUTC
)
Working pick.
This pick serves as working as well as output pick. It is changed by:
- Picking the phase arrival in the stack.
- Running ICCS.
- Running MCCC.
AimbatSeismogramParametersBase
Bases: SQLModel
Base class that defines the seismogram parameters used in AIMBAT.
Attributes:
| Name | Type | Description |
|---|---|---|
flip |
bool
|
Whether or not the seismogram should be flipped. |
select |
bool
|
Whether or not this seismogram should be used for processing. |
t1 |
datetime | None
|
Working pick. |
Source code in src/aimbat/lib/models.py
flip
class-attribute
instance-attribute
flip: bool = False
Whether or not the seismogram should be flipped.
select
class-attribute
instance-attribute
select: bool = True
Whether or not this seismogram should be used for processing.
t1
class-attribute
instance-attribute
t1: datetime | None = Field(
default=None, sa_type=_DateTimeUTC
)
Working pick.
This pick serves as working as well as output pick. It is changed by:
- Picking the phase arrival in the stack.
- Running ICCS.
- Running MCCC.
AimbatSeismogramParametersSnapshot
Bases: AimbatSeismogramParametersBase
Class to store a snapshot of ICCS processing parameters of a single seismogram.
Attributes:
| Name | Type | Description |
|---|---|---|
flip |
bool
|
Whether or not the seismogram should be flipped. |
select |
bool
|
Whether or not this seismogram should be used for processing. |
t1 |
datetime | None
|
Working pick. |
Source code in src/aimbat/lib/models.py
flip
class-attribute
instance-attribute
flip: bool = False
Whether or not the seismogram should be flipped.
select
class-attribute
instance-attribute
select: bool = True
Whether or not this seismogram should be used for processing.
t1
class-attribute
instance-attribute
t1: datetime | None = Field(
default=None, sa_type=_DateTimeUTC
)
Working pick.
This pick serves as working as well as output pick. It is changed by:
- Picking the phase arrival in the stack.
- Running ICCS.
- Running MCCC.
AimbatSnapshot
Bases: SQLModel
Class to store AIMBAT snapshots.
The AimbatSnapshot class does not actually save any parameter data. It is used to keep track of the AimbatEventParametersSnapshot and AimbatSeismogramParametersSnapshot instances.
Attributes:
| Name | Type | Description |
|---|---|---|
event |
AimbatEvent
|
Event this snapshot is associated with. |
event_id |
UUID
|
Event ID this snapshot is associated with. |
Source code in src/aimbat/lib/models.py
event
class-attribute
instance-attribute
event: AimbatEvent = Relationship(
back_populates="snapshots"
)
Event this snapshot is associated with.
event_id
class-attribute
instance-attribute
event_id: UUID = Field(
default=None,
foreign_key="aimbatevent.id",
ondelete="CASCADE",
)
Event ID this snapshot is associated with.
AimbatStation
Bases: SQLModel
Class to store station information.
Attributes:
| Name | Type | Description |
|---|---|---|
channel |
str
|
Channel code. |
elevation |
float | None
|
Station elevation. |
id |
UUID
|
Unique ID. |
latitude |
float
|
Station latitude |
location |
str
|
Location ID. |
longitude |
float
|
Station longitude |
name |
str
|
Station name. |
network |
str
|
Network name. |
seismograms |
list[AimbatSeismogram]
|
Seismograms recorded at this station. |
Source code in src/aimbat/lib/models.py
id
class-attribute
instance-attribute
Unique ID.
location
class-attribute
instance-attribute
location: str = Field(allow_mutation=False)
Location ID.
seismograms
class-attribute
instance-attribute
seismograms: list[AimbatSeismogram] = Relationship(
back_populates="station", cascade_delete=True
)
Seismograms recorded at this station.
project
Functions:
| Name | Description |
|---|---|
create_project |
Create a new AIMBAT project. |
delete_project |
Delete the AIMBAT project. |
print_project_info |
Show AIMBAT project information. |
create_project
Create a new AIMBAT project.
Source code in src/aimbat/lib/project.py
delete_project
Delete the AIMBAT project.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If unable to delete project. |
Source code in src/aimbat/lib/project.py
print_project_info
Show AIMBAT project information.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no project found. |
Source code in src/aimbat/lib/project.py
seismogram
Functions:
| Name | Description |
|---|---|
delete_seismogram |
Delete an AimbatSeismogram from the database. |
delete_seismogram_by_id |
Delete an AimbatSeismogram from the database by ID. |
dump_seismogram_table |
Dump the table data to json. |
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 active avent. |
plot_seismograms |
Plot all seismograms for a particular event ordered by great circle distance. |
print_seismogram_table |
Prints a pretty table with AIMBAT seismograms. |
set_seismogram_parameter |
Set parameter value for an AimbatSeismogram instance. |
set_seismogram_parameter_by_id |
Set parameter value for an AimbatSeismogram by ID. |
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/lib/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/lib/seismogram.py
dump_seismogram_table
Dump the table data to json.
Source code in src/aimbat/lib/seismogram.py
get_seismogram_parameter
get_seismogram_parameter(
seismogram: AimbatSeismogram, name: SeismogramParameter
) -> bool | datetime
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 | datetime
|
Seismogram parameter value. |
Source code in src/aimbat/lib/seismogram.py
get_seismogram_parameter_by_id
get_seismogram_parameter_by_id(
session: Session,
seismogram_id: UUID,
name: SeismogramParameter,
) -> bool | datetime
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 | datetime
|
Seismogram parameter value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no AimbatSeismogram is found with the given ID. |
Source code in src/aimbat/lib/seismogram.py
get_selected_seismograms
get_selected_seismograms(
session: Session, all_events: bool = False
) -> Sequence[AimbatSeismogram]
Get the selected seismograms for the active avent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
all_events
|
bool
|
Get the selected seismograms for all events. |
False
|
Returns: Selected seismograms.
Source code in src/aimbat/lib/seismogram.py
plot_seismograms
Plot all seismograms for a particular event ordered by great circle distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_qt
|
bool
|
Plot with pqtgraph instead of pyplot |
False
|
Source code in src/aimbat/lib/seismogram.py
print_seismogram_table
Prints a pretty table with AIMBAT seismograms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short
|
bool
|
Shorten and format the output to be more human-readable. |
required |
all_events
|
bool
|
Print seismograms for all events. |
False
|
Source code in src/aimbat/lib/seismogram.py
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 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
set_seismogram_parameter
set_seismogram_parameter(
session: Session,
seismogram: AimbatSeismogram,
name: SeismogramParameter,
value: datetime | 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
|
datetime | bool | str
|
Value to set parameter to. |
required |
Source code in src/aimbat/lib/seismogram.py
set_seismogram_parameter_by_id
set_seismogram_parameter_by_id(
session: Session,
seismogram_id: UUID,
name: SeismogramParameter,
value: datetime | 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
|
datetime | bool | str
|
Value to set. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no AimbatSeismogram is found with the given ID. |
Source code in src/aimbat/lib/seismogram.py
snapshot
Functions:
| Name | Description |
|---|---|
create_snapshot |
Create a snapshot of the AIMBAT processing parameters. |
delete_snapshot |
Delete an AIMBAT parameter snapshot. |
delete_snapshot_by_id |
Delete an AIMBAT parameter snapshot. |
get_snapshots |
Get the snapshots for the active avent. |
print_snapshot_table |
Print a pretty table with AIMBAT snapshots. |
rollback_to_snapshot |
Rollback to an AIMBAT parameters snapshot. |
rollback_to_snapshot_by_id |
Rollback to an AIMBAT parameters snapshot. |
create_snapshot
create_snapshot(
session: Session, comment: str | None = None
) -> None
Create a snapshot of the AIMBAT processing parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
comment
|
str | None
|
Optional comment. |
None
|
Source code in src/aimbat/lib/snapshot.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/lib/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/lib/snapshot.py
get_snapshots
get_snapshots(
session: Session, all_events: bool = False
) -> Sequence[AimbatSnapshot]
Get the snapshots for the active avent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Database session. |
required |
all_events
|
bool
|
Get the selected snapshots for all events. |
False
|
Returns: Snapshots.
Source code in src/aimbat/lib/snapshot.py
print_snapshot_table
Print a pretty table with AIMBAT snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short
|
bool
|
Shorten and format the output to be more human-readable. |
required |
all_events
|
bool
|
Print all snapshots instead of limiting to the active event. |
required |
Source code in src/aimbat/lib/snapshot.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/lib/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/lib/snapshot.py
station
Functions:
| Name | Description |
|---|---|
delete_station |
Delete an AimbatStation from the database. |
delete_station_by_id |
Delete an AimbatStation from the database by ID. |
dump_station_table |
Dump the table data to json. |
get_stations_in_event |
Get the stations for a particular event. |
print_station_table |
Prints a pretty table with AIMBAT stations. |
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/lib/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/lib/station.py
dump_station_table
Dump the table data to json.
Source code in src/aimbat/lib/station.py
get_stations_in_event
get_stations_in_event(
session: Session, event: AimbatEvent
) -> Sequence[AimbatStation]
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 |
Returns: Stations in event.
Source code in src/aimbat/lib/station.py
print_station_table
Prints a pretty table with AIMBAT stations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short
|
bool
|
Shorten and format the output to be more human-readable. |
required |
all_events
|
bool
|
Print stations for all events. |
False
|
Source code in src/aimbat/lib/station.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
typing
Custom types used in AIMBAT.
Classes:
| Name | Description |
|---|---|
EventParameter |
|
SeismogramParameter |
|
EventParameterBool
EventParameterBool = Literal[COMPLETED, BANDPASS_APPLY]
TypeAlias for AimbatEvent attributes with bool values.
EventParameterFloat
EventParameterFloat = Literal[
MIN_CCNORM, BANDPASS_FMIN, BANDPASS_FMAX
]
TypeAlias for AimbatEvent attributes with float values.
EventParameterTimedelta
EventParameterTimedelta = Literal[WINDOW_PRE, WINDOW_POST]
TypeAlias for AimbatEvent attributes with timedelta values.
EventParameter
Bases: StrEnum
AimbatEvent enum class for typing.
This enum class is used for typing, cli args etc. The attributes must be
the same as in the AimbatEvent model.
Source code in src/aimbat/lib/typing.py
SeismogramParameter
Bases: StrEnum
AimbatSeismograParameters enum class for typing.
This enum class is used for typing, cli args etc. The attributes must be
the same as in the [AimbatParameters][aimbat.lib.models.AimbatParameters] model.
Source code in src/aimbat/lib/typing.py
utils
Modules:
| Name | Description |
|---|---|
checkdata |
|
sampledata |
|
checkdata
Functions:
| Name | Description |
|---|---|
checkdata_event |
Check if event information is complete. |
checkdata_seismogram |
Check if seismogram information is complete. |
checkdata_station |
Check if station information is complete. |
run_checks |
Run all checks on one or more SAC files. |
checkdata_event
Check if event information is complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Event
|
event object to test. |
required |
Source code in src/aimbat/lib/utils/checkdata.py
checkdata_seismogram
checkdata_seismogram(seismogram: Seismogram) -> list[str]
Check if seismogram information is complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seismogram
|
Seismogram
|
seismogram object to test. |
required |
Source code in src/aimbat/lib/utils/checkdata.py
checkdata_station
Check if station information is complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
station
|
Station
|
station object to test. |
required |
Source code in src/aimbat/lib/utils/checkdata.py
run_checks
Run all checks on one or more SAC files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sacfiles
|
list[Path]
|
SAC files to test. |
required |
Source code in src/aimbat/lib/utils/checkdata.py
sampledata
Functions:
| Name | Description |
|---|---|
delete_sampledata |
Delete sample data. |
download_sampledata |
Download sample data. |
delete_sampledata
download_sampledata
download_sampledata(force: bool = False) -> None
Download sample data.