Skip to content

aimbat.models

ORM classes mapping to AIMBAT database tables.

Each class in this module corresponds to a table in the SQLite project database and is built on SQLModel, which combines SQLAlchemy (for database access) with Pydantic (for validation).

The main classes and their relationships are:

  • AimbatEvent — a seismic event. Only one event can be the default at a time, enforced by a database constraint on the is_default column.
  • AimbatStation — a seismic recording station.
  • AimbatSeismogram — links an AimbatEvent to an AimbatStation and holds the timing metadata (begin_time, delta, t0). Waveform data is accessed via the associated AimbatDataSource.
  • AimbatDataSource — records where the waveform data for a seismogram is stored, along with its type (e.g. SAC).
  • AimbatEventParameters — processing parameters shared across all seismograms of an event (window bounds, bandpass filter settings, MCCC settings, etc.).
  • AimbatSeismogramParameters — per-seismogram processing parameters (flip, select, working pick t1).
  • AimbatSnapshot — captures a point-in-time copy of event and seismogram parameters via AimbatEventParametersSnapshot and AimbatSeismogramParametersSnapshot, enabling rollback and comparison.

Type Aliases:

Name Description
AimbatTypes

Union of all AIMBAT models that exist in the database.

Classes:

Name Description
AimbatDataSource

Class to store data source information.

AimbatEvent

Class to store seismic event information.

AimbatEventParameters

Processing parameters common to all seismograms of a particular event.

AimbatEventParametersBase

Base class defining event-level processing parameters for AIMBAT.

AimbatEventParametersSnapshot

Snapshot of processing parameters for a particular event.

AimbatSeismogram

Class to store seismogram metadata.

AimbatSeismogramParameters

Processing parameters for a single seismogram.

AimbatSeismogramParametersBase

Base class defining seismogram-level processing parameters for AIMBAT.

AimbatSeismogramParametersSnapshot

Snapshot of processing parameters for a single seismogram.

AimbatSnapshot

Container for a point-in-time snapshot of event and seismogram parameters.

AimbatStation

Class to store station information.

AimbatDataSource

Bases: SQLModel

Class to store data source information.

Parameters:

Name Type Description Default
id UUID

Unique ID.

UUID('252ffd4c-5d0c-47ba-9ea7-12492f245c42')
sourcename str

Path or name of the data source.

required
datatype DataType

Data type of the data source.

required
seismogram_id UUID

Foreign key referencing the parent seismogram.

None

Attributes:

Name Type Description
seismogram AimbatSeismogram

The seismogram this data source belongs to.

Source code in src/aimbat/models/_models.py
class AimbatDataSource(SQLModel, table=True):
    """Class to store data source information."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    sourcename: str = Field(description="Path or name of the data source.")
    datatype: DataType = Field(description="Data type of the data source.")
    seismogram_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatseismogram.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent seismogram.",
    )
    seismogram: "AimbatSeismogram" = Relationship(back_populates="datasource")
    "The seismogram this data source belongs to."

seismogram class-attribute instance-attribute

seismogram: AimbatSeismogram = Relationship(
    back_populates="datasource"
)

The seismogram this data source belongs to.

AimbatEvent

Bases: SQLModel

Class to store seismic event information.

Parameters:

Name Type Description Default
id UUID

Unique ID.

UUID('abbb71d0-3eac-4c92-8b64-f55a457d03dd')
is_default bool | None

Indicates if an event is the default event.

None
time PydanticTimestamp

Event time.

required
latitude float

Event latitude.

required
longitude float

Event longitude.

required
depth float | None

Event depth.

None
last_modified PydanticTimestamp | None

Timestamp of the last modification to this event's parameters.

None

Attributes:

Name Type Description
parameters AimbatEventParameters

Event parameters.

seismograms list[AimbatSeismogram]

List of seismograms of this event.

snapshots list[AimbatSnapshot]

List of snapshots.

Source code in src/aimbat/models/_models.py
class AimbatEvent(SQLModel, table=True):
    """Class to store seismic event information."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )

    is_default: bool | None = Field(
        default=None,
        unique=True,
        description="Indicates if an event is the default event.",
    )

    time: PydanticTimestamp = Field(
        unique=True,
        sa_type=SAPandasTimestamp,
        allow_mutation=False,
        description="Event time.",
    )

    latitude: float = Field(description="Event latitude.")
    longitude: float = Field(description="Event longitude.")
    depth: float | None = Field(default=None, description="Event depth.")
    last_modified: PydanticTimestamp | None = Field(
        default=None,
        sa_type=SAPandasTimestamp,
        description="Timestamp of the last modification to this event's parameters.",
    )
    seismograms: list[AimbatSeismogram] = Relationship(
        back_populates="event", cascade_delete=True
    )
    "List of seismograms of this event."

    parameters: AimbatEventParameters = Relationship(
        back_populates="event", cascade_delete=True
    )
    "Event parameters."

    snapshots: list[AimbatSnapshot] = Relationship(
        back_populates="event", cascade_delete=True
    )
    "List of snapshots."

    if TYPE_CHECKING:
        # Column properties defined below, but add same default values for type checking purposes
        seismogram_count: int = 0
        station_count: int = 0

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.

