Weights Component

In an inverse problem like full-waveform inversion, there is a problem of uneven distribution and quality of data. The weights component takes care of weighing your data up or down according to what is needed.


class lasif.components.weights.WeightsComponent(weights_folder, communicator, component_name)[source]

Component dealing with station and event weights.

  • weights_folder (pathlib.Path) – The folder with the weight toml files.

  • communicator – The communicator instance.

  • component_name – The name of this component for the communicator.

calculate_station_weight(lat_1: float, lon_1: float, locations: numpy.ndarray)[source]

Calculates the weight set for a set of stations for one event

  • lat_1 (float) – latitude of station

  • lon_1 (float) – longitude of station

  • locations (numpy.ndarray) – array of latitudes and longitudes of other stations


weight. weight for this specific station

Return type


change_weight_set(weight_set_name: str, weight_set: dict, events_dict: dict)[source]

Changes an existing weight set. Writes into a tempfile and if successful it will replace the old file with the tempfile.

  • weight_set_name – The name of the weight set.

  • weight_set (dict) – The actual weight set

  • events_dict (dict) – A dictionary specifying the used events.


Get the number of weight sets managed by this component.

create_folder_for_weight_set(weight_set_name: str)[source]

Create the folder needed for weight set


weight_set_name (str) – name of weight set

create_new_weight_set(weight_set_name: str, events_dict: dict)[source]

Creates a new weight set.

  • weight_set_name (str) – The name of the weight set.

  • events_dict (dict) – A dictionary specifying the used events.

get(weight_set_name: str)[source]

Returns a weight_set object.


iteration_name (str) – The name of the iteration to retrieve.

get_filename_for_weight_set(weight_set: str)[source]

Helper function returning the filename of a weight set.


weight_set (str) – Name of weight set

get_long_weight_set_name(weight_set_name: str)[source]

Returns the long form of a weight set from its short name.


weight_set_name (str) – Name of weight set


Returns a dictionary with the keys being the weight_set names and the values the weight_set filenames.

has_weight_set(weight_set_name: str)[source]

Test for existence of a weight_set.


weight_set_name (str) – The name of the weight_set.


Get a list of all weight sets managed by this component.