initial upload
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
version: 3
|
||||
|
||||
#################################################
|
||||
# computational domian #
|
||||
#################################################
|
||||
domain:
|
||||
min_max_dep: [-10, 50] # depth in km
|
||||
min_max_lat: [0, 2] # latitude in degree
|
||||
min_max_lon: [0, 2] # longitude in degree
|
||||
n_rtp: [61, 61, 61] # number of nodes in depth,latitude,longitude direction
|
||||
|
||||
#################################################
|
||||
# traveltime data file path #
|
||||
#################################################
|
||||
source:
|
||||
src_rec_file: OUTPUT_FILES/OUTPUT_FILES_signal/src_rec_file_forward_errloc.dat # source receiver file path
|
||||
swap_src_rec: true # swap source and receiver
|
||||
|
||||
#################################################
|
||||
# initial model file path #
|
||||
#################################################
|
||||
model:
|
||||
init_model_path: 2_models/model_init_N61_61_61.h5 # path to initial model file
|
||||
|
||||
#################################################
|
||||
# parallel computation settings #
|
||||
#################################################
|
||||
parallel: # parameters for parallel computation
|
||||
n_sims: 8 # number of simultanoues runs (parallel the sources)
|
||||
ndiv_rtp: [1, 1, 1] # number of subdivision on each direction (parallel the computional domain)
|
||||
|
||||
############################################
|
||||
# output file setting #
|
||||
############################################
|
||||
output_setting:
|
||||
output_dir: OUTPUT_FILES/OUTPUT_FILES_joint_step1 # path to output director (default is ./OUTPUT_FILES/)
|
||||
output_final_model: true # output merged final model (final_model.h5) or not.
|
||||
output_in_process: false # output model at each inv iteration or not.
|
||||
output_in_process_data: false # output src_rec_file at each inv iteration or not.
|
||||
output_file_format: 0
|
||||
|
||||
# output files:
|
||||
# File: 'out_data_grid.h5'. Keys: ['Mesh']['elem_conn'], element index;
|
||||
# ['Mesh']['node_coords_p'], phi coordinates of nodes;
|
||||
# ['Mesh']['node_coords_t'], theta coordinates of nodes;
|
||||
# ['Mesh']['node_coords_r'], r coordinates of nodes;
|
||||
# ['Mesh']['node_coords_x'], phi coordinates of elements;
|
||||
# ['Mesh']['node_coords_y'], theta coordinates of elements;
|
||||
# ['Mesh']['node_coords_z'], r coordinates of elements;
|
||||
# File: 'out_data_sim_group_0'. Keys: ['model']['vel_inv_XXXX'], velocity model at iteration XXXX;
|
||||
# ['model']['xi_inv_XXXX'], xi model at iteration XXXX;
|
||||
# ['model']['eta_inv_XXXX'], eta model at iteration XXXX
|
||||
# ['model']['Ks_inv_XXXX'], sensitivity kernel related to slowness at iteration XXXX
|
||||
# ['model']['Kxi_inv_XXXX'], sensitivity kernel related to xi at iteration XXXX
|
||||
# ['model']['Keta_inv_XXXX'], sensitivity kernel related to eta at iteration XXXX
|
||||
# ['model']['Ks_density_inv_XXXX'], kernel density of Ks at iteration XXXX
|
||||
# ['model']['Kxi_density_inv_XXXX'], kernel density of Kxi at iteration XXXX
|
||||
# ['model']['Keta_density_inv_XXXX'], kernel density of Keta at iteration XXXX
|
||||
# ['model']['Ks_over_Kden_inv_XXXX'], slowness kernel over kernel density at iteration XXXX
|
||||
# ['model']['Kxi_over_Kden_inv_XXXX'], xi kernel over kernel density at iteration XXXX
|
||||
# ['model']['Keta_over_Kden_inv_XXXX'], eta kernel over kernel density at iteration XXXX
|
||||
# ['model']['Ks_update_inv_XXXX'], slowness kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['model']['Kxi_update_inv_XXXX'], xi kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['model']['Keta_update_inv_XXXX'], eta kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['1dinv']['vel_1dinv_inv_XXXX'], 2d velocity model at iteration XXXX, in 1d inversion mode
|
||||
# ['1dinv']['r_1dinv'], r coordinates (depth), in 1d inversion mode
|
||||
# ['1dinv']['t_1dinv'], t coordinates (epicenter distance), in 1d inversion mode
|
||||
# File: 'src_rec_file_step_XXXX.dat' or 'src_rec_file_forward.dat'. The synthetic traveltime data file.
|
||||
# File: 'final_model.h5'. Keys: ['eta'], ['xi'], ['vel'], the final model.
|
||||
# File: 'middle_model_step_XXXX.h5'. Keys: ['eta'], ['xi'], ['vel'], the model at step XXXX.
|
||||
# File: 'inversion_grid.txt'. The location of inversion grid nodes
|
||||
# File: 'objective_function.txt'. The objective function value at each iteration
|
||||
# File: 'out_data_sim_group_X'. Keys: ['src_YYYY']['time_field_inv_XXXX'], traveltime field of source YYYY at iteration XXXX;
|
||||
# ['src_YYYY']['adjoint_field_inv_XXXX'], adjoint field of source YYYY at iteration XXXX;
|
||||
# ['1dinv']['time_field_1dinv_YYYY_inv_XXXX'], 2d traveltime field of source YYYY at iteration XXXX, in 1d inversion mode
|
||||
# ['1dinv']['adjoint_field_1dinv_YYYY_inv_XXXX'], 2d adjoint field of source YYYY at iteration XXXX, in 1d inversion mode
|
||||
|
||||
|
||||
#################################################
|
||||
# inversion or forward modeling #
|
||||
#################################################
|
||||
# run mode
|
||||
# 0 for forward simulation only,
|
||||
# 1 for inversion
|
||||
# 2 for earthquake relocation
|
||||
# 3 for inversion + earthquake relocation
|
||||
# 4 for 1d model inversion
|
||||
run_mode: 2
|
||||
|
||||
#################################################
|
||||
# relocation parameters setting #
|
||||
#################################################
|
||||
relocation: # update earthquake hypocenter and origin time (when run_mode : 2 and 3)
|
||||
min_Ndata: 4 # if the number of data of the earthquake is less than <min_Ndata>, the earthquake will not be relocated. defaut value: 4
|
||||
|
||||
# relocation_strategy
|
||||
step_length : 0.01 # initial step length of relocation perturbation. 0.01 means maximum 1% perturbation for each iteration.
|
||||
step_length_decay : 0.9 # if objective function increase, step size -> step length * step_length_decay. default: 0.9
|
||||
rescaling_dep_lat_lon_ortime: [10.0, 15.0, 15.0, 1.0] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
|
||||
max_change_dep_lat_lon_ortime: [10.0, 15.0, 15.0, 1.0] # the change of dep,lat,lon,ortime do not exceed max_change. Unit: km,km,km,second
|
||||
max_iterations : 50 # maximum number of iterations for relocation
|
||||
tol_gradient : 0.0001 # if the norm of gradient is smaller than the tolerance, the iteration of relocation terminates
|
||||
|
||||
# -------------- using absolute traveltime data --------------
|
||||
abs_time:
|
||||
use_abs_time : true # 'yes' for using absolute traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
|
||||
# -------------- using common source differential traveltime data --------------
|
||||
cs_dif_time:
|
||||
use_cs_time : false # 'yes' for using common source differential traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
|
||||
# -------------- using common receiver differential traveltime data --------------
|
||||
cr_dif_time:
|
||||
use_cr_time : true # 'yes' for using common receiver differential traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
@@ -0,0 +1,312 @@
|
||||
version: 3
|
||||
|
||||
#################################################
|
||||
# computational domian #
|
||||
#################################################
|
||||
domain:
|
||||
min_max_dep: [-10, 50] # depth in km
|
||||
min_max_lat: [0, 2] # latitude in degree
|
||||
min_max_lon: [0, 2] # longitude in degree
|
||||
n_rtp: [61, 61, 61] # number of nodes in depth,latitude,longitude direction
|
||||
|
||||
#################################################
|
||||
# traveltime data file path #
|
||||
#################################################
|
||||
source:
|
||||
src_rec_file: OUTPUT_FILES/OUTPUT_FILES_joint_step1/src_rec_file_reloc_0050_obs.dat # source receiver file path
|
||||
swap_src_rec: true # swap source and receiver (only valid for regional source and receiver, those of tele remain unchanged)
|
||||
|
||||
#################################################
|
||||
# initial model file path #
|
||||
#################################################
|
||||
model:
|
||||
init_model_path: 2_models/model_init_N61_61_61.h5 # path to initial model file
|
||||
# model_1d_name: dummy_model_1d_name # 1D model name used in teleseismic 2D solver (iasp91, ak135, user_defined is available), defined in include/1d_model.h
|
||||
|
||||
#################################################
|
||||
# parallel computation settings #
|
||||
#################################################
|
||||
parallel: # parameters for parallel computation
|
||||
n_sims: 8 # number of simultanoues runs (parallel the sources)
|
||||
ndiv_rtp: [1, 1, 1] # number of subdivision on each direction (parallel the computional domain)
|
||||
nproc_sub: 1 # number of processors for sweep parallelization (parallel the fast sweep method)
|
||||
use_gpu: false # true if use gpu (EXPERIMENTAL)
|
||||
|
||||
############################################
|
||||
# output file setting #
|
||||
############################################
|
||||
output_setting:
|
||||
output_dir: OUTPUT_FILES/OUTPUT_FILES_joint_step2 # path to output director (default is ./OUTPUT_FILES/)
|
||||
output_source_field: false # True: output the traveltime field and adjoint field of all sources at each iteration. Default: false. File: 'out_data_sim_group_X'.
|
||||
output_kernel: false # True: output sensitivity kernel and kernel density. Default: false. File: 'out_data_sim_group_X'.
|
||||
output_final_model: true # True: output merged final model. This file can be used as the input model for TomoATT. Default: true. File: 'model_final.h5'.
|
||||
output_middle_model: false # True: output merged intermediate models during inversion. This file can be used as the input model for TomoATT. Default: false. File: 'middle_model_step_XXXX.h5'
|
||||
output_in_process: false # True: output at each inv iteration, otherwise, only output step 0, Niter-1, Niter. Default: true. File: 'out_data_sim_group_0'.
|
||||
output_in_process_data: false # True: output src_rec_file at each inv iteration, otherwise, only output step 0, Niter-2, Niter-1. Default: true. File: 'src_rec_file_step_XXXX.dat'
|
||||
single_precision_output: false # True: output results in single precision. Default: false.
|
||||
verbose_output_level: 0 # output internal parameters, (to do).
|
||||
output_file_format: 0 # 0: hdf5, 1: ascii
|
||||
|
||||
# output files:
|
||||
# File: 'out_data_grid.h5'. Keys: ['Mesh']['elem_conn'], element index;
|
||||
# ['Mesh']['node_coords_p'], phi coordinates of nodes;
|
||||
# ['Mesh']['node_coords_t'], theta coordinates of nodes;
|
||||
# ['Mesh']['node_coords_r'], r coordinates of nodes;
|
||||
# ['Mesh']['node_coords_x'], phi coordinates of elements;
|
||||
# ['Mesh']['node_coords_y'], theta coordinates of elements;
|
||||
# ['Mesh']['node_coords_z'], r coordinates of elements;
|
||||
# File: 'out_data_sim_group_0'. Keys: ['model']['vel_inv_XXXX'], velocity model at iteration XXXX;
|
||||
# ['model']['xi_inv_XXXX'], xi model at iteration XXXX;
|
||||
# ['model']['eta_inv_XXXX'], eta model at iteration XXXX
|
||||
# ['model']['Ks_inv_XXXX'], sensitivity kernel related to slowness at iteration XXXX
|
||||
# ['model']['Kxi_inv_XXXX'], sensitivity kernel related to xi at iteration XXXX
|
||||
# ['model']['Keta_inv_XXXX'], sensitivity kernel related to eta at iteration XXXX
|
||||
# ['model']['Ks_density_inv_XXXX'], kernel density of Ks at iteration XXXX
|
||||
# ['model']['Kxi_density_inv_XXXX'], kernel density of Kxi at iteration XXXX
|
||||
# ['model']['Keta_density_inv_XXXX'], kernel density of Keta at iteration XXXX
|
||||
# ['model']['Ks_over_Kden_inv_XXXX'], slowness kernel over kernel density at iteration XXXX
|
||||
# ['model']['Kxi_over_Kden_inv_XXXX'], xi kernel over kernel density at iteration XXXX
|
||||
# ['model']['Keta_over_Kden_inv_XXXX'], eta kernel over kernel density at iteration XXXX
|
||||
# ['model']['Ks_update_inv_XXXX'], slowness kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['model']['Kxi_update_inv_XXXX'], xi kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['model']['Keta_update_inv_XXXX'], eta kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['1dinv']['vel_1dinv_inv_XXXX'], 2d velocity model at iteration XXXX, in 1d inversion mode
|
||||
# ['1dinv']['r_1dinv'], r coordinates (depth), in 1d inversion mode
|
||||
# ['1dinv']['t_1dinv'], t coordinates (epicenter distance), in 1d inversion mode
|
||||
# File: 'src_rec_file_step_XXXX.dat' or 'src_rec_file_forward.dat'. The synthetic traveltime data file.
|
||||
# File: 'final_model.h5'. Keys: ['eta'], ['xi'], ['vel'], the final model.
|
||||
# File: 'middle_model_step_XXXX.h5'. Keys: ['eta'], ['xi'], ['vel'], the model at step XXXX.
|
||||
# File: 'inversion_grid.txt'. The location of inversion grid nodes
|
||||
# File: 'objective_function.txt'. The objective function value at each iteration
|
||||
# File: 'out_data_sim_group_X'. Keys: ['src_YYYY']['time_field_inv_XXXX'], traveltime field of source YYYY at iteration XXXX;
|
||||
# ['src_YYYY']['adjoint_field_inv_XXXX'], adjoint field of source YYYY at iteration XXXX;
|
||||
# ['1dinv']['time_field_1dinv_YYYY_inv_XXXX'], 2d traveltime field of source YYYY at iteration XXXX, in 1d inversion mode
|
||||
# ['1dinv']['adjoint_field_1dinv_YYYY_inv_XXXX'], 2d adjoint field of source YYYY at iteration XXXX, in 1d inversion mode
|
||||
|
||||
|
||||
#################################################
|
||||
# inversion or forward modeling #
|
||||
#################################################
|
||||
# run mode
|
||||
# 0 for forward simulation only,
|
||||
# 1 for inversion
|
||||
# 2 for earthquake relocation
|
||||
# 3 for inversion + earthquake relocation
|
||||
# 4 for 1d model inversion
|
||||
run_mode: 3
|
||||
|
||||
have_tele_data: false # An error will be reported if false but source out of study region is used. Default: false.
|
||||
|
||||
|
||||
###################################################
|
||||
# model update parameters setting #
|
||||
###################################################
|
||||
model_update:
|
||||
max_iterations: 40 # maximum number of inversion iterations
|
||||
optim_method: 0 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
|
||||
|
||||
#common parameters for all optim methods
|
||||
step_length: 0.02 # the initial step length of model perturbation. 0.01 means maximum 1% perturbation for each iteration.
|
||||
|
||||
# parameters for optim_method 0 (gradient_descent)
|
||||
optim_method_0:
|
||||
step_method: 1 # the method to modulate step size. 0: according to objective function; 1: according to gradient direction
|
||||
# if step_method:0. if objective function increase, step size -> step length * step_length_decay.
|
||||
step_length_decay: 0.9 # default: 0.9
|
||||
# if step_method:1. if the angle between the current and the previous gradients is greater than step_length_gradient_angle, step size -> step length * step_length_change[0].
|
||||
# otherwise, step size -> step length * step_length_change[1].
|
||||
step_length_gradient_angle: 120 # default: 120.0
|
||||
step_length_change: [0.5, 1.2] # default: [0.5,1.2]
|
||||
# Kdensity_coe is used to rescale the final kernel: kernel -> kernel / pow(density of kernel, Kdensity_coe). if Kdensity_coe > 0, the region with less data will be enhanced during the inversion
|
||||
# e.g., if Kdensity_coe = 0, kernel remains upchanged; if Kdensity_coe = 1, kernel is fully normalized. 0.5 or less is recommended if really required.
|
||||
Kdensity_coe: 0 # default: 0.0, limited range: 0.0 - 0.95
|
||||
|
||||
# parameters for optim_method 1 (halve-stepping) or 2 (lbfgs)
|
||||
optim_method_1_2:
|
||||
max_sub_iterations: 20 # maximum number of each sub-iteration
|
||||
regularization_weight: 0.5 # weight value for regularization (lbfgs mode only)
|
||||
coefs_regulalization_rtp: [1, 1, 1] # regularization coefficients for rtp (lbfgs mode only)
|
||||
|
||||
# smoothing
|
||||
smoothing:
|
||||
smooth_method: 0 # 0: multiparametrization, 1: laplacian smoothing (EXPERIMENTAL)
|
||||
l_smooth_rtp: [1, 1, 1] # smoothing coefficients for laplacian smoothing
|
||||
|
||||
# parameters for smooth method 0 (multigrid model parametrization)
|
||||
# inversion grid can be viewed in OUTPUT_FILES/inversion_grid.txt
|
||||
n_inversion_grid: 5 # number of inversion grid sets
|
||||
|
||||
uniform_inv_grid_dep: false # true if use uniform inversion grid for dep, false if use flexible inversion grid
|
||||
uniform_inv_grid_lat: true # true if use uniform inversion grid for lat, false if use flexible inversion grid
|
||||
uniform_inv_grid_lon: true # true if use uniform inversion grid for lon, false if use flexible inversion grid
|
||||
|
||||
# -------------- uniform inversion grid setting --------------
|
||||
# settings for uniform inversion grid
|
||||
n_inv_dep_lat_lon: [12, 9, 9] # number of the base inversion grid points
|
||||
min_max_dep_inv: [-10, 50] # depth in km (Radius of the earth is defined in config.h/R_earth)
|
||||
min_max_lat_inv: [0, 2] # latitude in degree
|
||||
min_max_lon_inv: [0, 2] # longitude in degree
|
||||
|
||||
# -------------- flexible inversion grid setting --------------
|
||||
# settings for flexible inversion grid
|
||||
dep_inv: [-10, 0, 10, 20, 30, 40, 50, 60] # inversion grid for vel in depth (km)
|
||||
lat_inv: [30, 30.2, 30.4, 30.6, 30.8, 31, 31.2, 31.4, 31.6, 31.8, 32] # inversion grid for vel in latitude (degree)
|
||||
lon_inv: [30, 30.2, 30.4, 30.6, 30.8, 31, 31.2, 31.4, 31.6, 31.8, 32] # inversion grid for vel in longitude (degree)
|
||||
trapezoid: [1, 0, 50] # usually set as [1.0, 0.0, 50.0] (default)
|
||||
|
||||
# if we want to use another inversion grid for inverting anisotropy, set invgrid_ani: true (default: false)
|
||||
invgrid_ani: false
|
||||
|
||||
# ---------- uniform inversion grid setting for anisotropy ----------
|
||||
n_inv_dep_lat_lon_ani: [12, 11, 11] # number of the base inversion grid points
|
||||
min_max_dep_inv_ani: [-7, 63] # depth in km (Radius of the earth is defined in config.h/R_earth)
|
||||
min_max_lat_inv_ani: [30, 32] # latitude in degree
|
||||
min_max_lon_inv_ani: [30, 32] # longitude in degree
|
||||
|
||||
# ---------- flexible inversion grid setting for anisotropy ----------
|
||||
# settings for flexible inversion grid for anisotropy
|
||||
dep_inv_ani: [-7, -3, 0, 3, 7, 12, 18, 25, 33, 42, 52, 63] # inversion grid for ani in depth (km)
|
||||
lat_inv_ani: [30, 30.2, 30.4, 30.6, 30.8, 31, 31.2, 31.4, 31.6, 31.8, 32] # inversion grid for ani in latitude (degree)
|
||||
lon_inv_ani: [30, 30.2, 30.4, 30.6, 30.8, 31, 31.2, 31.4, 31.6, 31.8, 32] # inversion grid for ani in longitude (degree)
|
||||
trapezoid_ani: [1, 0, 50] # usually set as [1.0, 0.0, 50.0] (default)
|
||||
|
||||
# Carefully change trapezoid and trapezoid_ani, if you really want to use trapezoid inversion grid, increasing the inversion grid spacing with depth to account for the worse data coverage in greater depths.
|
||||
# The trapezoid_ inversion grid with index (i,j,k) in longitude, latitude, and depth is defined as:
|
||||
# if dep_inv[k] < trapezoid[1], lon = lon_inv[i];
|
||||
# lat = lat_inv[j];
|
||||
# dep = dep_inv[k];
|
||||
# if trapezoid[1] <= dep_inv[k] < trapezoid[2], lon = mid_lon_inv+(lon_inv[i]-mid_lon_inv)*(dep_inv[k]-trapezoid[1])/(trapezoid[2]-trapezoid[1])*trapezoid[0];
|
||||
# lat = mid_lat_inv+(lat_inv[i]-mid_lat_inv)*(dep_inv[k]-trapezoid[1])/(trapezoid[2]-trapezoid[1])*trapezoid[0];
|
||||
# dep = dep_inv[k];
|
||||
# if trapezoid[2] <= dep_inv[k], lon = mid_lon_inv+(lon_inv[i]-mid_lon_inv)*trapezoid[0];
|
||||
# lat = mid_lat_inv+(lat_inv[i]-mid_lat_inv)*trapezoid[0];
|
||||
# dep = dep_inv[k];
|
||||
# The shape of trapezoid inversion gird (x) looks like:
|
||||
#
|
||||
# lon_inv[0] [1] [2] [3] [4]
|
||||
# |<-------- (lon_inv[end] - lon_inv[0]) ---->|
|
||||
# dep_inv[0] | x x x x x |
|
||||
# | |
|
||||
# dep_inv[1] | x x x x x |
|
||||
# | |
|
||||
# dep_inv[2] = trapezoid[1] / x x x x x \
|
||||
# / \
|
||||
# dep_inv[3] / x x x x x \
|
||||
# / \
|
||||
# dep_inv[4] = trapezoid[2] / x x x x x \
|
||||
# | |
|
||||
# dep_inv[5] | x x x x x |
|
||||
# | |
|
||||
# dep_inv[6] | x x x x x |
|
||||
# |<---- trapezoid[0]* (lon_inv[end] - lon_inv[0]) ------>|
|
||||
|
||||
# inversion grid volume rescale (kernel -> kernel / volume of inversion grid mesh),
|
||||
# this precondition may be carefully applied if the sizes of inversion grids are unbalanced
|
||||
invgrid_volume_rescale: false
|
||||
|
||||
# path to station correction file (under development)
|
||||
use_sta_correction: false
|
||||
# initial_sta_correction_file: dummy_sta_correction_file # the path of initial station correction
|
||||
step_length_sta_correction: 0.001 # step length relate to the update of station correction terms
|
||||
|
||||
|
||||
# In the following data subsection, XXX_weight means a weight is assigned to the data, influencing the objective function and gradient
|
||||
# XXX_weight : [d1,d2,w1,w2] means:
|
||||
# if XXX < d1, weight = w1
|
||||
# if d1 <= XXX < d2, weight = w1 + (XXX-d1)/(d2-d1)*(w2-w1), (linear interpolation)
|
||||
# if d2 <= XXX , weight = w2
|
||||
# You can easily set w1 = w2 = 1.0 to normalize the weight related to XXX.
|
||||
# -------------- using absolute traveltime data --------------
|
||||
abs_time:
|
||||
use_abs_time: true # 'true' for using absolute traveltime data to update model parameters; 'false' for not using (no need to set parameters in this section)
|
||||
residual_weight: [1, 3, 1, 1] # XXX is the absolute traveltime residual (second) = abs(t^{obs}_{n,i} - t^{syn}_{n,j})
|
||||
distance_weight: [100, 200, 1, 1] # XXX is epicenter distance (km) between the source and receiver related to the data
|
||||
|
||||
# -------------- using common source differential traveltime data --------------
|
||||
cs_dif_time:
|
||||
use_cs_time: true # 'true' for using common source differential traveltime data to update model parameters; 'false' for not using (no need to set parameters in this section)
|
||||
residual_weight: [1, 3, 1, 1] # XXX is the common source differential traveltime residual (second) = abs(t^{obs}_{n,i} - t^{obs}_{n,j} - t^{syn}_{n,i} + t^{syn}_{n,j}).
|
||||
azimuthal_weight: [15, 30, 1, 1] # XXX is the azimuth difference between two separate stations related to the common source.
|
||||
|
||||
# -------------- using common receiver differential traveltime data --------------
|
||||
cr_dif_time:
|
||||
use_cr_time: false # 'true' for using common receiver differential traveltime data to update model parameters; 'false' for not using (no need to set parameters in this section)
|
||||
residual_weight: [1, 3, 1, 1] # XXX is the common receiver differential traveltime residual (second) = abs(t^{obs}_{n,i} - t^{obs}_{m,i} - t^{syn}_{n,i} + t^{syn}_{m,i})
|
||||
azimuthal_weight: [15, 30, 1, 1] # XXX is the azimuth difference between two separate sources related to the common receiver.
|
||||
|
||||
# -------------- global weight of different types of data (to balance the weight of different data) --------------
|
||||
global_weight:
|
||||
balance_data_weight: true # yes: over the total weight of the each type of the data. no: use original weight (below weight for each type of data needs to be set)
|
||||
abs_time_weight: 1 # weight of absolute traveltime data after balance, default: 1.0
|
||||
cs_dif_time_local_weight: 1 # weight of common source differential traveltime data after balance, default: 1.0
|
||||
cr_dif_time_local_weight: 1 # weight of common receiver differential traveltime data after balance, default: 1.0
|
||||
teleseismic_weight: 1 # weight of teleseismic data after balance, default: 1.0 (exclude in this version)
|
||||
|
||||
# -------------- inversion parameters --------------
|
||||
update_slowness : true # update slowness (velocity) or not. default: true
|
||||
update_azi_ani : true # update azimuthal anisotropy (xi, eta) or not. default: false
|
||||
|
||||
# -------------- for teleseismic inversion (under development) --------------
|
||||
# depth_taper : [d1,d2] means:
|
||||
# if XXX < d1, kernel <- kernel * 0.0
|
||||
# if d1 <= XXX < d2, kernel <- kernel * (XXX-d1)/(d2-d1), (linear interpolation)
|
||||
# if d2 <= XXX , kernel <- kernel * 1.0
|
||||
# You can easily set d1 = -200, d1 = -100 to remove this taper.
|
||||
depth_taper : [-1e+07, -1e+07]
|
||||
|
||||
#################################################
|
||||
# relocation parameters setting #
|
||||
#################################################
|
||||
relocation: # update earthquake hypocenter and origin time (when run_mode : 2 and 3)
|
||||
min_Ndata: 4 # if the number of data of the earthquake is less than <min_Ndata>, the earthquake will not be relocated. defaut value: 4
|
||||
|
||||
# relocation_strategy
|
||||
step_length : 0.01 # initial step length of relocation perturbation. 0.01 means maximum 1% perturbation for each iteration.
|
||||
step_length_decay : 0.9 # if objective function increase, step size -> step length * step_length_decay. default: 0.9
|
||||
rescaling_dep_lat_lon_ortime : [10, 15, 15, 1] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
|
||||
max_change_dep_lat_lon_ortime : [10, 15, 15, 1] # the change of dep,lat,lon,ortime do not exceed max_change. Unit: km,km,km,second
|
||||
max_iterations : 201 # maximum number of iterations for relocation
|
||||
tol_gradient : 0.0001 # if the norm of gradient is smaller than the tolerance, the iteration of relocation terminates
|
||||
|
||||
# -------------- using absolute traveltime data --------------
|
||||
abs_time:
|
||||
use_abs_time : true # 'yes' for using absolute traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
residual_weight : [1, 3, 1, 1] # XXX is the absolute traveltime residual (second) = abs(t^{obs}_{n,i} - t^{syn}_{n,j})
|
||||
distance_weight : [1, 3, 1, 1] # XXX is epicenter distance (km) between the source and receiver related to the data
|
||||
|
||||
# -------------- using common source differential traveltime data --------------
|
||||
cs_dif_time:
|
||||
use_cs_time : false # 'yes' for using common source differential traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
residual_weight : [1, 3, 1, 1] # XXX is the common source differential traveltime residual (second) = abs(t^{obs}_{n,i} - t^{obs}_{n,j} - t^{syn}_{n,i} + t^{syn}_{n,j}).
|
||||
azimuthal_weight : [100, 200, 1, 1] # XXX is the azimuth difference between two separate stations related to the common source.
|
||||
|
||||
# -------------- using common receiver differential traveltime data --------------
|
||||
cr_dif_time:
|
||||
use_cr_time : true # 'yes' for using common receiver differential traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
residual_weight : [15, 30, 1, 1] # XXX is the common receiver differential traveltime residual (second) = abs(t^{obs}_{n,i} - t^{obs}_{m,i} - t^{syn}_{n,i} + t^{syn}_{m,i})
|
||||
azimuthal_weight : [15, 30, 1, 1] # XXX is the azimuth difference between two separate sources related to the common receiver.
|
||||
|
||||
|
||||
# -------------- global weight of different types of data (to balance the weight of different data) --------------
|
||||
global_weight:
|
||||
balance_data_weight: true # yes: over the total weight of the each type of the data. no: use original weight (below weight for each type of data needs to be set)
|
||||
abs_time_local_weight: 1 # weight of absolute traveltime data for relocation after balance, default: 1.0
|
||||
cs_dif_time_local_weight: 1 # weight of common source differential traveltime data for relocation after balance, default: 1.0
|
||||
cr_dif_time_local_weight: 1 # weight of common receiver differential traveltime data for relocation after balance, default: 1.0
|
||||
|
||||
####################################################################
|
||||
# inversion strategy for tomography and relocation #
|
||||
####################################################################
|
||||
inversion_strategy: # update model parameters and earthquake hypocenter iteratively (when run_mode : 3)
|
||||
|
||||
inv_mode : 1 # 0 for update model parameters and relocation iteratively. 1 for update model parameters and relocation simultaneously.
|
||||
|
||||
# for inv_mode : 0, parameters below are required
|
||||
inv_mode_0: # update model for <model_update_N_iter> steps, then update location for <relocation_N_iter> steps, and repeat the process for <max_loop> loops.
|
||||
model_update_N_iter : 1
|
||||
relocation_N_iter : 1
|
||||
max_loop : 10
|
||||
|
||||
# for inv_mode : 1, parameters below are required
|
||||
inv_mode_1: # update model and location simultaneously for <max_loop> loops.
|
||||
max_loop : 40
|
||||
@@ -0,0 +1,139 @@
|
||||
version: 3
|
||||
|
||||
#################################################
|
||||
# computational domian #
|
||||
#################################################
|
||||
domain:
|
||||
min_max_dep: [-10, 50] # depth in km
|
||||
min_max_lat: [0, 2] # latitude in degree
|
||||
min_max_lon: [0, 2] # longitude in degree
|
||||
n_rtp: [61, 61, 61] # number of nodes in depth,latitude,longitude direction
|
||||
|
||||
#################################################
|
||||
# traveltime data file path #
|
||||
#################################################
|
||||
source:
|
||||
src_rec_file: OUTPUT_FILES/OUTPUT_FILES_joint_step2/src_rec_file_inv_0039_reloc_0039_obs.dat # source receiver file path
|
||||
swap_src_rec: true # swap source and receiver (only valid for regional source and receiver, those of tele remain unchanged)
|
||||
|
||||
#################################################
|
||||
# initial model file path #
|
||||
#################################################
|
||||
model:
|
||||
init_model_path: OUTPUT_FILES/OUTPUT_FILES_joint_step2/final_model.h5 # path to initial model file
|
||||
# model_1d_name: dummy_model_1d_name # 1D model name used in teleseismic 2D solver (iasp91, ak135, user_defined is available), defined in include/1d_model.h
|
||||
|
||||
#################################################
|
||||
# parallel computation settings #
|
||||
#################################################
|
||||
parallel: # parameters for parallel computation
|
||||
n_sims: 8 # number of simultanoues runs (parallel the sources)
|
||||
ndiv_rtp: [1, 1, 1] # number of subdivision on each direction (parallel the computional domain)
|
||||
nproc_sub: 1 # number of processors for sweep parallelization (parallel the fast sweep method)
|
||||
use_gpu: false # true if use gpu (EXPERIMENTAL)
|
||||
|
||||
############################################
|
||||
# output file setting #
|
||||
############################################
|
||||
output_setting:
|
||||
output_dir: OUTPUT_FILES/OUTPUT_FILES_joint_step3 # path to output director (default is ./OUTPUT_FILES/)
|
||||
output_source_field: false # True: output the traveltime field and adjoint field of all sources at each iteration. Default: false. File: 'out_data_sim_group_X'.
|
||||
output_kernel: false # True: output sensitivity kernel and kernel density. Default: false. File: 'out_data_sim_group_X'.
|
||||
output_final_model: true # True: output merged final model. This file can be used as the input model for TomoATT. Default: true. File: 'model_final.h5'.
|
||||
output_middle_model: false # True: output merged intermediate models during inversion. This file can be used as the input model for TomoATT. Default: false. File: 'middle_model_step_XXXX.h5'
|
||||
output_in_process: false # True: output at each inv iteration, otherwise, only output step 0, Niter-1, Niter. Default: true. File: 'out_data_sim_group_0'.
|
||||
output_in_process_data: false # True: output src_rec_file at each inv iteration, otherwise, only output step 0, Niter-2, Niter-1. Default: true. File: 'src_rec_file_step_XXXX.dat'
|
||||
single_precision_output: false # True: output results in single precision. Default: false.
|
||||
verbose_output_level: 0 # output internal parameters, (to do).
|
||||
output_file_format: 0 # 0: hdf5, 1: ascii
|
||||
|
||||
# output files:
|
||||
# File: 'out_data_grid.h5'. Keys: ['Mesh']['elem_conn'], element index;
|
||||
# ['Mesh']['node_coords_p'], phi coordinates of nodes;
|
||||
# ['Mesh']['node_coords_t'], theta coordinates of nodes;
|
||||
# ['Mesh']['node_coords_r'], r coordinates of nodes;
|
||||
# ['Mesh']['node_coords_x'], phi coordinates of elements;
|
||||
# ['Mesh']['node_coords_y'], theta coordinates of elements;
|
||||
# ['Mesh']['node_coords_z'], r coordinates of elements;
|
||||
# File: 'out_data_sim_group_0'. Keys: ['model']['vel_inv_XXXX'], velocity model at iteration XXXX;
|
||||
# ['model']['xi_inv_XXXX'], xi model at iteration XXXX;
|
||||
# ['model']['eta_inv_XXXX'], eta model at iteration XXXX
|
||||
# ['model']['Ks_inv_XXXX'], sensitivity kernel related to slowness at iteration XXXX
|
||||
# ['model']['Kxi_inv_XXXX'], sensitivity kernel related to xi at iteration XXXX
|
||||
# ['model']['Keta_inv_XXXX'], sensitivity kernel related to eta at iteration XXXX
|
||||
# ['model']['Ks_density_inv_XXXX'], kernel density of Ks at iteration XXXX
|
||||
# ['model']['Kxi_density_inv_XXXX'], kernel density of Kxi at iteration XXXX
|
||||
# ['model']['Keta_density_inv_XXXX'], kernel density of Keta at iteration XXXX
|
||||
# ['model']['Ks_over_Kden_inv_XXXX'], slowness kernel over kernel density at iteration XXXX
|
||||
# ['model']['Kxi_over_Kden_inv_XXXX'], xi kernel over kernel density at iteration XXXX
|
||||
# ['model']['Keta_over_Kden_inv_XXXX'], eta kernel over kernel density at iteration XXXX
|
||||
# ['model']['Ks_update_inv_XXXX'], slowness kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['model']['Kxi_update_inv_XXXX'], xi kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['model']['Keta_update_inv_XXXX'], eta kernel over kernel density at iteration XXXX, smoothed by inversion grid
|
||||
# ['1dinv']['vel_1dinv_inv_XXXX'], 2d velocity model at iteration XXXX, in 1d inversion mode
|
||||
# ['1dinv']['r_1dinv'], r coordinates (depth), in 1d inversion mode
|
||||
# ['1dinv']['t_1dinv'], t coordinates (epicenter distance), in 1d inversion mode
|
||||
# File: 'src_rec_file_step_XXXX.dat' or 'src_rec_file_forward.dat'. The synthetic traveltime data file.
|
||||
# File: 'final_model.h5'. Keys: ['eta'], ['xi'], ['vel'], the final model.
|
||||
# File: 'middle_model_step_XXXX.h5'. Keys: ['eta'], ['xi'], ['vel'], the model at step XXXX.
|
||||
# File: 'inversion_grid.txt'. The location of inversion grid nodes
|
||||
# File: 'objective_function.txt'. The objective function value at each iteration
|
||||
# File: 'out_data_sim_group_X'. Keys: ['src_YYYY']['time_field_inv_XXXX'], traveltime field of source YYYY at iteration XXXX;
|
||||
# ['src_YYYY']['adjoint_field_inv_XXXX'], adjoint field of source YYYY at iteration XXXX;
|
||||
# ['1dinv']['time_field_1dinv_YYYY_inv_XXXX'], 2d traveltime field of source YYYY at iteration XXXX, in 1d inversion mode
|
||||
# ['1dinv']['adjoint_field_1dinv_YYYY_inv_XXXX'], 2d adjoint field of source YYYY at iteration XXXX, in 1d inversion mode
|
||||
|
||||
|
||||
#################################################
|
||||
# inversion or forward modeling #
|
||||
#################################################
|
||||
# run mode
|
||||
# 0 for forward simulation only,
|
||||
# 1 for inversion
|
||||
# 2 for earthquake relocation
|
||||
# 3 for inversion + earthquake relocation
|
||||
# 4 for 1d model inversion
|
||||
run_mode: 2
|
||||
|
||||
have_tele_data: false # An error will be reported if false but source out of study region is used. Default: false.
|
||||
|
||||
|
||||
#################################################
|
||||
# relocation parameters setting #
|
||||
#################################################
|
||||
relocation: # update earthquake hypocenter and origin time (when run_mode : 2 and 3)
|
||||
min_Ndata: 4 # if the number of data of the earthquake is less than <min_Ndata>, the earthquake will not be relocated. defaut value: 4
|
||||
|
||||
# relocation_strategy
|
||||
step_length : 0.01 # initial step length of relocation perturbation. 0.01 means maximum 1% perturbation for each iteration.
|
||||
step_length_decay : 0.9 # if objective function increase, step size -> step length * step_length_decay. default: 0.9
|
||||
rescaling_dep_lat_lon_ortime : [10, 15, 15, 1] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
|
||||
max_change_dep_lat_lon_ortime : [10, 15, 15, 1] # the change of dep,lat,lon,ortime do not exceed max_change. Unit: km,km,km,second
|
||||
max_iterations : 100 # maximum number of iterations for relocation
|
||||
tol_gradient : 0.0001 # if the norm of gradient is smaller than the tolerance, the iteration of relocation terminates
|
||||
|
||||
# -------------- using absolute traveltime data --------------
|
||||
abs_time:
|
||||
use_abs_time : false # 'yes' for using absolute traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
residual_weight : [1, 3, 1, 1] # XXX is the absolute traveltime residual (second) = abs(t^{obs}_{n,i} - t^{syn}_{n,j})
|
||||
distance_weight : [1, 3, 1, 1] # XXX is epicenter distance (km) between the source and receiver related to the data
|
||||
|
||||
# -------------- using common source differential traveltime data --------------
|
||||
cs_dif_time:
|
||||
use_cs_time : false # 'yes' for using common source differential traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
residual_weight : [1, 3, 1, 1] # XXX is the common source differential traveltime residual (second) = abs(t^{obs}_{n,i} - t^{obs}_{n,j} - t^{syn}_{n,i} + t^{syn}_{n,j}).
|
||||
azimuthal_weight : [100, 200, 1, 1] # XXX is the azimuth difference between two separate stations related to the common source.
|
||||
|
||||
# -------------- using common receiver differential traveltime data --------------
|
||||
cr_dif_time:
|
||||
use_cr_time : true # 'yes' for using common receiver differential traveltime data to update ortime and location; 'no' for not using (no need to set parameters in this section)
|
||||
residual_weight : [15, 30, 1, 1] # XXX is the common receiver differential traveltime residual (second) = abs(t^{obs}_{n,i} - t^{obs}_{m,i} - t^{syn}_{n,i} + t^{syn}_{m,i})
|
||||
azimuthal_weight : [15, 30, 1, 1] # XXX is the azimuth difference between two separate sources related to the common receiver.
|
||||
|
||||
|
||||
# -------------- global weight of different types of data (to balance the weight of different data) --------------
|
||||
global_weight:
|
||||
balance_data_weight: true # yes: over the total weight of the each type of the data. no: use original weight (below weight for each type of data needs to be set)
|
||||
abs_time_local_weight: 1 # weight of absolute traveltime data for relocation after balance, default: 1.0
|
||||
cs_dif_time_local_weight: 1 # weight of common source differential traveltime data for relocation after balance, default: 1.0
|
||||
cr_dif_time_local_weight: 1 # weight of common receiver differential traveltime data for relocation after balance, default: 1.0
|
||||
@@ -0,0 +1,50 @@
|
||||
version: 3
|
||||
|
||||
#################################################
|
||||
# computational domian #
|
||||
#################################################
|
||||
domain:
|
||||
min_max_dep: [-10, 50] # depth in km
|
||||
min_max_lat: [0, 2] # latitude in degree
|
||||
min_max_lon: [0, 2] # longitude in degree
|
||||
n_rtp: [61, 61, 61] # number of nodes in depth,latitude,longitude direction
|
||||
|
||||
#################################################
|
||||
# traveltime data file path #
|
||||
#################################################
|
||||
source:
|
||||
src_rec_file: 1_src_rec_files/src_rec_config.dat # source receiver file path
|
||||
swap_src_rec: true # swap source and receiver
|
||||
|
||||
#################################################
|
||||
# initial model file path #
|
||||
#################################################
|
||||
model:
|
||||
init_model_path: 2_models/model_ckb_N61_61_61.h5 # path to initial model file
|
||||
|
||||
#################################################
|
||||
# parallel computation settings #
|
||||
#################################################
|
||||
parallel: # parameters for parallel computation
|
||||
n_sims: 8 # number of simultanoues runs (parallel the sources)
|
||||
ndiv_rtp: [1, 1, 1] # number of subdivision on each direction (parallel the computional domain)
|
||||
|
||||
############################################
|
||||
# output file setting #
|
||||
############################################
|
||||
output_setting:
|
||||
output_dir: OUTPUT_FILES/OUTPUT_FILES_signal # path to output director (default is ./OUTPUT_FILES/)
|
||||
output_final_model: true # output merged final model (final_model.h5) or not.
|
||||
output_in_process: false # output model at each inv iteration or not.
|
||||
output_in_process_data: false # output src_rec_file at each inv iteration or not.
|
||||
output_file_format: 0
|
||||
|
||||
#################################################
|
||||
# inversion or forward modeling #
|
||||
#################################################
|
||||
# run mode
|
||||
# 0 for forward simulation only,
|
||||
# 1 for inversion
|
||||
# 2 for earthquake relocation
|
||||
# 3 for inversion + earthquake relocation
|
||||
run_mode: 0
|
||||
29
examples/eg3_joint_inversion/README.md
Normal file
29
examples/eg3_joint_inversion/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# joint inversion
|
||||
|
||||
This is a toy model to simultaneously update model parameters and locate earthquakes (Figure 8e.)
|
||||
|
||||
Reference:
|
||||
[1] J. Chen, M. Nagaso, M. Xu, and P. Tong, TomoATT: An open-source package for Eikonal equation-based adjoint-state traveltime tomography for seismic velocity and azimuthal anisotropy, submitted.
|
||||
https://doi.org/10.48550/arXiv.2412.00031
|
||||
|
||||
Python modules are required to initiate the inversion and to plot final results:
|
||||
- h5py
|
||||
- PyTomoAT
|
||||
- Pygmt
|
||||
- gmt
|
||||
|
||||
Run this example:
|
||||
|
||||
1. Run bash script `bash run_this_example.sh` to execute the test.
|
||||
|
||||
2. After inversion, run `plot_output.py` to plot the results.
|
||||
|
||||
The initial and true models:
|
||||
|
||||

