Inversion of Source¶
This is the core of the MCMTpy, and all parameters are written into a JSON file named sample_dc.json. Some brief descriptions of the parameters are included here following the definination.
We do not recommend using relative paths because of the possibility of errors. Absolute paths are preferred.
Path¶
GFs_json_file
The path to the Json-file used to calculate Green Function Database.
GFs_file
The path to the Green Function Database.
Raw_data_file
The path to the Raw data ASDF file.
Source_tag
Raw data ASDF file’s source name which setted in the data preprocess function.
Raw_p_n0
The number of points before the first arrival. Be consistent with the GFs’
samples_before_first_arrival.
Dt
Sampling rate of the raw data.
Output_path
Inversion result output file path.
Source Time Function¶
Trapezoid_stf_mode
Whether to use pyfk provided trapezoid shaped source time function. Set to be .true. you need to set the following parameters correctly:
durarisedelta
dura
Duration time (s).
rise
Rise time (s).
delta
The time interval (s).
Stf_file
Stf_file should be an SAC file as the source time function when set
Trapezoid_stf_modeto be .false..
Note
To read the data from the Stf_file file, keep the sampling rate of SAC data consistent with the data and GFs.
MPI and Chains_n¶
MPI_n
CPU number
Chains_n
A total of n Markov Chains are sampled on each core (CPU).
N
Each Markov Chains’ sampling number.
Misfit¶
Geometrical_spreading_mode
Whether the geometric diffusion correction is turned on or not. Waveform normalization is used when it set to be .false., and please set the magnitude M0 not to be inverted in
Fixed_FM. Only one ofGeometrical_spreading_modeandAmplitude_normalization_modecan be .true..
Distance_0
The reference epicentral distance when
Geometrical_spreading_modeset to be .true..
Amplitude_normalization_mode
Waveform normalization mode.Only one of
Geometrical_spreading_modeandAmplitude_normalization_modecan be .true..
Use_file_mode
When set it to be .false., don’t need to provide
Raw_data_inv_infofile. Setting following parameters (Raw_data_inv_info_writed,NET_STA,P_inv_comp,S_inv_comp,Surf_inv_comp,P_win,S_win,Surf_win,Phase_weight,Distance_weight,P_maxlag,S_maxlag,Surf_maxlag,P_filter,S_filter,Surf_filter) correctly,MCMTpywill generate this file automatically, so you can change individual parameter values and use this file for inversion.Raw_data_inv_info_writedis the filename that generate this file automatically. When set it to be .true.,Raw_data_inv_infois needed which is the path to inversion file.
Raw_data_inv_info
The path to inversion parameters file. It includes the time window length, filtering range, weight and other parameters used for data. When set
Use_file_modeto be .true., it must be provided.Raw_data_inv_info.txt format.
1YN EYA
2Lat_lon_depth 26.108801 99.947502 0.000000
3P_inv_comp yes yes no
4S_inv_comp no no no
5Surf_inv_comp yes yes yes
6P_win -10.00 3.40
7S_win -5.00 25.20
8Surf_win -12.00 50.20
9Phase_weight 1.0 1.0 1.0
10Distance_weight 1.0
11P_maxlag 5.0000
12S_maxlag 15.0000
13Surf_maxlag 10.0000
14P_filter 0.010 0.20
15S_filter 0.010 0.100
16Surf_filter 0.005 0.100
17
18YN YUL
19Lat_lon_depth 25.885401 99.371696 0.000000
20P_inv_comp yes yes no
21S_inv_comp no no no
22Surf_inv_comp yes yes yes
23P_win -10.00 6.20
24S_win -5.00 25.20
25Surf_win -12.00 50.20
26Phase_weight 1.0 1.0 1.0
27Distance_weight 1.0
28P_maxlag 5.0000
29S_maxlag 15.0000
30Surf_maxlag 10.0000
31P_filter 0.010 0.200
32S_filter 0.010 0.100
33Surf_filter 0.005 0.100
Raw_data_inv_info_writed
Raw_data_inv_info_writedis the filename that generate this file automatically When setUse_file_modeto be .true..
NET_STA
The information contained in the two-dimensional list: [network_name] [station_name] [station_lat] [source_lon] [station_depth]
P_inv_comp
P wave Z/R/T component. ‘yes’: inversion. ‘no’: no inversion. Select the component you want to invert.
S_inv_comp
S wave Z/R/T component. ‘yes’: inversion. ‘no’: no inversion. Select the component you want to invert.
Surf_inv_comp
Surf wave Z/R/T component. ‘yes’: inversion. ‘no’: no inversion. Select the component you want to invert.
P_win
P wave P_win=[-1,2] unit/s; The P wave fitting band, and ‘-1’ means 1 second before the P wave, ‘2’ means 2 second after the P wave
S_win
S wave S_win…
Surf_win
Surf wave Surf_win…
Phase_weight
P/S/Surface wave inversion weight
Distance_weight
The weight of each station in
NET_STA
P_maxlag
The maximum number of moveable sampling points to fitting waveform of P wave. It is generally half the period of the P phase waveform. unit/s.
S_maxlag
The maximum number of moveable sampling points to fitting waveform of S wave.
Surf_maxlag
The maximum number of moveable sampling points to fitting waveform of Surf wave.
P_filter
P wave filter range, [freqmin, freqmax].
S_filter
S wave filter range, [freqmin, freqmax].
Surf_filter
Surf wave filter range, [freqmin, freqmax].
Inversion parameters¶
InvType
The type of source, mt(moment tensor) dc(double-couple) sf(single-couple) ep(explosion).
FM0
The initial value of the inversion, it’s a 1-d list.
dc:[m0, str, dip rake, lat, lon, depth, t0] || mt:[m0, m_xx, m_xy, m_xz, m_yy, m_yz, m_zz, lat, lon, depth, t0] || ep:[m0]
The default initial value of t0 is usually 0.
Fixed_FM
The length of the list corresponds to
FM0, and ‘constant’ means fixed to a constant and unchanged in the inversion process. ‘variable’ is represented as a variable and participates in the inversion.
FM_boundary
A 2-d list, FM’s boundary.
Noise_level_waveform
Noise level estimation of raw data.
MISFIT0
The initial error of the objective function, usually set to a very large value.
alpha_max
The initial value of alpha.
alpha_min
The final value of alpha.
a
The alpha function’s parameter.
b
The alpha function’s parameter.
sigma_mw
The standard deviation of the new solution of Mw.
sigma_mt
The standard deviation of the new solution of Moment Tensor.
sigma_dc
The standard deviation of the new solution of Strike Dip Rake.
sigma_sf
The standard deviation of the new solution of Single Couple (not test now).
sigma_ep
The standard deviation of the new solution of Explosion (not test now).
sigma_lat_lon
The standard deviation of the new solution of Latitude and Longitude (degree).
sigma_depth
The standard deviation of the new solution of Source Depth (km).
sigma_t
The standard deviation of the new solution of T0 (s).
Alpha¶
The alpha function is shown in following script, you can test different parameters
alpha_maxalpha_minaband plot thefigure.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3import math
4import numpy as np
5import matplotlib.pyplot as plt
6
7# parameters
8N=5e3
9a=1000 # 0.2*N
10b=100 # 0.04*N
11alpha_max=100
12alpha_min=0
13
14#------------------------------------------------------------#
15# we expect no parameters need to be changed below
16#------------------------------------------------------------#
17tt=np.linspace(0, round(N), num=round(N))
18yy=np.zeros(len(tt))
19for i in range(0,len(tt)):
20 yy[i]=(alpha_max-alpha_min)*(a+math.exp((tt[0]-a)/b))/(a+math.exp((tt[i]-a)/b))+alpha_min
21
22fig, axs = plt.subplots(1,1)
23axs.plot(tt,yy, linestyle='-', color='red', lw=3, alpha=0.6)
24axs.set_xlabel("Sample Number",fontsize=17)
25axs.set_ylabel("Alpha Value",fontsize=17)
26fig.show()
Logging file¶
MCMTpy will generates 1 logging files when it do Inversion, that is Inv_para_info.txt. They record all the parameter information of inversion process. You can find them in
Output_pathpath.
Example Double-Couple Inv¶
The example_path need to de changed to your path, and run this notebook to set sample_dc.json file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4import os
5import sys
6import json5
7
8
9# The root directory of the project
10example_path = '/Users/yf/3.Project/8.MCMTpy/MCMTpy-master/data/example_yunnan'
11
12
13#------------------------------------------------------------#
14# we expect no parameters need to be changed below
15#------------------------------------------------------------#
16# 1. get notebook path
17notebook_path = sys.path[0]
18os.chdir(notebook_path)
19# change path to Green_Funcs
20os.chdir('../YN.202105212148_Inv/dc_inv')
21
22# 2.show build_GFs.json
23filename = 'sample_dc.json'
24with open(filename, 'r',encoding='utf-8') as f1:
25 sample_dc_json=json5.load(f1)
26
27# 3.change parameters with absolute path
28sample_dc_json["GFs_json_file"] = os.path.join(example_path,"Green_Funcs/build_GFs_new.json")
29sample_dc_json["GFs_file"] =os.path.join(example_path,"Green_Funcs/GFs/GFs_splits" )
30sample_dc_json["Raw_data_file"] = os.path.join(example_path,"YN.202105212148_Inv/YN.202105212148_MCMTpy/YN.202105212148.h5")
31sample_dc_json["Output_path"] = os.path.join(example_path,"YN.202105212148_Inv/dc_inv/Output_YN.202105212148_dc")
32sample_dc_json["Raw_data_inv_info"] = os.path.join(example_path,"YN.202105212148_Inv/dc_inv/Raw_data_inv_info.txt")
33sample_dc_json["Raw_data_inv_info_writed"] = os.path.join(example_path,"YN.202105212148_Inv/dc_inv/Raw_data_inv_info_writed.txt")
34sample_dc_json_new = os.path.join(example_path,'YN.202105212148_Inv/dc_inv/sample_dc_new.json')
35
36sample_dc_json["MPI_n"] = 4 # CPU num
37sample_dc_json["Chains_n"] = 4 # Each MK-chains num
38sample_dc_json["N"] = 1e1 # each chain‘s search number
39
40sample_dc_json["alpha_max"] = 100 # The initial value of alpha
41sample_dc_json["alpha_min"] = 0 # The final value of alpha
42sample_dc_json["a"] = 10
43sample_dc_json["b"] = 10
44
45with open(sample_dc_json_new,'w') as f2:
46 json5.dump(sample_dc_json, f2, indent=2)
47f2.close()
48
49# 4.run MCMTpy in shell
50os.chdir(notebook_path)
51os.chdir('../YN.202105212148_Inv/dc_inv')
52# !MCMTpy sample MH -c ./sample_dc_new.json #> sample.log
Now you can run MCMTpy in bash:
$ MCMTpy sample MH -c ./sample_dc_new.json > sample.log
Note
Please follow the above parameter instructions and set all parameters correctly before running the program. Otherwise, it is easy to report an error!