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

salvus.flow.collections.event_block

Block wise receiver, source, and event structures.

Currently works for cartesian non-side set source and receiver objects.

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: Union[
            List[salvus.flow.collections.event_block.SourceBlock],
            salvus.flow.collections.event_block.SourceBlock,
        ],
        receiver_blocks: Union[
            List[salvus.flow.collections.event_block.ReceiverBlock],
            salvus.flow.collections.event_block.ReceiverBlock,
        ],
    ):
        ...

An event made up of source and receiver blocks.

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

Convert an event block to a Salvus event object.

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

EventBlockCollection

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

An in-memory event block collection.

Can be written

Parameters
  • block_events List[salvus.flow.collections.event_block.EventBlock] — A list of event blocks.
  • event_ids numpy.ndarray — The corresponding event ids, on for each block.
Methods
get()
def get(
    self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event_block.EventBlock:
    ...

Get a single event block.

Parameters
  • event_id Union[str, bytes, int] — The event id.
Returns salvus.flow.collections.event_block.EventBlock
get_all_coordinates()
def get_all_coordinates(self) -> Dict[str, numpy.ndarray]:
    ...

Get all source and receiver coordinates

Returns Dict[str, numpy.ndarray]
get_event()
def get_event(
    self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event.Event:
    ...

Get a event object.

Parameters
  • event_id Union[str, bytes, int] — The event id.
Returns salvus.flow.collections.event.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: Optional[matplotlib.axes._axes.Axes] = 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 Optional[matplotlib.axes._axes.Axes] — The axes to plot in. If not given, a new figure will be created.
Returns None
write()
def write(self, filename: Union[str, pathlib.Path]) -> None:
    ...

Write the block event collection to an HDF5 file.

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

EventBlockCollectionReader

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

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

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

Get a single event block.

Parameters
  • event_id Union[str, bytes, int] — The event id.
Returns salvus.flow.collections.event_block.EventBlock
get_all_coordinates()
def get_all_coordinates(self) -> Dict[str, numpy.ndarray]:
    ...

Get all source and receiver coordinates

Returns Dict[str, numpy.ndarray]
get_event()
def get_event(
    self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event.Event:
    ...

Get a event object.

Parameters
  • event_id Union[str, bytes, int] — The event id.
Returns salvus.flow.collections.event.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: Optional[matplotlib.axes._axes.Axes] = 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 Optional[matplotlib.axes._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,
        salvus_receiver_class: Union[
            Type[salvus.flow.simple_config.receiver.cartesian.Point2D],
            Type[salvus.flow.simple_config.receiver.cartesian.Point3D],
        ],
        fields: List[str],
        coordinates: Union[
            numpy.ndarray, Sequence[float], Sequence[Sequence[float]]
        ],
        receiver_ids: Union[numpy.ndarray, Sequence[Union[int, str, bytes]]],
        skip_value_validation: bool = False,
    ):
        ...

A receiver block combining many receivers of the same type.

Parameters
  • salvus_receiver_class Union[Type[salvus.flow.simple_config.receiver.cartesian.Point2D], Type[salvus.flow.simple_config.receiver.cartesian.Point3D]] — The salvus receiver type.
  • fields List[str] — The receiver fields.
  • coordinates Union[numpy.ndarray, Sequence[float], Sequence[Sequence[float]]] — The coordinate array.
  • receiver_ids Union[numpy.ndarray, Sequence[Union[int, str, bytes]]] — The receiver ids.
  • skip_value_validation bool — Optionally skip the value validation.
Methods
validate()
def validate(self) -> None:
    ...

Validate the contents.

Returns None

SourceBlock

class SourceBlock(builtins.object):
    def __init__(
        self,
        salvus_source_class: Union[type, abc.ABCMeta],
        coordinates: Union[
            numpy.ndarray, Sequence[float], Sequence[Sequence[float]]
        ],
        force_values: Union[
            numpy.ndarray, Sequence[float], Sequence[Sequence[float]]
        ],
        skip_value_validation: bool = False,
    ):
        ...

A source block combining many sources of the same type.

Parameters
  • salvus_source_class Union[type, abc.ABCMeta] — The salvus source class.
  • coordinates Union[numpy.ndarray, Sequence[float], Sequence[Sequence[float]]] — The coordinate array.
  • force_values Union[numpy.ndarray, Sequence[float], Sequence[Sequence[float]]] — The force values of each source.
  • skip_value_validation bool — Optionally skip the value validation.
Methods
validate()
def validate(self) -> None:
    ...

Validate the contents.

Returns None