|
||||
|
||||
The inversion results:
|
||||
|
||||

|
||||
|
||||
|
||||
34
examples/eg3_joint_inversion/assign_gaussian_noise.py
Normal file
34
examples/eg3_joint_inversion/assign_gaussian_noise.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from pytomoatt.src_rec import SrcRec
|
||||
|
||||
class AssignNoise:
|
||||
def __init__(self, in_fname, out_fname):
|
||||
self.in_fname = in_fname
|
||||
self.out_fname = out_fname
|
||||
self.sr = SrcRec.read(self.in_fname)
|
||||
|
||||
def assign_noise_for_tt(self, noise_level=0.1):
|
||||
self.sr.add_noise(noise_level)
|
||||
|
||||
def assign_noise_for_src(self, lat_pert=0.1, lon_pert=0.1, dep_pert=10, tau_pert=0.5):
|
||||
self.sr.add_noise_to_source(lat_pert, lon_pert, dep_pert, tau_pert)
|
||||
|
||||
if __name__ == "__main__":
|
||||
in_fname = "OUTPUT_FILES/OUTPUT_FILES_signal/src_rec_file_forward.dat" # input source receiver file
|
||||
out_fname = "OUTPUT_FILES/OUTPUT_FILES_signal/src_rec_file_forward_errloc.dat" # output source receiver file
|
||||
sigma = 0.1 # noise level in seconds
|
||||
lat_pert = 0.1 # assign noise for latitude in degrees
|
||||
lon_pert = 0.1 # assign noise for longitude in degrees
|
||||
dep_pert = 10 # assign noise for depth in km
|
||||
tau_pert = 0.5 # assign noise for origin time in seconds
|
||||
|
||||
# Initialize the instance
|
||||
an = AssignNoise(in_fname, out_fname)
|
||||
|
||||
# Assign noise for travel time
|
||||
an.assign_noise_for_tt(sigma)
|
||||
|
||||
# Assign noise for source
|
||||
an.assign_noise_for_src(lat_pert, lon_pert, dep_pert, tau_pert)
|
||||
|
||||
# Write the output file
|
||||
an.sr.write(out_fname)
|
||||
286
examples/eg3_joint_inversion/plot_output.py
Normal file
286
examples/eg3_joint_inversion/plot_output.py
Normal file
@@ -0,0 +1,286 @@
|
||||
# %%
|
||||
import pygmt
|
||||
pygmt.config(FONT="16p", IO_SEGMENT_MARKER="<<<")
|
||||
|
||||
import os
|
||||
|
||||
# %%
|
||||
from pytomoatt.model import ATTModel
|
||||
from pytomoatt.data import ATTData
|
||||
import numpy as np
|
||||
|
||||
# %%
|
||||
# read models
|
||||
|
||||
Ngrid = [61,61,61]
|
||||
data_file = '2_models/model_init_N%d_%d_%d.h5'%(Ngrid[0],Ngrid[1],Ngrid[2])
|
||||
par_file = '3_input_params/input_params_signal.yaml'
|
||||
model = ATTModel.read(data_file, par_file)
|
||||
initial_model = model.to_xarray()
|
||||
|
||||
data_file = '2_models/model_ckb_N%d_%d_%d.h5'%(Ngrid[0],Ngrid[1],Ngrid[2])
|
||||
model = ATTModel.read(data_file, par_file)
|
||||
ckb_model = model.to_xarray()
|
||||
|
||||
# initial model
|
||||
depth = 10.0
|
||||
vel_init = initial_model.interp_dep(depth, field='vel')
|
||||
start = [1.25,0]; end = [1.25,2]
|
||||
vel_init_sec = initial_model.interp_sec(start, end, field='vel', val = 1)
|
||||
|
||||
# checkerboard model
|
||||
vel_ckb = ckb_model.interp_dep(depth, field='vel') # lon = [:,0], lat = [:,1], vel = [:,2]
|
||||
vel_ckb_sec = ckb_model.interp_sec(start, end, field='vel', val = 1)
|
||||
|
||||
# anisotropic arrow
|
||||
samp_interval = 3
|
||||
length = 7
|
||||
width = 0.1
|
||||
ani_thd = 0.02
|
||||
|
||||
ani_ckb_phi = ckb_model.interp_dep(depth, field='phi', samp_interval=samp_interval)
|
||||
ani_ckb_epsilon = ckb_model.interp_dep(depth, field='epsilon', samp_interval=samp_interval)
|
||||
ani_ckb = np.hstack([ani_ckb_phi, ani_ckb_epsilon[:,2].reshape(-1, 1)*length, np.ones((ani_ckb_epsilon.shape[0],1))*width]) # lon, lat, angle, length, width
|
||||
idx = np.where(ani_ckb_epsilon[:,2] > ani_thd)
|
||||
ani_ckb = ani_ckb[idx[0],:]
|
||||
|
||||
try:
|
||||
os.mkdir('img')
|
||||
except:
|
||||
pass
|
||||
|
||||
# %%
|
||||
# read src_rec_file for data
|
||||
from pytomoatt.src_rec import SrcRec
|
||||
|
||||
sr = SrcRec.read('1_src_rec_files/src_rec_config.dat')
|
||||
station = sr.receivers[['stlo','stla','stel']].values.T
|
||||
true_loc = sr.sources[['evlo','evla','evdp']].values.T
|
||||
earthquake = true_loc
|
||||
|
||||
sr = SrcRec.read('OUTPUT_FILES/OUTPUT_FILES_signal/src_rec_file_forward_errloc.dat')
|
||||
init_loc = sr.sources[['evlo','evla','evdp']].values.T
|
||||
|
||||
# %%
|
||||
# categorize earthquakes
|
||||
ev_idx1 = []
|
||||
ev_idx2 = []
|
||||
ev_idx3 = []
|
||||
for i in range(earthquake.shape[1]):
|
||||
dep = earthquake[2,i]
|
||||
if dep < 15:
|
||||
ev_idx1.append(i)
|
||||
elif dep < 25:
|
||||
ev_idx2.append(i)
|
||||
elif dep < 35:
|
||||
ev_idx3.append(i)
|
||||
|
||||
# %%
|
||||
# plot the model setting
|
||||
fig = pygmt.Figure()
|
||||
|
||||
region = [0,2,0,2]
|
||||
frame = ["xa1","ya1"]
|
||||
projection = "M10c"
|
||||
spacing = 0.04
|
||||
|
||||
vel_range = 20
|
||||
|
||||
# -------------- initial model and earthquake location --------------
|
||||
fig.basemap(region=region, frame=["xa1","ya1","+tInitial model and locations"], projection=projection)
|
||||
# velocity perturbation
|
||||
pygmt.makecpt(cmap="../utils/svel13_chen.cpt", series=[-vel_range, vel_range], background=True, reverse=False)
|
||||
x = vel_init[:,0]; y = vel_init[:,1]; value = (vel_init[:,2] - vel_init[:,2])/vel_init[:,2] * 100
|
||||
grid = pygmt.surface(x=x, y=y, z=value, spacing=spacing,region=region)
|
||||
fig.grdimage(grid = grid)
|
||||
# earthquakes
|
||||
fig.plot(x = init_loc[0,ev_idx1], y = init_loc[1,ev_idx1], style = "c0.1c", fill = "red")
|
||||
fig.plot(x = init_loc[0,ev_idx2], y = init_loc[1,ev_idx2], style = "c0.1c", fill = "green")
|
||||
fig.plot(x = init_loc[0,ev_idx3], y = init_loc[1,ev_idx3], style = "c0.1c", fill = "black")
|
||||
|
||||
# stations
|
||||
fig.plot(x = station[0,:], y = station[1,:], style = "t0.4c", fill = "blue", pen = "black", label = "Station")
|
||||
|
||||
# # anisotropic arrow
|
||||
# fig.plot(ani_ckb, style='j', fill='yellow1', pen='0.5p,black')
|
||||
|
||||
fig.shift_origin(xshift=11)
|
||||
|
||||
fig.basemap(region=[0,40,0,2], frame=["xa20+lDepth (km)","ya1","Nswe"], projection="X2c/10c")
|
||||
x = vel_init_sec[:,3]; y = vel_init_sec[:,1]; value = (vel_init_sec[:,4] - vel_init_sec[:,4])/vel_init_sec[:,4] * 100
|
||||
grid = pygmt.surface(x=x, y=y, z=value, spacing="1/0.04",region=[0,40,0,2])
|
||||
fig.grdimage(grid = grid)
|
||||
|
||||
# earthquakes
|
||||
fig.plot(x = init_loc[2,ev_idx1], y = init_loc[1,ev_idx1], style = "c0.1c", fill = "red")
|
||||
fig.plot(x = init_loc[2,ev_idx2], y = init_loc[1,ev_idx2], style = "c0.1c", fill = "green")
|
||||
fig.plot(x = init_loc[2,ev_idx3], y = init_loc[1,ev_idx3], style = "c0.1c", fill = "black")
|
||||
|
||||
|
||||
fig.shift_origin(xshift=4)
|
||||
|
||||
|
||||
# -------------- true model and earthquake location --------------
|
||||
fig.basemap(region=region, frame=["xa1","ya1","+tTrue model and locations"], projection=projection)
|
||||
# velocity perturbation
|
||||
pygmt.makecpt(cmap="../utils/svel13_chen.cpt", series=[-vel_range, vel_range], background=True, reverse=False)
|
||||
x = vel_ckb[:,0]; y = vel_ckb[:,1]; value = (vel_ckb[:,2] - vel_init[:,2])/vel_init[:,2] * 100
|
||||
grid = pygmt.surface(x=x, y=y, z=value, spacing=spacing,region=region)
|
||||
fig.grdimage(grid = grid)
|
||||
# earthquakes
|
||||
fig.plot(x = true_loc[0,ev_idx1], y = true_loc[1,ev_idx1], style = "c0.1c", fill = "red")
|
||||
fig.plot(x = true_loc[0,ev_idx2], y = true_loc[1,ev_idx2], style = "c0.1c", fill = "green")
|
||||
fig.plot(x = true_loc[0,ev_idx3], y = true_loc[1,ev_idx3], style = "c0.1c", fill = "black")
|
||||
|
||||
# stations
|
||||
# fig.plot(x = loc_st[0,:], y = loc_st[1,:], style = "t0.4c", fill = "blue", pen = "black", label = "Station")
|
||||
|
||||
# anisotropic arrow
|
||||
fig.plot(ani_ckb, style='j', fill='yellow1', pen='0.5p,black')
|
||||
|
||||
fig.shift_origin(xshift=11)
|
||||
|
||||
fig.basemap(region=[0,40,0,2], frame=["xa20+lDepth (km)","ya1","Nswe"], projection="X2c/10c")
|
||||
x = vel_ckb_sec[:,3]; y = vel_ckb_sec[:,1]; value = (vel_ckb_sec[:,4] - vel_init_sec[:,4])/vel_init_sec[:,4] * 100
|
||||
grid = pygmt.surface(x=x, y=y, z=value, spacing="1/0.04",region=[0,40,0,2])
|
||||
fig.grdimage(grid = grid)
|
||||
|
||||
# earthquakes
|
||||
fig.plot(x = true_loc[2,ev_idx1], y = true_loc[1,ev_idx1], style = "c0.1c", fill = "red")
|
||||
fig.plot(x = true_loc[2,ev_idx2], y = true_loc[1,ev_idx2], style = "c0.1c", fill = "green")
|
||||
fig.plot(x = true_loc[2,ev_idx3], y = true_loc[1,ev_idx3], style = "c0.1c", fill = "black")
|
||||
|
||||
|
||||
# ------------------- colorbar -------------------
|
||||
fig.shift_origin(xshift=-11, yshift=-1.5)
|
||||
fig.colorbar(frame = ["a%f"%(vel_range),"x+ldlnVp (%)"], position="+e+w4c/0.3c+h")
|
||||
|
||||
fig.shift_origin(xshift=6, yshift=-1)
|
||||
fig.basemap(region=[0,1,0,1], frame=["wesn"], projection="X6c/1.5c")
|
||||
ani = [
|
||||
[0.2, 0.6, 45, 0.02*length, width], # lon, lat, phi, epsilon, size
|
||||
[0.5, 0.6, 45, 0.05*length, width],
|
||||
[0.8, 0.6, 45, 0.10*length, width],
|
||||
]
|
||||
fig.plot(ani, style='j', fill='yellow1', pen='0.5p,black')
|
||||
fig.text(text=["0.02", "0.05", "0.10"], x=[0.2,0.5,0.8], y=[0.2]*3, font="16p,Helvetica", justify="CM")
|
||||
fig.shift_origin(xshift= 11, yshift=2.5)
|
||||
|
||||
fig.show()
|
||||
fig.savefig('img/model_setting.png', dpi=300)
|
||||
|
||||
# %%
|
||||
# plot the joint inversion results
|
||||
|
||||
fig = pygmt.Figure()
|
||||
|
||||
region = [0,2,0,2]
|
||||
projection = "M10c"
|
||||
spacing = 0.04
|
||||
|
||||
vel_range = 20
|
||||
|
||||
tag_list = ["joint_step1", "joint_step2", "joint_step3"]
|
||||
|
||||
for itag, tag in enumerate(tag_list):
|
||||
|
||||
if (tag == "joint_step1"):
|
||||
# model
|
||||
x = vel_init[:,0]; y = vel_init[:,1]; value = (vel_init[:,2] - vel_init[:,2])/vel_init[:,2] * 100
|
||||
x_sec = vel_init_sec[:,3]; y_sec = vel_init_sec[:,1]; value_sec = (vel_init_sec[:,4] - vel_init_sec[:,4])/vel_init_sec[:,4] * 100
|
||||
|
||||
# location
|
||||
sr = SrcRec.read('OUTPUT_FILES/OUTPUT_FILES_%s/src_rec_file_reloc_0050.dat'%(tag))
|
||||
re_loc = sr.sources[['evlo','evla','evdp']].values.T
|
||||
|
||||
frame = ["xa1","ya1","+tStep %d, preliminary location"%(itag+1)]
|
||||
elif (tag == "joint_step2"):
|
||||
# model
|
||||
data_file = "OUTPUT_FILES/OUTPUT_FILES_%s/final_model.h5"%(tag)
|
||||
model = ATTModel.read(data_file, par_file)
|
||||
inv_model = model.to_xarray()
|
||||
vel_inv = inv_model.interp_dep(depth, field='vel') # lon = [:,0], lat = [:,1], vel = [:,2]
|
||||
x = vel_inv[:,0]; y = vel_inv[:,1]; value = (vel_inv[:,2] - vel_init[:,2])/vel_init[:,2] * 100
|
||||
vel_inv_sec = inv_model.interp_sec(start, end, field='vel', val = 1)
|
||||
x_sec = vel_inv_sec[:,3]; y_sec = vel_inv_sec[:,1]; value_sec = (vel_inv_sec[:,4] - vel_init_sec[:,4])/vel_init_sec[:,4] * 100
|
||||
|
||||
ani_inv_phi = inv_model.interp_dep(depth, field='phi', samp_interval=samp_interval)
|
||||
ani_inv_epsilon = inv_model.interp_dep(depth, field='epsilon', samp_interval=samp_interval)
|
||||
ani_inv = np.hstack([ani_inv_phi, ani_inv_epsilon[:,2].reshape(-1, 1)*length, np.ones((ani_inv_epsilon.shape[0],1))*width]) # lon, lat, angle, length, width
|
||||
idx = np.where(ani_inv_epsilon[:,2] > ani_thd)
|
||||
ani = ani_inv[idx[0],:]
|
||||
|
||||
# location
|
||||
sr = SrcRec.read('OUTPUT_FILES/OUTPUT_FILES_%s/src_rec_file_inv_0039_reloc_0039.dat'%(tag))
|
||||
re_loc = sr.sources[['evlo','evla','evdp']].values.T
|
||||
|
||||
frame = ["xa1","ya1","+tStep %d, joint inversion"%(itag+1)]
|
||||
elif (tag == "joint_step3"):
|
||||
|
||||
# model
|
||||
x = vel_inv[:,0]; y = vel_inv[:,1]; value = (vel_inv[:,2] - vel_init[:,2])/vel_init[:,2] * 100
|
||||
x_sec = vel_inv_sec[:,3]; y_sec = vel_inv_sec[:,1]; value_sec = (vel_inv_sec[:,4] - vel_init_sec[:,4])/vel_init_sec[:,4] * 100
|
||||
ani = ani_inv[idx[0],:]
|
||||
|
||||
# location
|
||||
sr = SrcRec.read('OUTPUT_FILES/OUTPUT_FILES_%s/src_rec_file_reloc_0100.dat'%(tag))
|
||||
re_loc = sr.sources[['evlo','evla','evdp']].values.T
|
||||
|
||||
frame = ["xa1","ya1","+tStep %d, relocation"%(itag+1)]
|
||||
|
||||
# plot the inversion result
|
||||
|
||||
|
||||
# -------------- inversion model --------------
|
||||
fig.basemap(region=region, frame=frame, projection=projection)
|
||||
# velocity perturbation
|
||||
pygmt.makecpt(cmap="../utils/svel13_chen.cpt", series=[-vel_range, vel_range], background=True, reverse=False)
|
||||
grid = pygmt.surface(x=x, y=y, z=value, spacing=spacing,region=region)
|
||||
fig.grdimage(grid = grid)
|
||||
# earthquakes
|
||||
fig.plot(x = re_loc[0,ev_idx1], y = re_loc[1,ev_idx1], style = "c0.1c", fill = "red")
|
||||
fig.plot(x = re_loc[0,ev_idx2], y = re_loc[1,ev_idx2], style = "c0.1c", fill = "green")
|
||||
fig.plot(x = re_loc[0,ev_idx3], y = re_loc[1,ev_idx3], style = "c0.1c", fill = "black")
|
||||
|
||||
# stations
|
||||
# fig.plot(x = loc_st[0,:], y = loc_st[1,:], style = "t0.4c", fill = "blue", pen = "black", label = "Station")
|
||||
|
||||
# anisotropic arrow
|
||||
if (tag == "joint_step2" or tag == "joint_step3"):
|
||||
fig.plot(ani, style='j', fill='yellow1', pen='0.5p,black')
|
||||
|
||||
fig.shift_origin(xshift=11)
|
||||
|
||||
fig.basemap(region=[0,40,0,2], frame=["xa20+lDepth (km)","ya1","Nswe"], projection="X2c/10c")
|
||||
grid = pygmt.surface(x=x_sec, y=y_sec, z=value_sec, spacing="1/0.04",region=[0,40,0,2])
|
||||
fig.grdimage(grid = grid)
|
||||
|
||||
# earthquakes
|
||||
fig.plot(x = re_loc[2,ev_idx1], y = re_loc[1,ev_idx1], style = "c0.1c", fill = "red")
|
||||
fig.plot(x = re_loc[2,ev_idx2], y = re_loc[1,ev_idx2], style = "c0.1c", fill = "green")
|
||||
fig.plot(x = re_loc[2,ev_idx3], y = re_loc[1,ev_idx3], style = "c0.1c", fill = "black")
|
||||
|
||||
fig.shift_origin(xshift=4)
|
||||
|
||||
# ------------------- colorbar -------------------
|
||||
fig.shift_origin(xshift=-4)
|
||||
|
||||
fig.shift_origin(xshift=-11, yshift=-1.5)
|
||||
fig.colorbar(frame = ["a%f"%(vel_range),"x+ldlnVp (%)"], position="+e+w4c/0.3c+h")
|
||||
|
||||
fig.shift_origin(xshift=6, yshift=-1)
|
||||
fig.basemap(region=[0,1,0,1], frame=["wesn"], projection="X6c/1.5c")
|
||||
ani = [
|
||||
[0.2, 0.6, 45, 0.02*length, width], # lon, lat, phi, epsilon, size
|
||||
[0.5, 0.6, 45, 0.05*length, width],
|
||||
[0.8, 0.6, 45, 0.10*length, width],
|
||||
]
|
||||
fig.plot(ani, style='j', fill='yellow1', pen='0.5p,black')
|
||||
fig.text(text=["0.02", "0.05", "0.10"], x=[0.2,0.5,0.8], y=[0.2]*3, font="16p,Helvetica", justify="CM")
|
||||
fig.shift_origin(xshift= 11, yshift=2.5)
|
||||
|
||||
|
||||
fig.show()
|
||||
fig.savefig('img/model_joint.png', dpi=300)
|
||||
|
||||
|
||||
63
examples/eg3_joint_inversion/prepare_input_files.py
Normal file
63
examples/eg3_joint_inversion/prepare_input_files.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# download src_ref_files from Zenodo
|
||||
import os
|
||||
import numpy as np
|
||||
import sys
|
||||
try:
|
||||
from pytomoatt.model import ATTModel
|
||||
from pytomoatt.checkerboard import Checker
|
||||
from pytomoatt.src_rec import SrcRec
|
||||
except:
|
||||
print("ERROR: ATTModel not found. Please install pytomoatt first."
|
||||
"See https://tomoatt.github.io/PyTomoATT/installation.html for details.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class BuildInitialModel():
|
||||
def __init__(self, par_file="./3_input_params/input_params_signal.yaml", output_dir="2_models"):
|
||||
"""
|
||||
Build initial model for tomography inversion
|
||||
"""
|
||||
self.am = ATTModel(par_file)
|
||||
self.output_dir = output_dir
|
||||
|
||||
def build_initial_model(self, vel_min=5.0, vel_max=8.0):
|
||||
"""
|
||||
Build initial model for tomography inversion
|
||||
"""
|
||||
self.am.vel[self.am.depths < 0, :, :] = vel_min
|
||||
idx = np.where((0 <= self.am.depths) & (self.am.depths < 40.0))[0]
|
||||
self.am.vel[idx, :, :] = np.linspace(vel_min, vel_max, idx.size)[::-1][:, np.newaxis, np.newaxis]
|
||||
self.am.vel[self.am.depths >= 40.0, :, :] = vel_max
|
||||
|
||||
|
||||
def build_ckb_model(output_dir="2_models"):
|
||||
cbk = Checker(f'{output_dir}/model_init_N61_61_61.h5', para_fname="./3_input_params/input_params_signal.yaml")
|
||||
cbk.checkerboard(
|
||||
n_pert_x=2, n_pert_y=2, n_pert_z=2,
|
||||
pert_vel=0.2, pert_ani=0.1, ani_dir=60.0,
|
||||
lim_x=[0.5, 1.5], lim_y=[0.5, 1.5], lim_z=[0, 40]
|
||||
)
|
||||
cbk.write(f'{output_dir}/model_ckb_N61_61_61.h5')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# download src_rec_config.dat
|
||||
url = 'https://zenodo.org/records/14053821/files/src_rec_config.dat'
|
||||
path = "1_src_rec_files/src_rec_config.dat"
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
if not os.path.exists(path):
|
||||
sr = SrcRec.read(url)
|
||||
sr.write(path)
|
||||
|
||||
# build initial model
|
||||
output_dir = "2_models"
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
bim = BuildInitialModel(output_dir=output_dir)
|
||||
bim.build_initial_model()
|
||||
bim.am.write('{}/model_init_N{:d}_{:d}_{:d}.h5'.format(bim.output_dir, *bim.am.n_rtp))
|
||||
|
||||
# build ckb model
|
||||
build_ckb_model(output_dir)
|
||||
|
||||
|
||||
|
||||
40
examples/eg3_joint_inversion/run_this_example.sh
Normal file
40
examples/eg3_joint_inversion/run_this_example.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
# Step 1: Generate necessary input files
|
||||
python prepare_input_files.py
|
||||
|
||||
# Step 2: Run forward modeling
|
||||
# # for WSL
|
||||
# mpirun -n 8 --allow-run-as-root --oversubscribe ../../build/bin/TOMOATT -i 3_input_params/input_params_signal.yaml
|
||||
# # for Linux
|
||||
# mpirun -n 8 ../../build/bin/TOMOATT -i 3_input_params/input_params_signal.yaml
|
||||
# for conda install
|
||||
mpirun -n 8 TOMOATT -i 3_input_params/input_params_signal.yaml
|
||||
|
||||
# Step 3: Assign data noise and location perturbation to the observational data
|
||||
python assign_gaussian_noise.py
|
||||
|
||||
# Step 4: Do joint inversion
|
||||
# # for WSL
|
||||
# # step 1. relocation for 50 iterations in the initial model, using traveltimes and common-receiver differential arrival times
|
||||
# mpirun -n 8 --allow-run-as-root --oversubscribe ../../build/bin/TOMOATT -i 3_input_params/input_params_joint_step1.yaml
|
||||
# # step 2. simultaneously update model parameters and locations for 40 iterations,
|
||||
# # using traveltimes and common-source differential arrival times for model update
|
||||
# # using traveltimes and common-receiver differential arrival times for location
|
||||
# mpirun -n 8 --allow-run-as-root --oversubscribe ../../build/bin/TOMOATT -i 3_input_params/input_params_joint_step2.yaml
|
||||
# # step 3. relocation for 50 iterations in the initial model, using only common-receiver differential arrival times
|
||||
# mpirun -n 8 --allow-run-as-root --oversubscribe ../../build/bin/TOMOATT -i 3_input_params/input_params_joint_step3.yaml
|
||||
|
||||
# # for Linux
|
||||
# mpirun -n 8 ../../build/bin/TOMOATT -i 3_input_params/input_params_joint_step1.yaml
|
||||
# mpirun -n 8 ../../build/bin/TOMOATT -i 3_input_params/input_params_joint_step2.yaml
|
||||
# mpirun -n 8 ../../build/bin/TOMOATT -i 3_input_params/input_params_joint_step3.yaml
|
||||
|
||||
# for conda install
|
||||
mpirun -n 8 TOMOATT -i 3_input_params/input_params_joint_step1.yaml
|
||||
mpirun -n 8 TOMOATT -i 3_input_params/input_params_joint_step2.yaml
|
||||
mpirun -n 8 TOMOATT -i 3_input_params/input_params_joint_step3.yaml
|
||||
|
||||
# Step 5 (Optional): Plot the results
|
||||
python plot_output.py
|
||||
Reference in New Issue
Block a user