pycmt3d package

Submodules

pycmt3d.cmt3d module

class pycmt3d.cmt3d.Cmt3D(cmtsource, data_container, config)[source]

Bases: object

Class that handles the solver part of source inversion

Parameters:
  • cmtsource (pycmt3d.CMTSource) – earthquake source
  • data_container – all data and window
  • config (pycmt3d.Config) – configuration for source inversion
apply_station_correction(obsd, synt, istart, iend)[source]

Apply station correction on windows based one cross-correlation time shift if config.station_correction

Parameters:
  • obsd
  • synt
  • istart
  • iend
Returns:

calculate_azimuth_bin()[source]

Calculate the azimuth and sort them into bins

Returns:
calculate_criteria(obsd, synt, istart, iend)[source]

Calculate the time shift, max cross-correlation value and energy differnce

Parameters:
  • obsd (obspy.core.trace.Trace) – observed data trace
  • synt (obspy.core.trace.Trace) – synthetic data trace
  • istart (int) – start index of window
  • iend – end index of window
  • iend – int
Returns:

[number of shift points, max cc value, dlnA]

Return type:

[int, float, float]

calculate_dsyn(datalist)[source]

Calculate dsyn matrix based on perturbed seismograms

Parameters:datalist
Returns:
calculate_kai_total_value()[source]

Calculate the sum of kai value

Returns:
calculate_var_one_trace(obsd, synt, win_time)[source]

Calculate the variance reduction on a pair of obsd and synt and windows

Parameters:
  • obsd (obspy.core.trace.Trace) – observed data trace
  • synt (obspy.core.trace.Trace) – synthetic data trace
  • win_time (list or numpy.array) – [win_start, win_end]
Returns:

waveform misfit reduction and observed data energy [v1, d1]

Return type:

[float, float]

calculate_variance()[source]

Calculate variance reduction based on old and new source solution

Returns:
compute_A_b(window, win_idx, dsyn)[source]

Calculate the matrix A and vector b based on one pair of observed data and synthetic data on a given window.

Parameters:
  • window (pycmt3d.Window) – data and window information
  • win_idx (integer) – window index(a specific window)
  • dsyn (numpy.array) – derivative synthetic data matrix
Returns:

compute_new_syn(datalist, dm)[source]

Compute new synthetic data based on new CMTSOLUTION

Parameters:
  • datalist – dictionary of all data
  • dm – CMTSolution perterbation, i.e., (self.new_cmt_par-self.cmt_par)
Returns:

static construct_hanning_taper(npts)[source]

Hanning taper construct

Parameters:npts – number of points
Returns:
convert_new_cmt_par()[source]

Convert self.new_cmt_par array to CMTSource instance

Returns:
static get_azimuth_bin_number(azimuth)[source]

Calculate the bin number of a given azimuth

Parameters:azimuth – test test test
Returns:
get_station_info(datalist)[source]

Using the event location and station information to calculate azimuth and distance !!! Obsolete, not used any more !!!

Parameters:datalist – data dictionary(referred to pycmt3d.Window.datalist)
Returns:
inversion_result_table()[source]

Print out the inversion table

Returns:
invert_bootstrap()[source]

It is used to evaluate the mean, standard deviation, and variance of new parameters

Returns:
invert_cmt()[source]

ensemble all measurements together to form Matrix A and vector b to solve the A * (dm) = b A is the Hessian Matrix and b is the misfit

Returns:
invert_solver(A, b, print_mode=False)[source]

Solver part. Hession matrix A and misfit vector b will be reconstructed here based on different constraints.

Parameters:
  • A – basic Hessian matrix
  • b – basic misfit vector
  • print_mode – if True, then print out log information; if False, then no log information
Returns:

linear_solver(old_par, A, b, npar, na)[source]

if invert for moment tensor with zero-trace constraints or no constraint

nonlinear_solver(old_par, A, b, npar, na)[source]

if invert for moment tensor with double couple constraints setup starting solution, solve directly for moment instead of dm, exact implementation of (A16) logger.info(‘Non-linear Inversion’)

Returns:
normalize_weight()[source]

Normalize the weighting and make the maximum to 1

Returns:
plot_stats_histogram(outputdir='.', format='png')[source]

Plot inversion histogram

Parameters:outputdir
Returns:
plot_summary(outputdir='.', format='png')[source]

Plot inversion summary

Parameters:outputdir – output directory
Returns:
prepare_for_weighting()[source]

Prepare necessary information for weighting, e.x., calculating azimuth, distance and energty of a window. Also, based on the tags, sort window into different categories.

Returns:
static print_cmtsource_summary(cmt)[source]

Print CMTSolution source summary

Returns:
print_inversion_summary()[source]

Print out the inversion summary

Returns:
setup_matrix()[source]

Calculate A and b for all windows

Returns:
setup_weight(weight_mode='num_wins')[source]

Use Window information to setup weight.

Returns:
setup_weight_for_category(window)[source]

Setup weight for each category if config.normalize_category window_weight = window_weight / N_windows_in_category

Parameters:window
Returns:
setup_weight_for_location(window, naz_bin, naz_bin_all)[source]

setup weight from location information, including distance, component and azimuth

Parameters:
  • window
  • naz_bin
  • naz_bin_all
Returns:

source_inversion()[source]

the Source Inversion method :return:

write_new_cmtfile(outputdir='.')[source]

Write new_cmtsource into a file

write_new_syn(outputdir='.', format='sac')[source]

pycmt3d.config module

Configuration object for pycmt3d

