Result Visualization

  • This is the plotting script of the MCMTpy, and all parameters are written into a JSON file named plot.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

plot_output_path,

  • Plot result output file path.

Inv_json_file,

  • The path to the Json-file used in inversion.

fig_format,

  • Output figure format.

Hist

plot_hist

  • Whether to plot hist-figure.

N_start

  • The sequence number of all-FM Markov chain to plot in hist-figure.

N_start_accept

  • The sequence number of all-accept-FM Markov chain to plot in hist-figure.

num_bins

  • Number of grids to draw in hist-figure.

num_std

  • Range of axes in each subgraph (mean +- several times standard deviation). num_std means n times standard deviation.

labels_name

  • Labels’ name, it’s depend on the number parameters that you want to inverse.

  • eg: dc–> [‘mw’,’strike/°’,’dip/°’,’rake/°’,’x/km’,’y/km’,’z/km’,’t0/s’].

  • eg: mt–> [‘Mw’, ‘Mxx’, ‘Myy’, ‘Mzz’, ‘Mxy’, ‘Mxz’, ‘Myz’, ‘x/km’, ‘y/km’, ‘z/km’, ‘t0/s’].

Misfit

plot_misfit

  • Whether to plot misfit-figure.

MPI_n_st

  • Which MPI’s misfit do you want to draw in figure.

Chains_n_st

  • Which Chains’s misfit do you want to draw in figure.

Note

We can only specify a chain of an MPI to draw misfit-figure.

Waveform

plot_waveform

  • Whether to plot waveform-figure.

NET_STA

  • The information contained in the two-dimensional list: [network_name] [station_name] [station_lat] [source_lon] [station_depth]

FM_best

  • The best focal mechanism, 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]

line_n_sta

  • Draw several stations per row in waveform-figure.

max_p_ylim

  • The maximum amplitude of P wave drawing in waveform-figure.

max_s_ylim

  • The maximum amplitude of S wave drawing in waveform-figure.

max_surf_ylim

  • The maximum amplitude of Surf wave drawing in waveform-figure.

plot_comp

  • Which components of the waveform that you want to plot in waveform-figure.

  • The 2-d list represent the three components of P, S and Surf, respectively ZRT.

plot_comp_name

  • Labels’ name, it’s depend on the number parameters that you want to plot with plot_comp.

Example

  • 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# The root directory of the project
 9example_path = '/Users/yf/3.Project/8.MCMTpy/MCMTpy-master/data/example_yunnan'
10
11#------------------------------------------------------------#
12# we expect no parameters need to be changed below
13#------------------------------------------------------------#
14# 1. get notebook path
15notebook_path = sys.path[0]
16os.chdir(notebook_path)
17
18# 2.change path to Green_Funcs
19os.chdir(notebook_path)
20os.chdir('../YN.202105212148_Inv/dc_inv')
21print(os.listdir())
22
23# 3.read plot_dc.json 
24filename = 'plot_dc.json'
25with open(filename, 'r',encoding='utf-8') as f1:
26    plot_dc_json=json5.load(f1)
27
28# 4.change parameters with absolute path
29plot_dc_json["plot_output_path"] = os.path.join(example_path,"YN.202105212148_Inv/dc_inv/figure_dc")
30plot_dc_json["Inv_json_file"] = os.path.join(example_path,"YN.202105212148_Inv/dc_inv/sample_dc_new.json") 
31plot_dc_json_new = os.path.join(example_path,'YN.202105212148_Inv/dc_inv/plot_dc_new.json')
32
33# 5.hist
34plot_dc_json["plot_hist"] =True
35plot_dc_json["N_start"] = 0 
36plot_dc_json["N_start_accept"] = 1
37plot_dc_json["num_bins"] =  50     
38plot_dc_json["num_std"] =5      
39plot_dc_json["labels_name"] = ['Mw','strike/°','dip/°','rake/°','z/km']
40
41# 6. misfit
42plot_dc_json["plot_misfit"] = True
43plot_dc_json["MPI_n_st"] = 0
44plot_dc_json["Chains_n_st"] = 0
45
46# 7. waveform
47plot_dc_json["plot_waveform"] = True
48plot_dc_json["FM_best"] = [6.68,  135.1,  87.0,  -168.1,    25.58,  99.86,  5.95,  -0.57 ]     
49plot_dc_json["line_n_sta"] = 3                                     # Draw the data of several stations in a row
50plot_dc_json["max_p_ylim"] = 1                                     # max amp y-axis of p wave
51plot_dc_json["max_s_ylim"] = 1.0
52plot_dc_json["max_surf_ylim"] = 1
53plot_dc_json["plot_comp"] = [[1,1,0],[0,0,0],[1,1,1]]              # What components do you want to draw? P、S、Surf's Z/R/T
54
55
56with open(plot_dc_json_new,'w') as f2:
57    json5.dump(plot_dc_json, f2, indent=2)
58f2.close()
59
60# 8.run MCMTpy in shell
61os.chdir(notebook_path)
62os.chdir('../YN.202105212148_Inv/dc_inv')
63# !MCMTpy plot pyfk -c plot_dc_new.json > plot.log
  • Now you can run MCMTpy in bash:

    $ MCMTpy plot pyfk -c plot_dc_new.json
    
  • Show hist in jupyter notebook:

    fig_hist = os.path.join(plot_dc_json["plot_output_path"],'hist.jpg')
    Image(filename = fig_hist, width=600)
    
../_images/hist.png
  • Show hist_accept in jupyter notebook:

    fig_hist_accept = os.path.join(plot_dc_json["plot_output_path"],'hist_accept.jpg')
    Image(filename = fig_hist_accept, width=600)
    
../_images/hist_accept.png
  • Show misfit in jupyter notebook:

    fig_misfit = os.path.join(plot_dc_json["plot_output_path"],'misfit.jpg')
    Image(filename = fig_misfit, width=600)
    
../_images/misfit.png
  • Show waveform in jupyter notebook:

    fig_waveform = os.path.join(plot_dc_json["plot_output_path"],'waveform.jpg')
    Image(filename = fig_waveform, width=1000)
    
../_images/waveform.png

Note

Please follow the above parameter instructions and set all parameters correctly before running the program. Otherwise, it is easy to report an error!