seisflows.tools.signal
Signal processing or manipulation functions which are used to manipulate time series, or interact with ObsPy Trace and Stream objects. Primarily used by the Preprocessing module
Functions
|
Apply a filter to waveform data using ObsPy, throw on a standard |
|
Trims the time waveform of st_trim to match the time series of st. This |
|
Resample all traces in st_a to the sampling rate of st_b. Resamples |
|
Normalize amplitudes of Stream object waveforms based on the given choice of |
|
Apply mute on data based on early or late arrivals, and short or long |
|
Constructs a tapered mask that can be applied to trace to mute early or |
|
Apply a tapered mask to a set of waveforms in a Stream to mute early or |
|
Mute traces based on a given distance (dist) |
Retrieve the coordinates from a Stream object. |
|
Get the coordinates of the source object. |
Module Contents
- seisflows.tools.signal.filter(st, choice, min_freq=None, max_freq=None, zerophase=True, **kwargs)
Apply a filter to waveform data using ObsPy, throw on a standard demean, detrened and taper prior to filtering. Options for different filtering types. Uses default filter options from ObsPy.
Zerophase enforced to be True to avoid phase shifting data.
- Parameters:
st (obspy.core.stream.Stream) – stream to be filtered
- Return type:
obspy.core.stream.Stream
- Returns:
filtered traces
- seisflows.tools.signal.trim(st, st_trim)
Trims the time waveform of st_trim to match the time series of st. This allows cutting down longer observed waveform data so that preprocessing steps are not performed on unncessarily long time series.
- Parameters:
st (obspy.core.stream.Stream) – Stream that sets the desired time series
st_trim (obspy.core.stream.Stream) – Stream that will have its time series cut to match st
- Return type:
(obspy.core.stream.Stream, obspy.core.stream.Stream)
- Returns:
(st, trimmed version of st_trim)
- seisflows.tools.signal.resample(st_a, st_b)
Resample all traces in st_a to the sampling rate of st_b. Resamples one to one, that is each trace in obs is resampled to the corresponding indexed trace in syn
- Parameters:
st_a (obspy.core.stream.Stream) – stream to be resampled using sampling rates from st_b
st_b (obspy.core.stream.Stream) – stream whose sampling rates will be used to resample st_a. Usually this is the synthetic data
- Return type:
(obspy.core.stream.Stream, obspy.core.stream.Stream)
- Returns:
st_a (resampled), st_b (original)
- seisflows.tools.signal.normalize(st, choice=None, st_rel=None)
Normalize amplitudes of Stream object waveforms based on the given choice of normalization function.
- Parameters:
st (obspy.core.stream.Stream) – All of the data streams to be normalized
choice (str) – choice of normalization parameter, from the following: - None: Do not normalize. Used to bypass procedure TRACE-WISE NORMALIZATION - TNORML1: normalize per trace by the L1 norm of itself - TNORML2: normalize per trace by the L2 norm of itself - TNORM_MAX: normalize by the maximum positive amplitude in the trace - TNORM_ABSMAX: normalize by the absolute maximum amplitude in the trace - TNORM_MEAN: normalize by the mean of the absolute trace RELATIVE NORMALIZATION - RNORM_MAX: normalize st by the max positive amplitude of st_rel - RNORM_ABSMAX: normalize st by abs max amplitude of st_rel
st_rel (obspy.core.stream.Stream) – Second stream used for relative normalization. Optional and only required if ‘RNORM’ set as choice
- Return type:
obspy.core.stream.Stream
- Returns:
stream with normalized traces
- seisflows.tools.signal.mute(st)
Apply mute on data based on early or late arrivals, and short or long source receiver distances
- Parameters:
st (obspy.core.stream.Stream) – stream to mute
- Return type:
obspy.core.stream.Stream
- Returns:
muted stream object
- seisflows.tools.signal.mask(slope, const, offset, nt, dt, length=400)
Constructs a tapered mask that can be applied to trace to mute early or late arrivals. Called by the Default preprocessing module.
Note
t_mask = slope * offset + const itmin = t_mask - length/2 itmax = t_mask + length/2 t_array = [itmin, itmax]
offset = || s - r || is distance between source and receiver [m] const has units of time [s] slope has units of time/dist (or velocity**-1) [s/m]
- Parameters:
slope (float) – slope applied to source receiver distance to mute arrivals
const (float) – a constant time offset used to shift the mask in time
offset (float) – source-receiver distance in units of distance
nt (int) – number of samples in the waveform to be masked
dt (float) – sampling rate of the waveform to be masked
length (int) – length, in time of the output mask function
- Return type:
np.array
- Returns:
A mask array that can be directly multipled with a waveform
- seisflows.tools.signal.mute_arrivals(st, slope, const, choice)
Apply a tapered mask to a set of waveforms in a Stream to mute early or late arrivals
- Parameters:
st (obspy.stream) – Stream object containing waveforms to mute
slope (float) – slope applied to source receiver distance to mute arrivals
const (float) – a constant time offset used to shift the mask in time
choice (str) – “early” to mute early arrivals, “late” to mute late arrivals
- Return type:
obspy.stream
- Returns:
muted stream object
- seisflows.tools.signal.mute_offsets(st, dist, choice)
Mute traces based on a given distance (dist)
short: ||s-r|| < dist long: ||s-r|| > dist
- Parameters:
st (obspy.stream) – Stream object containing waveforms to mute
dist (float) – cutoff distancekil
choice (str) – “short” to mute short src-rcv distances, “long” to mute long src-rcv distances
- Return type:
obspy.stream
- Returns:
muted stream object
- seisflows.tools.signal.get_receiver_coords(st)
Retrieve the coordinates from a Stream object. Only works for SU format currently
- Parameters:
st (obspy.core.stream.Stream) – a stream to query for coordinates
- Rtype r_coords:
list
- Return r_coords:
list of receiver coordinates, matching the order in st ([rx], [ry], [rz])
- seisflows.tools.signal.get_source_coords(st)
Get the coordinates of the source object. Only works for SU format currently
- Parameters:
st (obspy.core.stream.Stream) – a stream to query for coordinates
- Rtype s_coords:
tuple of lists
- Return s_coords:
list of source coordinates, matching the order in st ([sx], [sy], [sz])