pytomo3d.adjoint package

Submodules

pytomo3d.adjoint.adjsrc module

Methods that handles adjoint sources

copyright:Wenjie Lei (lei@princeton.edu), 2016
license:GNU General Public License, Version 3 (http://www.gnu.org/copyleft/gpl.html)
pytomo3d.adjoint.adjsrc.calculate_adjsrc_on_stream(observed, synthetic, windows, config, adj_src_type, figure_mode=False, figure_dir=None, adjoint_src_flag=True)[source]

calculate adjoint source on a pair of stream and windows selected

Parameters:
  • observed (obspy.Stream) – observed stream
  • synthetic (obspy.Stream) – observed stream
  • windows (list) – list of pyflex windows, like: [[Windows(), Windows(), Windows()], [Windows(), Windows()], ...] For each element, it contains windows for one channel
  • config (pyadjoit.Config) – config for calculating adjoint source
  • adj_src_type (str) – adjoint source type
  • figure_mode (bool) – plot flag. Leave it to True if you want to see adjoint plots for every trace
  • adjoint_src_flag (bool) – adjoint source flag. Set it to True if you want to calculate adjoint sources
Returns:

pytomo3d.adjoint.adjsrc.calculate_adjsrc_on_trace(obs, syn, window_time, config, adj_src_type, figure_mode=False, figure_dir=None, adjoint_src_flag=True)[source]

Calculate adjoint source on a pair of trace and windows selected

Parameters:
  • obs (obspy.Trace) – observed trace
  • syn (obspy.Trace) – synthetic trace
  • window_time – window time information, 2-dimension array, like [[win_1_left, win_1_right], [win_2_left, win_2_right], ...]
  • config (pyadjoint.Config) – config of pyadjoint
  • adj_src_type (str) – adjoint source type, options include: 1) “cc_traveltime_misfit” 2) “multitaper_misfit” 3) “waveform_misfit”
  • adjoint_src_flag (bool) – whether calcualte adjoint source or not. If False, only make measurements
  • plot_flag (bool) – whether make plots or not. If True, it will lot a adjoint source figure right after calculation
Returns:

adjoint source(pyadjoit.AdjointSource)

pytomo3d.adjoint.adjsrc.calculate_baz(elat, elon, slat, slon)[source]

Calculate back azimuth

Parameters:
  • elat – event latitude
  • elon – event longitude
  • slat – station latitude
  • slon – station longitude
Returns:

back azimuth

pytomo3d.adjoint.adjsrc.load_adjoint_config_yaml(filename)[source]

load yaml and setup pyadjoint.Config object

pytomo3d.adjoint.adjsrc.postprocess_adjsrc(adjsrcs, interp_starttime, interp_delta, interp_npts, rotate_flag=False, inventory=None, event=None, sum_over_comp_flag=False, weight_flag=False, weight_dict=None, filter_flag=False, pre_filt=None)[source]

Postprocess adjoint sources to fit SPECFEM input(same as raw_synthetic) 1) zero padding the adjoint sources 2) interpolation 3) add multiple instrument together if there are 4) rotate from (R, T) to (N, E)

Parameters:
  • adjsrcs (list) – adjoint sources list from the same station
  • adj_starttime – starttime of adjoint sources
  • adj_starttime – obspy.UTCDateTime
  • raw_synthetic (obspy.Stream or obspy.Trace) – raw synthetic from SPECFEM output, as reference
  • inventory (obspy.Inventory) – station inventory
  • event (obspy.Event) – event information
  • sum_over_comp_flag – sum over component flag
  • weight_dict – weight dictionary
pytomo3d.adjoint.adjsrc.rotate_adj(adj_stream, event, inventory)[source]
pytomo3d.adjoint.adjsrc.sum_adj_on_component(adj_stream, weight_flag, weight_dict=None)[source]

Sum adjoint source on different channels but same component together, like “II.AAK.00.BHZ” and “II.AAK.10.BHZ” to form “II.AAK.BHZ”

Parameters:
  • adj_stream – adjoint source stream
  • weight_dict

    weight dictionary, should be something like {“Z”:{“II.AAK.00.BHZ”: 0.5, “II.AAK.10.BHZ”: 0.5},

    “R”:{“II.AAK.00.BHR”: 0.3, “II.AAK.10.BHR”: 0.7}, “T”:{“II.AAK..BHT”: 1.0}}
Returns:

summed adjoint source stream

pytomo3d.adjoint.adjsrc.zero_padding_stream(stream, starttime, endtime)[source]

Zero padding the stream to time [starttime, endtime)

pytomo3d.adjoint.plot_util module

Methods that handles plotting adjoint sources

copyright:Wenjie Lei (lei@princeton.edu), 2016
license:GNU General Public License, Version 3 (http://www.gnu.org/copyleft/gpl.html)
pytomo3d.adjoint.plot_util.plot_adjoint_and_data(adjsrc, win_times, obs_tr, syn_tr)[source]
pytomo3d.adjoint.plot_util.plot_adjoint_source(adjsrc, win_times=None, obs_tr=None, syn_tr=None, figname=None)[source]

Plot adjoint source for multiple windows

Parameters:
  • figname (str) – output figure file name
  • adjsrc (pyadjoint.AdjointSource) – adjoint source

:param adjsrc :return:

pytomo3d.adjoint.plot_util.plot_only_adjoint(adjsrc, wintimes=None)[source]

Module contents