AimbatEventParameters

Bases: AimbatEventParametersBase

Processing parameters common to all seismograms of a particular event.

Parameters:

Name Type Description Default
completed bool

Mark an event as completed.

False
min_ccnorm float

Minimum cross-correlation used when automatically de-selecting seismograms.

0.5
window_pre PydanticNegativeTimedelta

Pre-pick window length in seconds.

Timedelta('-1 days +23:59:45')
window_post PydanticPositiveTimedelta

Post-pick window length in seconds.

Timedelta('0 days 00:00:15')
bandpass_apply bool

Whether to apply bandpass filter to seismograms.

False
bandpass_fmin float

Minimum frequency for bandpass filter in Hz (ignored if bandpass_apply is False).

0.05
bandpass_fmax float

Maximum frequency for bandpass filter in Hz (ignored if bandpass_apply is False).

2.0
mccc_damp float

Damping factor for MCCC algorithm.

0.1
mccc_min_ccnorm float

Minimum correlation coefficient required to include a pair in the MCCC inversion.

0.5
id UUID

Unique ID.

UUID('01354de6-b9ce-422a-8a06-cbbf53b7d124')
event_id UUID

Foreign key referencing the parent event.

None

Methods:

Name Description
check_freq_range

Validate that bandpass_fmax is strictly greater than bandpass_fmin.

Attributes:

Name Type Description
event AimbatEvent

The event these parameters belong to.

snapshots list[AimbatEventParametersSnapshot]

Parameter snapshots for this event.

