Synthesize the Test Data

  • The synthesized test data can help us check whether the Green’s function database is correctly calculated.

  • 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.

Source

srcType

  • The type of Source, mt(moment tensor) dc(double-couple) sf(single-couple) ep(explosion).

point

  • The latitude longitude and depth of the source.

source_mechanism

  • Focal mechanism.

  • When srcType = dc: source_mechanism = [Mw, Strike, Dip, Rake]

  • When srcType = mt: source_mechanism = [Mw, Mxx, Mxy, Mxz, Myy, Myz, Mzz]

Station

NET_STA

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

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:

    dura rise delta

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_mode to 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.

Filter

filter_mode

  • Whether to filter.

freqmin

  • The minimum frequency of filtering.

freqmax

  • The maximum frequency of filtering.

Add Noise

Add_noise

  • Whether add noise to syn.

noise_level_waveform

  • Noise level added to the waveform.

noise_level_arrive_time

  • Noise level added to the phase time as tp and ts.

Output

Output_mode

  • Output data or not.

Output_path

  • Path of output data

source_name

  • Event name of output data, you can set it any way you want. Only lowercase letters are supported.

ASDF_filename

  • The name of the output ASDF file

Example

  • The example_path need to de changed to your path, and run this notebook to set syn.json file.

 1#!/usr/bin/env python3
 2# -*- coding: utf-8 -*-
 3
 4import os
 5import sys
 6import json5
 7import shutil
 8
 9# The root directory of the project
10example_path = '/Users/yf/3.Project/8.MCMTpy/MCMTpy-master/data/example_yunnan'
11
12#------------------------------------------------------------#
13# we expect no parameters need to be changed below
14#------------------------------------------------------------#
15# change path to Green_Funcs
16notebook_path = sys.path[0]
17os.chdir(notebook_path)
18os.chdir('../syn')
19print(os.listdir())
20
21# show build_GFs.json 
22filename = 'syn.json'
23with open(filename, 'r',encoding='utf-8') as f1:
24    syn_json=json5.load(f1)
25
26# change parameters with absolute path
27syn_json["GFs_json_file"] = os.path.join(example_path,"Green_Funcs/build_GFs_new.json")
28syn_json["Stf_file"] = os.path.join(example_path,"syn/Stf_file/Stf_file.sac")
29syn_json["Output_path"] = os.path.join(example_path,"syn/Synthetic")       
30syn_json_new = os.path.join(example_path,'syn/syn_new.json')
31
32with open(syn_json_new,'w') as f2:
33    json5.dump(syn_json, f2, indent=2)
34f2.close()
35
36shutil.rmtree('./Synthetic')
37# !MCMTpy syn pyfk  -c ./syn_new.json  > syn.log
  • Now you can run MCMTpy in bash:

    $ MCMTpy  syn pyfk  -c ./syn.json
    
  • View syn waveform:

 1#!/usr/bin/env python3
 2# -*- coding: utf-8 -*-
 3
 4import os
 5import pyasdf
 6
 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## change the path
15h5_path = os.path.join(example_path,'syn/Synthetic/SYN_test.h5')
16source_name = 'source_syn'
17
18### read h5 data --> Sta_data (dict)
19ds_raw=pyasdf.ASDFDataSet(h5_path,mpi=False,mode='r')
20Station_list = ds_raw.waveforms.list()
21Station_num = len(Station_list)
22
23Sta_data={}
24for i in range(0,Station_num,1):
25    info={}
26    tags = ds_raw.waveforms[Station_list[i]].get_waveform_tags()
27    if source_name in tags:
28        raw_sac = ds_raw.waveforms[Station_list[i]][source_name]
29        tp = float( ds_raw.waveforms[Station_list[i]][source_name][0].stats.asdf['labels'][1] )
30        ts = float( ds_raw.waveforms[Station_list[i]][source_name][0].stats.asdf['labels'][3] )
31        info.update({ "tp": tp})  
32        info.update({ "ts": ts})
33        info.update({ "data": raw_sac})
34        Sta_data.update({ Station_list[i]: info})
35
36# plot data
37ax = Sta_data['YN.YUM']['data'].plot()
38Sta_data['YN.YUM']['data'][0].stats

Note

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