../_images/core_light.jpg

Core#

seismoviz.core.read_catalog(source, **kwargs)#

Creates a Catalog object from either a CSV file path or a pandas DataFrame.

Parameters:
sourcestr or pd.DataFrame

Either a path to a CSV file containing the seismic catalog or a pandas DataFrame with the catalog data already loaded.

**kwargs

Additional keyword arguments to pass to pandas.read_csv() when source is a file path.

Returns:
Catalog

An instance of the Catalog class with the data loaded.

Examples

From a CSV file:

# Reading a catalog from a CSV file
catalog = sv.read_catalog(
    source='seismic_data.csv'
)

From a DataFrame:

# Creating a catalog from an existing DataFrame
catalog = sv.read_catalog(source=df)

Warning

The input must contain the following columns: lon, lat, time, depth, mag, and id. If any of these columns are missing, an error will be raised.

seismoviz.core.create_cross_section(catalog, center, num_sections, thickness, strike, map_length, depth_range, section_distance=1.0)#

Creates a seismic cross-section from a given Catalog.

Parameters:
catalogCatalog

An instance of the Catalog class containing seismic event data.

centertuple[float, float]

A tuple representing the geographical coordinates (longitude, latitude) of the center of the cross-section.

num_sectionstuple[int, int]

A tuple specifying the number of sections to create to the left and right of the center (e.g., (2, 2) will create 2 sections on each side of the center).

thicknessint

The maximum distance (in km) that events can be from the cross-section plane to be included in the section.

strikeint

The strike angle (in degrees) of the cross-section, measured clockwise from north. Cross section will be computed perpendicular to strike.

map_lengthfloat

The length of the cross-section (in km), which determines the horizontal extent of the plotted data.

depth_rangetuple[float, float]

A tuple specifying the minimum and maximum depth (in km) of events to include in the cross-section.

section_distancefloat, optional

The distance (in km) between adjacent sections. Default is 1.

Returns:
CrossSection

An instance of the CrossSection class with the seismic events that fit the specified parameters.

Examples

cs = sv.create_cross_section(
    catalog=catalog,
    center=(13.12, 42.83),
    num_sections=(2,2),
    thickness=1,
    strike=155,
    map_length=40,
    depth_range=(0, 10),
    section_distance=2
)

The output will be a CrossSection object. To access the data, you can use the cs.data attribute, which is a DataFrame containing all the events within the sections. Each event is labeled with a section_id, allowing you to easily identify which section it belongs to.

seismoviz.select(instance, x=None, y=None, custom=False, section_ids=None, **kwargs)#

Launch an interactive tool to select seismic events.

Note

When custom is True, you can choose which graph to use for the sections by selecting the columns with x and y. Otherwise, the selection is set automatically: a Catalog instance produces a map selection, while a CrossSection instance produces a cross-section selection.

Parameters:
instancetype

An object containing seismic data and plotting configurations.

xstr, optional

The column name for the x-axis variable. Required if custom is True.

ystr, optional

The column name for the y-axis variable. Required if custom is True.

custombool, optional

Flag to indicate if a custom selection should be used. Defaults to False.

section_idsint, list, optional

When the instance is a CrossSection, this parameter allows specifying which section(s) to display. Can be a single section ID (int) or a list of IDs. If specified, only events from the selected section(s) will be displayed.

**kwargsdict, optional

Additional keyword arguments for customizing the selection.

Returns:
An interactive selection object with a confirm_selection() method.
Raises:
ValueError

If custom is True and either x or y is not provided, or if the type of instance is unsupported.