Source code in src/aimbat/models/_models.py
class AimbatEventParameters(AimbatEventParametersBase, table=True):
    """Processing parameters common to all seismograms of a particular event."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    event_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatevent.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent event.",
    )
    event: "AimbatEvent" = Relationship(back_populates="parameters")
    "The event these parameters belong to."
    snapshots: list["AimbatEventParametersSnapshot"] = Relationship(
        back_populates="parameters", cascade_delete=True
    )
    "Parameter snapshots for this event."

event class-attribute instance-attribute

event: AimbatEvent = Relationship(
    back_populates="parameters"
)

The event these parameters belong to.

snapshots class-attribute instance-attribute

snapshots: list[AimbatEventParametersSnapshot] = (
    Relationship(
        back_populates="parameters", cascade_delete=True
    )
)

Parameter snapshots for this event.

check_freq_range

check_freq_range() -> Self

Validate that bandpass_fmax is strictly greater than bandpass_fmin.

Source code in src/aimbat/models/_parameters.py
@model_validator(mode="after")
def check_freq_range(self) -> Self:
    """Validate that `bandpass_fmax` is strictly greater than `bandpass_fmin`."""
    if self.bandpass_fmax <= self.bandpass_fmin:
        raise ValueError("bandpass_fmax must be > bandpass_fmin")
    return self

AimbatEventParametersBase

Bases: SQLModel

Base class defining event-level processing parameters for AIMBAT.

This class serves as a base that is inherited by the actual classes that create the database tables. The attributes correspond exactly to the AIMBAT event parameters.

Parameters:

Name Type Description Default
completed bool

Mark an event as completed.

False
min_ccnorm float

Minimum cross-correlation used when automatically de-selecting seismograms.

0.5
window_pre PydanticNegativeTimedelta

Pre-pick window length in seconds.

Timedelta('-1 days +23:59:45')
window_post PydanticPositiveTimedelta

Post-pick window length in seconds.

Timedelta('0 days 00:00:15')
bandpass_apply bool

Whether to apply bandpass filter to seismograms.

False
bandpass_fmin float

Minimum frequency for bandpass filter in Hz (ignored if bandpass_apply is False).

0.05
bandpass_fmax float

Maximum frequency for bandpass filter in Hz (ignored if bandpass_apply is False).

2.0
mccc_damp float

Damping factor for MCCC algorithm.

0.1
mccc_min_ccnorm float

Minimum correlation coefficient required to include a pair in the MCCC inversion.

0.5

Methods:

Name Description
check_freq_range

Validate that bandpass_fmax is strictly greater than bandpass_fmin.

Source code in src/aimbat/models/_parameters.py
class AimbatEventParametersBase(SQLModel):
    """Base class defining event-level processing parameters for AIMBAT.

    This class serves as a base that is inherited by the actual classes that
    create the database tables. The attributes correspond exactly to the AIMBAT
    event parameters.
    """

    completed: bool = Field(
        default=False,
        title="Completed",
        description="Mark an event as completed.",
    )

    min_ccnorm: float = Field(
        ge=0.0,
        le=1.0,
        default_factory=lambda: settings.min_ccnorm,
        title="Min CC norm",
        description="Minimum cross-correlation used when automatically de-selecting seismograms.",
    )

    window_pre: PydanticNegativeTimedelta = Field(
        sa_type=SAPandasTimedelta,
        default_factory=lambda: settings.window_pre,
        title="Window pre",
        description="Pre-pick window length in seconds.",
    )

    window_post: PydanticPositiveTimedelta = Field(
        sa_type=SAPandasTimedelta,
        default_factory=lambda: settings.window_post,
        title="Window post",
        description="Post-pick window length in seconds.",
    )

    bandpass_apply: bool = Field(
        default_factory=lambda: settings.bandpass_apply,
        title="Bandpass apply",
        description="Whether to apply bandpass filter to seismograms.",
    )

    bandpass_fmin: float = Field(
        default_factory=lambda: settings.bandpass_fmin,
        ge=0,
        title="Bandpass f min",
        description="Minimum frequency for bandpass filter in Hz (ignored if `bandpass_apply` is False).",
    )

    bandpass_fmax: float = Field(
        default_factory=lambda: settings.bandpass_fmax,
        gt=0,
        title="Bandpass f max",
        description="Maximum frequency for bandpass filter in Hz (ignored if `bandpass_apply` is False).",
    )

    mccc_damp: float = Field(
        default_factory=lambda: settings.mccc_damp,
        ge=0,
        title="MCCC damp",
        description="Damping factor for MCCC algorithm.",
    )

    mccc_min_ccnorm: float = Field(
        default_factory=lambda: settings.mccc_min_ccnorm,
        ge=0,
        le=1,
        title="MCCC min CC norm",
        description="Minimum correlation coefficient required to include a pair in the MCCC inversion.",
    )

    @model_validator(mode="after")
    def check_freq_range(self) -> Self:
        """Validate that `bandpass_fmax` is strictly greater than `bandpass_fmin`."""
        if self.bandpass_fmax <= self.bandpass_fmin:
            raise ValueError("bandpass_fmax must be > bandpass_fmin")
        return self

check_freq_range

check_freq_range() -> Self

Validate that bandpass_fmax is strictly greater than bandpass_fmin.

Source code in src/aimbat/models/_parameters.py
@model_validator(mode="after")
def check_freq_range(self) -> Self:
    """Validate that `bandpass_fmax` is strictly greater than `bandpass_fmin`."""
    if self.bandpass_fmax <= self.bandpass_fmin:
        raise ValueError("bandpass_fmax must be > bandpass_fmin")
    return self

AimbatEventParametersSnapshot

Bases: AimbatEventParametersBase

Snapshot of processing parameters for a particular event.

Parameters:

Name Type Description Default
completed bool

Mark an event as completed.

False
min_ccnorm float

Minimum cross-correlation used when automatically de-selecting seismograms.

0.5
window_pre PydanticNegativeTimedelta

Pre-pick window length in seconds.

Timedelta('-1 days +23:59:45')
window_post PydanticPositiveTimedelta

Post-pick window length in seconds.

Timedelta('0 days 00:00:15')
bandpass_apply bool

Whether to apply bandpass filter to seismograms.

False
bandpass_fmin float

Minimum frequency for bandpass filter in Hz (ignored if bandpass_apply is False).

0.05
bandpass_fmax float

Maximum frequency for bandpass filter in Hz (ignored if bandpass_apply is False).

2.0
mccc_damp float

Damping factor for MCCC algorithm.

0.1
mccc_min_ccnorm float

Minimum correlation coefficient required to include a pair in the MCCC inversion.

0.5
id UUID

Unique ID.

UUID('a88e33fb-be0d-429d-bc44-a72ee5d1ba49')
snapshot_id UUID

Foreign key referencing the parent snapshot.

None
parameters_id UUID

Foreign key referencing the source event parameters.

None

Methods:

Name Description
check_freq_range

Validate that bandpass_fmax is strictly greater than bandpass_fmin.

Attributes:

Name Type Description
parameters AimbatEventParameters

The event parameters this snapshot was taken from.

snapshot AimbatSnapshot

The snapshot this record belongs to.

Source code in src/aimbat/models/_models.py
class AimbatEventParametersSnapshot(AimbatEventParametersBase, table=True):
    """Snapshot of processing parameters for a particular event."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    snapshot_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatsnapshot.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent snapshot.",
    )
    snapshot: "AimbatSnapshot" = Relationship(
        back_populates="event_parameters_snapshot"
    )
    "The snapshot this record belongs to."
    parameters: AimbatEventParameters = Relationship(back_populates="snapshots")
    "The event parameters this snapshot was taken from."
    parameters_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbateventparameters.id",
        ondelete="CASCADE",
        description="Foreign key referencing the source event parameters.",
    )

