aimbat.types
Custom types used in AIMBAT.
Classes:
| Name | Description |
|---|---|
EventParameter |
|
SAPandasTimedelta |
SQLAlchemy TypeDecorator for pandas.Timedelta. |
SAPandasTimestamp |
SQLAlchemy TypeDecorator for pandas.Timestamp. |
SeismogramParameter |
|
EventParameter
Bases: StrEnum
AimbatEvent enum for CLI arg typing.
Source code in src/aimbat/types/_enums.py
SAPandasTimedelta
Bases: TypeDecorator[Timedelta]
SQLAlchemy TypeDecorator for pandas.Timedelta.
Stores duration as an integer of nanoseconds for maximum precision.
Methods:
| Name | Description |
|---|---|
process_bind_param |
Convert a value to an integer count of nanoseconds for storage. |
process_result_value |
Convert a stored nanosecond count back to a |
Source code in src/aimbat/types/_sqlalchemy.py
process_bind_param
Convert a value to an integer count of nanoseconds for storage.
A bare number (or numeric string) is interpreted as seconds, via
coerce_to_timedelta - the same rule PydanticTimedelta uses - so a
value reaching this column without going through Pydantic validation
(table models skip it) is not silently misread as nanoseconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to store. |
required |
dialect
|
Dialect
|
The dialect in use for the current connection. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Duration in nanoseconds, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/aimbat/types/_sqlalchemy.py
process_result_value
Convert a stored nanosecond count back to a Timedelta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value read from the database. |
required |
dialect
|
Dialect
|
The dialect in use for the current connection. |
required |
Returns:
| Type | Description |
|---|---|
Timedelta | None
|
The corresponding |
Source code in src/aimbat/types/_sqlalchemy.py
SAPandasTimestamp
Bases: TypeDecorator[Timestamp]
SQLAlchemy TypeDecorator for pandas.Timestamp.
Ensures timezone-aware UTC storage in a DateTime column.
Methods:
| Name | Description |
|---|---|
process_bind_param |
Convert a value to a UTC-aware |
process_result_value |
Convert a stored value back to a UTC-aware |
Source code in src/aimbat/types/_sqlalchemy.py
process_bind_param
Convert a value to a UTC-aware datetime for storage.
Naive values are assumed to already be UTC; aware values are
converted to UTC. Precision is truncated to microseconds, since
datetime cannot represent nanoseconds.
PydanticTimestamp validation is expected to have already rejected
naive values before they reach this point; the naive-to-UTC handling
here is a defensive fallback, not the primary validation point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to store. |
required |
dialect
|
Dialect
|
The dialect in use for the current connection. |
required |
Returns:
| Type | Description |
|---|---|
datetime | None
|
A UTC-aware |
Source code in src/aimbat/types/_sqlalchemy.py
process_result_value
Convert a stored value back to a UTC-aware Timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value read from the database. |
required |
dialect
|
Dialect
|
The dialect in use for the current connection. |
required |
Returns:
| Type | Description |
|---|---|
Timestamp | None
|
A UTC-aware |
Source code in src/aimbat/types/_sqlalchemy.py
SeismogramParameter
Bases: StrEnum
AimbatSeismogramParameters enum for CLI arg typing.