aimbat.io
I/O for AIMBAT data sources.
Data source modules plug in by decorating their functions with the decorator
factories from this package (station_creator, event_creator,
seismogram_creator, source_records_reader, seismogram_data_reader,
seismogram_data_writer). Not every source needs to implement everything. A
source that only provides waveform data would register a reader and writer
but skip the creator functions, and one whose station, event and seismogram
all come out of a single read adds a source_records_reader so ingestion
reads it once. A source is identified by an opaque sourcename string whose
meaning is defined by the registered callbacks; for file-based sources it is
a filesystem path, but non-file sources are free to use any identifier.
SAC (aimbat.io.sac), JSON (aimbat.io.json), and miniSEED
(aimbat.io.mseed) data sources are loaded automatically and their
capabilities registered on import of this package.
Modules:
| Name | Description |
|---|---|
json |
JSON data source support for AIMBAT. |
mseed |
miniSEED waveform I/O for AIMBAT. |
sac |
SAC file I/O for AIMBAT. |
Classes:
| Name | Description |
|---|---|
DataType |
Valid AIMBAT data types. |
SeismogramReadContext |
What a registered seismogram-data reader is handed for one read. |
SourceRecords |
The records built from a single read of one data source. |
SourceRecordsRequest |
Which records one read of a data source is asked to produce. |
SourceUnavailableError |
A probe could not determine whether a data source is present. |
Functions:
| Name | Description |
|---|---|
clear_seismogram_data_cache |
Drop every entry from the in-memory waveform read cache. |
create_event |
Create an |
create_seismogram |
Create an |
create_station |
Create an |
event_creator |
Decorator that registers a function as an event creator for |
file_source_present |
Return whether a filesystem-backed data source is present. |
read_seismogram_data |
Read seismogram waveform data from a data source. |
read_source_records |
Build the requested records from a data source, reading it once where possible. |
register_event_creator |
Register a function that creates an |
register_seismogram_creator |
Register a function that creates an |
register_seismogram_data_reader |
Register a function that reads seismogram waveform data from a data source. |
register_seismogram_data_writer |
Register a function that writes seismogram waveform data to a data source. |
register_source_probe |
Register a function that checks whether a data source is still present. |
register_source_records_reader |
Register a function that builds several records from one read of a data source. |
register_station_creator |
Register a function that creates an |
seismogram_creator |
Decorator that registers a function as a seismogram creator for |
seismogram_data_reader |
Decorator that registers a function as a seismogram data reader for |
seismogram_data_writer |
Decorator that registers a function as a seismogram data writer for |
source_present |
Check whether a data source is still present and provides its seismogram. |
source_probe |
Decorator that registers a function as a source-presence probe for |
source_records_reader |
Decorator that registers a function as a source-records reader for |
stage_seismogram_data |
Stage a waveform write to flush when |
station_creator |
Decorator that registers a function as a station creator for |
supports_event_creation |
Return whether |
supports_seismogram_creation |
Return whether |
supports_seismogram_data_reading |
Return whether |
supports_seismogram_data_writing |
Return whether |
supports_source_probe |
Return whether |
supports_source_records_reading |
Return whether |
supports_station_creation |
Return whether |
write_seismogram_data |
Write seismogram waveform data to a data source. |
Attributes:
| Name | Type | Description |
|---|---|---|
DATATYPE_SUFFIXES |
dict[DataType, list[str]]
|
|
DATATYPE_SUFFIXES
module-attribute
DATATYPE_SUFFIXES: dict[DataType, list[str]] = {
DataType.SAC: [".sac", ".bhz", ".bhn", ".bhe"],
DataType.JSON_EVENT: [".json"],
DataType.JSON_STATION: [".json"],
DataType.MSEED: [".mseed", ".miniseed", ".ms"],
}
.json maps to both JSON_EVENT and JSON_STATION, so a suffix alone
never resolves to one DataType - callers must pass an explicit DataType
for JSON sources rather than inferring it from this mapping.
DataType
Bases: StrEnum
Valid AIMBAT data types.
Attributes:
| Name | Type | Description |
|---|---|---|
JSON_EVENT |
JSON file containing a single seismic event record. |
|
JSON_STATION |
JSON file containing a single seismic station record. |
|
MSEED |
miniSEED waveform file. Waveform data only - no station or event data. |
|
SAC |
SAC (Seismic Analysis Code) waveform file. Provides station, event, and seismogram data. |
Source code in src/aimbat/io/_data.py
JSON_EVENT
class-attribute
instance-attribute
JSON_EVENT = auto()
JSON file containing a single seismic event record.
JSON_STATION
class-attribute
instance-attribute
JSON_STATION = auto()
JSON file containing a single seismic station record.
MSEED
class-attribute
instance-attribute
MSEED = auto()
miniSEED waveform file. Waveform data only - no station or event data.
SAC
class-attribute
instance-attribute
SAC = auto()
SAC (Seismic Analysis Code) waveform file. Provides station, event, and seismogram data.
SeismogramReadContext
dataclass
SourceRecords
dataclass
The records built from a single read of one data source.
A field is None when it was not asked for, or when the source has
nothing to build it from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
station
|
AimbatStation | None
|
|
None
|
event
|
AimbatEvent | None
|
|
None
|
seismogram
|
AimbatSeismogram | None
|
|
None
|
Source code in src/aimbat/io/_base.py
SourceRecordsRequest
dataclass
SourceUnavailableError
Bases: Exception
A probe could not determine whether a data source is present.
Distinct from a clean "absent": raised when the answer is unknowable
right now (an unreadable file, an unreachable mount). aimbat data prune
treats this as a hard stop, never as a licence to delete.
Source code in src/aimbat/io/_base.py
clear_seismogram_data_cache
Drop every entry from the in-memory waveform read cache.
Staged (uncommitted) writes in _pending are left intact.
create_event
create_event(
datasource: str | PathLike[str], datatype: DataType
) -> AimbatEvent
Create an AimbatEvent from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
Returns:
| Type | Description |
|---|---|
AimbatEvent
|
A new |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Source code in src/aimbat/io/_base.py
create_seismogram
create_seismogram(
datasource: str | PathLike[str], datatype: DataType
) -> AimbatSeismogram
Create an AimbatSeismogram from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
Returns:
| Type | Description |
|---|---|
AimbatSeismogram
|
A new |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Source code in src/aimbat/io/_base.py
create_station
create_station(
datasource: str | PathLike[str], datatype: DataType
) -> AimbatStation
Create an AimbatStation from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
Returns:
| Type | Description |
|---|---|
AimbatStation
|
A new |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Source code in src/aimbat/io/_base.py
event_creator
event_creator(
datatype: DataType,
) -> Callable[
[Callable[[str | PathLike[str]], AimbatEvent]],
Callable[[str | PathLike[str]], AimbatEvent],
]
Decorator that registers a function as an event creator for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function creates events from. |
required |
Example
Source code in src/aimbat/io/_base.py
file_source_present
Return whether a filesystem-backed data source is present.
Shared implementation for the file-based probes (SAC, miniSEED, JSON). A
reachable regular file is present; a reachable directory that simply does
not contain the named entry is a clean False. Anything that leaves the
answer unknowable right now - a missing or unreadable parent directory (a
moved or unmounted tree), a permission error, an unreachable mount -
raises SourceUnavailableError rather than being mistaken for a deletion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sourcename
|
str | PathLike[str]
|
Path to the file backing the data source. |
required |
Raises:
| Type | Description |
|---|---|
SourceUnavailableError
|
If presence cannot be determined right now. |
Source code in src/aimbat/io/_base.py
read_seismogram_data
read_seismogram_data(
datasource: str | PathLike[str],
datatype: DataType,
session: Session | None = None,
) -> NDArray[floating]
Read seismogram waveform data from a data source.
Results are cached in memory by (datasource, datatype) key, alongside
the source's modification time and size; a cached array is re-read when
either has changed since, so a source written behind AIMBAT's back does
not keep serving stale data. The returned array is read-only.
If session is given and has a staged write for this key (from
stage_seismogram_data), the staged value is returned instead of reading
the data source, so a session sees its own uncommitted waveform write.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
session
|
Session | None
|
Session whose staged writes should be consulted first. |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[floating]
|
Read-only seismogram waveform data as a NumPy array. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Source code in src/aimbat/io/_base.py
read_source_records
read_source_records(
datasource: str | PathLike[str],
datatype: DataType,
*,
station: bool = True,
event: bool = True,
seismogram: bool = True,
) -> SourceRecords
Build the requested records from a data source, reading it once where possible.
Data types with a registered source-records reader (SAC) read the source a single time and build everything asked for from it. The rest fall back to their individual creators, one read each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
station
|
bool
|
Whether an |
True
|
event
|
bool
|
Whether an |
True
|
seismogram
|
bool
|
Whether an |
True
|
Returns:
| Type | Description |
|---|---|
SourceRecords
|
The requested records; the fields that were not asked for are |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If a record is asked for that |
Source code in src/aimbat/io/_base.py
register_event_creator
register_event_creator(
datatype: DataType,
fn: Callable[[str | PathLike[str]], AimbatEvent],
) -> None
Register a function that creates an AimbatEvent from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this creator handles. |
required |
fn
|
Callable[[str | PathLike[str]], AimbatEvent]
|
Callable that accepts a logical source identifier and returns an
|
required |
Source code in src/aimbat/io/_base.py
register_seismogram_creator
register_seismogram_creator(
datatype: DataType,
fn: Callable[[str | PathLike[str]], AimbatSeismogram],
) -> None
Register a function that creates an AimbatSeismogram from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this creator handles. |
required |
fn
|
Callable[[str | PathLike[str]], AimbatSeismogram]
|
Callable that accepts a logical source identifier and returns an
|
required |
Source code in src/aimbat/io/_base.py
register_seismogram_data_reader
register_seismogram_data_reader(
datatype: DataType, fn: SeismogramDataReader
) -> None
Register a function that reads seismogram waveform data from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this reader handles. |
required |
fn
|
SeismogramDataReader
|
Callable that accepts a |
required |
Source code in src/aimbat/io/_base.py
register_seismogram_data_writer
register_seismogram_data_writer(
datatype: DataType,
fn: Callable[
[str | PathLike[str], NDArray[floating]], None
],
) -> None
Register a function that writes seismogram waveform data to a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this writer handles. |
required |
fn
|
Callable[[str | PathLike[str], NDArray[floating]], None]
|
Callable that accepts a logical source identifier and a NumPy array, and writes the data to the source. |
required |
Source code in src/aimbat/io/_base.py
register_source_probe
register_source_probe(
datatype: DataType, fn: SourcePresenceProbe
) -> None
Register a function that checks whether a data source is still present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this probe handles. |
required |
fn
|
SourcePresenceProbe
|
Callable that accepts a |
required |
Source code in src/aimbat/io/_base.py
register_source_records_reader
register_source_records_reader(
datatype: DataType, fn: SourceRecordsReader
) -> None
Register a function that builds several records from one read of a data source.
Optional: a data type with no reader of its own is served by calling its
individual creators instead (see read_source_records). Registering one
is worth it when a single read yields more than one record, as it does
for SAC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this reader handles. |
required |
fn
|
SourceRecordsReader
|
Callable that accepts a |
required |
Source code in src/aimbat/io/_base.py
register_station_creator
register_station_creator(
datatype: DataType,
fn: Callable[[str | PathLike[str]], AimbatStation],
) -> None
Register a function that creates an AimbatStation from a data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type this creator handles. |
required |
fn
|
Callable[[str | PathLike[str]], AimbatStation]
|
Callable that accepts a logical source identifier and returns an
|
required |
Source code in src/aimbat/io/_base.py
seismogram_creator
seismogram_creator(
datatype: DataType,
) -> Callable[
[Callable[[str | PathLike[str]], AimbatSeismogram]],
Callable[[str | PathLike[str]], AimbatSeismogram],
]
Decorator that registers a function as a seismogram creator for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function creates seismograms from. |
required |
Example
Source code in src/aimbat/io/_base.py
seismogram_data_reader
seismogram_data_reader(
datatype: DataType,
) -> Callable[[SeismogramDataReader], SeismogramDataReader]
Decorator that registers a function as a seismogram data reader for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function reads waveform data from. |
required |
Example
Source code in src/aimbat/io/_base.py
seismogram_data_writer
seismogram_data_writer(
datatype: DataType,
) -> Callable[
[
Callable[
[str | PathLike[str], NDArray[floating]], None
]
],
Callable[
[str | PathLike[str], NDArray[floating]], None
],
]
Decorator that registers a function as a seismogram data writer for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function writes waveform data to. |
required |
Example
Source code in src/aimbat/io/_base.py
source_present
Check whether a data source is still present and provides its seismogram.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sourcename
|
str
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
session
|
Session | None
|
Session made available to the probe (needed by sources whose identity is resolved through the database). |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
SourceUnavailableError
|
If the probe cannot determine presence right now (e.g. an unreadable file or an unreachable mount). |
Source code in src/aimbat/io/_base.py
source_probe
Decorator that registers a function as a source-presence probe for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function probes. |
required |
Example
Source code in src/aimbat/io/_base.py
source_records_reader
source_records_reader(
datatype: DataType,
) -> Callable[[SourceRecordsReader], SourceRecordsReader]
Decorator that registers a function as a source-records reader for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function reads records from. |
required |
Example
Source code in src/aimbat/io/_base.py
stage_seismogram_data
stage_seismogram_data(
session: Session | None,
datasource: str | PathLike[str],
datatype: DataType,
data: NDArray[floating],
) -> None
Stage a waveform write to flush when session commits.
The write is validated immediately (a datatype with no registered writer
raises straight away), but the data source is not touched until session
commits. The staged value is discarded if session rolls back or is
abandoned, and is visible to reads made through the same session before
the commit.
A copy of data is taken at call time, so later mutation of the caller's
array does not change what is persisted. The (datasource, datatype) key
is also captured now: renaming the data source on the model before the
commit would flush to the old path. Staged pages are held in memory until
the commit with no eviction (unlike the read cache), so staging waveform
writes for a very large event holds every new array at once.
Staging is keyed by (datasource, datatype), not by seismogram: staging
a second write for the same data source in one session before committing
replaces the first, and only the last survives the flush.
If session is None (a detached instance, attached to no session)
there is no transaction to bind to, so the write falls back to an eager
write_seismogram_data call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session | None
|
The session that owns the seismogram, or |
required |
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
data
|
NDArray[floating]
|
Seismogram waveform data to write. |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Source code in src/aimbat/io/_base.py
station_creator
station_creator(
datatype: DataType,
) -> Callable[
[Callable[[str | PathLike[str]], AimbatStation]],
Callable[[str | PathLike[str]], AimbatStation],
]
Decorator that registers a function as a station creator for datatype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
DataType
|
The data type the decorated function creates stations from. |
required |
Example
Source code in src/aimbat/io/_base.py
supports_event_creation
supports_seismogram_creation
supports_seismogram_data_reading
supports_seismogram_data_writing
supports_source_probe
supports_source_records_reading
supports_station_creation
write_seismogram_data
write_seismogram_data(
datasource: str | PathLike[str],
datatype: DataType,
data: NDArray[floating],
) -> None
Write seismogram waveform data to a data source.
Writes eagerly and invalidates the cache entry for (datasource,
datatype). AimbatSeismogram.data assignment no longer calls this
directly - it stages the write via stage_seismogram_data and the flush
listener in aimbat.io._flush calls this on the owning session's commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasource
|
str | PathLike[str]
|
Logical source identifier for the data source. |
required |
datatype
|
DataType
|
Data type of the source. |
required |
data
|
NDArray[floating]
|
Seismogram waveform data to write. |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
Source code in src/aimbat/io/_base.py
json
JSON data source support for AIMBAT.
Provides station and event creation from JSON files:
-
JSON_STATION(DataType.JSON_STATION): a JSON file containing a single station record. Field names matchAimbatStation: -
JSON_EVENT(DataType.JSON_EVENT): a JSON file containing a single event record. Field names matchAimbatEvent:
Functions:
| Name | Description |
|---|---|
create_event_from_json |
Create an |
create_station_from_json |
Create an |
json_source_present |
Return whether the JSON file backing this record still exists. |
create_event_from_json
create_event_from_json(
path: str | PathLike[str],
) -> AimbatEvent
Create an AimbatEvent from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the JSON file. |
required |
Returns:
| Type | Description |
|---|---|
AimbatEvent
|
A new |
Source code in src/aimbat/io/json.py
create_station_from_json
create_station_from_json(
path: str | PathLike[str],
) -> AimbatStation
Create an AimbatStation from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path to the JSON file. |
required |
Returns:
| Type | Description |
|---|---|
AimbatStation
|
A new |
Source code in src/aimbat/io/json.py
json_source_present
json_source_present(context: SeismogramReadContext) -> bool
Return whether the JSON file backing this record still exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SeismogramReadContext
|
Read context whose |
required |
Raises:
| Type | Description |
|---|---|
SourceUnavailableError
|
If presence cannot be determined right now (an unreadable file, a missing parent directory, an unreachable mount). |
Source code in src/aimbat/io/json.py
mseed
miniSEED waveform I/O for AIMBAT.
Registers a reader and writer only - no station, event, or seismogram
creator. pysmo.classes.MSeed carries no station coordinates and no event
data, only channel identity, timing and samples, so there is nothing for a
creator to build a station or event from, and no pick concept to supply a
t0 from either.
Scope boundary: this reader round-trips files AIMBAT itself wrote (e.g. via
aimbat.core.add_seismograms_to_project), it is not a general-purpose
miniSEED ingestion path. MSeed.from_file requires exactly one contiguous
segment and raises ValueError on a data gap or more than one channel.
Real-world archival or downloaded miniSEED is routinely multiplexed
(several channels in one file) and/or gappy (a channel split across
segments); reading that needs MSeed.all_from_file plus a policy for
picking, splitting, or merging segments, which this module does not
attempt. Such a file needs pre-processing (trimmed to one channel, one
contiguous segment) before it fits AIMBAT's one-file-one-seismogram model.
This module registers its capabilities with the I/O dispatch layer on import, so importing it is sufficient to enable miniSEED support.
Functions:
| Name | Description |
|---|---|
mseed_source_present |
Return whether the miniSEED file backing this seismogram still exists. |
read_seismogram_data_from_mseedfile |
Read seismogram waveform data from a miniSEED file. |
write_seismogram_data_to_mseedfile |
Write seismogram waveform data to a miniSEED file. |
mseed_source_present
mseed_source_present(
context: SeismogramReadContext,
) -> bool
Return whether the miniSEED file backing this seismogram still exists.
A miniSEED file written by add_seismograms_to_project is created once and
then treated exactly like any other external file, so a missing one is an
ordinary prunable orphan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SeismogramReadContext
|
Read context whose |
required |
Raises:
| Type | Description |
|---|---|
SourceUnavailableError
|
If presence cannot be determined right now (an unreadable file, a missing parent directory, an unreachable mount). |
Source code in src/aimbat/io/mseed.py
read_seismogram_data_from_mseedfile
read_seismogram_data_from_mseedfile(
context: SeismogramReadContext,
) -> NDArray[floating]
Read seismogram waveform data from a miniSEED file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SeismogramReadContext
|
Read context whose |
required |
Returns:
| Type | Description |
|---|---|
NDArray[floating]
|
Seismogram amplitude data. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file holds zero, or more than one, contiguous segment (a data gap, or more than one channel) - see the module docstring's scope boundary. |
Source code in src/aimbat/io/mseed.py
write_seismogram_data_to_mseedfile
write_seismogram_data_to_mseedfile(
mseedfile: str | PathLike[str], data: NDArray[floating]
) -> None
Write seismogram waveform data to a miniSEED file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mseedfile
|
str | PathLike[str]
|
Name of the miniSEED file. |
required |
data
|
NDArray[floating]
|
Seismogram amplitude data to write. |
required |
Source code in src/aimbat/io/mseed.py
sac
SAC file I/O for AIMBAT.
Reads and writes seismogram data from SAC files via pysmo, and creates
AimbatStation, AimbatEvent, and AimbatSeismogram model instances from
SAC file metadata.
This module registers its capabilities with the I/O dispatch layer on import, so importing it is sufficient to enable SAC support.
Functions:
| Name | Description |
|---|---|
create_event_from_sacfile |
Create an |
create_seismogram_from_sacfile |
Create an |
create_seismogram_from_sacfile_and_pick_header |
Create an |
create_station_from_sacfile |
Create an |
read_records_from_sacfile |
Build every record a request asks for from one read of a SAC file. |
read_seismogram_data_from_sacfile |
Read seismogram waveform data from a SAC file. |
sac_source_present |
Return whether the SAC file backing this seismogram still exists. |
write_seismogram_data_to_sacfile |
Write seismogram waveform data to a SAC file. |
create_event_from_sacfile
create_event_from_sacfile(
sacfile: str | PathLike[str],
) -> AimbatEvent
Create an AimbatEvent instance from a SAC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sacfile
|
str | PathLike[str]
|
Name of the SAC file. |
required |
Returns:
| Type | Description |
|---|---|
AimbatEvent
|
A new |
Source code in src/aimbat/io/sac.py
create_seismogram_from_sacfile
create_seismogram_from_sacfile(
sacfile: str | PathLike[str],
) -> AimbatSeismogram
Create an AimbatSeismogram instance from a SAC file, using the configured pick header.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sacfile
|
str | PathLike[str]
|
Name of the SAC file. |
required |
Returns:
| Type | Description |
|---|---|
AimbatSeismogram
|
A new |
Source code in src/aimbat/io/sac.py
create_seismogram_from_sacfile_and_pick_header
create_seismogram_from_sacfile_and_pick_header(
sacfile: str | PathLike[str], sac_pick_header: str
) -> AimbatSeismogram
Create an AimbatSeismogram instance from a SAC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sacfile
|
str | PathLike[str]
|
Name of the SAC file. |
required |
sac_pick_header
|
str
|
SAC header to use as t0 in AIMBAT. |
required |
Returns:
| Type | Description |
|---|---|
AimbatSeismogram
|
A new |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/aimbat/io/sac.py
create_station_from_sacfile
create_station_from_sacfile(
sacfile: str | PathLike[str],
) -> AimbatStation
Create an AimbatStation instance from a SAC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sacfile
|
str | PathLike[str]
|
Name of the SAC file. |
required |
Returns:
| Type | Description |
|---|---|
AimbatStation
|
A new |
Source code in src/aimbat/io/sac.py
read_records_from_sacfile
read_records_from_sacfile(
request: SourceRecordsRequest,
) -> SourceRecords
Build every record a request asks for from one read of a SAC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
SourceRecordsRequest
|
The records wanted, and the SAC file to build them from. |
required |
Returns:
| Type | Description |
|---|---|
SourceRecords
|
The requested records. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a seismogram is wanted and the configured
|
Source code in src/aimbat/io/sac.py
read_seismogram_data_from_sacfile
read_seismogram_data_from_sacfile(
context: SeismogramReadContext,
) -> NDArray[floating]
Read seismogram waveform data from a SAC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SeismogramReadContext
|
Read context whose |
required |
Returns:
| Type | Description |
|---|---|
NDArray[floating]
|
Seismogram amplitude data. |
Source code in src/aimbat/io/sac.py
sac_source_present
sac_source_present(context: SeismogramReadContext) -> bool
Return whether the SAC file backing this seismogram still exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SeismogramReadContext
|
Read context whose |
required |
Raises:
| Type | Description |
|---|---|
SourceUnavailableError
|
If presence cannot be determined right now (an unreadable file, a missing parent directory, an unreachable mount). |
Source code in src/aimbat/io/sac.py
write_seismogram_data_to_sacfile
Write seismogram waveform data to a SAC file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sacfile
|
str | PathLike[str]
|
Name of the SAC file. |
required |
data
|
NDArray[floating]
|
Seismogram amplitude data to write. |
required |