parameters class-attribute instance-attribute

parameters: AimbatEventParameters = Relationship(
    back_populates="snapshots"
)

The event parameters this snapshot was taken from.

snapshot class-attribute instance-attribute

snapshot: AimbatSnapshot = Relationship(
    back_populates="event_parameters_snapshot"
)

The snapshot this record belongs to.

check_freq_range

check_freq_range() -> Self

Validate that bandpass_fmax is strictly greater than bandpass_fmin.

Source code in src/aimbat/models/_parameters.py
@model_validator(mode="after")
def check_freq_range(self) -> Self:
    """Validate that `bandpass_fmax` is strictly greater than `bandpass_fmin`."""
    if self.bandpass_fmax <= self.bandpass_fmin:
        raise ValueError("bandpass_fmax must be > bandpass_fmin")
    return self

AimbatSeismogram

Bases: SQLModel

Class to store seismogram metadata.

Parameters:

Name Type Description Default
id UUID

Unique ID.

UUID('97cd2ec1-2e17-4bcf-980a-2cc615963505')
begin_time PydanticTimestamp

Start time of the seismogram.

required
delta PydanticPositiveTimedelta

Sampling interval.

required
t0 PydanticTimestamp

Initial phase arrival pick.

required
station_id UUID

Foreign key referencing the recording station.

