initial upload

This commit is contained in:
2025-12-17 10:53:43 +08:00
commit f3f1778f77
308 changed files with 129940 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,181 @@
import argparse
from ruamel.yaml import YAML
from contextlib import suppress
def map_value_to_bool(params_in, target_key, orig_key=None):
"""
Map an integer value to a boolean and update the target key in params_in.
Parameters:
params_in (dict): The input dictionary.
target_key (str): The key whose value needs to be mapped to a boolean.
Returns:
None
"""
if orig_key is None:
orig_key = target_key
print('key name {} is changed to {}'.format(orig_key, target_key))
value = params_in.get(orig_key, None)
if value is not None:
params_in[target_key] = bool(value)
print('value {} type is changed from int to bool'.format(target_key))
# remove the old key
if orig_key != target_key:
params_in.pop(orig_key, None)
def move_value(params_out, params_in):
try:
params_out = params_in
except KeyError:
print('Cannot move value from {} to {}'.format(params_in, params_out))
if __name__ == '__main__':
# parse the argument for the input file
parser = argparse.ArgumentParser(description='Convert a parameter file from version 2 to version 3')
parser.add_argument('-i', '--input', help='Input file name', required=True)
args = parser.parse_args()
infile = args.input
# path to the v3 model file
v3_model_file = './params_model_v3.yaml'
yaml = YAML()
# read the input file
try:
with open(infile, 'r') as f:
str_in = f.read()
params_in = yaml.load(str_in)
except IOError:
raise ValueError('Cannot read the input file')
# read the v3 model file
try:
with open(v3_model_file, 'r') as f:
str_v3 = f.read()
params_v3 = yaml.load(str_v3)
except IOError:
raise ValueError('Cannot read the v3 model file')
# check the version of the input file
if params_in['version'] != 2:
raise ValueError('The input file is not version 2')
# change version to 3
params_v3['version'] = 3
# copy the values in the input file to the output file
#
# domain section
#
params_v3['domain'] = params_in['domain']
#
# source section
#
params_v3['source'] = params_in['source']
map_value_to_bool(params_v3['source'], 'swap_src_rec')
#
# model section
#
params_v3['model'] = params_in['model']
#
# parallel section
#
params_v3['parallel'] = params_in['parallel']
# change parallel->use_gpu from 0,1 to false,true
map_value_to_bool(params_v3['parallel'], 'use_gpu')
#
# output_setting section
#
move_value(params_v3['output_setting']['output_dir'],params_in['inversion']['output_dir'])
map_value_to_bool(params_v3['output_setting'], 'output_source_field', 'is_output_source_field')
map_value_to_bool(params_v3['output_setting'], 'output_model_dat', 'is_output_model_dat')
map_value_to_bool(params_v3['output_setting'], 'output_final_model', 'is_output_final_model')
map_value_to_bool(params_v3['output_setting'], 'output_in_process', 'is_output_in_process')
map_value_to_bool(params_v3['output_setting'], 'single_precision_output', 'is_single_precision_output')
# remove the old key 'output_setting'->'is_verbose_output'
params_v3['output_setting'].pop('is_verbose_output', None)
move_value(params_v3['output_setting']['output_file_format'], params_in['calculation']['output_file_format'])
#
# run_mode section
#
move_value(params_v3['run_mode'], params_in['inversion']['run_mode'])
#
# model_update section
#
move_value(params_v3['model_update']['max_iterations'], params_in['inversion']['max_iterations_inv'])
move_value(params_v3['model_update']['optim_method'], params_in['inversion']['optim_method'])
move_value(params_v3['model_update']['step_length'], params_in['inversion']['step_size'])
move_value(params_v3['model_update']['optim_method_0']['step_length_decay'], params_in['inversion']['step_size_decay'])
move_value(params_v3['model_update']['optim_method_0']['step_length_sc'], params_in['inversion']['step_size_sc'])
move_value(params_v3['model_update']['optim_method_1_2']['max_sub_iterations'], params_in['inversion']['max_sub_iterations'])
move_value(params_v3['model_update']['optim_method_1_2']['regularization_weight'], params_in['inversion']['regularization_weight'])
move_value(params_v3['model_update']['smoothing']['smooth_method'], params_in['inversion']['smooth_method'])
move_value(params_v3['model_update']['smoothing']['l_smooth_rtp'], params_in['inversion']['l_smooth_rtp'])
move_value(params_v3['model_update']['n_inversion_grid'], params_in['inversion']['n_inversion_grid'])
with suppress(KeyError) : move_value(params_v3['model_update']['type_invgrid_dep'], params_in['inversion']['type_dep_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['type_invgrid_lat'], params_in['inversion']['type_lat_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['type_invgrid_lon'], params_in['inversion']['type_lon_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['n_inv_dep_lat_lon'], params_in['inversion']['n_inv_dep_lat_lon'])
with suppress(KeyError) : move_value(params_v3['model_update']['min_max_dep_inv'], params_in['inversion']['min_max_dep_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['min_max_lat_inv'], params_in['inversion']['min_max_lat_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['min_max_lon_inv'], params_in['inversion']['min_max_lon_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['dep_inv'], params_in['inversion']['dep_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['lat_inv'], params_in['inversion']['lat_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['lon_inv'], params_in['inversion']['lon_inv'])
with suppress(KeyError) : move_value(params_v3['model_update']['sta_correction_file'], params_in['inversion']['sta_correction_file'])
with suppress(KeyError) : move_value(params_v3['model_update']['update_slowness'], params_in['inv_strategy']['is_inv_slowness'])
with suppress(KeyError) : move_value(params_v3['model_update']['update_azi_ani'], params_in['inv_strategy']['is_inv_azi_ani'])
with suppress(KeyError) : move_value(params_v3['model_update']['update_rad_ani'], params_in['inv_strategy']['is_inv_rad_ani'])
map_value_to_bool(params_v3['model_update'], 'update_slowness')
map_value_to_bool(params_v3['model_update'], 'update_azi_ani')
map_value_to_bool(params_v3['model_update'], 'update_rad_ani')
with suppress(KeyError) : move_value(params_v3['model_update']['depth_taper'], params_in['inv_strategy']['kernel_taper'])
with suppress(KeyError) : move_value(params_v3['model_update']['use_sta_correction'], params_in['inv_strategy']['is_sta_correction'])
map_value_to_bool(params_v3['model_update'], 'use_sta_correction')
#
# relocation section
#
# replocation section is completely new in v3, so we don't need to move any value
#
# inversion_strategy section
#
# inversion_strategy section is completely new in v3, so we don't need to move any value
#
# calculation section
#
move_value(params_v3['calculation'], params_in['calculation'])
# write the output file with adding .v3 to the file name
outfile = infile + '.v3.yaml'
with open(outfile, 'w') as f:
yaml.dump(params_v3, f)

View File

@@ -0,0 +1,71 @@
# This script shows how to recompose the output data for further analysis
# As the result data is collectively written out by each process, the data is composed on subgrid basis.
# the data needs to be reindexed and reassembled to a global grid.
import numpy as np
import sys
sys.path.append("../../utils/")
from tomoatt_data_retrieval import get_data_from_h5
#
# plot calculated travel time field
# number of grids
nx = 50
ny = 50
nz = 10
# number of subgrid
ndiv_x = 2
ndiv_y = 2
ndiv_z = 1
# read data
_src_id = 0
_inv_id = 0
# filling 0 for digit
inv_id = str(_inv_id).zfill(4)
src_id = str(_src_id).zfill(4)
# file name
#fname_data = "OUTPUT_FILES/T_res_inv_{}_src_{}.dat".format(inv_id, src_id)
fname_data = "OUTPUT_FILES/out_data_sim_{}.h5".format(_src_id)
# path for grid data
fname_grid = "OUTPUT_FILES/out_data_grid.h5"
# name dataset to be read
dataset_name = "/Data/fun_inv_{}".format(inv_id)
data, r, t, p = get_data_from_h5(fname_data, fname_grid, dataset_name, nz, ny, nx, ndiv_z, ndiv_y, ndiv_x, verbose=True)
# plot
import matplotlib.pyplot as plt
fig, axs = plt.subplots(3, 1, figsize=(15, 5))
#axs[0].imshow(data[5,:,:], cmap='jet', interpolation='bilinear')
ir_slice=5
axs[0].pcolormesh(p[ir_slice,0,:], t[ir_slice,:,0], data[ir_slice,:,:], shading='auto')
axs[0].set_title('lon-lat')
axs[0].set_xlabel('longitude')
axs[0].set_ylabel('latitude')
axs[0].set_aspect(1)
it_slice=15
axs[1].pcolormesh(p[0,it_slice,:], r[:,it_slice,0], data[:,it_slice,:], shading='auto')
axs[1].set_title('r-lon')
axs[1].set_xlabel('longitude')
axs[1].set_ylabel('latitude')
axs[1].set_aspect(10)
ip_slice=15
axs[2].pcolormesh(t[0,:,ip_slice], r[:,0,ip_slice], data[:,:,ip_slice], shading='auto')
axs[2].set_title('r-lat')
axs[2].set_xlabel('longitude')
axs[2].set_ylabel('latitude')
axs[2].set_aspect(10)
plt.tight_layout()
plt.show()

View File

@@ -0,0 +1,49 @@
version : 2
domain :
min_max_dep : [-10.0, 10.0] # depth in km
min_max_lat : [37.7,42.3] # latitude in degree
min_max_lon : [22.7,27.3] # longitude in degree
n_rtp : [10,50,50] # number of nodes
source :
src_rec_file : 'OUTPUT_FILES/src_rec_file_forward.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 1 # swap source and receiver (1: yes, 0: no)
model :
init_model_path : './test_model_init.h5' # path to initial model file (ignored if init_model_type is '1d_*')
inversion :
run_mode : 1 # 0 for forward simulation only, 1 for inversion
optim_method : 1 # optimization method. 0 : "grad_descent", 1 : "halve-stepping", 2 : "lbfgs",
max_iterations_inv : 3 # maximum number of inversion iterations
step_size : 0.001 # step size for inversion
# parameters for multiparametric inversion
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [5,10,10] # number of the base inversion grid points
min_max_dep_inv : [-10.0, 10.0] # depth in km with R = 6371.0
min_max_lat_inv : [37.7,42.3] # latitude in degree
min_max_lon_inv : [22.7,27.3] # longitude in degree
# parameter for halving-stepping or lbfgs
max_sub_iterations : 10 # maximum number of sub-iterations
regularization_weight : 100.0 # regularization weight
#l_smooth_rtp : [10,10,10] #
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,1,1] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-4
max_iterations : 500
stencil_order : 3 # 1 or 3
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_setting :
is_output_source_field : 0 # output the calculated field of all sources 1 for yes; 0 for no; default: 1
is_verbose_output : 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
is_output_model_dat : 0 # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1

View File

@@ -0,0 +1,56 @@
version : 2
domain :
min_max_dep : [-10.0, 10.0] # depth in km
min_max_lat : [37.7,42.3] # latitude in degree
min_max_lon : [22.7,27.3] # longitude in degree
n_rtp : [10,50,50] # number of nodes
source :
src_rec_file : 'OUTPUT_FILES/src_rec_file_forward.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 1 # swap source and receiver (1: yes, 0: no)
model :
init_model_path : './test_model_init.h5' # path to initial model file (ignored if init_model_type is '1d_*')
inversion :
run_mode : 1 # 0 for forward simulation only, 1 for inversion
max_iterations_inv : 20 # maximum number of inversion iterations
step_size : 0.03 # step size for inversion
step_size_decay : 0.7 # if objective function increase, step size -> step size * step_size_decay. default: 0.9
#output_dir : './OUTPUT_FILES_inversion_asc' # default: "./OUTPUT_FILES/"
# parameters for multiparametric inversion
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [5,10,10] # number of the base inversion grid points
min_max_dep_inv : [-10.0, 10.0] # depth in km with R = 6371.0
min_max_lat_inv : [37.7,42.3] # latitude in degree
min_max_lon_inv : [22.7,27.3] # longitude in degree
type_dep_inv : 1 # 0: uniform inversion grid (above), 1: flexible grid, manually designed (following)
dep_inv : [-15,-10,-5,0,5,10,15]
type_lat_inv : 0 # 0: uniform inversion grid (above), 1: flexible grid, manually designed (following)
lat_inv : []
type_lon_inv : 0 # 0: uniform inversion grid (above), 1: flexible grid, manually designed (following)
lon_inv : []
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [2,2,2] # number of subdomains
nproc_sub : 1 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-4
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_file_format : 0 # 0: hdf5, 1: ascii
output_setting :
is_output_source_field : 0 # output the calculated field of all sources 1 for yes; 0 for no; default: 1
is_verbose_output : 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
is_output_model_dat : 0 # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
#is_output_in_process : 0 # output the model file in process or not. 1 for yes; 0 for no; default: 1

View File

@@ -0,0 +1,34 @@
version : 2
domain :
min_max_dep : [-10.0, 10.0] # depth in km
min_max_lat : [37.7,42.3] # latitude in degree
min_max_lon : [22.7,27.3] # longitude in degree
n_rtp : [10,50,50] # number of nodes
source :
src_rec_file : 'src_rec_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 1 # swap source and receiver (1: yes, 0: no)
model :
init_model_path : './test_model_true.h5' # path to initial model file (ignored if init_model_type is '1d_*')
inversion :
run_mode : 0 # 0 for forward simulation only, 1 for inversion
n_inversion_grid : 1
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,1,1] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-4
max_iterations : 500
stencil_order : 3 # 1 or 3
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_setting :
is_output_source_field : 0 # output the calculated field of all sources 1 for yes; 0 for no; default: 1
is_verbose_output : 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
is_output_model_dat : 0 # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1

View File

@@ -0,0 +1,182 @@
version : 3 # the third version of input parameters
#################################################
# computational domian #
#################################################
domain : # computational domain for forward simulation and inversion
min_max_dep : [-10.0, 50.0] # depth in km
min_max_lat : [34.5,40.5] # latitude in degree
min_max_lon : [34.5,40.5] # longitude in degree
n_rtp : [61,61,61] # number of nodes for forward modeling. 'ntp' represents dep,lat,lon
#################################################
# traveltime data file path #
#################################################
source :
src_rec_file : 'src_rec.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 0 # swap source and receiver (1: yes, 0: no)
#################################################
# initial model file path #
#################################################
model :
init_model_path : 'model_init_N61_61_61.h5' # path to initial model file (ignored if init_model_type is '1d_*')
#################################################
# parallel setting for HPC #
#################################################
parallel :
n_sims : 5 # number of simultaneous run: (highest parallel efficiency) parallel the source, usually less than Number of sources over 4
ndiv_rtp : [1,1,1] # number of subdomains in depth, latitude, longitude: (moderate parallel efficiency) use domain decomposition to parallel the computational of traveltime field of each source
nproc_sub : 1 # number of subprocess used for each subdomain (low parallel efficiency, usually set 1)
use_gpu: 0 # 1 if use gpu (EXPERIMENTAL)
############################################
# output file setting #
############################################
output_setting :
output_dir : 'progrma_test/2-local_image/OUTPUT_FILES_abs_single' # default: "./OUTPUT_FILES/"
is_output_source_field : no # output the calculated field of all sources default: yes
is_output_model_dat : yes # output model_parameters_inv_0000.dat (txt format) or not (high I/O cost). default: no
is_output_final_model: yes # output merged final model or not. default: yes
is_output_in_process: yes # output model at each inv iteration or not. default: yes
is_single_precision_output: no # output results in single precision or not. default: no
verbose_output_level : 0 # output internal parameters, if 0, only model parameters are out. Higher level, more internal parameters are output. default: 0
#################################################
# inversion or forward modeling #
#################################################
run_mode : 1 # 0 for forward simulation only, 1 for inversion and location
###################################################
# model update parameters setting #
###################################################
model_update : # update model parameters (when run_mode : 1)
yes_or_no : yes # 'yes' for updating model parameters; 'no' for not updating model paramters (no need to set parameters in this section);
# -------------- model_update_strategy -----------------
max_iterations : 5 # maximum number of iterations for model update
optim_method: 0 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
optim_method_0: # for gradient descent method
step_length : 0.01 # step length of model perturbation at each iteration. 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
optim_method_1_2: # for halve-stepping or lbfgs method
max_sub_iterations: 20 # maximum number of each sub-iteration
l_smooth_rtp: [1, 1, 1] # smoothing coefficients for laplacian smoothing
regularization_weight: 0.5 # weight value for regularization (lbfgs mode only)
# -------------- multigrid model parameterization -----------------
n_inversion_grid : 5 # number of inversion grid sets
# flexible inversion grid (if type_*_inv : 1)
type_dep_inv : 1 # 0: use <min_max_dep_inv> to generate uniform inversion grid for depth, 1: use <dep_inv> to generate flexible inversion grid for depth
dep_inv : [-7.0, -3.0, 0.0, 3.0, 7.0, 12.0, 18.0, 25.0, 33.0, 42.0, 52.0, 63.0]
type_lat_inv : 0 # 0: use <min_max_lat_inv> to generate uniform inversion grid for latitude, 1: use <lat_inv> to generate flexible inversion grid for latitude
lat_inv : [0.0, 1.0]
type_lon_inv : 0 # 0: use <min_max_lon_inv> to generate uniform inversion grid for longitude, 1: use <lon_inv> to generate flexible inversion grid for longitude
lon_inv : [0.0, 1.0]
# uniform inversion grid (if type_*_inv : 0)
n_inv_dep_lat_lon : [10,10,10] # number of the base inversion grid points
min_max_dep_inv : [-10.0, 40.0] # depth in km with R = 6371.0
min_max_lat_inv : [34.5,40.5] # latitude in degree
min_max_lon_inv : [34.5,40.5] # longitude in degree
# -------------- using absolute traveltime data --------------
abs_time:
yes_or_no : yes # 'yes' for using absolute traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight : [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- using common source differential traveltime data --------------
cs_dif_time:
yes_or_no : yes # 'yes' for using common source differential traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight : [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two stations.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
yes_or_no : yes # 'yes' for using common receiver differential traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight : [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two earthquakes.
# -------------- global weight of different types of data (to balance the weight of different data) --------------
global_weight:
is_balance_data_weight : yes # yes: over the total weight of the each type of the data. the obj of different data means the average data misfit; no: use original weight (below weight for each type of data needs to be set)
abs_time_weight : 1.0 # weight of absolute traveltime data, default: 1.0
cs_dif_time_local_weight : 1.0 # weight of common source differential traveltime data, default: 1.0
cr_dif_time_local_weight : 1.0 # weight of common receiver differential traveltime data, default: 1.0
teleseismic_weight : 1.0 # weight of teleseismic data, default: 1.0 (exclude in this version)
# -------------- inversion parameters (exclude in this version) --------------
is_inv_slowness : yes # update slowness (velocity) or not. default: yes
is_inv_azi_ani : no # update azimuthal anisotropy (xi, eta) or not. default: no
is_inv_rad_ani : no # update radial anisotropy (in future) or not. default: no
# -------------- for teleseismic inversion (exclude in this version) --------------
depth_taper : [-200.0, -100.0] # kernel weight : depth. --> 0: -inf ~ taper[0]; 0 ~ 1 : taper[0] ~ taper[1]; 1 : taper[1] ~ inf
#################################################
# relocation parameters setting #
#################################################
relocation: # update earthquake hypocenter and origin time (when run_mode : 1)
yes_or_no : yes # 'yes' for relocating earthquakes; 'no' for not relocating earthquakes (no need to set parameters in this section);
# relocation_strategy
step_length : 0.01 # step length of relocation perturbation at each iteration. 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, 10.0, 10.0, 1.0] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
max_change_dep_lat_lon_ortime : [5.0, 5.0, 5.0, 0.5] # 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
# more option for using different types of data is under development (following)
# -------------- using absolute traveltime data --------------
abs_time:
yes_or_no : yes # 'yes' for using absolute traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight : [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
yes_or_no : yes # 'yes' for using common receiver differential traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
distance_weight : [10.0, 30.0, 1.0, 0.1] # weight of distance (km) between two earthquakes.
####################################################################
# inversion strategy for tomography and relocation #
####################################################################
inversion_strategy: # if both update model parameters (yes) and relocation (yes), set inversion strategies here
inv_mode : 0 # 0 for update model parameters and relocation iteratively. (other options for future work)
# for inv_mode : 0, parameters below are required
inv_mode_0: # Fristly, do relocation; Subsequently, do relocation every N steps; Finally, do relocation
relocation_first : yes # yes: do relocation first; no: do not relocation first. default: yes
relocation_first_iterations : 10 # maximum number of iterations for relocation in the beginning. default: 10
relocation_every_N_steps : 5 # subsequently, do relocation every N steps of updating model parameters. The iteration of relocation follows <max_iterations> in Section <relocation>
relocation_final : yes # yes: do relocation finally; no: do not relocation finally. default: yes
relocation_final_iterations : 10 # maximum number of iterations for relocation in the beginning. default: 10
########################################################################
# Scheme of Eikonal solver (fast sweeping method) #
########################################################################
calculation : # prefer not to change the default value unless well know the detail
convergence_tolerance : 1e-6 # threshold for determining the convergence of the eikonal solver, default: 1e-6
max_iterations : 500 # max itertions of the eikonal solver default: 500
stencil_order : 1 # 1 for first order discretization; 3 for 3rd order WENO discretization. default: 1
stencil_type : 1 # 0 for no upwind scheme; 1 for upwind scheme; default: 1
sweep_type : 0 # 0: legacy, 1: cuthill-mckee with shm parallelization default: 0

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,241 @@
# %% [markdown]
# # notebook for create init and true test model
# %%
import numpy as np
import math
# grid
R_earth = 6371.0
rr1=6361
rr2=6381
tt1=(38.0-0.3)/180*math.pi
tt2=(42.0+0.3)/180*math.pi
pp1=(23.0-0.3)/180*math.pi
pp2=(27.0+0.3)/180*math.pi
n_rtp = [10,50,50]
dr = (rr2-rr1)/(n_rtp[0]-1)
dt = (tt2-tt1)/(n_rtp[1]-1)
dp = (pp2-pp1)/(n_rtp[2]-1)
rr = np.array([rr1 + x*dr for x in range(n_rtp[0])])
tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])
pp = np.array([pp1 + x*dp for x in range(n_rtp[2])])
# initial model
gamma = 0.0
s0 = 1.0/6.0
slow_p=0.06
ani_p=0.04
eta_init = np.zeros(n_rtp)
xi_init = np.zeros(n_rtp)
zeta_init = np.zeros(n_rtp)
fun_init = np.zeros(n_rtp)
vel_init = np.zeros(n_rtp)
# true model
eta_true = np.zeros(n_rtp)
xi_true = np.zeros(n_rtp)
zeta_true = np.zeros(n_rtp)
fun_true = np.zeros(n_rtp)
vel_true = np.zeros(n_rtp)
c=0
for ir in range(n_rtp[0]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[2]):
# already initialized above
#eta_init[ir,it,ip] = 0.0
#xi_init[ir,it,ip] = 0.0
zeta_init[ir,it,ip] = gamma*math.sqrt(eta_init[ir,it,ip]**2 + xi_init[ir,it,ip]**2)
fun_init[ir,it,ip] = s0
vel_init[ir,it,ip] = 1.0/s0
# true model
if (tt[it] >= 38.0/180.0*math.pi and tt[it] <= 42.0/180.0*math.pi \
and pp[ip] >= 23.0/180.0*math.pi and pp[ip] <= 27.0/180.0*math.pi):
c+=1
sigma = math.sin(2.0*math.pi*(tt[it]-38.0/180.0*math.pi)/(4.0/180.0*math.pi))*math.sin(2.0*math.pi*(pp[ip]-23.0/180.0*math.pi)/(4.0/180.0*math.pi))
else:
sigma = 0.0
if sigma < 0:
psi = 60.0/180.0*math.pi
elif sigma > 0:
psi = 120.0/180.0*math.pi
else:
psi = 0.0
eta_true[ir,it,ip] = ani_p*abs(sigma)*math.sin(2.0*psi)
xi_true[ir,it,ip] = ani_p*abs(sigma)*math.cos(2.0*psi)
zeta_true[ir,it,ip] = gamma*math.sqrt(eta_true[ir,it,ip]**2 + xi_true[ir,it,ip]**2)
fun_true[ir,it,ip] = s0/(1.0+sigma*slow_p)
vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip]
#r_earth = 6378.1370
print("depminmax {} {}".format(R_earth-rr1,R_earth-rr2))
print(c)
# %%
# write out in hdf5 format
import h5py
fout_init = h5py.File('test_model_init.h5', 'w')
fout_true = h5py.File('test_model_true.h5', 'w')
# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init
fout_init.create_dataset('eta', data=eta_init)
fout_init.create_dataset('xi', data=xi_init)
fout_init.create_dataset('zeta', data=zeta_init)
fout_init.create_dataset('vel', data=vel_init)
# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true
fout_true.create_dataset('eta', data=eta_true)
fout_true.create_dataset('xi', data=xi_true)
fout_true.create_dataset('zeta', data=zeta_true)
fout_true.create_dataset('vel', data=vel_true)
fout_init.close()
fout_true.close()
# %% [markdown]
# # prepare src station file
#
# The following code creates a src_rec_file for the inversion, which describes the source and receiver positions and arrival times.
# Format is as follows:
#
# ```
# 26 1992 1 1 2 43 56.900 1.8000 98.9000 137.00 2.80 8 305644 <- src  : id_src year month day hour min sec lat lon dep_km mag num_recs id_event
# 26 1 PCBI 1.8900 98.9253 1000.0000 P 10.40 18.000 <- arrival : id_src id_rec name_rec lat lon elevation_m phase epicentral_distance_km arrival_time_sec
# 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400
# 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200
# ....
#
# ```
# %%
import random
random.seed(1145141919810)
# dummys
year_dummy = 1998
month_dummy = 1
day_dummy = 1
hour_dummy = 0
minute_dummy = 0
second_dummy = 0
mag_dummy = 3.0
id_dummy = 1000
st_name_dummy = 'AAAA'
phase_dummy = 'P'
arriv_t_dummy = 0.0
weight_dummy = 0.444
tt1deg = tt1 * 180.0/math.pi
tt2deg = tt2 * 180.0/math.pi
pp1deg = pp1 * 180.0/math.pi
pp2deg = pp2 * 180.0/math.pi
n_srcs = [10,20,20]
#n_srcs = [2,1,1]
n_src = n_srcs[0]*n_srcs[1]*n_srcs[2]
n_rec = [30 for x in range(n_src)]
lines = []
nij_rec = math.sqrt(n_rec[0])
pos_src=[]
pos_rec=[]
# create receiver coordinates
elev_recs=[]
lon_recs=[]
lat_recs=[]
rec_names=[]
for i in range(n_rec[0]):
#elev_recs.append(random.uniform(-100.0,-100.0)) # elevation in m
#elev_recs.append(0) # elevation in m
#lon_recs .append(random.uniform(pp1deg*1.1,pp2deg*0.9))
#lat_recs .append(random.uniform(tt1deg*1.1,tt2deg*0.9))
rec_names.append(i)
# regularly
elev_recs.append(0.0)
tmp_ilon = i%nij_rec
tmp_ilat = int(i/nij_rec)
lon_recs.append(pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec)
lat_recs.append(tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec)
# create source coordinates
for ir in range(n_srcs[0]):
for it in range(n_srcs[1]):
for ip in range(n_srcs[2]):
i_src = ir*n_srcs[1]*n_srcs[2] + it*n_srcs[2] + ip
# define one point in the domain (rr1 bottom, rr2 top)
# random
#dep = random.uniform((R_earth-rr1)*0.5,(R_earth-rr1)*0.98)
#lon = random.uniform(pp1deg,pp2deg)
#lat = random.uniform(tt1deg,tt2deg)
# regular
dep = (R_earth-rr1)/n_srcs[0]*ir
lon = pp1deg + ip*(pp2deg-pp1deg)/n_srcs[2]
lat = tt1deg + it*(tt2deg-tt1deg)/n_srcs[1]
# put independent name for each source
id_dummy = "src_"+str(i_src)
src = [i_src, year_dummy, month_dummy, day_dummy, hour_dummy, minute_dummy, second_dummy, lat, lon, dep, mag_dummy, n_rec[i_src], id_dummy, weight_dummy]
lines.append(src)
pos_src.append([lon,lat,dep])
# create dummy station
for i_rec in range(n_rec[i_src]):
elev_rec = elev_recs[i_rec]
lon_rec = lon_recs[i_rec]
lat_rec = lat_recs[i_rec]
st_name_dummy = "rec_"+str(rec_names[i_rec])
rec = [i_src, i_rec, st_name_dummy, lat_rec, lon_rec, elev_rec, phase_dummy, arriv_t_dummy, weight_dummy]
lines.append(rec)
pos_rec.append([lon_rec,lat_rec,elev_rec])
# write out ev_arrivals file
fname = 'src_rec_test.dat'
with open(fname, 'w') as f:
for line in lines:
for elem in line:
f.write('{} '.format(elem))
f.write('\n')
# %%
# draw src and rec positions
import matplotlib.pyplot as plt
for i_src in range(n_src):
plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')
# %%
# plot receivers
for i_rec in range(n_rec[0]):
plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')
# %%

View File

@@ -0,0 +1,236 @@
version: 2
domain:
min_max_dep: [-10, 10] # depth in km
min_max_lat: [37.7, 42.3] # latitude in degree
min_max_lon: [22.7, 27.3] # longitude in degree
n_rtp: [10, 50, 50] # number of nodes in depth,latitude,longitude direction
source:
src_rec_file: OUTPUT_FILES/src_rec_file_forward.dat # source receiver file path
swap_src_rec: true # swap source and receiver
model:
init_model_path: ./test_model_init.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: # parameters for parallel computation
n_sims: 1 # number of simultanoues runs
ndiv_rtp: [1, 2, 2] # number of subdivision on each direction
nproc_sub: 2 # number of processors for sweep parallelization
use_gpu: true # 1 if use gpu (EXPERIMENTAL)
output_setting:
######### moved to here
output_dir: ./OUTPUT_FILES/ # path to output director (default is ./OUTPUT_FILES/)
output_source_field: false # output the calculated field of all sources 1 for yes; 0 for no; default: 1
output_model_dat: false # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
######is_verbose_output: 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
output_final_model: true # output merged final model or not. 1 for yes; 0 for no; default: 1
output_in_process: true # output model at each inv iteration or not. 1 for yes; 0 for no; default: 1
single_precision_output: false # output results in single precision or not. 1 for yes; 0 for no; default: 0
##### new feature !!!
verbose_output_level: 0 # output internal parameters, if 0, only model parameters are out. Higher level, more internal parameters are output. default: 0
output_file_format: 0
##### moved to here!!
# run mode
# 0 for forward simulation only,
# 1 for inversion
# 2 for earthquake relocation
# 3 for inversion+earthquake relocation
run_mode: 1
##### new section
# parameters for model update (inversion)
# ignored if run_mode is not 1 or 3
model_update:
#run_or_not: true # true for run model update, false for not model update
#### name slighly changed !!!
max_iterations: 3 # maximum number of inversion iterations
optim_method: 1 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
# common parameters for all optim methods
step_length: 0.01 # step length of model perturbation at each iteration. 0.01 means maximum 1% perturbation for each iteration.
# parameters for optim_method 0 (grad_descent)
optim_method_0:
step_length_decay: 0.9 # if objective function increase, step size -> step length * step_length_decay. default: 0.9
#####step_size_sc: 0.001 # ... # use it also ?
# parameters for optim_method 1 (halve-stepping) or 2 (lbfgs)
optim_method_1_2:
max_sub_iterations: 10 # maximum number of each sub-iteration
regularization_weight: 100 # weight value for regularization (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)
n_inversion_grid: 5 # number of inversion grid sets
# inversion grid type
type_invgrid_dep: 1 # 0: uniform inversion grid, 1: flexible grid
type_invgrid_lat: 0 # 0: uniform inversion grid, 1: flexible grid
type_invgrid_lon: 0 # 0: uniform inversion grid, 1: flexible grid
# settings for uniform inversion grid (if type_*_inv : 0)
n_inv_dep_lat_lon: [5, 10, 10] # number of the base inversion grid points (ignored if type_*_inv : 1)
min_max_dep_inv: [-10, 10] # depth in km (Radius of the earth is defined in config.h/R_earth) (ignored if type_dep_inv : 1)
min_max_lat_inv: [37.7, 42.3] # latitude in degree
min_max_lon_inv: [22.7, 27.3] # longitude in degree
# settings for flexible inversion grid (if type_*_inv : 1)
dep_inv: [-10.0, -7.5, -5.0, -2.5, 0.0, 2.5, 5.0, 7.5, 10.0] # depth in km (Radius of the earth is defined in config.h/R_earth)
lat_inv: [0.0, 1.0] # latitude in degree (ignored if type_lat_inv : 0)
lon_inv: [0.0, 1.0] # longitude in degree (ignored if type_lon_inv : 0)
# path to station correction file
sta_correction_file: dummy_sta_correction_file # station correction file path
##
## new feature !!!
##
# -------------- 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.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight: [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- 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.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight: [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two stations.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
use_cr_time: true # '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.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight: [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two earthquakes.
# -------------- 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. the obj of different data means the average data misfit; no: use original weight (below weight for each type of data needs to be set)
abs_time_weight: 1.0 # weight of absolute traveltime data, default: 1.0
cs_dif_time_local_weight: 1.0 # weight of common source differential traveltime data, default: 1.0
cr_dif_time_local_weight: 1.0 # weight of common receiver differential traveltime data, default: 1.0
teleseismic_weight: 1.0 # weight of teleseismic data, default: 1.0 (exclude in this version)
# -------------- inversion parameters (exclude in this version) --------------
update_slowness : true # update slowness (velocity) or not. default: true
update_azi_ani : false # update azimuthal anisotropy (xi, eta) or not. default: false
update_rad_ani : false # update radial anisotropy (in future) or not. default: false
# -------------- for teleseismic inversion (exclude in this version) --------------
## changed from kernel_taper
depth_taper : [-200.0, -100.0] # kernel weight : depth. --> 0: -inf ~ taper[0]; 0 ~ 1 : taper[0] ~ taper[1]; 1 : taper[1] ~ inf
# this top tag is not necessary
########inversion:
###########run_mode: 1 # 0 for forward simulation only, 1 for inversion
###########output_dir: ./OUTPUT_FILES/ # path to output director (default is ./OUTPUT_FILES/)
###########optim_method: 1 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
####max_iterations_inv: 3 # maximum number of inversion iterations
#####step_size: 0.001 # initial step size for model update
#####step_size_sc: 0.001 # ...
#####step_size_decay: 0.9 # ...
#####smooth_method: 0 # 0: multiparametrization, 1: laplacian smoothing (EXPERIMENTAL)
# parameters for multiparametric inversion
######n_inversion_grid: 5 # number of inversion grid sets
#######n_inv_dep_lat_lon: [5, 10, 10] # number of the base inversion grid points
########sta_correction_file: dummy_sta_correction_file # station correction file path
#######type_dep_inv: 0 # 0: uniform inversion grid, 1: flexible grid
#######type_lat_inv: 0 # 0: uniform inversion grid, 1: flexible grid
#######type_lon_inv: 0 # 0: uniform inversion grid, 1: flexible grid
# parameters for uniform inversion grid
#####min_max_dep_inv: [-10, 10] # depth in km (Radius of the earth is defined in config.h/R_earth)
#####min_max_lat_inv: [37.7, 42.3] # latitude in degree
#####min_max_lon_inv: [22.7, 27.3] # longitude in degree
# parameters for flexible inversion grid
# n_inv_r_flex: 3
# dep_inv: [1, 1, 1]
# n_inv_t_flex: 3
# lat_inv: [1, 1, 1]
# n_inv_p_flex: 3
# lon_inv: [1, 1, 1]
# parameters for halve-stepping or lbfg mode
####max_sub_iterations: 10 # maximum number of each sub-iteration
######l_smooth_rtp: [1, 1, 1] # smoothing coefficients for laplacian smoothing
######regularization_weight: 100 # weight value for regularization (lbfgs mode only)
### new section !!!
#################################################
# relocation parameters setting #
#################################################
relocation: # update earthquake hypocenter and origin time (when run_mode : 1)
###yes_or_no : yes # 'yes' for relocating earthquakes; 'no' for not relocating earthquakes (no need to set parameters in this section);
# relocation_strategy
step_length : 0.01 # step length of relocation perturbation at each iteration. 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, 10.0, 10.0, 1.0] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
max_change_dep_lat_lon_ortime : [5.0, 5.0, 5.0, 0.5] # 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
# more option for using different types of data is under development (following)
# -------------- using absolute traveltime data --------------
abs_time:
use_abs_time : yes # 'yes' for using absolute traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight : [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
use_cr_time : true # 'yes' for using common receiver differential traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
distance_weight : [10.0, 30.0, 1.0, 0.1] # weight of distance (km) between two earthquakes.
#### the name of this tag is changed !!!
#inv_strategy: # flags for selecting the target parameters to be inversed
inversion_strategy:
# this flag is not used, because the function is duplicated with "run_mode"
#inv_mode : 0 # 0 for update model parameters and relocation iteratively. (other options for future work)
####is_inv_slowness: true # 1: slowness value will be calculated in inversion, 0: will not be calculated
####is_inv_azi_ani: true # 1: azimuth anisotropy value will be calculated in inversion, 0: will not be calculated
####is_inv_rad_ani: 0 # flag for radial anisotropy (Not implemented yet)
####kernel_taper: [-1e+07, -1e+07]
####is_sta_correction: 0
inv_mode : 0 # 0 for update model parameters and relocation iteratively. (other options for future work)
# for inv_mode : 0, parameters below are required
inv_mode_0: # Fristly, do relocation; Subsequently, do relocation every N steps; Finally, do relocation
relocation_first : true # yes: do relocation first; no: do not relocation first. default: yes
relocation_first_iterations : 10 # maximum number of iterations for relocation in the beginning. default: 10
relocation_every_N_steps : 5 # subsequently, do relocation every N steps of updating model parameters. The iteration of relocation follows <max_iterations> in Section <relocation>
relocation_final : true # yes: do relocation finally; no: do not relocation finally. default: yes
relocation_final_iterations : 10 # maximum number of iterations for relocation in the beginning. default: 10
########################################################################
# Scheme of Eikonal solver (fast sweeping method) #
########################################################################
calculation:
convergence_tolerance: 0.0001 # threshold value for checking the convergence for each forward/adjoint run
max_iterations: 500 # number of maximum iteration for each forward/adjoint run
stencil_order: 3 # order of stencil, 1 or 3
stencil_type: 0 # 0: , 1: first-order upwind scheme (only sweep_type 0 is supported)
sweep_type: 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
#######output_file_format: 0

View File

@@ -0,0 +1,80 @@
version: 2
domain:
min_max_dep: [-10, 10] # depth in km
min_max_lat: [37.7, 42.3] # latitude in degree
min_max_lon: [22.7, 27.3] # longitude in degree
n_rtp: [10, 50, 50] # number of nodes in depth,latitude,longitude direction
source:
src_rec_file: OUTPUT_FILES/src_rec_file_forward.dat # source receiver file path
swap_src_rec: 1 # swap source and receiver (1: yes, 0: no)
model:
init_model_path: ./test_model_init.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
inversion:
run_mode: 1 # 0 for forward simulation only, 1 for inversion
output_dir: ./OUTPUT_FILES/ # path to output director (default is ./OUTPUT_FILES/)
optim_method: 1 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
max_iterations_inv: 3 # maximum number of inversion iterations
step_size: 0.001 # initial step size for model update
step_size_sc: 0.001 # ...
step_size_decay: 0.9 # ...
smooth_method: 0 # 0: multiparametrization, 1: laplacian smoothing (EXPERIMENTAL)
# parameters for multiparametric inversion
n_inversion_grid: 5 # number of inversion grid sets
n_inv_dep_lat_lon: [5, 10, 10] # number of the base inversion grid points
# sta_correction_file: dummy_sta_correction_file # station correction file path
type_dep_inv: 0 # 0: uniform inversion grid, 1: flexible grid
type_lat_inv: 0 # 0: uniform inversion grid, 1: flexible grid
type_lon_inv: 0 # 0: uniform inversion grid, 1: flexible grid
# parameters for uniform inversion grid
min_max_dep_inv: [-10, 10] # depth in km (Radius of the earth is defined in config.h/R_earth)
min_max_lat_inv: [37.7, 42.3] # latitude in degree
min_max_lon_inv: [22.7, 27.3] # longitude in degree
# parameters for flexible inversion grid
# n_inv_r_flex: 3
# dep_inv: [1, 1, 1]
# n_inv_t_flex: 3
# lat_inv: [1, 1, 1]
# n_inv_p_flex: 3
# lon_inv: [1, 1, 1]
# parameters for halve-stepping or lbfg mode
max_sub_iterations: 10 # maximum number of each sub-iteration
l_smooth_rtp: [1, 1, 1] # smoothing coefficients for laplacian smoothing
regularization_weight: 100 # weight value for regularization (lbfgs mode only)
inv_strategy: # flags for selecting the target parameters to be inversed
is_inv_slowness: 1 # 1: slowness value will be calculated in inversion, 0: will not be calculated
is_inv_azi_ani: 1 # 1: azimuth anisotropy value will be calculated in inversion, 0: will not be calculated
is_inv_rad_ani: 0 # flag for radial anisotropy (Not implemented yet)
kernel_taper: [-1e+07, -1e+07]
is_sta_correction: 0
parallel: # parameters for parallel computation
n_sims: 1 # number of simultanoues runs
ndiv_rtp: [1, 2, 2] # number of subdivision on each direction
nproc_sub: 2 # number of processors for sweep parallelization
use_gpu: 0 # 1 if use gpu (EXPERIMENTAL)
calculation:
convergence_tolerance: 0.0001 # threshold value for checking the convergence for each forward/adjoint run
max_iterations: 500 # number of maximum iteration for each forward/adjoint run
stencil_order: 3 # order of stencil, 1 or 3
stencil_type: 0 # 0: , 1: first-order upwind scheme (only sweep_type 0 is supported)
sweep_type: 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_file_format: 0
output_setting:
is_output_source_field: 0 # output the calculated field of all sources 1 for yes; 0 for no; default: 1
is_output_model_dat: 0 # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
is_verbose_output: 0 # output internal parameters, if no, only model parameters are out. 1 for yes; 0 for no; default: 0
is_output_final_model: 1 # output merged final model or not. 1 for yes; 0 for no; default: 1
is_output_in_process: 1 # output model at each inv iteration or not. 1 for yes; 0 for no; default: 1
is_single_precision_output: 0 # output results in single precision or not. 1 for yes; 0 for no; default: 0

View File

@@ -0,0 +1,182 @@
version: 3
#################################################
# computational domian #
#################################################
domain:
min_max_dep: [-10, 10] # depth in km
min_max_lat: [37.7, 42.3] # latitude in degree
min_max_lon: [22.7, 27.3] # longitude in degree
n_rtp: [10, 50, 50] # number of nodes in depth,latitude,longitude direction
source:
src_rec_file: OUTPUT_FILES/src_rec_file_forward.dat # source receiver file path
swap_src_rec: 1 # swap source and receiver (1: yes, 0: no)
model:
init_model_path: ./test_model_init.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: # parameters for parallel computation
n_sims: 1 # number of simultanoues runs
ndiv_rtp: [1, 2, 2] # number of subdivision on each direction
nproc_sub: 2 # number of processors for sweep parallelization
use_gpu: false # 1 if use gpu (EXPERIMENTAL)
output_setting:
output_dir: ./OUTPUT_FILES/ # path to output director (default is ./OUTPUT_FILES/)
output_source_field: false # output the calculated field of all sources 1 for yes; 0 for no; default: 1
output_model_dat: false # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
output_final_model: true # output merged final model or not. 1 for yes; 0 for no; default: 1
output_in_process: true # output model at each inv iteration or not. 1 for yes; 0 for no; default: 1
single_precision_output: false # output results in single precision or not. 1 for yes; 0 for no; default: 0
verbose_output_level: 0 # output internal parameters, if 0, only model parameters are out. Higher level, more internal parameters are output. default: 0
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: 1
###################################################
# model update parameters setting #
###################################################
model_update: # update model parameters (when run_mode : 1 and 3)
max_iterations: 3 # maximum number of inversion iterations
optim_method: 1 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
# common parameters for all optim methods
step_length: 0.01 # step length of model perturbation at each iteration. 0.01 means maximum 1% perturbation for each iteration.
# parameters for optim_method 0 (grad_descent)
optim_method_0:
step_length_decay: 0.9 # if objective function increase, step size -> step length * step_length_decay. default: 0.9
step_length_sc: 0.001 # ... # use it also ?
# parameters for optim_method 1 (halve-stepping) or 2 (lbfgs)
optim_method_1_2:
max_sub_iterations: 10 # maximum number of each sub-iteration
regularization_weight: 100 # weight value for regularization (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)
n_inversion_grid: 5 # number of inversion grid sets
# inversion grid type
type_invgrid_dep: 1 # 0: uniform inversion grid, 1: flexible grid
type_invgrid_lat: 0 # 0: uniform inversion grid, 1: flexible grid
type_invgrid_lon: 0 # 0: uniform inversion grid, 1: flexible grid
# settings for uniform inversion grid (if type_*_inv : 0)
n_inv_dep_lat_lon: [5, 10, 10] # number of the base inversion grid points (ignored if type_*_inv : 1)
min_max_dep_inv: [-10, 10] # depth in km (Radius of the earth is defined in config.h/R_earth) (ignored if type_dep_inv : 1)
min_max_lat_inv: [37.7, 42.3] # latitude in degree
min_max_lon_inv: [22.7, 27.3] # longitude in degree
# settings for flexible inversion grid (if type_*_inv : 1)
dep_inv: [-10.0, -7.5, -5.0, -2.5, 0.0, 2.5, 5.0, 7.5, 10.0] # depth in km (Radius of the earth is defined in config.h/R_earth)
lat_inv: [0.0, 1.0] # latitude in degree (ignored if type_lat_inv : 0)
lon_inv: [0.0, 1.0] # longitude in degree (ignored if type_lon_inv : 0)
# path to station correction file
sta_correction_file: dummy_sta_correction_file # station correction file path
# -------------- 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.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight: [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- 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.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight: [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two stations.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
use_cr_time: true # '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.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight: [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two earthquakes.
# -------------- 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. the obj of different data means the average data misfit; no: use original weight (below weight for each type of data needs to be set)
abs_time_weight: 1.0 # weight of absolute traveltime data, default: 1.0
cs_dif_time_local_weight: 1.0 # weight of common source differential traveltime data, default: 1.0
cr_dif_time_local_weight: 1.0 # weight of common receiver differential traveltime data, default: 1.0
teleseismic_weight: 1.0 # weight of teleseismic data, default: 1.0 (exclude in this version)
# -------------- inversion parameters (exclude in this version) --------------
update_slowness: true # update slowness (velocity) or not. default: true
update_azi_ani: false # update azimuthal anisotropy (xi, eta) or not. default: false
update_rad_ani: false # update radial anisotropy (in future) or not. default: false
# -------------- for teleseismic inversion (exclude in this version) --------------
depth_taper: [-200.0, -100.0] # kernel weight : depth. --> 0: -inf ~ taper[0]; 0 ~ 1 : taper[0] ~ taper[1]; 1 : taper[1] ~ inf
#################################################
# relocation parameters setting #
#################################################
relocation: # update earthquake hypocenter and origin time (when run_mode : 1)
# relocation_strategy
step_length: 0.01 # step length of relocation perturbation at each iteration. 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, 10.0, 10.0, 1.0] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
max_change_dep_lat_lon_ortime: [5.0, 5.0, 5.0, 0.5] # 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
# more option for using different types of data is under development (following)
# -------------- using absolute traveltime data --------------
abs_time:
use_abs_time: yes # 'yes' for using absolute traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight: [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight: [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
use_cr_time: true # 'yes' for using common receiver differential traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight: [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
distance_weight: [10.0, 30.0, 1.0, 0.1] # weight of distance (km) between two earthquakes.
####################################################################
# inversion strategy for tomography and relocation #
####################################################################
inversion_strategy: # update model parameters and earthquake hypocenter iteratively (when run_mode : 3)
inv_mode: 0 # 0 for update model parameters and relocation iteratively. (other options for future work)
# for inv_mode : 0, parameters below are required
inv_mode_0: # Fristly, do relocation; Subsequently, do relocation every N steps; Finally, do relocation
relocation_first: true # yes: do relocation first; no: do not relocation first. default: yes
relocation_first_iterations: 10 # maximum number of iterations for relocation in the beginning. default: 10
relocation_every_N_steps: 5 # subsequently, do relocation every N steps of updating model parameters. The iteration of relocation follows <max_iterations> in Section <relocation>
relocation_final: true # yes: do relocation finally; no: do not relocation finally. default: yes
relocation_final_iterations: 10 # maximum number of iterations for relocation in the beginning. default: 10
# --- parameters for core solver ---------------------------------------------------------
# --- please do not change the following parameters unless you know what you are doing ---
########################################################################
# Scheme of Eikonal solver (fast sweeping method) #
########################################################################
calculation:
convergence_tolerance: 0.0001 # threshold value for checking the convergence for each forward/adjoint run
max_iterations: 500 # number of maximum iteration for each forward/adjoint run
stencil_order: 3 # order of stencil, 1 or 3
stencil_type: 0 # 0: , 1: first-order upwind scheme (only sweep_type 0 is supported)
sweep_type: 1 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,206 @@
version: 2
#################################################
# computational domian #
#################################################
domain:
min_max_dep: [-10, 10] # depth in km
min_max_lat: [37.7, 42.3] # latitude in degree
min_max_lon: [22.7, 27.3] # longitude in degree
n_rtp: [10, 50, 50] # number of nodes in depth,latitude,longitude direction
#################################################
# traveltime data file path #
#################################################
source:
src_rec_file: OUTPUT_FILES/src_rec_file_forward.dat ### source receiver file path
swap_src_rec: true # swap source and receiver
#################################################
# initial model file path #
#################################################
model:
init_model_path: ./test_model_init.h5 # path to initial model file
#################################################
# parallel computation settings #
#################################################
parallel: # parameters for parallel computation
n_sims: 1 # number of simultanoues runs
ndiv_rtp: [1, 2, 2] # number of subdivision on each direction
nproc_sub: 2 # number of processors for sweep parallelization
use_gpu: true # true if use gpu (EXPERIMENTAL)
############################################
# output file setting #
############################################
output_setting:
output_dir: ./OUTPUT_FILES/ # path to output director (default is ./OUTPUT_FILES/)
output_source_field: false # output the calculated field of all sources 1 for yes; 0 for no; default: 1
output_model_dat: false # output model_parameters_inv_0000.dat or not. 1 for yes; 0 for no; default: 1
output_final_model: true # output merged final model or not. 1 for yes; 0 for no; default: 1
output_in_process: true # output model at each inv iteration or not. 1 for yes; 0 for no; default: 1
single_precision_output: false # output results in single precision or not. 1 for yes; 0 for no; default: 0
verbose_output_level: 0 # output internal parameters, if 0, only model parameters are out. Higher level, more internal parameters are output. default: 0
output_file_format: 0 # in/output file format, if 0: HDF5, if 1: ASCII
#################################################
# 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: 1
###################################################
# model update parameters setting #
###################################################
model_update: # update model parameters (when run_mode : 1 and 3)
max_iterations: 3 # maximum number of inversion iterations
optim_method: 1 # optimization method. 0 : grad_descent, 1 : halve-stepping, 2 : lbfgs (EXPERIMENTAL)
# common parameters for all optim methods
step_length: 0.01 # step length of model perturbation at each iteration. 0.01 means maximum 1% perturbation for each iteration.
# parameters for optim_method 0 (grad_descent)
optim_method_0:
step_length_decay: 0.9 # if objective function increase, step size -> step length * step_length_decay. default: 0.9
step_length_sc: 0.001 # ... # use it also ?
# parameters for optim_method 1 (halve-stepping) or 2 (lbfgs)
optim_method_1_2:
max_sub_iterations: 10 # maximum number of each sub-iteration
regularization_weight: 100 # weight value for regularization (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)
n_inversion_grid: 5 # number of inversion grid sets
# inversion grid type
type_invgrid_dep: 1 # 0: uniform inversion grid, 1: flexible grid
type_invgrid_lat: 0 # 0: uniform inversion grid, 1: flexible grid
type_invgrid_lon: 0 # 0: uniform inversion grid, 1: flexible grid
# settings for uniform inversion grid (if type_*_inv : 0)
n_inv_dep_lat_lon: [5, 10, 10] # number of the base inversion grid points (ignored if type_*_inv : 1)
min_max_dep_inv: [-10, 10] # depth in km (Radius of the earth is defined in config.h/R_earth) (ignored if type_dep_inv : 1)
min_max_lat_inv: [37.7, 42.3] # latitude in degree
min_max_lon_inv: [22.7, 27.3] # longitude in degree
# settings for flexible inversion grid (if type_*_inv : 1)
dep_inv: [-10.0, -7.5, -5.0, -2.5, 0.0, 2.5, 5.0, 7.5, 10.0] # depth in km (Radius of the earth is defined in config.h/R_earth)
lat_inv: [0.0, 1.0] # latitude in degree (ignored if type_lat_inv : 0)
lon_inv: [0.0, 1.0] # longitude in degree (ignored if type_lon_inv : 0)
# path to station correction file
use_sta_correction: false
sta_correction_file: dummy_sta_correction_file # station correction file path
# -------------- 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.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight: [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- 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.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight: [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two stations.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
use_cr_time: true # '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.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight: [15.0, 30.0, 1.0, 0.1] # weight of azimuth between two earthquakes.
# -------------- 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. the obj of different data means the average data misfit; no: use original weight (below weight for each type of data needs to be set)
abs_time_weight: 1.0 # weight of absolute traveltime data, default: 1.0
cs_dif_time_local_weight: 1.0 # weight of common source differential traveltime data, default: 1.0
cr_dif_time_local_weight: 1.0 # weight of common receiver differential traveltime data, default: 1.0
teleseismic_weight: 1.0 # weight of teleseismic data, default: 1.0 (exclude in this version)
# -------------- inversion parameters (exclude in this version) --------------
update_slowness : true # update slowness (velocity) or not. default: true
update_azi_ani : false # update azimuthal anisotropy (xi, eta) or not. default: false
update_rad_ani : false # update radial anisotropy (in future) or not. default: false
# -------------- for teleseismic inversion (exclude in this version) --------------
depth_taper : [-200.0, -100.0] # kernel weight : depth. --> 0: -inf ~ taper[0]; 0 ~ 1 : taper[0] ~ taper[1]; 1 : taper[1] ~ inf
#################################################
# relocation parameters setting #
#################################################
relocation: # update earthquake hypocenter and origin time (when run_mode : 1)
# relocation_strategy
step_length : 0.01 # step length of relocation perturbation at each iteration. 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, 10.0, 10.0, 1.0] # The perturbation is related to <rescaling_dep_lat_lon_ortime>. Unit: km,km,km,second
max_change_dep_lat_lon_ortime : [5.0, 5.0, 5.0, 0.5] # 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 # threshold value for checking the convergence for each iteration
# params keeped for current version of relocation but may not be required
ortime_local_search : true # true: do local search for origin time; false: do not do local search for origin time
ref_ortime_change : 0.5 # reference value for origin time change (unit: second). If the change of origin time is larger than ref_ortime_change, do local search for origin time.
step_length_ortime_rescale : 0.1 # step length for rescaling origin time
# more option for using different types of data is under development (following)
# -------------- using absolute traveltime data --------------
abs_time:
use_abs_time : yes # 'yes' for using absolute traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual. wt = residual_weight[2] for res < residual_weight[0]. wt = residual_weight[3] for res > residual_weight[1], and linear weight in between.
distance_weight : [50.0, 150.0, 1.0, 0.1] # weight of epicenter distance. wt = distance_weight[2] for dis < distance_weight[0]. wt = distance_weight[3] for dis > distance_weight[1], and linear weight in between.
# -------------- using common receiver differential traveltime data --------------
cr_dif_time:
use_cr_time : true # 'yes' for using common receiver differential traveltime data to update model parameters; 'no' for not using (no need to set parameters in this section)
residual_weight : [1.0, 3.0, 1.0, 0.1] # weight (wt) of residual.
azimuthal_weight : [10.0, 30.0, 1.0, 0.1] # weight of azimuth (deg.) between two earthquakes.
####################################################################
# inversion strategy for tomography and relocation #
####################################################################
inversion_strategy: # update model parameters and earthquake hypocenter iteratively (when run_mode : 3)
inv_mode : 0 # 0 for update model parameters and relocation iteratively. (other options for future work)
# for inv_mode : 0, parameters below are required
inv_mode_0: # Fristly, do relocation; Subsequently, do relocation every N steps; Finally, do relocation
relocation_first : true # true: do relocation first; false: do not relocation first. default: true
relocation_first_iterations : 10 # maximum number of iterations for relocation in the beginning. default: 10
relocation_every_N_steps : 5 # subsequently, do relocation every N steps of updating model parameters. The iteration of relocation follows <max_iterations> in Section <relocation>
relocation_final : true # true: do relocation finally; false: do not relocation finally. default: true
relocation_final_iterations : 10 # maximum number of iterations for relocation in the beginning. default: 10
# --- parameters for core solver ---------------------------------------------------------
# --- please do not change the following parameters unless you know what you are doing ---
########################################################################
# Scheme of Eikonal solver (fast sweeping method) #
########################################################################
calculation:
convergence_tolerance: 0.0001 # threshold value for checking the convergence for each forward/adjoint run
max_iterations: 500 # number of maximum iteration for each forward/adjoint run
stencil_order: 3 # order of stencil, 1 or 3
stencil_type: 0 # 0: , 1: first-order upwind scheme (only sweep_type 0 is supported)
sweep_type: 1 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,13 @@
#!/bin/bash
python make_test_model.py
# run for preparing true travel times
mpirun -n 2 ../../build/bin/TOMOATT -i input_params_pre.yml
# run for inversion
mpirun -n 2 ../../build/bin/TOMOATT -i input_params.yml
#mpirun -n 8 ../../build/bin/TOMOATT -i input_params_flexible_inv_grid.yml
# then final model can be plot by e.g. check_3d_out.ipynb
#paraview OUTPUT_FILES/out_data_sim.xmf

View File

@@ -0,0 +1,312 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 165,
"metadata": {},
"outputs": [],
"source": [
"# load yaml files with ruamel.yaml\n",
"import sys\n",
"from ruamel.yaml import YAML\n",
"\n",
"yaml=YAML()\n",
"\n",
"fold = \"./params_log_old.yaml\"\n",
"fnew = \"./params_model_v3.yaml\"\n",
"\n",
"# load the old file as string\n",
"with open(fold, 'r') as f:\n",
" str_old = f.read()\n",
" params_in = yaml.load(str_old)\n",
"\n",
"# load the new file as string\n",
"with open(fnew, 'r') as f:\n",
" str_new = f.read()\n",
" params_v3 = yaml.load(str_new)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 166,
"metadata": {},
"outputs": [],
"source": [
"params_v3['domain'] = params_in['domain']"
]
},
{
"cell_type": "code",
"execution_count": 167,
"metadata": {},
"outputs": [],
"source": [
"params_v3['source'] = params_in['source']"
]
},
{
"cell_type": "code",
"execution_count": 168,
"metadata": {},
"outputs": [],
"source": [
"params_v3['model'] = params_in['model']"
]
},
{
"cell_type": "code",
"execution_count": 169,
"metadata": {},
"outputs": [],
"source": [
"params_v3['parallel'] = params_in['parallel']"
]
},
{
"cell_type": "code",
"execution_count": 170,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'n_sims': 1, 'ndiv_rtp': [1, 2, 2], 'nproc_sub': 2, 'use_gpu': 0}"
]
},
"execution_count": 170,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_v3['parallel']"
]
},
{
"cell_type": "code",
"execution_count": 171,
"metadata": {},
"outputs": [],
"source": [
"params_v3['parallel']['use_gpu'] = True"
]
},
{
"cell_type": "code",
"execution_count": 172,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'n_sims': 1, 'ndiv_rtp': [1, 2, 2], 'nproc_sub': 2, 'use_gpu': True}"
]
},
"execution_count": 172,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_v3['parallel']"
]
},
{
"cell_type": "code",
"execution_count": 173,
"metadata": {},
"outputs": [],
"source": [
"# dump params_v3 as a new file\n",
"fout = fold+\".v3.yaml\"\n",
"\n",
"with open(fout, 'w') as fp:\n",
" yaml.dump(params_v3, fp)\n"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'src_rec_file': 'OUTPUT_FILES/src_rec_file_forward.dat', 'swap_src_rec': 1}"
]
},
"execution_count": 135,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_v3['source']"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'src_rec_file': 'OUTPUT_FILES/src_rec_file_forward.dat', 'swap_src_rec': 1}"
]
},
"execution_count": 124,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_in['source']"
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'min_max_dep': [-10, 10],\n",
" 'min_max_lat': [37.7, 42.3],\n",
" 'min_max_lon': [22.7, 27.3],\n",
" 'n_rtp': [10, 50, 50]}"
]
},
"execution_count": 125,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params_in['domain']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

File diff suppressed because it is too large Load Diff