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

salvus.project.components.action.seismology.seismology_action_component

Classes

SeismologyActionComponent

class SeismologyActionComponent(builtins.object):
    def __init__(self, project: salvus.project.project.Project):
        ...

Seismology specific actions.

Parameters
  • project salvus.project.project.Project — The project for the component.
Methods
add_asdf_file()
def add_asdf_file(
    self,
    filename: Union[str, pathlib.Path],
    data_name: str,
    receiver_fields: List[str],
    event_name: Optional[str] = None,
) -> None:
    ...

Convenience function adding a complete ASDF file to the project.

There are a few prerequisites and assumption about the ASDF file:

  • It must contain exactly one earthquake/event and this event must contain a moment tensor.
  • All waveform data is assumed to be for this one event meaning that the start time of every trace should approximately be the event time and it should be long enough so that the receiver records the phases one it interested in.
  • All waveform data must have an associated StationXML file.
Parameters
  • filename Union[str, pathlib.Path] — Path to the ASDF file.
  • data_name str — Name of the data set within the project.
  • receiver_fields List[str] — Receiver fields for the new to be created receivers.
  • event_name Optional[str] — Specify a custom event name. If not given it will automatically derive a descriptive event name.
Returns None
add_receiver_weights_to_windows()
def add_receiver_weights_to_windows(
    self,
    data_selection_configuration: str,
    events: Union[
        str,
        Sequence[str],
        salvus.flow.collections.event.Event,
        Sequence[salvus.flow.collections.event.Event],
        salvus.flow.collections.event_collection.EventCollection,
    ],
    weighting_chain: List[Dict],
    normalize: bool,
) -> None:
    ...

Add station weights to existing windows.

This is largely a convenience method to ease weight computation for seismological full waveform inversions as it offers a few already implemented common weight selection schemes as well as an easy interface to add custom weighting schemes in a seismological context.

Everything here could also be done by utilizing the functionality by the WindowAndWeight component in SalvusProject.

Will only modify the weights of receivers that have windows picked so if you repick the windows, best recompute the weights.

It will overwrite any already chosen weight.

Parameters
  • data_selection_configuration str — Name of the data selection configuration.
  • events Union[str, Sequence[str], salvus.flow.collections.event.Event, Sequence[salvus.flow.collections.event.Event], salvus.flow.collections.event_collection.EventCollection] — Events to pick weights for.
  • weighting_chain List[Dict] — A list of weighting functions to be applied in order. Weights from different functions will be multiplied together.
  • normalize bool — If True (recommended) normalize the sum of all weights to be equal to the receiver count after the all weighting functions have been applied.
Returns None
download_data_for_event()
def download_data_for_event(
    self,
    data_name: str,
    event: Union[str, salvus.flow.collections.event.Event],
    add_receivers_to_project_event: bool,
    receiver_fields: Optional[List[str]] = None,
    seconds_before_event: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    seconds_after_event: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    download_providers: Optional[Sequence[str]] = None,
    channel_priorities: Sequence[str] = (
        "BH[Z,N,E,1,2,3]",
        "LH[Z,N,E,1,2,3]",
        "HH[Z,N,E,1,2,3]",
        "EH[Z,N,E,1,2,3]",
        "MH[Z,N,E,1,2,3]",
    ),
    location_priorities: Sequence[str] = ("", "00", "10", "20", "01", "02"),
    minimum_interstation_distance_in_m: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ] = 1000.0,
    network: Optional[str] = None,
    station: Optional[str] = None,
    location: Optional[str] = None,
    channel: Optional[str] = None,
) -> None:
    ...

Download seismological data for a given project and event.

Parameters
  • data_name str — The name the data set will have in the project.
  • event Union[str, salvus.flow.collections.event.Event] — The event.
  • add_receivers_to_project_event bool — Add new receivers to the project or not.
  • receiver_fields Optional[List[str]] — Receiver fields.
  • seconds_before_event Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Use this many seconds before the event.
  • seconds_after_event Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Use this many seconds after the event.
  • download_providers Optional[Sequence[str]] — Download providers.
  • channel_priorities Sequence[str] — Channel priority list.
  • location_priorities Sequence[str] — Location priority list.
  • minimum_interstation_distance_in_m Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Minimum interstation distance in meters.
  • network Optional[str] — Only use these network codes if specified.
  • station Optional[str] — Only use these station codes if specified.
  • location Optional[str] — Only use these location codes if specified.
  • channel Optional[str] — Only use these channel codes if specified.