None
event_id UUID

Foreign key referencing the parent event.

None
extra dict[Hashable, Any]

Dictionary to store any additional metadata for the seismogram.

<class 'dict'>

Methods:

Name Description
end_time

End time of the seismogram, derived from begin_time, delta, and data length.

Attributes:

Name Type Description
data NDArray[float64]

Seismogram waveform data array.

datasource AimbatDataSource

Data source for the seismogram waveform.

event AimbatEvent

The event this seismogram belongs to.

flip bool

Whether the seismogram should be flipped.

parameters AimbatSeismogramParameters

Processing parameters for this seismogram.

select bool

Whether this seismogram should be used for processing.

station AimbatStation

The station that recorded this seismogram.

t1 Timestamp | None

Working phase arrival pick.

Source code in src/aimbat/models/_models.py
class AimbatSeismogram(SQLModel, table=True):
    """Class to store seismogram metadata."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    begin_time: PydanticTimestamp = Field(
        sa_type=SAPandasTimestamp, description="Start time of the seismogram."
    )
    delta: PydanticPositiveTimedelta = Field(
        sa_type=SAPandasTimedelta, description="Sampling interval."
    )
    t0: PydanticTimestamp = Field(
        sa_type=SAPandasTimestamp, description="Initial phase arrival pick."
    )
    datasource: AimbatDataSource = Relationship(
        back_populates="seismogram", cascade_delete=True
    )
    "Data source for the seismogram waveform."
    station_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatstation.id",
        ondelete="CASCADE",
        description="Foreign key referencing the recording station.",
    )
    station: "AimbatStation" = Relationship(back_populates="seismograms")
    "The station that recorded this seismogram."
    event_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatevent.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent event.",
    )
    extra: dict[Hashable, Any] = Field(
        default_factory=dict,
        sa_column=Column(MutableDict.as_mutable(PickleType)),
        description="Dictionary to store any additional metadata for the seismogram.",
    )
    event: "AimbatEvent" = Relationship(back_populates="seismograms")
    "The event this seismogram belongs to."
    parameters: "AimbatSeismogramParameters" = Relationship(
        back_populates="seismogram",
        cascade_delete=True,
    )
    "Processing parameters for this seismogram."

    if TYPE_CHECKING:
        # Add same default values for type checking purposes
        # as in AimbatSeismogramParametersBase
        flip: bool = False
        select: bool = True
        t1: Timestamp | None = None
        data: npt.NDArray[np.float64] = np.array([])

        @property
        def end_time(self) -> Timestamp: ...

    else:

        @computed_field
        def end_time(self) -> PydanticTimestamp:
            """End time of the seismogram, derived from begin_time, delta, and data length."""
            if len(self.data) == 0:
                return self.begin_time
            return self.begin_time + self.delta * (len(self.data) - 1)

        @property
        def flip(self) -> bool:
            """Whether the seismogram should be flipped."""
            return self.parameters.flip

        @flip.setter
        def flip(self, value: bool) -> None:
            self.parameters.flip = value

        @property
        def select(self) -> bool:
            """Whether this seismogram should be used for processing."""
            return self.parameters.select

        @select.setter
        def select(self, value: bool) -> None:
            self.parameters.select = value

        @property
        def t1(self) -> Timestamp | None:
            """Working phase arrival pick."""
            return self.parameters.t1

        @t1.setter
        def t1(self, value: Timestamp | None) -> None:
            self.parameters.t1 = value

        @property
        def data(self) -> npt.NDArray[np.float64]:
            """Seismogram waveform data array."""
            if self.datasource is None:
                raise ValueError("Expected a valid datasource name, got None.")
            return read_seismogram_data(
                self.datasource.sourcename, self.datasource.datatype
            )

        @data.setter
        def data(self, value: npt.NDArray[np.float64]) -> None:
            if self.datasource is None:
                raise ValueError("Expected a valid datasource name, got None.")
            write_seismogram_data(
                self.datasource.sourcename, self.datasource.datatype, value
            )

data property writable

Seismogram waveform data array.

datasource class-attribute instance-attribute

datasource: AimbatDataSource = Relationship(
    back_populates="seismogram", cascade_delete=True
)

Data source for the seismogram waveform.

event class-attribute instance-attribute

event: AimbatEvent = Relationship(
    back_populates="seismograms"
)

The event this seismogram belongs to.

flip property writable

flip: bool

Whether the seismogram should be flipped.

parameters class-attribute instance-attribute

parameters: AimbatSeismogramParameters = Relationship(
    back_populates="seismogram", cascade_delete=True
)

Processing parameters for this seismogram.

select property writable

select: bool

Whether this seismogram should be used for processing.

station class-attribute instance-attribute

station: AimbatStation = Relationship(
    back_populates="seismograms"
)

The station that recorded this seismogram.

t1 property writable

t1: Timestamp | None

Working phase arrival pick.

end_time

end_time() -> PydanticTimestamp

End time of the seismogram, derived from begin_time, delta, and data length.

Source code in src/aimbat/models/_models.py
@computed_field
def end_time(self) -> PydanticTimestamp:
    """End time of the seismogram, derived from begin_time, delta, and data length."""
    if len(self.data) == 0:
        return self.begin_time
    return self.begin_time + self.delta * (len(self.data) - 1)

AimbatSeismogramParameters

Bases: AimbatSeismogramParametersBase

Processing parameters for a single seismogram.

Parameters:

Name Type Description Default
flip bool

Whether or not the seismogram should be flipped.

False
select bool

Whether or not this seismogram should be used for processing.

True
t1 PydanticTimestamp | None

Working pick. This pick serves as working as well as output pick. It is changed by: 1. Picking the phase arrival in the stack, 2. Running ICCS, 3. Running MCCC.

None
id UUID

Unique ID.

UUID('b406d06e-86ce-453f-ac14-f31ffe0ebe48')
seismogram_id UUID

Foreign key referencing the parent seismogram.

None

Attributes:

Name Type Description
seismogram AimbatSeismogram

The seismogram these parameters belong to.

snapshots list[AimbatSeismogramParametersSnapshot]

Parameter snapshots for this seismogram.

Source code in src/aimbat/models/_models.py
class AimbatSeismogramParameters(AimbatSeismogramParametersBase, table=True):
    """Processing parameters for a single seismogram."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    seismogram_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatseismogram.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent seismogram.",
    )
    seismogram: "AimbatSeismogram" = Relationship(back_populates="parameters")
    "The seismogram these parameters belong to."
    snapshots: list["AimbatSeismogramParametersSnapshot"] = Relationship(
        back_populates="parameters", cascade_delete=True
    )
    "Parameter snapshots for this seismogram."

