Mondaic
This API reference is not for the latest stable Salvus version.

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: typing.Union[typing.List[SourceBlock], SourceBlock],
        receiver_blocks: typing.Union[
            typing.List[ReceiverBlock], ReceiverBlock
        ],
    ): ...

An event made up of source and receiver blocks.

Parameters
  • source_blocks typing.Union[typing.List[SourceBlock], SourceBlock] — One or more source blocks.
  • receiver_blocks typing.Union[typing.List[ReceiverBlock], ReceiverBlock] — One or more receiver blocks.
Methods
get_event()
def get_event(self, event_name: str) -> Event: ...

Convert an event block to a Salvus event object.

Parameters
  • event_name str — The name of the event. This is set here.
Returns Event

EventBlockCollection

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

An in-memory event block collection.

Can be written

Parameters
  • block_events typing.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: typing.Union[str, bytes, int]) -> EventBlock: ...

Get a single event block.

Parameters
  • event_id typing.Union[str, bytes, int] — The event id.
Returns EventBlock
get_all_coordinates()
def get_all_coordinates(self) -> typing.Dict[str, np.ndarray]: ...

Get all source and receiver coordinates

Returns typing.Dict[str, np.ndarray]
get_event()
def get_event(self, event_id: typing.Union[str, bytes, int]) -> Event: ...

Get a event object.

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

Get an array of all available event ids.

Returns typing.List[str]
plot_coordinates()
def plot_coordinates(
    self,
    plot_sources: bool = True,
    plot_receivers: bool = True,
    figsize: typing.Tuple[int, int] = (15, 15),
    ax: typing.Optional[matplotlib.axes.Axes] = None,
) -> None: ...

Plot all coordinates.

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

Write the block event collection to an HDF5 file.

Parameters
  • filename typing.Union[str, pathlib.Path] — The filename to write to.
Returns None

EventBlockCollectionReader

class EventBlockCollectionReader(
    salvus.flow.collections.event_block._BaseEventBlockCollection
):
    def __init__(self, filename: typing.Union[str, pathlib.Path]): ...

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

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

Get a single event block.

Parameters
  • event_id typing.Union[str, bytes, int] — The event id.
Returns EventBlock
get_all_coordinates()
def get_all_coordinates(self) -> typing.Dict[str, np.ndarray]: ...

Get all source and receiver coordinates

Returns typing.Dict[str, np.ndarray]
get_event()
def get_event(self, event_id: typing.Union[str, bytes, int]) -> Event: ...

Get a event object.

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

Get an array of all available event ids.

Returns typing.List[str]
plot_coordinates()
def plot_coordinates(
    self,
    plot_sources: bool = True,
    plot_receivers: bool = True,
    figsize: typing.Tuple[int, int] = (15, 15),
    ax: typing.Optional[matplotlib.axes.Axes] = None,
) -> None: ...

Plot all coordinates.

Parameters
  • plot_sources bool — Plot the sources.
  • plot_receivers bool — Plot the receivers.
  • figsize typing.Tuple[int, int] — Size of the matplotlib figure. Only used if ax is not passed.
  • ax typing.Optional[matplotlib.axes.Axes] — 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: typing.Union[
            np.ndarray, typing.Sequence[typing.Union[int, str, bytes]]
        ],
        fields: typing.List[str],
    ): ...

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

Parameters
  • coordinates Coordinates | npt.ArrayLike — The coordinates.
  • receiver_ids typing.Union[np.ndarray, typing.Sequence[typing.Union[int, str, bytes]]] — The receiver ids.
  • fields typing.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._SourceMechanism,
    ): ...

A source block combining many sources of the same type.

Parameters
  • coordinates Coordinates | npt.ArrayLike — The coordinate array.
  • source_mechanism source_mechanism._SourceMechanism — The source mechanism for the sources.
Methods
get_salvus_sources()
def get_salvus_sources(self) -> list[source._Base]: ...

Get Salvus source objects corresponding to the block.

Returns list[source._Base]