Mondaic

salvus.flow.collections.event_block

salvus.flow.collections.event_block salvus flow collections event_block

Block wise receiver, source, and event structures.

The main intention of this format is to facilitate working with large amount of sources and receivers in Salvus.

Classes

EventBlock

class EventBlock(builtins.object):
    def __init__(
        self,
        source_blocks: list[SourceBlock] | SourceBlock,
        receiver_blocks: list[ReceiverBlock] | ReceiverBlock,
    ): ...

An event made up of source and receiver blocks.

Parameters
  • source_blocks list[SourceBlock] | SourceBlock — One or more source blocks.
  • receiver_blocks list[ReceiverBlock] | ReceiverBlock — One or more receiver blocks.
Methods
get_event()
def get_event(
    self,
    event_name: str,
    source_time_functions: list[stf._Base] | stf._Base | None = None,
) -> Event: ...

Convert an event block to a Salvus event object.

Parameters
  • event_name str — The name of the event. This is set here.
  • source_time_functions list[stf._Base] | stf._Base | None — Optional list of source time functions to attach to the event’s sources. If given, the length of this list must match the total number of sources in all source blocks or be only a single entry which will be used for all sources.
Returns Event

EventBlockCollection

class EventBlockCollection(
    salvus.flow.collections.event_block._BaseEventBlockCollection
):
    def __init__(
        self, block_events: list[EventBlock], event_ids: npt.ArrayLike
    ): ...

The base event collection object.

An in-memory event block collection.

Can be written

Parameters
  • block_events list[EventBlock] — A list of event blocks.
  • event_ids npt.ArrayLike — The corresponding event ids, on for each block.
Methods
get()
def get(self, event_id: str | bytes | int) -> EventBlock: ...

Get a single event block.

Parameters
  • event_id str | bytes | int — The event id.
Returns EventBlock
get_all_coordinates()
def get_all_coordinates(self) -> dict[str, npt.NDArray]: ...

Get all source and receiver coordinates.

Returns dict[str, npt.NDArray]
get_event()
def get_event(self, event_id: str | bytes | int) -> Event: ...

Get a event object.

Parameters
  • event_id str | bytes | int — The event id.
Returns Event
list()
def list(self) -> list[str]: ...

Get an array of all available event ids.

Returns list[str]
plot_coordinates()
def plot_coordinates(
    self,
    plot_sources: bool = True,
    plot_receivers: bool = True,
    figsize: tuple[int, int] = (15, 15),
    ax: matplotlib.axes.Axes | None = None,
) -> None: ...

Plot all coordinates.

Parameters
  • plot_sources bool — Plot the sources.
  • plot_receivers bool — Plot the receivers.
  • figsize tuple[int, int] — Size of the matplotlib figure. Only used if ax is not passed.
  • ax matplotlib.axes.Axes | None — The axes to plot in. If not given, a new figure will be created.
Returns None
write()
def write(self, filename: pathlib.Path | str) -> None: ...

Write the block event collection to an HDF5 file.

Parameters
  • filename pathlib.Path | str — The filename to write to.
Returns None

EventBlockCollectionReader

class EventBlockCollectionReader(
    salvus.flow.collections.event_block._BaseEventBlockCollection
):
    def __init__(self, filename: pathlib.Path | str): ...

The base event collection object.

An event block collection reading from an HDF5 file without reading everything at once.

Parameters
  • filename pathlib.Path | str — Path to the HDF5 file.
Methods
get()
def get(self, event_id: str | bytes | int) -> EventBlock: ...

Get a single event block.

Parameters
  • event_id str | bytes | int — The event id.
Returns EventBlock
get_all_coordinates()
def get_all_coordinates(self) -> dict[str, npt.NDArray]: ...

Get all source and receiver coordinates.

Returns dict[str, npt.NDArray]
get_event()
def get_event(self, event_id: str | bytes | int) -> Event: ...

Get a event object.

Parameters
  • event_id str | bytes | int — The event id.
Returns Event
list()
def list(self) -> list[str]: ...

Get an array of all available event ids.

Returns list[str]
plot_coordinates()
def plot_coordinates(
    self,
    plot_sources: bool = True,
    plot_receivers: bool = True,
    figsize: tuple[int, int] = (15, 15),
    ax: matplotlib.axes.Axes | None = None,
) -> None: ...

Plot all coordinates.

Parameters
  • plot_sources bool — Plot the sources.
  • plot_receivers bool — Plot the receivers.
  • figsize tuple[int, int] — Size of the matplotlib figure. Only used if ax is not passed.
  • ax matplotlib.axes.Axes | None — The axes to plot in. If not given, a new figure will be created.
Returns None

ReceiverBlock

class ReceiverBlock(builtins.object):
    def __init__(
        self,
        coordinates: Coordinates | npt.ArrayLike,
        receiver_ids: np.ndarray | typing.Sequence[int | str | bytes],
        fields: list[str],
    ): ...

A receiver block combining many points receivers of the same type.

Parameters
  • coordinates Coordinates | npt.ArrayLike — The coordinates.
  • receiver_ids np.ndarray | typing.Sequence[int | str | bytes] — The receiver ids.
  • fields list[str] — The receiver fields.
Methods
get_salvus_receivers()
def get_salvus_receivers(self) -> list[receiver._Base]: ...

Get Salvus receiver objects corresponding to the block.

Returns list[receiver._Base]

SourceBlock

class SourceBlock(builtins.object):
    def __init__(
        self,
        coordinates: Coordinates | npt.ArrayLike,
        source_mechanism: source_mechanism_module.SourceMechanism,
    ): ...

A source block combining many sources of the same type.

Parameters
  • coordinates Coordinates | npt.ArrayLike — The coordinate array.
  • source_mechanism source_mechanism_module.SourceMechanism — The source mechanism for the sources.
Methods
get_salvus_sources()
def get_salvus_sources(
    self, source_time_functions: list[stf._Base] | stf._Base | None = None
) -> list[source._Base]: ...

Get Salvus source objects corresponding to the block.

Parameters
  • source_time_functions list[stf._Base] | stf._Base | None — Optional source time function(s). Can be a single STF (used for all sources) or a list matching the number of sources in the block.
Returns list[source._Base]