seismogram class-attribute instance-attribute

seismogram: AimbatSeismogram = Relationship(
    back_populates="parameters"
)

The seismogram these parameters belong to.

snapshots class-attribute instance-attribute

snapshots: list[AimbatSeismogramParametersSnapshot] = (
    Relationship(
        back_populates="parameters", cascade_delete=True
    )
)

Parameter snapshots for this seismogram.

AimbatSeismogramParametersBase

Bases: SQLModel

Base class defining seismogram-level processing parameters for AIMBAT.

Parameters:

Name Type Description Default
flip bool

Whether or not the seismogram should be flipped.

False
select bool

Whether or not this seismogram should be used for processing.

True
t1 PydanticTimestamp | None

Working pick. This pick serves as working as well as output pick. It is changed by: 1. Picking the phase arrival in the stack, 2. Running ICCS, 3. Running MCCC.

None
Source code in src/aimbat/models/_parameters.py
class AimbatSeismogramParametersBase(SQLModel):
    """Base class defining seismogram-level processing parameters for AIMBAT."""

    flip: bool = Field(
        default=False,
        description="Whether or not the seismogram should be flipped.",
    )

    select: bool = Field(
        default=True,
        description="Whether or not this seismogram should be used for processing.",
    )

    t1: PydanticTimestamp | None = Field(
        default=None,
        sa_type=SAPandasTimestamp,
        description=(
            "Working pick. This pick serves as working as well as output pick."
            " It is changed by: 1. Picking the phase arrival in the stack,"
            " 2. Running ICCS, 3. Running MCCC."
        ),
    )

