pyadjoint.main

Main processing scripts to calculate adjoint sources based on two waveforms

Module Contents

Functions

calculate_adjoint_source(observed, synthetic, config, ...)

Central function of Pyadjoint used to calculate adjoint sources and misfit.

plot_adjoint_source(observed, synthetic, ...)

Generic plotting function for adjoint sources and data.

get_example_data()

Helper function returning example data for Pyadjoint.

pyadjoint.main.calculate_adjoint_source(observed, synthetic, config, windows, plot=False, plot_filename=None, observed_2=None, synthetic_2=None, windows_2=None, **kwargs)[source]

Central function of Pyadjoint used to calculate adjoint sources and misfit.

This function uses the notion of observed and synthetic data to offer a nomenclature most users are familiar with. Please note that it is nonetheless independent of what the two data arrays actually represent.

The function tapers the data from left_window_border to right_window_border, both in seconds since the first sample in the data arrays.

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

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

  • config (configuration parameters that control measurement) – pyadjoint.config.Config

  • windows (list of tuples) – [(left, right),…] representing left and right window borders to be tapered in units of seconds since first sample in data array

  • plot (bool or empty matplotlib.figure.Figure instance) – Also produce a plot of the adjoint source. This will force the adjoint source to be calculated regardless of the value of adjoint_src.

  • plot_filename (str) – If given, the plot of the adjoint source will be saved there. Only used if plot is True.

  • observed_2 (obspy.core.trace.Trace) – second observed waveform to calculate adjoint sources from station pairs

  • synthetic_2 (obspy.core.trace.Trace) – second synthetic waveform to calculate adjoint sources from station pairs

  • windows_2 (list of tuples) – [(left, right),…] representing left and right window borders to be tapered in units of seconds since first sample in data array. Used to window observed_2 and synthetic_2

pyadjoint.main.plot_adjoint_source(observed, synthetic, adjoint_source, misfit, windows, adjoint_source_name)[source]

Generic plotting function for adjoint sources and data.

Many types of adjoint sources can be represented in the same manner. This is a convenience function that can be called by different the implementations for different adjoint sources.

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

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

  • adjoint_source (numpy.ndarray) – The adjoint source.

  • misfit (float) – The associated misfit value.

  • windows (list of tuples) – [(left, right),…] representing left and right window borders to be tapered in units of seconds since first sample in data array

  • adjoint_source_name (str) – The name of the adjoint source.

pyadjoint.main.get_example_data()[source]

Helper function returning example data for Pyadjoint.

The returned data is fully preprocessed and ready to be used with Pyadjoint.

Returns

Tuple of observed and synthetic streams

Return type

tuple of obspy.core.stream.Stream objects

Example

>>> from pyadjoint import get_example_data
>>> observed, synthetic = get_example_data()
>>> print(observed)  
3 Trace(s) in Stream:
SY.DBO.S3.MXR | 2014-11-15T02:31:50.259999Z - ... | 1.0 Hz, 3600 samples
SY.DBO.S3.MXT | 2014-11-15T02:31:50.259999Z - ... | 1.0 Hz, 3600 samples
SY.DBO.S3.MXZ | 2014-11-15T02:31:50.259999Z - ... | 1.0 Hz, 3600 samples
>>> print(synthetic)  
3 Trace(s) in Stream:
SY.DBO..LXR   | 2014-11-15T02:31:50.259999Z - ... | 1.0 Hz, 3600 samples
SY.DBO..LXT   | 2014-11-15T02:31:50.259999Z - ... | 1.0 Hz, 3600 samples
SY.DBO..LXZ   | 2014-11-15T02:31:50.259999Z - ... | 1.0 Hz, 3600 samples