signal

Utility functions for Pyadjoint.

copyright

adjTomo Dev Team (adjtomo@gmail.com), 2022 Lion Krischer (krischer@geophysik.uni-muenchen.de), 2015

license

BSD 3-Clause (“BSD New” or “BSD Simplified”)

Module Contents

Functions

get_window_info(window, dt)

Convenience function to get window start and end times, and start and end

sanity_check_waveforms(observed, synthetic)

Perform a number of basic sanity checks to assure the data is valid

taper_window(trace, left_border_in_seconds, ...)

Helper function to taper a window within a data trace.

window_taper(signal, taper_percentage, taper_type)

Window taper function to taper a time series with various taper functions.

process_cycle_skipping(phi_w, nfreq_max, nfreq_min, wvec)

Check for cycle skipping by looking at the smoothness of phi

Attributes

signal.EXAMPLE_DATA_PDIFF = [800, 900][source]
signal.EXAMPLE_DATA_SDIFF = [1500, 1600][source]
signal.TAPER_COLLECTION = ['cos', 'cos_p10', 'hann', 'hamming'][source]
signal.get_window_info(window, dt)[source]

Convenience function to get window start and end times, and start and end samples. Repeated a lot throughout package so useful to keep it defined in one place.

Parameters
  • window (tuple, list) – (left sample, right sample) borders of window in sample

  • dt (float) – delta T, time step of time series

Return type

tuple (float, float, int)

Returns

(left border in sample, right border in sample, length of window in sample)

signal.sanity_check_waveforms(observed, synthetic)[source]

Perform a number of basic sanity checks to assure the data is valid in a certain sense.

It checks the types of both, the start time, sampling rate, number of samples, etc.

Parameters
  • observed (obspy.core.trace.Trace) – The observed data.

  • synthetic (obspy.core.trace.Trace) – The synthetic data.

Raises

PyadjointError

signal.taper_window(trace, left_border_in_seconds, right_border_in_seconds, taper_percentage, taper_type, **kwargs)[source]

Helper function to taper a window within a data trace. This function modifies the passed trace object in-place.

Parameters
  • trace (obspy.core.trace.Trace) – The trace to be tapered.

  • left_border_in_seconds (float) – The left window border in seconds since the first sample.

  • right_border_in_seconds (float) – The right window border in seconds since the first sample.

  • taper_percentage (float) – Decimal percentage of taper at one end (ranging from 0.0 (0%) to 0.5 (50%)).

  • taper_type (str) – The taper type, supports anything obspy.core.trace.Trace.taper() can use.

Any additional keyword arguments are passed to the obspy.core.trace.Trace.taper() method.

Example

>>> import obspy
>>> tr = obspy.read()[0]
>>> tr.plot()
>>> from pyadjoint.utils.signal import taper_window
>>> taper_window(tr, 4, 11, taper_percentage=0.10, taper_type="hann")
>>> tr.plot()
signal.window_taper(signal, taper_percentage, taper_type)[source]

Window taper function to taper a time series with various taper functions. Affect arrays in place but also returns the array. Both will edit the array.

Parameters
  • signal (ndarray(float)) – time series

  • taper_percentage (float) – total percentage of taper in decimal

  • taper_type (str) – select available taper type, options are: cos, cos_p10, hann, hamming

Returns

tapered signal array

Return type

ndarray(float)

signal.process_cycle_skipping(phi_w, nfreq_max, nfreq_min, wvec, phase_step=1.5)[source]

Check for cycle skipping by looking at the smoothness of phi

Parameters
  • phi_w (np.array) – phase anomaly from transfer functions

  • nfreq_min (int) – minimum frequency for suitable MTM measurement

  • nfreq_max (int) – maximum frequency for suitable MTM measurement

  • phase_step (float) – maximum step for cycle skip correction (?)

  • wvec (np.array) – angular frequency array generated from Discrete Fourier Transform sample frequencies