AimbatSeismogramParametersSnapshot

Bases: AimbatSeismogramParametersBase

Snapshot of processing parameters for a single seismogram.

Parameters:

Name Type Description Default
flip bool

Whether or not the seismogram should be flipped.

False
select bool

Whether or not this seismogram should be used for processing.

True
t1 PydanticTimestamp | None

Working pick. This pick serves as working as well as output pick. It is changed by: 1. Picking the phase arrival in the stack, 2. Running ICCS, 3. Running MCCC.

None
id UUID

Unique ID.

UUID('89ac41d0-b34d-48ac-ad17-ce6c4b442bf3')
seismogram_parameters_id UUID

Foreign key referencing the source seismogram parameters.

required
snapshot_id UUID

Foreign key referencing the parent snapshot.

None

Attributes:

Name Type Description
parameters AimbatSeismogramParameters

The seismogram parameters this snapshot was taken from.

snapshot AimbatSnapshot

The snapshot this record belongs to.

Source code in src/aimbat/models/_models.py
class AimbatSeismogramParametersSnapshot(AimbatSeismogramParametersBase, table=True):
    """Snapshot of processing parameters for a single seismogram."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    seismogram_parameters_id: uuid.UUID = Field(
        foreign_key="aimbatseismogramparameters.id",
        ondelete="CASCADE",
        description="Foreign key referencing the source seismogram parameters.",
    )
    parameters: AimbatSeismogramParameters = Relationship(back_populates="snapshots")
    "The seismogram parameters this snapshot was taken from."
    snapshot_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatsnapshot.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent snapshot.",
    )
    snapshot: "AimbatSnapshot" = Relationship(
        back_populates="seismogram_parameters_snapshots"
    )
    "The snapshot this record belongs to."

parameters class-attribute instance-attribute

parameters: AimbatSeismogramParameters = Relationship(
    back_populates="snapshots"
)

The seismogram parameters this snapshot was taken from.

snapshot class-attribute instance-attribute

snapshot: AimbatSnapshot = Relationship(
    back_populates="seismogram_parameters_snapshots"
)

The snapshot this record belongs to.

AimbatSnapshot

Bases: SQLModel

Container for a point-in-time snapshot of event and seismogram parameters.

The AimbatSnapshot class does not actually save any parameter data. It is used to keep track of the AimbatEventParametersSnapshot and AimbatSeismogramParametersSnapshot instances.

Parameters:

Name Type Description Default
id UUID

Unique ID.

UUID('187aef2d-a057-40df-b33e-6c642bbba57c')
date PydanticTimestamp

Timestamp when the snapshot was created.

Timestamp('2026-03-06 10:31:20.205708+0000', tz='UTC')
comment str | None

Optional comment for the snapshot.

None
event_id UUID

Foreign key referencing the parent event.

None

Attributes:

Name Type Description
event AimbatEvent

The event this snapshot belongs to.

event_parameters_snapshot AimbatEventParametersSnapshot

Event parameter snapshot associated with this snapshot.

seismogram_parameters_snapshots list[AimbatSeismogramParametersSnapshot]

Seismogram parameter snapshots associated with this snapshot.

Source code in src/aimbat/models/_models.py
class AimbatSnapshot(SQLModel, table=True):
    """Container for a point-in-time snapshot of event and seismogram parameters.

    The AimbatSnapshot class does not actually save any parameter data.
    It is used to keep track of the AimbatEventParametersSnapshot and
    AimbatSeismogramParametersSnapshot instances.
    """

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    date: PydanticTimestamp = Field(
        default_factory=lambda: Timestamp.now(tz=timezone.utc),
        unique=True,
        allow_mutation=False,
        sa_type=SAPandasTimestamp,
        description="Timestamp when the snapshot was created.",
    )
    comment: str | None = Field(
        default=None, description="Optional comment for the snapshot."
    )
    event_parameters_snapshot: AimbatEventParametersSnapshot = Relationship(
        back_populates="snapshot", cascade_delete=True
    )
    "Event parameter snapshot associated with this snapshot."
    seismogram_parameters_snapshots: list[AimbatSeismogramParametersSnapshot] = (
        Relationship(back_populates="snapshot", cascade_delete=True)
    )
    "Seismogram parameter snapshots associated with this snapshot."
    event_id: uuid.UUID = Field(
        default=None,
        foreign_key="aimbatevent.id",
        ondelete="CASCADE",
        description="Foreign key referencing the parent event.",
    )
    event: "AimbatEvent" = Relationship(back_populates="snapshots")
    "The event this snapshot belongs to."

    if TYPE_CHECKING:
        # defined as column properties below, but add same default values for type checking purposes
        seismogram_count: int = 0
        selected_seismogram_count: int = 0
        flipped_seismogram_count: int = 0

event class-attribute instance-attribute

event: AimbatEvent = Relationship(
    back_populates="snapshots"
)

The event this snapshot belongs to.

event_parameters_snapshot class-attribute instance-attribute

event_parameters_snapshot: AimbatEventParametersSnapshot = (
    Relationship(
        back_populates="snapshot", cascade_delete=True
    )
)

Event parameter snapshot associated with this snapshot.

seismogram_parameters_snapshots class-attribute instance-attribute

seismogram_parameters_snapshots: list[
    AimbatSeismogramParametersSnapshot
] = Relationship(
    back_populates="snapshot", cascade_delete=True
)

Seismogram parameter snapshots associated with this snapshot.

AimbatStation

Bases: SQLModel

Class to store station information.

Parameters:

Name Type Description Default
id UUID

Unique ID.

UUID('d26e84d2-254b-440c-a8bb-75115df09d3c')
name str

Station name.

required
network str

Network name.

required
location str

Location ID.

required
channel str

Channel code.

required
latitude float

Station latitude.

required
longitude float

Station longitude.

required
elevation float | None

Station elevation.

None

Attributes:

Name Type Description
seismograms list[AimbatSeismogram]

Seismograms recorded at this station.

Source code in src/aimbat/models/_models.py
class AimbatStation(SQLModel, table=True):
    """Class to store station information."""

    id: uuid.UUID = Field(
        default_factory=uuid.uuid4, primary_key=True, description="Unique ID."
    )
    name: str = Field(allow_mutation=False, description="Station name.")
    network: str = Field(allow_mutation=False, description="Network name.")
    location: str = Field(allow_mutation=False, description="Location ID.")
    channel: str = Field(allow_mutation=False, description="Channel code.")
    latitude: float = Field(description="Station latitude.")
    longitude: float = Field(description="Station longitude.")
    elevation: float | None = Field(default=None, description="Station elevation.")
    seismograms: list[AimbatSeismogram] = Relationship(
        back_populates="station", cascade_delete=True
    )
    "Seismograms recorded at this station."

seismograms class-attribute instance-attribute

seismograms: list[AimbatSeismogram] = Relationship(
    back_populates="station", cascade_delete=True
)

Seismograms recorded at this station.