Returns None
get_events_from_csv_catalog_file()
def get_events_from_csv_catalog_file(
    self,
    filename: pathlib.Path,
    max_count: Union[int, numpy.int32, numpy.int64],
    min_moment_magnitude: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    max_moment_magnitude: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    min_distance_in_meters: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    min_year: Union[int, numpy.int32, numpy.int64],
    max_year: Union[int, numpy.int32, numpy.int64],
    random_seed: Optional[int, numpy.int32, numpy.int64] = None,
) -> salvus.flow.collections.event_collection.EventCollection:
    ...

Get optimally distributed events from a given catalog file that could be added to the project. This method is aware of the currently available events in the project and can be used to add new events to an existing project.

Have a look at the Salvus documentation for information on where to acquire/how to create these catalog files. It does not use any standard seismological event file formats for performance reasons.

It is optimal in the sense that it will always select the one event from the catalog that has the smallest distance to the next closest existing event. It is then removed from the catalog and the procedure repeats until max_count elements have been added or until min_distance_in_meter or some other constraint can no longer be satisfied. The first event will always be random if the project does not yet have any events.

Parameters
  • filename pathlib.Path — Path to the CSV file.
  • max_count Union[int, numpy.int32, numpy.int64] — Get at max this many events. Less events might be returned if any of the other constraints can no longer be fulfilled.
  • min_moment_magnitude Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Lower magnitude bound for the chosen events.
  • max_moment_magnitude Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Upper magnitude bound for the chosen events.
  • min_distance_in_meters Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Minimum acceptable great-circle distance in meters between any two events.
  • min_year Union[int, numpy.int32, numpy.int64] — Minimum year from which to choose events.
  • max_year Union[int, numpy.int32, numpy.int64] — Maximum year from which to choose events.
  • random_seed Optional[int, numpy.int32, numpy.int64] — The first event is randomly chosen if the project does not yet contain any events. Specify a seed to make it reproducible. Useful for test and potentially tutorials.
Returns salvus.flow.collections.event_collection.EventCollection
get_events_with_windows()
def get_events_with_windows(
    self, data_selection_configuration_name: str
) -> List[str]:
    ...

Returns the names of all events that have windows for a chosen data selection configuration.

Parameters
  • data_selection_configuration_name str — Name of the data selection configuration.
Returns List[str]
pick_windows()
def pick_windows(
    self,
    data_selection_configuration: str,
    observed_data_name: str,
    synthetic_data_name: str,
    events: Union[
        str,
        Sequence[str],
        salvus.flow.collections.event.Event,
        Sequence[salvus.flow.collections.event.Event],
        salvus.flow.collections.event_collection.EventCollection,
    ],
    receiver_field: str,
    window_taper_width_in_seconds: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    taper_type: str = "hanning",
    window_picking_function: Union[str, Callable],
    window_picking_function_kwargs: Dict[str, Any],
    save_results_in_project: bool = True,
    receiver_name_pattern: Optional[str] = None,
    overwrite: bool = False,
) -> List[
    salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet
]:
    ...

Pick windows on seismological data sets.

Uses a windows picking function inspired by LASIF.

Parameters
  • data_selection_configuration str — Name of the data selection configuration. If it does not exist yet, it will be created, otherwise a new one will be created.
  • observed_data_name str — Name of the data set to be considered observed data.
  • synthetic_data_name str — Name of the data set to be considered synthetic data.
  • events Union[str, Sequence[str], salvus.flow.collections.event.Event, Sequence[salvus.flow.collections.event.Event], salvus.flow.collections.event_collection.EventCollection] — List of events to pick windows for.
  • receiver_field str — Receiver field name on which to pick the windows.
  • window_taper_width_in_seconds Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Taper width in seconds when the windows will be applied to the data. The taper width will never be larger than half a window length. This is just passed on to the to be created EventWindowAndWeightSet.
  • taper_type str — The type of taper to use. Currently only "hanning" is supported which will use the classical cosine bell Hann/Hanning window. Will default to "hanning" if not given. This is just passed on to the to be created EventWindowAndWeightSet.
  • window_picking_function Union[str, Callable] — Either the string "built-in" in which case the built-in window picking function is used or an actual function which will be called for each receiver component.
  • window_picking_function_kwargs Dict[str, Any] — Additional keyword arguments to be passed to the window picking function.
  • save_results_in_project bool — Optionally choose not to save the results in the current project. This is useful when debugging window picking algorithms and trying to find the best settings.
  • receiver_name_pattern Optional[str] — Optionally specify a wildcarded receiver name pattern so only windows for matching receivers will be picked. Most useful for debugging and when save_results_in_project is False.
  • overwrite bool — If True potentially already existing window sets for individual will be overwritten with freshly picked windows.
Returns List[salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet]