earthscopestraintools.event_processing module
- earthscopestraintools.event_processing.calc_hypocentral_dist(eq_latitude, eq_longitude, eq_depth, station_latitude, station_longitude)
Function calculates hypocentral distance (km) between lat,long and earthquake. Note that the distance calculation does not account for Earth’s curvature with depth, and should be used for regional earthquakes only.
- Parameters:
eq_latitude (float) – latitude of earthquake
eq_longitude (float) – longitude of earthquake
eq_depth (float) – depth of earthquake
station_latitude (float) – latitude of station
station_longitude (float) – longitude of station
- Returns:
hypocentral distance in km
- Return type:
int
- earthscopestraintools.event_processing.calculate_magnitude(dynamic_strain_df, hypocentral_distance, site_term, longitude_term)
Calculates a magnitude estimate based on Barbour et al 2021.
- Parameters:
dynamic_strain_df (pandas.DataFrame) – dataframe containing dynamic strain during an event
hypocentral_distance (float) – distance from station to event hypocenter, in km
site_term (float) – site term from Barbour et al 2021
longitude_term (float) – longitude term from Barbour et al 2021
- Returns:
dataframe containing a dynamic strain based magnitude estimate as a function of time
- Return type:
pandas.DataFrame
- earthscopestraintools.event_processing.calculate_p_s_arrival(eq_latitude, eq_longitude, eq_time, station_latitude, station_longitude)
Function calculates arrival times for P and S waves at a given lat and long
- Parameters:
eq_latitude (float) – latitude of earthquake
eq_longitude (float) – longitude of earthquake
eq_time (datetime.datetime) – time of earthquake
station_latitude (float) – latitude of station
station_longitude (float) – longitude of station
- Returns:
p_arrival, s_arrival
- Return type:
datetime.datetime
- earthscopestraintools.event_processing.dynamic_strain(df, gauge_weights=[1, 1, 1, 1])
Calculates dynamic strain as RMS of gauge strains
- Parameters:
df (pandas.DataFrame) – dataframe containing gauge strains as columns and time as an index
gauge_weights (list, optional) – list of which gauges to include, defaults to [1, 1, 1, 1]
- Returns:
dataframe containing a single column of dynamic strain, time as an index
- Return type:
pandas.DataFrame
- earthscopestraintools.event_processing.get_stations_in_radius(latitude, longitude, depth, radius, print_it=False)
determine list of stations within a given radius from an event, using lat/long in gtsm metadata summary table
- Parameters:
latitude (float) – event latitude
longitude (float) – event longitude
depth (float) – event depth
radius (float) – radius from event, in km
print_it (bool, optional) – option to print list of stations within radius, and calculated distances from event, defaults to False
- Returns:
list of four character station codes for stations within the given radius
- Return type:
list
- earthscopestraintools.event_processing.magnitude_plot(dynamic_strain_df: DataFrame, magnitude_df: DataFrame, eq_time: datetime, eq_mag: datetime, title: str | None = None, save_as: str | None = None)
plot dynamic strain and associated magnitude estimate on the same plot
- Parameters:
dynamic_strain_df (pd.DataFrame) – dataframe containing dynamic strain during an event
magnitude_df (pd.DataFrame) – dataframe containing strain-based magnitude estimate during an event
eq_time (datetime.datetime) – event origin time
eq_mag (datetime.datetime) – published event magnitude from COMCAT
title (str, optional) – plot title, defaults to None
save_as (str, optional) – filename to save plot, defaults to None
- earthscopestraintools.event_processing.plot_coseismic_offset(df, title: str = '', remove_9s: bool = True, zero: bool = False, detrend: bool | None = None, ymin: float | None = None, ymax: float | None = None, plot_type: str = 'scatter', units: str | None = None, eq_time: datetime | None = None, coseismic_offset: bool = False, color='black', save_as: str | None = None)
plot strain data from an event
- Parameters:
df (pandas.DataFrame) – strain data including an event signal
title (str, optional) – plot title, defaults to “”
remove_9s (bool, optional) – option to remove gap fill values, defaults to True
zero (bool, optional) – option to zero the data against the first valid index, defaults to False
detrend (bool, optional) – option to linearly detrend data, will use pre-event data only if eq_time is provided, defaults to None
ymin (float, optional) – y-axis minimum for plot, defaults to None
ymax (float, optional) – y-axis maximum for plot, defaults to None
plot_type (str, optional) – matplotlib plot type. option of [‘scatter’,’line’], defaults to “scatter”
units (str, optional) – units to display on y-axis, defaults to None
eq_time (datetime.datetime, optional) – origin time of event, defaults to None
coseismic_offset (bool, optional) – option to calculate and display the coseismic offset as a difference of the mean of the first quintile and last quintile of data, defaults to False
color (str, optional) – matplotlib color option, defaults to “black”
save_as (str, optional) – filename to save plot, defaults to None
- earthscopestraintools.event_processing.pre_event_trend_correction(df, eq_time)
calculate a linear trend correction based on any data provided prior to event start time
- Parameters:
df (pandas.DataFrame) – dataframe containing strain data
eq_time (datetime.datetime) – time of event
- Returns:
dataframe containing a linear trend correction
- Return type:
pandas.DataFrame