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
EventBlockclass 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.
source_blocksUnion[List[salvus.flow.collections.event_block.SourceBlock], salvus.flow.collections.event_block.SourceBlock] — One or more source blocks.receiver_blocksUnion[List[salvus.flow.collections.event_block.ReceiverBlock], salvus.flow.collections.event_block.ReceiverBlock] — One or more receiver blocks.
get_event()
get_event()def get_event(self, event_name: str) -> salvus.flow.collections.event.Event:
...Convert an event block to a Salvus event object.
event_namestr — The name of the event. This is set here.
EventBlockCollection
EventBlockCollectionclass 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
block_eventsList[salvus.flow.collections.event_block.EventBlock] — A list of event blocks.event_idsnumpy.ndarray — The corresponding event ids, on for each block.
get()
get()def get(
self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event_block.EventBlock:
...Get a single event block.
event_idUnion[str, bytes, int] — The event id.
get_all_coordinates()
get_all_coordinates()def get_all_coordinates(self) -> Dict[str, numpy.ndarray]:
...Get all source and receiver coordinates
get_event()
get_event()def get_event(
self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event.Event:
...Get a event object.
event_idUnion[str, bytes, int] — The event id.
list()
list()def list(self) -> List[str]:
...Get an array of all available event ids.
plot_coordinates()
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.
plot_sourcesbool — Plot the sources.plot_receiversbool — Plot the receivers.figsizeTuple[int, int] — Size of the matplotlib figure. Only used ifaxis not passed.axOptional[matplotlib.axes._axes.Axes] — The axes to plot in. If not given, a new figure will be created.
write()
write()def write(self, filename: Union[str, pathlib.Path]) -> None:
...Write the block event collection to an HDF5 file.
filenameUnion[str, pathlib.Path] — The filename to write to.
EventBlockCollectionReader
EventBlockCollectionReaderclass 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.
filenameUnion[str, pathlib.Path] — Path to the HDF5 file.
get()
get()def get(
self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event_block.EventBlock:
...Get a single event block.
event_idUnion[str, bytes, int] — The event id.
get_all_coordinates()
get_all_coordinates()def get_all_coordinates(self) -> Dict[str, numpy.ndarray]:
...Get all source and receiver coordinates
get_event()
get_event()def get_event(
self, event_id: Union[str, bytes, int]
) -> salvus.flow.collections.event.Event:
...Get a event object.
event_idUnion[str, bytes, int] — The event id.
list()
list()def list(self) -> List[str]:
...Get an array of all available event ids.
plot_coordinates()
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.
plot_sourcesbool — Plot the sources.plot_receiversbool — Plot the receivers.figsizeTuple[int, int] — Size of the matplotlib figure. Only used ifaxis not passed.axOptional[matplotlib.axes._axes.Axes] — The axes to plot in. If not given, a new figure will be created.
ReceiverBlock
ReceiverBlockclass 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.
salvus_receiver_classUnion[Type[salvus.flow.simple_config.receiver.cartesian.Point2D], Type[salvus.flow.simple_config.receiver.cartesian.Point3D]] — The salvus receiver type.fieldsList[str] — The receiver fields.coordinatesUnion[numpy.ndarray, Sequence[float], Sequence[Sequence[float]]] — The coordinate array.receiver_idsUnion[numpy.ndarray, Sequence[Union[int, str, bytes]]] — The receiver ids.skip_value_validationbool — Optionally skip the value validation.
validate()
validate()def validate(self) -> None:
...Validate the contents.
SourceBlock
SourceBlockclass 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.
salvus_source_classUnion[type, abc.ABCMeta] — The salvus source class.coordinatesUnion[numpy.ndarray, Sequence[float], Sequence[Sequence[float]]] — The coordinate array.force_valuesUnion[numpy.ndarray, Sequence[float], Sequence[Sequence[float]]] — The force values of each source.skip_value_validationbool — Optionally skip the value validation.
validate()
validate()def validate(self) -> None:
...Validate the contents.