Core#
- seismoviz.core.read_catalog(source, **kwargs)#
Creates a
Catalogobject 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
Catalogclass 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, andid. 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
Catalogclass 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
CrossSectionclass 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
CrossSectionobject. To access the data, you can use thecs.dataattribute, which is a DataFrame containing all the events within the sections. Each event is labeled with asection_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
customisTrue, you can choose which graph to use for the sections by selecting the columns withxandy. Otherwise, the selection is set automatically: aCataloginstance produces a map selection, while aCrossSectioninstance 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
customisTrue.- ystr, optional
The column name for the y-axis variable. Required if
customisTrue.- 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.
- An interactive selection object with a
- Raises:
- ValueError
If
customis True and eitherxoryis not provided, or if the type ofinstanceis unsupported.