class pycmt3d.config.Config(npar, dlocation=0.0, ddepth=0.0, dmoment=0.0, weight_data=True, weight_function=None, weight_azi_mode='num_files', normalize_window=True, norm_mode='data_only', normalize_category=False, station_correction=True, zero_trace=True, double_couple=False, lamda_damping=0.0, bootstrap=True, bootstrap_repeat=300)[source]

Bases: object

Configuration for source inversion

Parameters:
  • npar – number of parameters to be inverted
  • dlocation – location perturbation when calculated perturbed synthetic data
  • ddepth – depth perturbation
  • dmoment – moment perturbation
  • weight_data – bool value of weighting data
  • weight_function – weighting function
  • normalize_window – add window energy into the weighting term
  • norm_mode – two modes: 1) “data_and_synt” 2) “data_only”
  • station_correction – bool value of whether applies station correction
  • zero_trace – bool value of whether applies zero-trace constraint
  • double_couple – bool value of whether applied double-couple constraint
  • lamda_damping – damping coefficient
  • bootstrap – bool value of whether applied bootstrap method
  • bootstrap_repeat – bootstrap iterations
print_summary()[source]

Print function of configuration

Returns:

pycmt3d.const module

All the constants used in pycmt3d

pycmt3d.source module

Source and Receiver classes of Instaseis.

copyright:Lion Krischer (krischer@geophysik.uni-muenchen.de), 2014 Martin van Driel (Martin@vanDriel.de), 2014
license:GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lgpl.html)
class pycmt3d.source.CMTSource(origin_time=UTCDateTime(1970, 1, 1, 0, 0), pde_latitude=0.0, pde_longitude=0.0, mb=0.0, ms=0.0, pde_depth_in_m=None, region_tag=None, eventname=None, cmt_time=0.0, half_duration=0.0, latitude=0.0, longitude=0.0, depth_in_m=None, m_rr=0.0, m_tt=0.0, m_pp=0.0, m_rt=0.0, m_rp=0.0, m_tp=0.0)[source]

Bases: object

Class to handle a seismic moment tensor source including a source time function.

M0[source]

Scalar Moment M0 in Nm

static adjust_eventname(eventname)[source]

Remove the leading char :param eventname: :return:

classmethod from_CMTSOLUTION_file(filename)[source]

Initialize a source object from a CMTSOLUTION file.

Parameters:filename – path to the CMTSOLUTION file
classmethod from_quakeml_file(filename)[source]

Initizliaze a source object from a quakeml file :param filename: path to a quakeml file

moment_magnitude[source]

Moment magnitude M_w

tensor[source]

List of moment tensor components in r, theta, phi coordinates: [m_rr, m_tt, m_pp, m_rt, m_rp, m_tp]

tensor_voigt[source]

List of moment tensor components in theta, phi, r coordinates in Voigt notation: [m_tt, m_pp, m_rr, m_rp, m_rt, m_tp]

time_shift[source]

Time shift between cmtsolution and pdesolution

write_CMTSOLUTION_file(filename)[source]

Initialize a source object from a CMTSOLUTION file.

Parameters:filename – path to the CMTSOLUTION file

pycmt3d.window module

class pycmt3d.window.DataContainer(par_list=[])[source]

Bases: object

Class that contains methods that load data and window information

add_measurements_from_asdf(flexwinfile, asdf_file_dict, obsd_tag=None, synt_tag=None, stationfile=None, initial_weight=1.0)[source]

Add measurments(window and data) from the given flexwinfile and the data format should be asdf. Usually, you can leave the obsd_tag=None and synt_tag=None unless if you have multiple tags in asdf file.

Parameters:
  • flexwinfile
  • asdf_file_dict
  • tag
Returns:

add_measurements_from_sac(flexwinfile, tag='untaged', initial_weight=1.0, load_mode='obsolute_time')[source]

Add measurments(window and data) from the given flexwinfile and the data format should be sac

Parameters:flexwinfile
Returns:
check_and_load_asdf_file(asdf_file_dict)[source]
get_stationxml_from_asdf(station_string, asdf_handle)[source]

Used to extrace station location information from stationxml in asdf

get_trace_from_asdf(station_string, asdf_handle, tag)[source]

Used to extract a specific trace out of an asdf file.

Parameters:
  • station_string
  • asdf_handle
  • tag
Returns:

load_data_from_asdf(win, asdf_ds, obsd_tag=None, synt_tag=None, station_dict=None)[source]

load data from asdf file

Returns:
load_data_from_sac(win_obj, tag=None, mode=None)[source]

Old way of loading obsd and synt data...

Parameters:win_obj
Returns:
static load_station_from_text(stationfile)[source]
static load_winfile(flexwin_file, initial_weight=1.0)[source]

old way of loading flexwin outputfile

print_summary()[source]

Print summary of data container

Returns:
write_new_syn_file(format='sac', outputdir='.')[source]

Write out new synthetic file based on new cmtsolution :return:

class pycmt3d.window.Window(station=None, network=None, location=None, component=None, num_wins=0, win_time=None, weight=None, obsd_fn=None, synt_fn=None, datalist=None, tag=None, source=None)[source]

Bases: object

Obsd, synt, deriv synt trace and window information from one component of one station. Also, window weighting, station azimuth, distance is also included.

get_location_info(cmtsource)[source]

calculating azimuth and distance, and then store it

Parameters:cmtsource – cmt source
Returns:
win_energy(mode='data_and_synt')[source]

Calculate energy inside the window

Parameters:mode – if mode == ‘data_and_synt’, then energy is calculated by sqrt(obsd_energy * synt_energy); if mode == ‘data_only’, then energy is calculated by obsd_energy only

Module contents

Table Of Contents

Previous topic

Tutorial

This Page