seisflows.tools.signal ====================== .. py:module:: seisflows.tools.signal .. autoapi-nested-parse:: 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 --------- .. autoapisummary:: seisflows.tools.signal.filter seisflows.tools.signal.trim seisflows.tools.signal.resample seisflows.tools.signal.normalize seisflows.tools.signal.mute seisflows.tools.signal.mask seisflows.tools.signal.mute_arrivals seisflows.tools.signal.mute_offsets seisflows.tools.signal.get_receiver_coords seisflows.tools.signal.get_source_coords Module Contents --------------- .. py:function:: 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. :type st: obspy.core.stream.Stream :param st: stream to be filtered :rtype: obspy.core.stream.Stream :return: filtered traces .. py:function:: 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. :type st: obspy.core.stream.Stream :param st: Stream that sets the desired time series :type st_trim: obspy.core.stream.Stream :param st_trim: Stream that will have its time series cut to match `st` :rtype: (obspy.core.stream.Stream, obspy.core.stream.Stream) :return: (`st`, trimmed version of `st_trim`) .. py:function:: 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` :type st_a: obspy.core.stream.Stream :param st_a: stream to be resampled using sampling rates from `st_b` :type st_b: obspy.core.stream.Stream :param st_b: stream whose sampling rates will be used to resample `st_a`. Usually this is the synthetic data :rtype: (obspy.core.stream.Stream, obspy.core.stream.Stream) :return: `st_a` (resampled), `st_b` (original) .. py:function:: normalize(st, choice=None, st_rel=None) Normalize amplitudes of Stream object waveforms based on the given choice of normalization function. :type st: obspy.core.stream.Stream :param st: All of the data streams to be normalized :type choice: str :param choice: 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` :type st_rel: obspy.core.stream.Stream :param st_rel: Second stream used for relative normalization. Optional and only required if 'RNORM' set as `choice` :rtype: obspy.core.stream.Stream :return: stream with normalized traces .. py:function:: mute(st) Apply mute on data based on early or late arrivals, and short or long source receiver distances :type st: obspy.core.stream.Stream :param st: stream to mute :rtype: obspy.core.stream.Stream :return: muted stream object .. py:function:: 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] :type slope: float :param slope: slope applied to source receiver distance to mute arrivals :type const: float :param const: a constant time offset used to shift the mask in time :type offset: float :param offset: source-receiver distance in units of distance :type nt: int :param nt: number of samples in the waveform to be masked :type dt: float :param dt: sampling rate of the waveform to be masked :type length: int :param length: length, in time of the output mask function :rtype: np.array :return: A mask array that can be directly multipled with a waveform .. py:function:: mute_arrivals(st, slope, const, choice) Apply a tapered mask to a set of waveforms in a Stream to mute early or late arrivals :type st: obspy.stream :param st: Stream object containing waveforms to mute :type slope: float :param slope: slope applied to source receiver distance to mute arrivals :type const: float :param const: a constant time offset used to shift the mask in time :type choice: str :param choice: "early" to mute early arrivals, "late" to mute late arrivals :rtype: obspy.stream :return: muted stream object .. py:function:: mute_offsets(st, dist, choice) Mute traces based on a given distance (`dist`) short: ||s-r|| < `dist` long: ||s-r|| > `dist` :type st: obspy.stream :param st: Stream object containing waveforms to mute :type dist: float :param dist: cutoff distancekil :type choice: str :param choice: "short" to mute short src-rcv distances, "long" to mute long src-rcv distances :rtype: obspy.stream :return: muted stream object .. py:function:: get_receiver_coords(st) Retrieve the coordinates from a Stream object. Only works for SU format currently :type st: obspy.core.stream.Stream :param st: 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]) .. py:function:: get_source_coords(st) Get the coordinates of the source object. Only works for SU format currently :type st: obspy.core.stream.Stream :param st: 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])