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

BIN
test/old_tests/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,50 @@
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 : 2 # optimization method. 0 : "grad_descent", 1 : "halve-stepping", 2 : "lbfgs",
max_iterations_inv : 20 # maximum number of inversion iterations
step_size : 0.01 # step size for inversion
# parameters for multiparametric inversion
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [5,20,20] # 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,43.3] # latitude in degree
min_max_lon_inv : [22.7,28.3] # longitude in degree
# parameter for halving-stepping or lbfgs
max_sub_iterations : 10 # maximum number of sub-iterations
#regularization_weight : 0.0 # regularization weight
smooth_method: 0
#l_smooth_rtp : [20,20,20] #
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,2] # number of subdomains
nproc_sub : 2 # 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_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 : 1 # output the model parameters in each iteration. 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,2,2] # 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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
# Inversion test
This is a test setup for inversion calculation.
1. Run all cells of `make_test_model.ipynb` for creating
- source, receiver file
- true model
- initial model
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
-> this will output src_rec_result.dat file which includes the arrival time at each station
3. run TOMOATT in inversion mode with `input_params.yml`.

View File

@@ -0,0 +1,66 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# check the change of objective values\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"fpath='objective_function.txt'\n",
"\n",
"objs=[]\n",
"\n",
"with open(fpath) as f:\n",
" lines = f.readlines()\n",
"\n",
" for l in lines:\n",
" if(l.startswith('i_inv')):\n",
" continue\n",
" objs.append(float(l.strip().split(',')[1]))\n",
"\n",
"\n",
"plt.xlabel('iteration')\n",
"plt.ylabel('objective function value')\n",
"plt.plot(objs)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "fbd0b2a7df497f398d93ab2f589d8a5daa3108cfb7ff2b90736653cca3aeadc0"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,185 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# read src_rec file and check its arrival time and distance from src to rec\n",
"import numpy as np\n",
"\n",
"def read_src_rec_file(fpath):\n",
"\n",
" with open(fpath, \"r\") as f:\n",
" lines = f.readlines()\n",
"\n",
" # list to store src lon lat\n",
" src_pos = []\n",
" # list to store rec lon lat\n",
" rec_pos_tmp=[]\n",
" rec_pos = []\n",
"\n",
" for line in lines:\n",
" # src line if there are 13 elements\n",
" if len(line.split()) == 13:\n",
" # store source lon lat dep\n",
" stlon = float(line.split()[8])\n",
" stlat = float(line.split()[7])\n",
" src_pos.append([stlon, stlat])\n",
"\n",
" nrec = float(line.split()[11])\n",
" # rec line if there are 9 elements\n",
" elif len(line.split()) == 9:\n",
" # store receiver lon lat dep\n",
" rclon = float(line.split()[4])\n",
" rclat = float(line.split()[3])\n",
" rctime= float(line.split()[8])\n",
" # calc epicentral distance from src\n",
" dist = np.sqrt((stlon-rclon)**2 + (stlat-rclat)**2)\n",
" rec_pos_tmp.append([rclon, rclat, rctime, dist])\n",
"\n",
" nrec-=1\n",
" else:\n",
" raise ValueError(\"src_rec_test_out.dat file is not correct\")\n",
"\n",
" if nrec==0:\n",
" rec_pos.append(rec_pos_tmp)\n",
" # remove all rec_pos_tmp\n",
" rec_pos_tmp = []\n",
"\n",
"\n",
"\n",
" src_pos = np.array(src_pos)\n",
" rec_pos = np.array(rec_pos)\n",
"\n",
" return src_pos, rec_pos"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"src_pos_true, rec_pos_true = read_src_rec_file(\"./src_rec_test_out.dat\")\n",
"src_pos_try, rec_pos_try = read_src_rec_file(\"./src_rec_test_out_out.dat\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot rec_pos for each src_pos with color by 3rd element\n",
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"def plot_srcrec(src_pos, rec_pos):\n",
"\n",
" # selected source\n",
" id_src = 1\n",
" \n",
" fig, axs = plt.subplots(2,1,figsize=(10,10))\n",
" \n",
" # plot arrival time\n",
" # src\n",
" axs[0].scatter(src_pos[id_src,0], src_pos[id_src,1], c='r', marker='o', s=100)\n",
" # rec\n",
" axs[0].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,2], s=10, marker='o')\n",
" \n",
" # colorbar\n",
" cbar = plt.colorbar(axs[0].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,2], s=100, marker='o'))\n",
" cbar.set_label('arrival time')\n",
" \n",
" # plot epicentral distance\n",
" # src\n",
" axs[1].scatter(src_pos[id_src,0], src_pos[id_src,1], c='r', marker='o', s=100)\n",
" # rec\n",
" axs[1].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,3], s=100, marker='o')\n",
" \n",
" # colorbar\n",
" cbar = plt.colorbar(axs[1].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,3], s=10, marker='o'))\n",
" cbar.set_label('epicentral distance')\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_srcrec(src_pos_true, rec_pos_true)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_srcrec(src_pos_try, rec_pos_try)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos_diff = rec_pos_true[:][:][2]-rec_pos_try[:][:][2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos_diff.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos_true.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
},
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,51 @@
version : 2
domain :
#min_max_dep : [-2.863,17.137] # depth in km
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_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test_out.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_type : '' # 'fd' (input file) or '1d_ak135'
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 : 0 # optimization method. 0 : "grad_descent", 2 : "lbfgs", 1 : "halve-stepping"
smooth_method : 0 # 0: multigrid parametrization, 1: laplacian smoothing with CG
max_iterations_inv : 100 # maximum number of inversion iterations
step_size : 0.01 # 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
# parameters for laplacian smoothing
l_smooth_rtp : [10,10,10] # smoothing coefficients for each direction
regularization_weight : 1.0 # regularization weight NOTWORKING
# parameter for halving-stepping or lbfgs
max_sub_iterations : 100 # maximum number of sub-iterations
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
use_gpu : 0 # 0: CPU, 1: GPU
calculation :
convergence_tolerance : 1e-6
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,36 @@
version : 2
domain :
#min_max_dep : [-2.863,17.137] # depth in km
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_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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_type : '' # 'fd' (input file) or '1d_ak135'
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 : [2,1,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-6
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,348 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"#R_earth = 6378.1370\n",
"R_earth = 6371.0\n",
"\n",
"rr1=6361 \n",
"rr2=6381\n",
"tt1=(38.0-0.3)/180*math.pi\n",
"tt2=(42.0+0.3)/180*math.pi\n",
"pp1=(23.0-0.3)/180*math.pi\n",
"pp2=(27.0+0.3)/180*math.pi\n",
"\n",
"n_rtp = [10,50,50]\n",
"n_rtp.reverse()\n",
"dr = (rr2-rr1)/(n_rtp[2]-1)\n",
"dt = (tt2-tt1)/(n_rtp[1]-1)\n",
"dp = (pp2-pp1)/(n_rtp[0]-1)\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[2])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[0])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"s0 = 1.0/6.0\n",
"slow_p=0.06\n",
"ani_p=0.04\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"a_init = np.zeros(n_rtp)\n",
"b_init = np.zeros(n_rtp)\n",
"c_init = np.zeros(n_rtp)\n",
"f_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"a_true = np.zeros(n_rtp)\n",
"b_true = np.zeros(n_rtp)\n",
"c_true = np.zeros(n_rtp)\n",
"f_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ip,it,ir] = 0.0\n",
" #xi_init[ip,it,ir] = 0.0\n",
" zeta_init[ip,it,ir] = gamma*math.sqrt(eta_init[ip,it,ir]**2 + xi_init[ip,it,ir]**2)\n",
" fun_init[ip,it,ir] = s0\n",
" vel_init[ip,it,ir] = 1.0/s0\n",
" a_init[ip,it,ir] = 1.0 + 2.0*zeta_init[ip,it,ir]\n",
" b_init[ip,it,ir] = 1.0 - 2.0*xi_init[ip,it,ir]\n",
" c_init[ip,it,ir] = 1.0 + 2.0*xi_init[ip,it,ir]\n",
" f_init[ip,it,ir] = -2.0 * eta_init[ip,it,ir]\n",
"\n",
" # true model\n",
" if (tt[it] >= 38.0/180.0*math.pi and tt[it] <= 42.0/180.0*math.pi \\\n",
" and pp[ip] >= 23.0/180.0*math.pi and pp[ip] <= 27.0/180.0*math.pi):\n",
" c+=1\n",
" 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))\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 120.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ip,it,ir] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ip,it,ir] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ip,it,ir] = gamma*math.sqrt(eta_true[ip,it,ir]**2 + xi_true[ip,it,ir]**2)\n",
" fun_true[ip,it,ir] = s0/(1.0+sigma*slow_p)\n",
" vel_true[ip,it,ir] = 1.0/fun_true[ip,it,ir] \n",
" a_true[ip,it,ir] = 1.0 + 2.0*zeta_true[ip,it,ir]\n",
" b_true[ip,it,ir] = 1.0 - 2.0*xi_true[ip,it,ir]\n",
" c_true[ip,it,ir] = 1.0 + 2.0*xi_true[ip,it,ir]\n",
" f_true[ip,it,ir] = -2.0 * eta_true[ip,it,ir]\n",
"\n",
"\n",
"\n",
"#r_earth = 6378.1370\n",
"print(\"depminmax {} {}\".format(R_earth-rr1,R_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out\n",
"import h5py\n",
"\n",
"fout_init = h5py.File('test_model_init.h5', 'w')\n",
"fout_true = h5py.File('test_model_true.h5', 'w')\n",
"\n",
"# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init\n",
"fout_init.create_dataset('eta', data=eta_init.T)\n",
"fout_init.create_dataset('xi', data=xi_init.T)\n",
"fout_init.create_dataset('zeta', data=zeta_init.T)\n",
"fout_init.create_dataset('fun', data=fun_init.T)\n",
"fout_init.create_dataset('fac_a', data=a_init.T)\n",
"fout_init.create_dataset('fac_b', data=b_init.T)\n",
"fout_init.create_dataset('fac_c', data=c_init.T)\n",
"fout_init.create_dataset('fac_f', data=f_init.T)\n",
"fout_init.create_dataset('vel', data=vel_init.T)\n",
"\n",
"# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true\n",
"fout_true.create_dataset('eta', data=eta_true.T)\n",
"fout_true.create_dataset('xi', data=xi_true.T)\n",
"fout_true.create_dataset('zeta', data=zeta_true.T)\n",
"fout_true.create_dataset('fun', data=fun_true.T)\n",
"fout_true.create_dataset('fac_a', data=a_true.T)\n",
"fout_true.create_dataset('fac_b', data=b_true.T)\n",
"fout_true.create_dataset('fac_c', data=c_true.T)\n",
"fout_true.create_dataset('fac_f', data=f_true.T)\n",
"fout_true.create_dataset('vel', data=vel_true.T)\n",
"\n",
"fout_init.close()\n",
"fout_true.close()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(1145141919810)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"dist_dummy = 100.0\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 500\n",
"n_rec = [30 for x in range(n_src)]\n",
"\n",
"\n",
"lines = []\n",
"\n",
"nij_src = math.sqrt(n_src)\n",
"nij_rec = math.sqrt(n_rec[0])\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"\n",
"# create receiver coordinates\n",
"elev_recs=[]\n",
"lon_recs=[]\n",
"lat_recs=[]\n",
"rec_names=[]\n",
"for i in range(n_rec[0]):\n",
" #elev_recs.append(random.uniform(-100.0,-100.0)) # elevation in m\n",
" #elev_recs.append(0) # elevation in m\n",
" #lon_recs .append(random.uniform(pp1deg*1.1,pp2deg*0.9))\n",
" #lat_recs .append(random.uniform(tt1deg*1.1,tt2deg*0.9))\n",
" rec_names.append(i)\n",
" # regularly\n",
" elev_recs.append(0.0)\n",
" tmp_ilon = i%nij_rec\n",
" tmp_ilat = int(i/nij_rec)\n",
" lon_recs.append(pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec)\n",
" lat_recs.append(tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec)\n",
"\n",
"\n",
"\n",
"# create dummy src\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" # random\n",
" #dep = random.uniform((R_earth-rr1)*0.5,(R_earth-rr1)*0.98)\n",
" #lon = random.uniform(pp1deg,pp2deg)\n",
" #lat = random.uniform(tt1deg,tt2deg)\n",
"\n",
" # regularl\n",
" dep = (R_earth-rr1)*0.9\n",
" tmp_ilon = i_src%nij_src\n",
" tmp_ilat = int(i_src/nij_src)\n",
" lon = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_src\n",
" lat = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_src\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" #elev_rec = 0.0 #random.uniform(0.0,-10.0) # elevation in m\n",
" #lon_rec = random.uniform(pp1deg,pp2deg)\n",
" #lat_rec = random.uniform(tt1deg,tt2deg)\n",
" # regularly\n",
" #elev_rec = -10.0\n",
" #tmp_ilon = i_rec%nij_rec\n",
" #tmp_ilat = int(i_rec/nij_rec)\n",
" #lon_rec = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec\n",
" #lat_rec = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec\n",
"\n",
" # \n",
" elev_rec = elev_recs[i_rec]\n",
" lon_rec = lon_recs[i_rec]\n",
" lat_rec = lat_recs[i_rec]\n",
" st_name_dummy = rec_names[i_rec]\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy, lat_rec, lon_rec, elev_rec, phase_dummy, dist_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_rec,lat_rec,elev_rec])\n",
"\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,14 @@
# Inversion test
This is a test setup for inversion calculation.
1. Run all cells of `make_test_model.ipynb` for creating
- source, receiver file
- true model
- initial model
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
-> this will output src_rec_result.dat file which includes the arrival time at each station
3. run TOMOATT in inversion mode with `input_params.yml`.

View File

@@ -0,0 +1,62 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# check the change of objective values\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"fpath='objective_function.txt'\n",
"\n",
"objs=[]\n",
"\n",
"with open(fpath) as f:\n",
" lines = f.readlines()\n",
"\n",
" for l in lines:\n",
" if(l.startswith('i_inv')):\n",
" continue\n",
" objs.append(float(l.strip().split(',')[1]))\n",
"\n",
"\n",
"plt.plot(objs)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "fbd0b2a7df497f398d93ab2f589d8a5daa3108cfb7ff2b90736653cca3aeadc0"
},
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,119 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"../../utils/\")\n",
"\n",
"from src_rec_file_helper import read_src_rec_file\n",
"\n",
"events_true = read_src_rec_file(\"./src_rec_test_out.dat\")\n",
"events_calc = read_src_rec_file(\"./src_rec_test_out_out.dat\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# check objective function value\n",
"v_obj = 0.0\n",
"for i_ev in range(len(events_true)):\n",
" for i_rec in range(len(events_true[i_ev].rec_list)):\n",
" v_obj += abs(events_true[i_ev].rec_list[i_rec].arr_time - events_calc[i_ev].rec_list[i_rec].arr_time)**2/2.0\n",
"\n",
"print(\"v_obj: \", v_obj)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# calculate summation of difference of arrival times at each receiver\n",
"list_diff_v_obj = []\n",
"for i_ev in range(len(events_true)):\n",
" for i_rec in range(len(events_true[i_ev].rec_list)):\n",
" #tmp_v_obj = abs(events_true[i_ev].rec_list[i_rec].arr_time - events_calc[i_ev].rec_list[i_rec].arr_time)**2/2.0\n",
" tmp_v_obj = events_true[i_ev].rec_list[i_rec].arr_time - events_calc[i_ev].rec_list[i_rec].arr_time\n",
"\n",
" if (i_ev == 0):\n",
" list_diff_v_obj.append(tmp_v_obj)\n",
" else:\n",
" list_diff_v_obj[i_rec] += tmp_v_obj\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot list_diff_v_obj on map\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"# colormap by list_diff_v_obj\n",
"cmap = plt.get_cmap('viridis')\n",
"norm = plt.Normalize(vmin=min(list_diff_v_obj), vmax=max(list_diff_v_obj))\n",
"\n",
"print(\"min: \", min(list_diff_v_obj))\n",
"print(\"max: \", max(list_diff_v_obj))\n",
"\n",
"list_lon = []\n",
"list_lat = []\n",
"\n",
"for i_rec in range(len(events_true[0].rec_list)):\n",
" list_lon.append(events_true[0].rec_list[i_rec].lon)\n",
" list_lat.append(events_true[0].rec_list[i_rec].lat)\n",
"\n",
"plt.scatter(list_lon, list_lat, c=list_diff_v_obj, cmap=cmap, norm=norm)\n",
"\n",
"# color bar\n",
"plt.colorbar()\n",
"\n",
"# tight \n",
"plt.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,284 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# compare result from TOMOATT and fortran code\n",
"\n",
"fpath_kernel_fort = './fortran/ega5/output/kernel_step1_sum'\n",
"fpath_synth_fort = './fortran/ega5/output/syn_step1_event1' # Table\n",
"fpath_adj_fort = './fortran/ega5/output/adj_step1_event1' # TableADJ\n",
"fpath_out_tomoatt = './out_data_sim_0.h5'\n",
"\n",
"# grid information in fortran code\n",
"nr = 55\n",
"nt = 55\n",
"np = 55\n",
"npoints = nr*nt*np\n",
"\n",
"# division\n",
"ndiv_r = 1 \n",
"ndiv_t = 1 \n",
"ndiv_p = 1 "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import h5py\n",
"import numpy\n",
"\n",
"\n",
"# read fortran test file and convert to numpy array\n",
"def read_fortran_result_file(fpath):\n",
" with open(fpath, 'r') as f:\n",
" lines = f.readlines()\n",
" lines = [line.strip() for line in lines]\n",
" lines = [line for line in lines if line]\n",
" lines = [line.split() for line in lines]\n",
" lines = numpy.array(lines, dtype=numpy.float64)\n",
" return lines\n",
"\n",
"fortran_data = read_fortran_result_file(fpath_kernel_fort)\n",
"## change dimension of fortran data\n",
"Ks_fort = fortran_data[:,3].reshape(nr, nt, np)\n",
"Kxi_fort = fortran_data[:,4].reshape(nr, nt, np)\n",
"Keta_fort = fortran_data[:,5].reshape(nr, nt, np)\n",
"\n",
"fortran_synth_data = read_fortran_result_file(fpath_synth_fort).reshape(nr, nt, np)\n",
"fortran_adj_data = read_fortran_result_file(fpath_adj_fort).reshape(nr, nt, np)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# read h5 data\n",
"import sys\n",
"sys.path.append(\"../../utils/\")\n",
"\n",
"from tomoatt_data_retrieval import get_data_from_h5\n",
"\n",
"#Ks_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/Ks_update_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p, verbose=True)\n",
"#Kxi_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/Kxi_update_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p)\n",
"#Keta_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/Keta_update_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p)\n",
"\n",
"Ks_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/Ks_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p, verbose=True)\n",
"Kxi_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/Kxi_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p)\n",
"Keta_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/Keta_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p)\n",
"\n",
"Syn_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/T_res_src_0_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p)\n",
"Adj_tomoatt = get_data_from_h5(fpath_out_tomoatt, \"Data/adjoint_field_src_0_inv_0000\", nr, nt, np, ndiv_r, ndiv_t, ndiv_p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot slice of Ks_inv\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.animation as animation\n",
"\n",
"\n",
"def plot_slice(data_es, data_fort, slice_ax, id_slice, contour=False, make_anime=False, tag=\"\"):\n",
"\n",
" if (slice_ax == 'r'):\n",
" data_es_v = data_es[ id_slice, :, :]\n",
" data_fort_v = data_fort[id_slice, :, :]\n",
" elif (slice_ax == 't'):\n",
" data_es_v = data_es[ :, id_slice, :]\n",
" data_fort_v = data_fort[:, id_slice, :]\n",
" elif (slice_ax == 'p'):\n",
" data_es_v = data_es[ :, :, id_slice]\n",
" data_fort_v = data_fort[:, :, id_slice]\n",
" else:\n",
" print(\"Error: slice_ax should be 'r', 't' or 'p'\")\n",
" return\n",
"\n",
" # use the same color range for both tomoatt and fortran \n",
" combined_data = numpy.array([data_es_v.flatten(),data_fort_v.flatten()])\n",
" #Get the min and max of all your data\n",
" _min, _max = numpy.amin(combined_data), numpy.amax(combined_data)\n",
" # make the color range symmetric\n",
" if (abs(_min) > abs(_max)):\n",
" if(_min < 0):\n",
" _max = -_min\n",
" else:\n",
" _min = -_max\n",
"\n",
"\n",
"\n",
" # make the color range symmetric\n",
" diff_data = data_es_v-data_fort_v\n",
" _min_diff, _max_diff = numpy.amin(diff_data), numpy.amax(diff_data)\n",
" if (abs(_min_diff) > abs(_max_diff)):\n",
" if (_min_diff < 0):\n",
" _max_diff = -_min_diff\n",
" else:\n",
" _min_diff = -_max_diff\n",
"\n",
" #cmap1=\"viridis\"\n",
" cmap1=\"seismic\"\n",
" cmap2=\"seismic\"\n",
"\n",
" plt.figure(figsize=(20,10))\n",
"\n",
" plt.subplot(1,3,1)\n",
" plt.imshow(data_es_v, cmap=cmap1, vmin=_min, vmax=_max)\n",
" plt.colorbar()\n",
" if(contour):\n",
" plt.contour(data_es_v, colors='k', linewidths=0.5)\n",
" plt.title('result_tomoatt')\n",
"\n",
" plt.subplot(1,3,2)\n",
" plt.imshow(data_fort_v, cmap=cmap1, vmin=_min, vmax=_max)\n",
" plt.colorbar()\n",
" if(contour): \n",
" plt.contour(data_fort_v, colors='k', linewidths=0.5)\n",
" plt.title('result_fort')\n",
" \n",
" plt.subplot(1,3,3)\n",
" plt.imshow(diff_data, cmap=cmap2, vmin=_min_diff, vmax=_max_diff)\n",
" plt.colorbar()\n",
" if(contour):\n",
" plt.contour(diff_data, colors='k', linewidths=0.5) \n",
" plt.title('tomoatt-fort')\n",
"\n",
" if (not make_anime):\n",
" plt.show()\n",
" else:\n",
" plt.savefig(\"out_\"+tag+\"_\"+slice_ax+str(id_slice).zfill(3)+\".png\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_slice(Syn_tomoatt, fortran_synth_data, 'r', 20, contour=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"def anime_slices(data_es, data_fort, slice_ax, tag):\n",
"\n",
" if (slice_ax == 'r'):\n",
" n = nr\n",
" elif (slice_ax == 't'):\n",
" n = nt\n",
" elif (slice_ax == 'p'):\n",
" n = np\n",
"\n",
" for i in range(0, n):\n",
" plot_slice(data_es, data_fort, slice_ax, i, contour=True, make_anime=True, tag=tag)\n",
"\n",
" ## make png files to gif\n",
" import subprocess\n",
" subprocess.call([\"convert\", \"-delay\", \"20\", \"-loop\", \"0\", \"out_{}_{}*.png\".format(tag,slice_ax), \"out_{}_{}.gif\".format(tag,slice_ax)])\n",
" # erase png files\n",
" for i in range(0, nr):\n",
" subprocess.call([\"rm\", \"out_{}_{}\".format(tag,slice_ax)+str(i).zfill(3)+\".png\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anime_slices(Ks_tomoatt, Ks_fort, 'r', 'Ks')\n",
"anime_slices(Ks_tomoatt, Ks_fort, 't', 'Ks')\n",
"anime_slices(Ks_tomoatt, Ks_fort, 'p', 'Ks')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anime_slices(Adj_tomoatt, fortran_adj_data,'r', 'Adj')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anime_slices(Keta_tomoatt, Keta_fort, 'r', 'Keta')\n",
"anime_slices(Keta_tomoatt, Keta_fort, 't', 'Keta')\n",
"anime_slices(Keta_tomoatt, Keta_fort, 'p', 'Keta')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anime_slices(Kxi_tomoatt, Kxi_fort, 'r', 'Kxi')\n",
"anime_slices(Kxi_tomoatt, Kxi_fort, 't', 'Kxi')\n",
"anime_slices(Kxi_tomoatt, Kxi_fort, 'p', 'Kxi')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anime_slices(Adj_tomoatt, fortran_adj_data, 'r', 'adj')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,3 @@
mpif90 ega5_sphe_3d_inversion_Tong_3Dinv.f90 -o a5.out
mpirun -n 4 a5.out

View File

@@ -0,0 +1,501 @@
500
12.902894 37.503373 16.794572
17.416074 36.974148 25.587149
10.553441 48.572870 29.755519
17.050082 30.582756 20.557365
7.733536 30.049830 22.686053
2.695465 45.678252 36.050257
19.018349 30.835213 33.695062
16.538200 39.559879 22.351080
2.947435 37.234474 24.550463
15.739527 49.857044 16.506392
15.732578 34.182860 27.127186
1.296549 48.107962 29.948977
14.587690 39.140723 23.153653
18.135532 45.517829 17.105875
8.364121 30.479830 15.883796
9.211189 38.133248 17.858524
4.272898 31.194404 18.573422
6.948694 35.954361 24.462624
12.746088 49.850406 26.847644
11.313107 45.103047 16.301263
3.313507 46.477589 36.875331
10.145642 42.073024 18.769733
8.250413 48.900277 19.475522
13.804441 49.786255 16.530966
17.835237 45.927679 19.912836
11.877357 33.654921 22.852455
12.871971 34.707392 21.890595
4.097522 34.532987 27.568581
17.874029 34.484387 34.692491
3.866172 33.865449 28.496058
16.252330 41.105672 19.464576
1.213538 36.013973 17.977264
14.955385 45.399043 29.827500
17.469489 35.163250 19.273657
7.375320 32.817054 28.313777
18.585662 33.143956 25.800265
15.518612 34.328928 29.752072
18.309939 33.218516 38.096180
5.752131 32.762387 39.124230
12.471990 48.600499 37.709010
8.119302 41.058539 27.574594
13.473451 36.710096 33.310765
12.096579 45.910913 20.602681
12.291621 35.421838 19.609690
6.722855 34.197625 22.922348
19.977008 33.357824 20.801610
14.042122 42.609560 36.961508
8.278199 33.440638 35.377468
10.130480 41.237552 26.524442
9.874228 41.667609 22.900117
2.528995 40.838610 35.938716
15.334613 43.507392 36.217644
2.660098 44.120069 32.041887
1.861117 38.659778 36.102099
17.497575 45.676303 27.354341
11.287530 40.851293 33.379047
18.006903 38.149825 25.683572
9.641227 30.509291 32.005355
11.281402 38.301783 26.210378
17.511430 43.700541 20.496900
6.279207 49.780686 35.342213
10.691969 45.580664 36.011519
15.409820 38.320676 17.830344
19.051727 44.632362 37.180772
1.812418 37.134760 37.694988
4.160294 33.803068 37.492413
19.990846 44.087650 38.916613
6.919528 36.705624 30.282383
3.762207 33.859941 23.084520
6.696542 31.799267 15.983610
5.207515 43.495341 36.539506
15.760515 33.837372 18.996584
16.401076 40.346859 29.422924
3.985079 48.258603 32.826637
16.886675 48.716436 23.605320
18.974327 46.091270 22.697943
7.384952 38.441961 16.463244
4.231388 42.800608 22.558010
3.169625 49.753544 33.780253
3.741493 42.843651 38.277171
1.703036 35.504006 28.680233
2.556739 31.467144 23.718764
8.546980 41.234760 31.150894
13.221493 40.941614 33.480616
6.837920 34.912584 35.820479
7.716762 41.133360 20.876900
10.321416 31.362250 29.092427
17.855166 45.569227 19.744126
5.414400 45.949803 24.029219
10.622310 33.633958 37.349613
18.821079 45.259309 23.690669
6.400983 42.879048 20.743236
10.339512 44.689643 20.088403
14.157235 42.069607 38.833834
17.014583 34.928036 31.302363
12.827352 36.255275 22.938120
7.405344 48.287391 34.564176
3.771071 43.293532 28.422367
11.910684 48.348929 36.441739
3.053959 43.737186 36.600389
8.579958 40.581127 25.851314
11.931197 31.720220 17.810105
7.425585 44.628309 34.089390
1.517343 49.451598 36.749768
13.373374 37.648809 36.512094
4.490529 47.682461 26.286905
17.470296 43.349799 16.006251
19.343889 44.865620 31.299373
15.455612 39.569737 21.775167
13.382569 38.684806 37.606354
16.876219 37.640250 22.490769
5.007780 43.252308 31.761110
14.917810 48.036944 16.404019
18.211096 33.840776 16.319922
7.586946 30.429530 17.767477
15.527441 36.791267 32.576167
8.395652 47.363883 30.734555
8.300918 45.773041 18.973032
12.811946 37.078433 31.654726
11.271027 44.367770 23.614827
7.883254 33.508117 25.081344
9.318537 34.252752 21.126458
10.125988 49.407886 23.732711
15.231482 31.012657 38.326734
17.583612 46.667417 35.223383
3.975712 45.446574 19.293018
6.378385 47.601238 37.559922
2.237225 46.922084 15.276371
18.881117 47.018476 32.117860
7.601149 37.424848 33.048987
1.545623 35.528771 31.054720
15.305942 41.902726 32.920003
8.780450 43.137000 29.771781
15.653881 33.574476 22.550923
8.374878 42.226796 29.428747
1.649332 37.516438 29.602287
15.471741 42.579812 34.244173
14.121526 31.968351 35.539179
19.951984 31.884994 38.930168
5.686047 46.021632 37.620089
3.356280 35.028285 27.812111
17.282928 32.916989 20.503907
17.587365 30.437778 27.868687
16.846272 32.526293 23.686783
5.595438 46.916388 30.602188
10.617813 47.056847 29.509244
3.472421 46.734969 23.827490
9.450474 39.510548 26.858533
7.050903 31.802893 18.651294
16.740378 42.673295 22.941474
8.748832 49.086459 28.498236
11.101980 48.419839 33.467477
1.821840 40.425959 24.967524
18.807331 49.210102 23.627239
16.048152 33.431415 27.275778
4.156495 37.028503 23.441579
8.252786 43.619866 31.044609
6.039243 44.924797 25.445324
15.698418 36.891680 31.709361
13.305460 31.432069 28.565380
1.884098 33.514374 39.083138
19.784318 48.068758 33.412684
10.067793 43.703751 38.394139
9.332467 39.505090 19.017737
12.280919 46.423916 38.722269
18.443031 39.348801 27.023964
15.761264 48.206337 22.708882
7.403360 37.157790 15.624682
11.901780 46.996568 29.408969
19.234729 44.636488 39.127281
4.699343 31.480019 22.985463
8.029268 33.651500 17.282239
9.408798 39.483198 37.726002
2.995543 45.341282 28.914835
1.469270 43.894101 35.258155
17.054291 30.978729 17.580649
5.151633 42.357135 21.048084
11.523488 48.279981 20.451448
12.625369 47.910449 23.809322
10.805510 39.289972 33.099199
16.688680 31.235778 31.772384
5.872404 46.921761 20.735459
7.760370 49.248566 27.412126
14.981766 48.345084 22.449809
17.494891 42.556305 17.939339
16.883756 35.789221 26.232745
18.320859 32.768764 34.301897
17.639973 41.691055 20.038187
9.699485 49.507576 29.079033
18.107852 35.136726 29.376171
18.308439 37.395076 27.395968
7.807415 35.196537 36.702486
19.870463 31.937476 26.900138
3.831742 44.590580 18.565134
15.201851 32.646130 39.026955
15.828158 47.973824 36.504196
13.003291 37.834748 30.167337
6.392706 37.452325 18.574045
16.906282 42.459442 35.050055
13.809721 39.226894 19.719641
2.349331 48.568978 36.858088
13.463109 31.025621 32.611917
7.791103 35.619114 35.466085
15.908805 31.883312 36.337440
12.117860 40.626769 15.503395
17.224971 30.288926 20.225713
7.769806 32.781915 20.240085
19.515691 32.790366 18.423108
13.086107 35.997238 32.187432
19.583843 46.680117 23.645876
5.856651 40.007246 21.179095
7.862932 44.479540 23.893157
6.880727 30.486859 36.304971
12.890612 39.620341 15.500047
17.079175 38.401798 27.785445
5.828536 41.348587 16.106890
16.937460 42.816015 36.720915
3.914160 30.441916 38.949482
19.655249 45.167885 21.419356
5.977111 38.508239 20.391821
6.927604 39.621611 32.875926
18.361222 45.590869 38.069800
10.260030 43.346131 15.879682
2.192603 39.046662 33.248710
19.085453 37.873403 16.629225
12.101016 38.044051 24.990450
5.819428 32.772253 26.474392
12.724981 46.690291 27.925452
18.061294 42.771723 33.725329
14.506720 47.805098 26.622413
19.850651 49.189715 25.849751
15.219038 43.463470 25.041924
19.886991 34.051333 32.426005
7.117638 32.476564 32.376542
5.495352 36.502620 28.691081
16.996145 40.153394 37.204504
6.456862 33.696229 34.883926
2.330674 33.891702 15.484274
16.654256 35.373110 33.898747
5.038885 38.192102 27.689718
14.123672 33.761702 24.479974
1.429166 47.744844 31.788410
4.269137 39.186264 18.096003
2.289546 40.394737 27.797130
8.634843 49.702312 16.408445
4.519147 37.133705 18.956423
15.655447 42.736719 21.384360
12.749631 32.600550 38.708210
4.951746 46.823971 36.767247
9.331854 35.692199 21.771833
10.011062 46.663543 24.723024
19.949108 42.198244 27.340252
10.252827 47.219953 25.322984
16.510059 43.107901 28.874568
6.363226 49.090611 17.454213
10.635868 40.297072 33.028443
16.850642 38.133906 27.489172
1.209319 37.893652 34.507359
12.115913 34.227874 36.364014
12.821762 39.440078 33.040301
18.591223 39.525593 31.873724
8.071489 49.360508 16.522758
8.888324 42.368580 26.650131
8.889626 41.127943 35.902008
10.999334 37.031617 39.494656
18.362983 30.378271 18.297875
4.302350 36.174539 25.849816
7.203800 35.926694 33.803271
5.955434 30.625004 18.539309
18.701156 48.114168 36.495495
9.310080 31.778387 24.469818
4.443713 48.914441 17.652480
6.915923 33.492221 30.512492
12.953648 47.034138 17.407188
13.014381 38.565701 16.404760
3.750504 34.237353 36.468920
14.823263 48.440372 22.486555
15.668423 46.749729 32.080923
15.249817 31.028147 15.608834
13.264813 47.340345 31.103057
15.198867 35.515848 16.671581
9.743653 41.383808 30.090270
13.220311 46.330492 36.129090
3.174404 32.263913 36.140707
6.044751 33.274473 15.721678
11.565608 35.746820 22.653814
16.179206 44.677125 24.020450
11.327136 44.811048 32.693529
1.636618 40.444103 18.356178
10.744547 37.150505 16.214572
13.261026 34.105829 21.999317
3.868859 49.216692 21.453701
18.240428 30.304513 30.673916
7.072615 35.062618 26.710350
9.121655 48.655297 29.967281
5.855663 35.811613 27.420149
12.000977 43.413023 15.537291
6.564213 36.838226 35.870052
7.714274 42.313338 28.048145
2.081489 43.751865 27.701850
8.319217 33.115678 38.739537
14.511302 34.703210 16.585363
9.035614 36.808248 20.909689
14.228832 44.449462 15.947576
10.282913 49.531593 19.906303
17.589859 47.123318 23.446360
4.864052 37.595184 15.336005
5.554797 45.565313 38.282334
10.528200 42.619743 24.326508
11.040215 46.010982 22.617869
11.404083 46.772047 20.275623
8.466629 43.802511 26.377092
14.969797 31.351324 25.339695
14.235184 33.858954 37.025746
8.455785 49.863795 33.265439
8.889406 35.667726 17.308049
6.681788 37.412732 15.346280
8.976410 34.648739 17.568041
10.814533 44.752360 29.627384
10.199468 40.546340 32.494767
14.496903 45.258427 38.066645
3.094126 35.259604 16.746947
8.520395 42.659554 15.880581
17.611133 41.555600 18.232809
14.251795 33.115916 20.736805
7.514731 30.399115 21.351999
5.196915 45.397866 34.915807
19.166354 32.396496 21.352377
13.151796 40.555799 27.727383
5.350548 46.598504 34.378491
9.529635 40.571371 18.426558
9.126816 41.898209 17.050111
13.802897 32.953515 28.238527
15.418929 34.298935 26.833731
12.574792 35.492734 26.555897
16.938654 44.491948 25.265210
10.924080 48.518974 17.175958
7.117455 42.434404 23.654994
14.009338 36.036521 39.017975
19.349324 30.799935 19.716167
14.201462 37.024155 38.578311
2.822673 33.994394 34.302821
13.892456 32.962351 32.359032
15.995095 43.754437 29.772219
12.968758 32.410285 24.381215
1.583361 48.689008 24.016421
15.389693 46.555314 19.407358
17.453486 39.698530 32.665472
12.941524 30.636925 27.452996
13.213848 32.944137 23.119204
5.801494 40.680483 39.987076
16.748570 32.170913 15.378249
5.500054 38.628247 24.922452
9.008471 31.774374 37.808194
14.855098 47.897280 39.249556
18.168511 33.566407 22.346673
17.753149 42.913741 33.127159
19.795910 35.010497 18.833259
13.418894 37.999490 18.797014
10.696075 37.767208 37.509466
1.516162 41.220767 36.769994
9.791821 47.293788 32.327841
15.542095 41.085072 23.263423
16.094111 33.695693 15.819606
11.757946 39.421142 30.979153
16.568937 34.064155 18.969278
6.911632 36.546812 20.978434
4.881109 32.834115 39.250059
14.023054 45.882062 37.160694
9.816248 46.742746 29.781763
8.756145 37.174411 24.408729
17.588240 44.192292 26.619717
17.340343 41.790910 28.580176
12.088289 45.478525 27.897123
2.586683 37.906181 27.284716
14.494787 31.239448 15.065949
19.880752 30.337209 16.025088
12.823786 43.458027 18.855097
15.293022 31.406674 37.847072
13.980302 44.345304 18.989914
8.991872 32.283652 15.894826
10.306169 44.491996 15.351453
9.244054 31.064154 35.461811
11.066989 35.074635 21.009033
9.996705 35.829850 28.967240
11.044099 39.587919 35.338766
1.917792 49.787496 20.053103
1.898804 31.727660 26.029601
17.236757 44.662413 28.599031
8.003001 41.530145 34.147378
11.296640 31.640054 29.667642
7.470842 38.590285 16.251505
4.120357 40.312343 30.229225
8.168395 39.952977 27.957050
14.557243 45.490199 23.005864
8.675602 35.746172 28.944592
13.436976 32.236888 28.823008
17.809797 33.690628 26.829731
8.031168 39.495328 32.948914
14.566420 42.285006 32.930929
10.051800 39.544345 25.797573
15.312497 35.367693 24.154386
2.101328 37.582577 35.819286
14.200961 38.741432 22.349646
17.750624 33.199228 15.433538
5.105492 42.003092 30.932790
10.710424 46.645944 31.550315
4.863936 33.255507 39.528023
10.640629 37.713774 30.208056
3.363033 36.409599 39.058745
11.715459 45.522667 32.434962
13.464532 47.534408 37.701884
5.753267 33.153432 38.744854
18.406300 45.310872 29.325427
13.206913 40.476137 23.713366
8.022162 30.669901 22.709029
3.752878 32.705859 37.542413
1.610955 47.782385 29.385167
3.282363 49.872369 28.006430
15.645580 31.838090 35.763354
4.094538 33.332994 30.739124
19.389613 49.000040 18.201493
12.304495 31.002744 35.347648
16.636205 41.587288 38.509899
16.242905 37.908027 22.830238
5.293874 39.810962 24.214172
17.730042 40.807401 24.413293
10.848526 46.719333 35.651427
7.126381 30.842360 33.846795
5.959882 33.494248 22.053307
19.655118 37.249880 30.995999
17.472236 42.954364 33.867949
8.702629 44.307435 34.928355
14.553503 36.391143 23.208353
16.004125 47.562957 34.801544
11.432695 47.088634 33.492738
18.226320 43.756214 35.926311
3.436149 42.651048 38.536654
13.874327 30.831422 25.310616
14.802646 40.372075 29.327322
17.366240 48.310718 23.205411
18.883354 33.973377 34.189039
4.940024 38.820683 21.764487
6.389472 34.087807 31.184860
9.686298 46.746346 32.711941
14.858616 49.173689 28.350539
12.892325 33.920028 27.283556
10.997502 36.579405 32.044916
17.125470 47.650177 29.239499
10.673225 33.505780 21.271442
15.673616 33.342102 36.331892
19.150955 35.558436 38.191118
7.109812 49.243617 18.690492
6.496059 31.449753 32.600549
16.655108 39.629968 37.582826
10.026644 39.787402 21.084604
7.611422 40.274845 26.509155
19.789113 39.105677 19.207532
2.261065 37.897836 16.342341
3.544031 45.823398 29.063016
8.128766 31.176403 35.862979
1.144189 43.284815 36.664338
11.880560 36.253201 23.576926
16.624167 49.768690 39.240587
15.503963 36.766183 20.953801
17.806003 30.839724 27.752022
8.304373 48.787565 21.408915
10.181775 35.977743 18.438917
17.122472 34.268485 38.754985
5.311906 43.788904 17.804844
12.012478 31.562773 17.345468
19.961598 36.302881 28.623923
19.538837 36.303158 31.781007
4.523682 48.587788 33.198009
13.324998 42.192480 29.795723
1.123948 43.299255 23.155238
17.451114 45.355883 24.606045
4.411658 44.468014 25.506241
3.964021 38.375390 37.494247
3.342860 44.301725 24.667203
16.858232 33.418985 37.621960
17.575051 42.057543 21.681617
3.721699 44.550901 22.869235
4.536435 32.653021 20.354643
12.418668 47.807467 24.510958
3.480837 37.949268 25.698086
17.659928 48.015778 25.153195
3.404855 39.565089 37.688459
19.441124 45.664148 24.812879
15.163402 48.596491 28.147741
7.069610 34.859944 37.842481
10.350486 40.456093 36.237884
19.801801 40.683590 39.924546
7.334750 39.747428 31.758286
18.418554 30.115213 16.453879
5.771517 49.221621 20.668848
18.747257 49.783529 38.782999
12.681107 36.749221 26.025580
18.648049 31.794062 33.729165
3.086854 38.310420 27.893166

View File

@@ -0,0 +1,6 @@
5
12.902894 37.503373 16.794572
17.416074 36.974148 25.587149
10.553441 48.572870 29.755519
17.050082 30.582756 20.557365
7.733536 30.049830 22.686053

View File

@@ -0,0 +1,61 @@
60
0.0 36.472809 29.812050
0.0 42.546922 16.133799
0.0 30.991032 23.169443
0.0 46.965102 39.508986
0.0 47.511915 37.527905
0.0 48.435600 20.814328
0.0 41.863499 15.672084
0.0 32.635381 25.986810
0.0 38.657687 39.966088
0.0 40.746866 34.837968
0.0 42.548883 27.938223
0.0 45.654715 39.054882
0.0 35.547420 37.107352
0.0 34.000382 19.128119
0.0 44.563868 35.283488
0.0 40.983368 32.490992
0.0 41.849069 38.852775
0.0 30.415956 28.399387
0.0 39.547377 26.435165
0.0 32.064886 30.332071
0.0 42.476838 23.230493
0.0 34.956877 26.244838
0.0 42.093400 15.092363
0.0 37.363268 23.303628
0.0 41.913218 33.323567
0.0 43.569418 26.558183
0.0 36.206968 29.037593
0.0 30.241436 25.506620
0.0 44.117881 30.429571
0.0 39.517000 34.746538
0.0 37.361734 22.829658
0.0 49.421317 23.380557
0.0 35.352432 34.053354
0.0 42.126659 22.069541
0.0 40.290506 34.457216
0.0 37.633977 35.795705
0.0 42.640993 22.595143
0.0 41.972681 38.966854
0.0 43.073835 35.660796
0.0 45.484914 23.240725
0.0 44.787236 30.506240
0.0 36.156778 18.188633
0.0 34.670427 29.724995
0.0 48.621299 19.602209
0.0 35.103483 16.672438
0.0 48.315182 37.314071
0.0 42.367526 34.248809
0.0 39.728066 28.578711
0.0 44.531207 26.103171
0.0 31.457146 27.143870
0.0 31.580000 17.230000
0.0 32.120000 19.330000
0.0 49.220000 16.330000
0.0 45.630000 18.290000
0.0 40.870000 19.970000
0.0 48.740000 27.460000
0.0 47.520000 32.420000
0.0 33.250000 33.980000
0.0 30.990000 34.470000
0.0 31.120000 39.100000

View File

@@ -0,0 +1,6 @@
5
0.0 36.472809 29.812050
0.0 42.546922 16.133799
0.0 30.991032 23.169443
0.0 46.965102 39.508986
0.0 47.511915 37.527905

View File

@@ -0,0 +1,737 @@
include "eikon_solver_mpi.f90"
! example: 3-D 3rd order anisotropic eikonal equation in cartesian coordinate (Point source)
! parameter setting:
! domain: R * Theta * Phi = [6275, 6375] * [49^\circ, 51^\circ] * [129^\circ, 131^\circ]
! analytic solution: T = |x-x_s|/c0
! isotropic eik equ: Tx^2 + Ty^2 + Tz^2 = s^2,
! boundary condition: T(x0,y0,z0) = 0 (point source)
! test function: 'FSM_WENO3_PS_sphe_3d' in "eikon_solver.f90"
!
program eikonal_2d
use mpi
! ######################### 参数声明 parameters statement #########################
implicit none
! mesh grid
integer,parameter :: nr=55,nt=55,np=55
double precision,parameter :: pi=3.14159265358979323846264338327950288
double precision,parameter :: rr1=6070,rr2=6400
double precision,parameter :: tt1=(30.0-1.5)/180*pi,tt2=(50.0+1.5)/180*pi
double precision,parameter :: pp1=(15.0-1.5)/180*pi,pp2=(40.0+1.5)/180*pi
double precision :: rr(nr),tt(nt),pp(np),dr,dt,dp
! source (STATIONS) & receiver (EARTHQUAKES)
integer :: nsou
double precision,allocatable :: rsou(:),tsou(:),psou(:) ! source (station)
integer :: nrec
double precision,allocatable :: rrec(:),trec(:),prec(:) ! receiver (earthquake)
! model parameter
double precision,parameter :: gamma = 0.0
double precision :: xi(nr,nt,np),eta(nr,nt,np),zeta(nr,nt,np) ! syn model (ani)
double precision :: xiT(nr,nt,np),etaT(nr,nt,np),zetaT(nr,nt,np) ! true model (ani)
double precision :: sigma1,sigma2,psi
double precision,parameter :: slow_p=0.04,ani_p=0.03
! Eikonal solver
double precision :: aT(nr,nt,np),bT(nr,nt,np),cT(nr,nt,np),fT(nr,nt,np),funT(nr,nt,np) ! true model 真实模型
double precision :: a(nr,nt,np),b(nr,nt,np),c(nr,nt,np),f(nr,nt,np),fun(nr,nt,np) ! syn model 猜测模型
double precision :: uT(nr,nt,np),TableT(nr,nt,np) !true timetable 真实走时场
double precision :: u(nr,nt,np),Table(nr,nt,np) !syn timetable 猜测走时场
!double precision :: T0para(8),tau(nr,nt,np) ! multiplicative factor
! adjoint source
double precision,allocatable :: sourceADJ(:),TtimeT(:,:),Ttime(:,:) ! adjoint source 伴随源,真实走时,合成走时
double precision :: TableADJ(nr,nt,np) ! adjoint field 伴随场
double precision :: Ks(nr,nt,np),Kxi(nr,nt,np),Keta(nr,nt,np) ! event kernel
integer,parameter :: nk = 3 ! number of kernels
double precision :: all_Ks(nr,nt,np),all_Kxi(nr,nt,np),all_Keta(nr,nt,np) ! sensitivity kernel
double precision :: all_Kernel(nr,nt,np,nk) ! kernels for all parameters together
!double precision,parameter :: radius = 40 ! kernel mask radius
! inversion grid
integer,parameter :: ninvr=11,ninvt=10,ninvp=10 ! inversion grid size (coarse)
double precision,parameter :: invr1=6070.0,invr2=6400.0
double precision,parameter :: invt1=30.0/180*pi,invt2=50.0/180*pi
double precision,parameter :: invp1=15.0/180*pi,invp2=40.0/180*pi
integer,parameter :: ngrid=5 ! number of nultigrid (multigrid technique)
double precision :: invr(ngrid,ninvr),invt(ngrid,ninvt),invp(ngrid,ninvp),dinvr,dinvt,dinvp
double precision :: update_value(nr,nt,np,nk) ! parameter update value 更新参数的变化量
! model update (optimization)
double precision :: stepsize ! stepsize
integer,parameter :: MaxIter=1 ! max iteration step
double precision :: old_obj, obj, sou_obj ! 优化目标函数 objective function
double precision,allocatable :: weight_sou(:),weight_rec(:) !weight function
double precision :: dis_ij, dis_zero !weight function
logical :: weight_sou_bool=.false. , weight_rec_bool= .false.
! temp var
double precision :: depth,lat,lon
! output file
character(Len=80) :: filename,form,form2
! loop index
integer :: iir,iit,iip,idi,idj,idk,i,j,k,iter,igrid
! computing time
double precision :: time_begin,time_end,alpha
! mpi parameter
integer :: ierr,myid,nproc
! ############################# main work #############################
call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,myid,ierr)
call mpi_comm_size(mpi_comm_world,nproc,ierr)
call CPU_TIME(time_begin) ! program start
! ################### read sources and receivers 读取地震台站数据 ###################
open(10,file='ega5/input/STATIONS_5.txt')
read(10,*) nsou
allocate(rsou(nsou),tsou(nsou),psou(nsou),weight_sou(nsou))
do i=1,nsou
read(10,*) depth,lat,lon
rsou(i) = 6371.0-depth
tsou(i) = lat/180.0*pi
psou(i) = lon/180.0*pi
end do
close(10)
open(10,file='ega5/input/EARTHQUAKES_5.txt')
read(10,*) nrec
allocate(rrec(nrec),trec(nrec),prec(nrec),weight_rec(nrec))
do i=1,nrec
read(10,*) depth,lat,lon
rrec(i) = 6371.0-depth
trec(i) = lat/180.0*pi
prec(i) = lon/180.0*pi
end do
close(10)
! distance based weight -rec 台站权重
if (weight_rec_bool) then
dis_zero = 0
do i=1,nrec-1
do j=i,nrec
call Epicenter_Distance(trec(i),prec(i),trec(j),prec(j),dis_ij)
dis_zero = dis_zero + dis_ij
end do
end do
dis_zero = dis_zero/nrec/(nrec-1)*2
dis_zero = dis_zero/2
do i=1,nrec
weight_rec(i)=0.0
do j=1,nrec
call Epicenter_Distance(trec(i),prec(i),trec(j),prec(j),dis_ij)
weight_rec(i) = weight_rec(i) + exp(-(dis_ij/dis_zero)**2)
end do
weight_rec(i) = 1.0/weight_rec(i)
end do
print *, dis_zero
end if
if (weight_rec_bool) then
! distance based weight - soruce 地震权重
dis_zero = 0
do i=1,nsou-1
do j=i,nsou
call Epicenter_Distance(tsou(i),psou(i),tsou(j),psou(j),dis_ij)
dis_zero = dis_zero + dis_ij
end do
end do
dis_zero = dis_zero/nsou/(nsou-1)*2
dis_zero = dis_zero/4
do i=1,nsou
weight_sou(i)=0.0
do j=1,nsou
call Epicenter_Distance(tsou(i),psou(i),tsou(j),psou(j),dis_ij)
weight_sou(i) = weight_sou(i) + exp(-(dis_ij/dis_zero)**2)
end do
weight_sou(i) = 1.0/weight_sou(i)
end do
print *, dis_zero
end if
! ---- 记录到 matlab 数据中 matlab record ----
if (myid .eq. 0) then
open(100,file='ega5/output/STATIONS')
open(101,file='ega5/output/EARTHQUAKES')
do i=1,nsou
write(100,'(f13.7,f13.7,f13.7,f13.7)') rsou(i),tsou(i),psou(i),weight_sou(i)
end do
do i=1,nrec
write(101,'(f13.7,f13.7,f13.7,f13.7)') rrec(i),trec(i),prec(i),weight_rec(i)
end do
close(100);close(101)
end if
! ######################### 生成网格 build mesh grid #####################################
! -------- forward modeling grid ----------
dr=(rr2-rr1)/(nr-1); dt=(tt2-tt1)/(nt-1); dp=(pp2-pp1)/(np-1)
do iir=1,nr
rr(iir)=rr1+(iir-1)*dr
end do
do iit=1,nt
tt(iit)=tt1+(iit-1)*dt
end do
do iip=1,np
pp(iip)=pp1+(iip-1)*dp
end do
! -------- inversion multigrid ----------
dinvr=(invr2-invr1)/(ninvr-1); dinvt=(invt2-invt1)/(ninvt-1); dinvp=(invp2-invp1)/(ninvp-1)
do igrid=1,ngrid
do iir=1,ninvr
invr(igrid,iir)=invr1+(iir-1)*dinvr-(igrid-1)*dinvr/ngrid
end do
do iit=1,ninvt
invt(igrid,iit)=invt1+(iit-1)*dinvt-(igrid-1)*dinvt/ngrid
end do
do iip=1,ninvp
invp(igrid,iip)=invp1+(iip-1)*dinvp-(igrid-1)*dinvp/ngrid
end do
end do
! ######################### 构建背景模型 build the synthetic and true model #####################################
do iir=1,nr
do iit=1,nt
do iip=1,np
! synthetic (initial) model
eta(iir,iit,iip)=0.0;
xi(iir,iit,iip)=0.0;
zeta(iir,iit,iip)=gamma*sqrt(eta(iir,iit,iip)**2+xi(iir,iit,iip)**2)
! if (rr(iir)>6351) then ! 6371 - 6351 20 km
! fun(iir,iit,iip) = 1.0/(5.8+(6371-rr(iir))/20.0*0.7)
! elseif (rr(iir)>6336) then ! 6351 - 6336 15 km
! fun(iir,iit,iip) = 1.0/(6.5+(6351-rr(iir))/15.0*0.6)
! elseif (rr(iir)>6251) then ! 6336 - 6251 85 km
! fun(iir,iit,iip) = 1.0/(8.04+(6336-rr(iir))/85.0*0.01)
! elseif (rr(iir)>6161) then ! 6251 - 6161 90 km
! fun(iir,iit,iip) = 1.0/(8.05+(6251-rr(iir))/90.0*0.25)
! elseif (rr(iir)>5961) then ! 6161 - 5961 200 km
! fun(iir,iit,iip) = 1.0/(8.30+(6161-rr(iir))/200.0*0.73)
! else
! fun(iir,iit,iip) = 1.0/9.03
! end if
if (rr(iir)>6351) then ! 6371 - 6351 20 km
fun(iir,iit,iip) = 1.0/(5.8+(6371-rr(iir))/20.0*0.7)
elseif (rr(iir)>6336) then ! 6351 - 6336 15 km
fun(iir,iit,iip) = 1.0/(6.5+(6351-rr(iir))/15.0*0.6)
elseif (rr(iir)>5961) then ! 6351 - 6336 15 km
fun(iir,iit,iip) = 1.0/(8.0+(6336-rr(iir))/375.0*1)
else
fun(iir,iit,iip) = 1.0/9.0
end if
!read(100,*) xi(iir,iit,iip)
!read(101,*) eta(iir,iit,iip)
!read(102,*) fun(iir,iit,iip)
a(iir,iit,iip)=1.0+2*zeta(iir,iit,iip);
b(iir,iit,iip)=1.0-2*xi(iir,iit,iip);
c(iir,iit,iip)=1.0+2*xi(iir,iit,iip);
f(iir,iit,iip)=-2*eta(iir,iit,iip);
Table(iir,iit,iip) = 0
! true (target) model
if (tt(iit)>=30.0/180*pi .and. tt(iit)<=50.0/180*pi .and. &
& pp(iip)>=15.0/180*pi .and. pp(iip)<=40.0/180*pi .and. &
& rr(iir)>=6211.0 .and. rr(iir)<=6371.0 ) then
sigma1 = sin(4*pi*(tt(iit)-30.0/180*pi)/(20.0/180*pi))* &
& sin(4*pi*(pp(iip)-15.0/180*pi)/(25.0/180*pi))* &
& sin(2*pi*(rr(iir)-6211)/160.0)
else
sigma1 = 0.0
end if
if (sigma1<0) then
psi = 60.0/180*pi
elseif (sigma1 > 0) then
psi = 150.0/180*pi
else
psi = 0
end if
etaT(iir,iit,iip)=ani_p*abs(sigma1)*sin(2*psi);
xiT(iir,iit,iip)=ani_p*abs(sigma1)*cos(2*psi);
zetaT(iir,iit,iip)=gamma*sqrt(etaT(iir,iit,iip)**2+xiT(iir,iit,iip)**2)
aT(iir,iit,iip)=1.0+2*zetaT(iir,iit,iip);
bT(iir,iit,iip)=1.0-2*xiT(iir,iit,iip);
cT(iir,iit,iip)=1.0+2*xiT(iir,iit,iip);
fT(iir,iit,iip)=-2*etaT(iir,iit,iip);
funT(iir,iit,iip) = fun(iir,iit,iip)/(1+sigma1*slow_p)
!fun(iir,iit,iip) = funT(iir,iit,iip)
!eta(iir,iit,iip)=etaT(iir,iit,iip);
!xi(iir,iit,iip)=xiT(iir,iit,iip);
!zeta(iir,iit,iip)=zetaT(iir,iit,iip)
!a(iir,iit,iip)=aT(iir,iit,iip)
!b(iir,iit,iip)=bT(iir,iit,iip)
!c(iir,iit,iip)=cT(iir,iit,iip)
!f(iir,iit,iip)=fT(iir,iit,iip)
TableT(iir,iit,iip) = 0
u(iir,iit,iip) = 0
end do
end do
end do
! ---- 记录到 matlab 数据中 matlab record ----
if (myid==0) then
open(100,file='ega5/output/model_true')
open(101,file='ega5/output/model_init')
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& funT(iir,iit,iip),xiT(iir,iit,iip),etaT(iir,iit,iip)
write(101,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& fun(iir,iit,iip),xi(iir,iit,iip),eta(iir,iit,iip)
end do
end do
end do
close(100);close(101)
! --------- 多重网格 multiple grid ------
do igrid=1,Ngrid
select case(igrid)
case (1:9)
write(form,'(I1)') igrid
case (10:99)
write(form,'(I2)') igrid
end select
open(100,file='ega5/output/multigrid'//trim(form))
do iir=1,ninvr
do iit=1,ninvt
do iip=1,ninvp
write(100,'(f13.7,f13.7,f13.7)') &
& invr(igrid,iir),invt(igrid,iit),invp(igrid,iip)
end do
end do
end do
close(100)
end do
end if
! ######################### 计算真实到时 calculate true traveltimes ######################
call mpi_barrier(mpi_comm_world,ierr)
allocate(TtimeT(nsou,nrec)) ! 初始化真实到时表 initiate true traveltimes
allocate(Ttime(nsou,nrec)) ! 初始化合成到时表 initiate syn traveltimes
allocate(sourceADJ(nrec)) ! 初始化伴随源 initiate adjoint source
if (myid==0) then
print *, ' '
print *, '----------------- calculating true timetable ... ----------------'
print *, ' '
end if
do i=1,nsou ! loop sources (STATIONS)
! -------- 求解程函方程 solve eikonal equations ------------
call mpi_barrier(mpi_comm_world,ierr)
!rsou(i)=6371.0; tsou(i)=30.5/180.0*pi; psou(i)=15.5/180.0*pi
call FSM_WENO3_PS_sphe_3d_mul_mpi(rr,tt,pp,nr,nt,np,aT,bT,cT,fT,TableT,funT,rsou(i),tsou(i),psou(i),u)
call mpi_barrier(mpi_comm_world,ierr)
! -------- 得到真实走时 calculate true arrival time at receiver --------
call Linear_Interp_3D(rr,tt,pp,TableT,nr,nt,np,rrec,trec,prec,TtimeT(i,:),nrec)
!if ((myid.eq.0) .and. 1>0) then
! print *, rsou(i),tsou(i)/pi*180,psou(i)/pi*180
! open(100,file='ega5/output/arrivaltime')
! do j=1,nrec
! write(100,'(i5.3,f8.2,f6.2,f6.2,f8.3)') j, rrec(j),trec(j)/pi*180,prec(j)/pi*180,TtimeT(i,j)
! end do
! close(100)
!end if
end do
print *, '----------------- calculating true timetable over ---------------- '
! ######################## 反演开始 inversion start ##########################
! ----- 初始化反演参数 initiate inversion parameters ----
stepsize = 0.01 ! 迭代步长 stepsize
old_obj = 0; obj = 0 ! 目标函数 objective function
if (myid .eq. 0) then
print *, ' '
print *, '----------------- inversion start ... ----------------'
print *, ' '
end if
do iter = 1,MaxIter
call mpi_barrier(mpi_comm_world,ierr)
if (myid .eq. 0) then
print *, '----------------- iteration ',iter,' starting ... ----------------'
end if
! ----- 初始化参数 initiate parameters ------
all_Ks = 0; all_Kxi = 0; all_Keta = 0;
obj = 0;
if (myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/misfit_step'//trim(form)
open(998, file=trim(filename))
end if
do i=1,nsou ! loop sources (STATIONS)
! ######################## 计算合成走时场 calculate synthetic timetable ########################
if (myid .eq. 0) then
print *, '----------------- calculating synthetic timetable ... ----------------'
end if
Table = 20
call mpi_barrier(mpi_comm_world,ierr)
call FSM_WENO3_PS_sphe_3d_mul_mpi(rr,tt,pp,nr,nt,np,a,b,c,f,Table,fun,rsou(i),tsou(i),psou(i),u)
call mpi_barrier(mpi_comm_world,ierr)
! -------- 得到合成走时 calculate synthetic arrival time at receiver --------
call Linear_Interp_3D(rr,tt,pp,Table,nr,nt,np,rrec,trec,prec,Ttime(i,:),nrec)
! -------- 构造伴随源 build adjoint source -------
call Adjoint_Source_Dt(Ttime(i,:),TtimeT(i,:),nrec,sourceADJ,sou_obj) ! absolute traveltime difference
if (myid .eq. 0) then
do j=1,nrec
write(998,'(f10.5)') Ttime(i,j)-TtimeT(i,j)
end do
end if
! weighting adjoint source
if (weight_rec_bool) then
do j=1,nrec
sourceADJ(j) = sourceADJ(j) * weight_rec(j)
end do
end if
if (1>0 .and. (myid .eq. 0)) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
select case (i)
case (1:9)
write(form2,'(I1)') i
case (10:99)
write(form2,'(I2)') i
end select
filename='ega5/output/syn_step'//trim(form)//'_event'//trim(form2)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7)') Table(iir,iit,iip)
end do
end do
end do
close(100)
end if
!
!print *, Ttime(i,:),TtimeT(i,:)
!call Adjoint_Source_Ddt(Ttime(i,:),TtimeT(i,:),nrec,sourceADJ,sou_obj) ! double difference traveltime
!do j=1,nrec-1
! do k=j,nrec
! write(998,'(f10.5)') (Ttime(i,j)-Ttime(i,k))-(TtimeT(i,j)-TtimeT(i,k))
! end do
!end do
! ######################## 计算伴随场 adjoint field ########################
if (myid .eq. 0) then
! print *, '----------------- calculating adjoint field ... ----------------'
end if
call FSM_O1_Adj_sphe_3d(rr,tt,pp,nr,nt,np,Table,TableADJ,zeta,xi,eta,nrec,rrec,trec,prec,sourceADJ)
!call FSM_O1_Adj_PS_sphe_3d(rr,tt,pp,nr,nt,np,T0para,tau,TableADJ,zeta,xi,eta,nrec,rrec,trec,prec,sourceADJ)
! ---- 记录到 matlab 数据中 matlab record (adjoint field) ----
if (1>0 .and. (myid .eq. 0)) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
select case (i)
case (1:9)
write(form2,'(I1)') i
case (10:99)
write(form2,'(I2)') i
end select
filename='ega5/output/adj_step'//trim(form)//'_event'//trim(form2)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7)') TableADJ(iir,iit,iip)
end do
end do
end do
close(100)
end if
! ######################## 计算敏感核 sensitivity kernel ########################
!print *, '----------------- calculating kernel ... ----------------'
call Sensitivity_Kernel(rr,tt,pp,nr,nt,np,Table,TableADJ,gamma,xi,eta,fun,Ks,Kxi,Keta)
! ------- 抹去伴随源处的大函数值 mask the source -------
!print *, '----------------- kernel mask ----------------'
!call Kernel_Mask(rr,tt,pp,nr,nt,np,Ks,rsou(i),tsou(i),psou(i),radius)
!call Kernel_Mask(rr,tt,pp,nr,nt,np,Kxi,rsou(i),tsou(i),psou(i),radius)
!call Kernel_Mask(rr,tt,pp,nr,nt,np,Keta,rsou(i),tsou(i),psou(i),radius)
call Kernel_Mask_new(rr,tt,pp,nr,nt,np,Ks,rsou(i),tsou(i),psou(i))
call Kernel_Mask_new(rr,tt,pp,nr,nt,np,Kxi,rsou(i),tsou(i),psou(i))
call Kernel_Mask_new(rr,tt,pp,nr,nt,np,Keta,rsou(i),tsou(i),psou(i))
! ---- 记录到 matlab 数据中 matlab record (adjoint field) ----
if (1<0 .and. myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
select case (i)
case (1:9)
write(form2,'(I1)') i
case (10:99)
write(form2,'(I2)') i
end select
filename='ega5/output/kernel_step'//trim(form)//'_event'//trim(form2)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& Ks(iir,iit,iip),Kxi(iir,iit,iip),Keta(iir,iit,iip)
end do
end do
end do
close(100)
end if
! --------- 敏感核,obj叠加 sum kernels and objective function -------
if (weight_sou_bool) then ! no weight
all_Ks = all_Ks + Ks * weight_sou(i);
all_Kxi = all_Kxi + Kxi * weight_sou(i);
all_Keta = all_Keta + Keta * weight_sou(i);
obj = obj + sou_obj !* weight_sou(i)
else ! source weighted
all_Ks = all_Ks + Ks;
all_Kxi = all_Kxi + Kxi;
all_Keta = all_Keta + Keta;
obj = obj + sou_obj
end if
end do
close(998)
! ---- 记录到 matlab 数据中 matlab record (kernel) ----
if (1>0 .and. myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/kernel_step'//trim(form)//'_sum'
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& all_Ks(iir,iit,iip),all_Kxi(iir,iit,iip),all_Keta(iir,iit,iip)
end do
end do
end do
close(100)
end if
! ##################### 模型更新 model update ####################
print *, '----------------- model updating ... ----------------'
all_Kernel(:,:,:,1) = all_Ks;
all_Kernel(:,:,:,2) = all_Kxi;
all_Kernel(:,:,:,3) = all_Keta;
! ------------ 更新速度(慢度) update velocity (slowness) ------------
call Parameter_Update_Multigrid(rr,tt,pp,nr,nt,np,all_Kernel,nk, &
& invr,invt,invp,ninvr,ninvt,ninvp,ngrid,stepsize,update_value)
if (1<0 .and. myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/model_update_step'//trim(form)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& -fun(iir,iit,iip)*update_value(iir,iit,iip,1), &
& -update_value(iir,iit,iip,2),-update_value(iir,iit,iip,3)
end do
end do
end do
close(100)
end if
do iir=1,nr
do iit=1,nt
do iip=1,np
fun(iir,iit,iip) = fun(iir,iit,iip)*(1-update_value(iir,iit,iip,1))
!fun(iir,iit,iip) = fun(iir,iit,iip)
end do
end do
end do
! ------------ 更新xi update xi ------------
do iir=1,nr
do iit=1,nt
do iip=1,np
xi(iir,iit,iip) = xi(iir,iit,iip)-update_value(iir,iit,iip,2)
end do
end do
end do
! ------------ 更新eta update eta ------------
do iir=1,nr
do iit=1,nt
do iip=1,np
eta(iir,iit,iip) = eta(iir,iit,iip)-update_value(iir,iit,iip,3)
end do
end do
end do
! ----------- 更新 update eikonal solver paramater -----------------
do iir=1,nr
do iit=1,nt
do iip=1,np
b(iir,iit,iip)=1.0-2*xi(iir,iit,iip);
c(iir,iit,iip)=1.0+2*xi(iir,iit,iip);
f(iir,iit,iip)=-2*eta(iir,iit,iip);
end do
end do
end do
! ##################### 调整下降步长 modify stepsize #############
if (myid .eq. 0) then
print *, ' '
end if
if (1>0 .and. (myid .eq. 0)) then
open(999,file='ega5/output/obj',access='append')
write(999,'(f9.2,f9.6)') obj, stepsize
close(999)
end if
if (iter == 1 ) then
if (myid .eq. 0) then
write(*,'(a,f9.2)') 'iter 1, obj is', obj
write(*,'(a,f9.6)') 'iter 1, stepsize is', stepsize
end if
elseif (iter >= 2 .and. obj < old_obj) then
!stepsize = min(0.01,stepsize*1.2)
if (myid .eq. 0) then
write(*,'(a,f9.2,a,f9.2)') 'objective function decreases, from', old_obj, ' to', obj
write(*,'(a,f9.6)') 'new stepsize is ', stepsize
end if
elseif (iter >= 2 .and. obj >= old_obj) then
!stepsize = max(0.002,stepsize*0.5)
if (myid .eq. 0) then
write(*,'(a,f9.2,a,f9.2)') 'objective function increases, from', old_obj, ' to', obj
write(*,'(a,f9.6)') 'new stepsize is ', stepsize
end if
end if
print *, '----------------- iteration ',iter,' over ----------------'
print *, ' '
print *, ' '
old_obj = obj
! ---- 记录到 matlab 数据中 matlab record ----
if (1>0 .and. (myid .eq. 0)) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/model_step'//trim(form)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& fun(iir,iit,iip),xi(iir,iit,iip),eta(iir,iit,iip)
end do
end do
end do
close(100)
end if
if (myid .eq. 0) then
call CPU_TIME(time_end)
write(*,'(f10.2)') time_end - time_begin
end if
end do
call mpi_finalize(ierr)
end program eikonal_2d

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0,301.0] # depth in km
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test_out.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
#src_rec_file : 'src_rec_compare_with_fortran_out.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_type : '' # 'fd' (input file) or '1d_ak135'
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 : 2 # optimization method. 0 : "grad_descent", 1 : "lbfgs", 2 : "halve-stepping"
smooth_method : 0 # 0: multigrid parametrization, 1: laplacian smoothing with CG
max_iterations_inv : 100 # maximum number of inversion iterations
step_size : 0.01 # step size for inversion
# parameters for multiparametric inversion
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [11,10,10] # number of the base inversion grid points
min_max_dep_inv : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat_inv : [30.0,50.0] # latitude in degree
min_max_lon_inv : [15.0,40.0] # longitude in degree
# parameters for laplacian smoothing
l_smooth_rtp : [1,1,1] # smoothing coefficients for each direction
regularization_weight : 2000.0 # regularization weight
# parameter for halving-stepping or lbfgs
max_sub_iterations : 100 # maximum number of sub-iterations
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
use_gpu : 0
calculation :
convergence_tolerance : 1e-5
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,36 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0,301.0] # depth in km
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
#src_rec_file : 'src_rec_compare_with_fortran.txt' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 1 # swap source and receiver
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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 : 8 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-5
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,328 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"#R_earth = 6378.1370\n",
"R_earth = 6371.0\n",
"\n",
"rr1=6070\n",
"rr2=6400\n",
"tt1=(30.0-1.5)/180*math.pi\n",
"tt2=(50.0+1.5)/180*math.pi\n",
"pp1=(15.0-1.5)/180*math.pi\n",
"pp2=(40.0+1.5)/180*math.pi\n",
"\n",
"n_rtp = [55,55,55]\n",
"n_rtp.reverse()\n",
"dr = (rr2-rr1)/(n_rtp[2]-1)\n",
"dt = (tt2-tt1)/(n_rtp[1]-1)\n",
"dp = (pp2-pp1)/(n_rtp[0]-1)\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[2])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[0])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"s0 = 1.0/6.0\n",
"slow_p=0.04\n",
"ani_p=0.03\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"a_init = np.zeros(n_rtp)\n",
"b_init = np.zeros(n_rtp)\n",
"c_init = np.zeros(n_rtp)\n",
"f_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"a_true = np.zeros(n_rtp)\n",
"b_true = np.zeros(n_rtp)\n",
"c_true = np.zeros(n_rtp)\n",
"f_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ip,it,ir] = 0.0\n",
" #xi_init[ip,it,ir] = 0.0\n",
" zeta_init[ip,it,ir] = gamma*math.sqrt(eta_init[ip,it,ir]**2 + xi_init[ip,it,ir]**2)\n",
" \n",
" if (rr[ir]>6351):\n",
" fun_init[ip,it,ir] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)\n",
" elif (rr[ir]>6336):\n",
" fun_init[ip,it,ir] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)\n",
" elif (rr[ir]>5961):\n",
" fun_init[ip,it,ir] = 1.0/(8.0+(6336-rr[ir])/375.0*1) \n",
" else:\n",
" fun_init[ip,it,ir] = 1.0/9.0\n",
"\n",
" vel_init[ip,it,ir] = 1.0/fun_init[ip,it,ir]\n",
" a_init[ip,it,ir] = 1.0 + 2.0*zeta_init[ip,it,ir]\n",
" b_init[ip,it,ir] = 1.0 - 2.0*xi_init[ip,it,ir]\n",
" c_init[ip,it,ir] = 1.0 + 2.0*xi_init[ip,it,ir]\n",
" f_init[ip,it,ir] = -2.0 * eta_init[ip,it,ir]\n",
"\n",
" # true model\n",
" if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \\\n",
" and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \\\n",
" and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):\n",
" c+=1\n",
" sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \\\n",
" *math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \\\n",
" *math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 150.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ip,it,ir] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ip,it,ir] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ip,it,ir] = gamma*math.sqrt(eta_true[ip,it,ir]**2 + xi_true[ip,it,ir]**2)\n",
" fun_true[ip,it,ir] = fun_init[ip,it,ir]/(1.0+sigma*slow_p)\n",
" vel_true[ip,it,ir] = 1.0/fun_true[ip,it,ir] \n",
" a_true[ip,it,ir] = 1.0 + 2.0*zeta_true[ip,it,ir]\n",
" b_true[ip,it,ir] = 1.0 - 2.0*xi_true[ip,it,ir]\n",
" c_true[ip,it,ir] = 1.0 + 2.0*xi_true[ip,it,ir]\n",
" f_true[ip,it,ir] = -2.0 * eta_true[ip,it,ir]\n",
"\n",
"\n",
"\n",
"print(\"depminmax {} {}\".format(R_earth-rr1,R_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out\n",
"import h5py\n",
"\n",
"fout_init = h5py.File('test_model_init.h5', 'w')\n",
"fout_true = h5py.File('test_model_true.h5', 'w')\n",
"\n",
"# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init\n",
"fout_init.create_dataset('eta', data=eta_init.T)\n",
"fout_init.create_dataset('xi', data=xi_init.T)\n",
"fout_init.create_dataset('zeta', data=zeta_init.T)\n",
"fout_init.create_dataset('fun', data=fun_init.T)\n",
"fout_init.create_dataset('fac_a', data=a_init.T)\n",
"fout_init.create_dataset('fac_b', data=b_init.T)\n",
"fout_init.create_dataset('fac_c', data=c_init.T)\n",
"fout_init.create_dataset('fac_f', data=f_init.T)\n",
"fout_init.create_dataset('vel', data=vel_init.T)\n",
"\n",
"# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true\n",
"fout_true.create_dataset('eta', data=eta_true.T)\n",
"fout_true.create_dataset('xi', data=xi_true.T)\n",
"fout_true.create_dataset('zeta', data=zeta_true.T)\n",
"fout_true.create_dataset('fun', data=fun_true.T)\n",
"fout_true.create_dataset('fac_a', data=a_true.T)\n",
"fout_true.create_dataset('fac_b', data=b_true.T)\n",
"fout_true.create_dataset('fac_c', data=c_true.T)\n",
"fout_true.create_dataset('fac_f', data=f_true.T)\n",
"fout_true.create_dataset('vel', data=vel_true.T)\n",
"\n",
"fout_init.close()\n",
"fout_true.close()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(1145141919810)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"dist_dummy = 100.0\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 500\n",
"n_rec = [60 for x in range(n_src)]\n",
"#n_src = 10\n",
"#n_rec = [10 for x in range(n_src)]\n",
"\n",
"\n",
"\n",
"lines = []\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"# create receiver coordinates\n",
"elev_recs=[]\n",
"lon_recs=[]\n",
"lat_recs=[]\n",
"rec_names=[]\n",
"for i in range(n_rec[0]):\n",
" #elev_recs.append(random.uniform(-100.0,-100.0)) # elevation in m\n",
" elev_recs.append(0) # elevation in m\n",
" lon_recs .append(random.uniform(pp1deg*1.1,pp2deg*0.9))\n",
" lat_recs .append(random.uniform(tt1deg*1.1,tt2deg*0.9))\n",
" rec_names.append(i)\n",
"\n",
"\n",
"\n",
"# create dummy src\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" dep = random.uniform((R_earth-rr1)*0.1,(R_earth-rr1)*0.9)\n",
" lon = random.uniform(pp1deg,pp2deg)\n",
" lat = random.uniform(tt1deg,tt2deg)\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" #elev_rec = random.uniform(0.0,-10.0) # elevation in m\n",
" #lon_rec = random.uniform(pp1deg,pp2deg)\n",
" #lat_rec = random.uniform(tt1deg,tt2deg)\n",
" elev_rec = elev_recs[i_rec]\n",
" lon_rec = lon_recs[i_rec]\n",
" lat_rec = lat_recs[i_rec]\n",
" st_name_dummy = rec_names[i_rec]\n",
"\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy, lat_rec, lon_rec, elev_rec, phase_dummy, dist_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_rec,lat_rec,elev_rec])\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,14 @@
# Inversion test
This is a test setup for inversion calculation.
1. Run all cells of `make_test_model.ipynb` for creating
- source, receiver file
- true model
- initial model
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
-> this will output src_rec_result.dat file which includes the arrival time at each station
3. run TOMOATT in inversion mode with `input_params.yml`.

View File

@@ -0,0 +1,64 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# check the change of objective values\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"fpath='objective_function.txt'\n",
"\n",
"objs=[]\n",
"\n",
"with open(fpath) as f:\n",
" lines = f.readlines()\n",
"\n",
" for l in lines:\n",
" if(l.startswith('i_inv')):\n",
" continue\n",
" objs.append(float(l.strip().split(',')[1]))\n",
"\n",
"\n",
"plt.plot(objs)\n"
]
},
{
"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.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]"
},
"vscode": {
"interpreter": {
"hash": "cdd74c396a461f81d13d16403c726c38089d3c42a4b6e59262cdb9511d16556b"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
mpif90 ega5_sphe_3d_inversion_Tong_3Dinv.f90 -o a5.out
mpirun -n 4 a5.out

View File

@@ -0,0 +1,2 @@
1
12.902894 37.503373 16.794572

View File

@@ -0,0 +1,2 @@
1
0.0 36.472809 29.812050

View File

@@ -0,0 +1,737 @@
include "eikon_solver_mpi.f90"
! example: 3-D 3rd order anisotropic eikonal equation in cartesian coordinate (Point source)
! parameter setting:
! domain: R * Theta * Phi = [6275, 6375] * [49^\circ, 51^\circ] * [129^\circ, 131^\circ]
! analytic solution: T = |x-x_s|/c0
! isotropic eik equ: Tx^2 + Ty^2 + Tz^2 = s^2,
! boundary condition: T(x0,y0,z0) = 0 (point source)
! test function: 'FSM_WENO3_PS_sphe_3d' in "eikon_solver.f90"
!
program eikonal_2d
use mpi
! ######################### 参数声明 parameters statement #########################
implicit none
! mesh grid
integer,parameter :: nr=55,nt=55,np=55
double precision,parameter :: pi=3.14159265358979323846264338327950288
double precision,parameter :: rr1=6070,rr2=6400
double precision,parameter :: tt1=(30.0-1.5)/180*pi,tt2=(50.0+1.5)/180*pi
double precision,parameter :: pp1=(15.0-1.5)/180*pi,pp2=(40.0+1.5)/180*pi
double precision :: rr(nr),tt(nt),pp(np),dr,dt,dp
! source (STATIONS) & receiver (EARTHQUAKES)
integer :: nsou
double precision,allocatable :: rsou(:),tsou(:),psou(:) ! source (station)
integer :: nrec
double precision,allocatable :: rrec(:),trec(:),prec(:) ! receiver (earthquake)
! model parameter
double precision,parameter :: gamma = 0.0
double precision :: xi(nr,nt,np),eta(nr,nt,np),zeta(nr,nt,np) ! syn model (ani)
double precision :: xiT(nr,nt,np),etaT(nr,nt,np),zetaT(nr,nt,np) ! true model (ani)
double precision :: sigma1,sigma2,psi
double precision,parameter :: slow_p=0.04,ani_p=0.03
! Eikonal solver
double precision :: aT(nr,nt,np),bT(nr,nt,np),cT(nr,nt,np),fT(nr,nt,np),funT(nr,nt,np) ! true model 真实模型
double precision :: a(nr,nt,np),b(nr,nt,np),c(nr,nt,np),f(nr,nt,np),fun(nr,nt,np) ! syn model 猜测模型
double precision :: uT(nr,nt,np),TableT(nr,nt,np) !true timetable 真实走时场
double precision :: u(nr,nt,np),Table(nr,nt,np) !syn timetable 猜测走时场
!double precision :: T0para(8),tau(nr,nt,np) ! multiplicative factor
! adjoint source
double precision,allocatable :: sourceADJ(:),TtimeT(:,:),Ttime(:,:) ! adjoint source 伴随源,真实走时,合成走时
double precision :: TableADJ(nr,nt,np) ! adjoint field 伴随场
double precision :: Ks(nr,nt,np),Kxi(nr,nt,np),Keta(nr,nt,np) ! event kernel
integer,parameter :: nk = 3 ! number of kernels
double precision :: all_Ks(nr,nt,np),all_Kxi(nr,nt,np),all_Keta(nr,nt,np) ! sensitivity kernel
double precision :: all_Kernel(nr,nt,np,nk) ! kernels for all parameters together
!double precision,parameter :: radius = 40 ! kernel mask radius
! inversion grid
integer,parameter :: ninvr=11,ninvt=10,ninvp=10 ! inversion grid size (coarse)
double precision,parameter :: invr1=6070.0,invr2=6400.0
double precision,parameter :: invt1=30.0/180*pi,invt2=50.0/180*pi
double precision,parameter :: invp1=15.0/180*pi,invp2=40.0/180*pi
integer,parameter :: ngrid=5 ! number of nultigrid (multigrid technique)
double precision :: invr(ngrid,ninvr),invt(ngrid,ninvt),invp(ngrid,ninvp),dinvr,dinvt,dinvp
double precision :: update_value(nr,nt,np,nk) ! parameter update value 更新参数的变化量
! model update (optimization)
double precision :: stepsize ! stepsize
integer,parameter :: MaxIter=1 ! max iteration step
double precision :: old_obj, obj, sou_obj ! 优化目标函数 objective function
double precision,allocatable :: weight_sou(:),weight_rec(:) !weight function
double precision :: dis_ij, dis_zero !weight function
logical :: weight_sou_bool=.false. , weight_rec_bool= .false.
! temp var
double precision :: depth,lat,lon
! output file
character(Len=80) :: filename,form,form2
! loop index
integer :: iir,iit,iip,idi,idj,idk,i,j,k,iter,igrid
! computing time
double precision :: time_begin,time_end,alpha
! mpi parameter
integer :: ierr,myid,nproc
! ############################# main work #############################
call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,myid,ierr)
call mpi_comm_size(mpi_comm_world,nproc,ierr)
call CPU_TIME(time_begin) ! program start
! ################### read sources and receivers 读取地震台站数据 ###################
open(10,file='ega5/input/STATIONS.txt')
read(10,*) nsou
allocate(rsou(nsou),tsou(nsou),psou(nsou),weight_sou(nsou))
do i=1,nsou
read(10,*) depth,lat,lon
rsou(i) = 6371.0-depth
tsou(i) = lat/180.0*pi
psou(i) = lon/180.0*pi
end do
close(10)
open(10,file='ega5/input/EARTHQUAKES.txt')
read(10,*) nrec
allocate(rrec(nrec),trec(nrec),prec(nrec),weight_rec(nrec))
do i=1,nrec
read(10,*) depth,lat,lon
rrec(i) = 6371.0-depth
trec(i) = lat/180.0*pi
prec(i) = lon/180.0*pi
end do
close(10)
! distance based weight -rec 台站权重
if (weight_rec_bool) then
dis_zero = 0
do i=1,nrec-1
do j=i,nrec
call Epicenter_Distance(trec(i),prec(i),trec(j),prec(j),dis_ij)
dis_zero = dis_zero + dis_ij
end do
end do
dis_zero = dis_zero/nrec/(nrec-1)*2
dis_zero = dis_zero/2
do i=1,nrec
weight_rec(i)=0.0
do j=1,nrec
call Epicenter_Distance(trec(i),prec(i),trec(j),prec(j),dis_ij)
weight_rec(i) = weight_rec(i) + exp(-(dis_ij/dis_zero)**2)
end do
weight_rec(i) = 1.0/weight_rec(i)
end do
print *, dis_zero
end if
if (weight_rec_bool) then
! distance based weight - soruce 地震权重
dis_zero = 0
do i=1,nsou-1
do j=i,nsou
call Epicenter_Distance(tsou(i),psou(i),tsou(j),psou(j),dis_ij)
dis_zero = dis_zero + dis_ij
end do
end do
dis_zero = dis_zero/nsou/(nsou-1)*2
dis_zero = dis_zero/4
do i=1,nsou
weight_sou(i)=0.0
do j=1,nsou
call Epicenter_Distance(tsou(i),psou(i),tsou(j),psou(j),dis_ij)
weight_sou(i) = weight_sou(i) + exp(-(dis_ij/dis_zero)**2)
end do
weight_sou(i) = 1.0/weight_sou(i)
end do
print *, dis_zero
end if
! ---- 记录到 matlab 数据中 matlab record ----
if (myid .eq. 0) then
open(100,file='ega5/output/STATIONS')
open(101,file='ega5/output/EARTHQUAKES')
do i=1,nsou
write(100,'(f13.7,f13.7,f13.7,f13.7)') rsou(i),tsou(i),psou(i),weight_sou(i)
end do
do i=1,nrec
write(101,'(f13.7,f13.7,f13.7,f13.7)') rrec(i),trec(i),prec(i),weight_rec(i)
end do
close(100);close(101)
end if
! ######################### 生成网格 build mesh grid #####################################
! -------- forward modeling grid ----------
dr=(rr2-rr1)/(nr-1); dt=(tt2-tt1)/(nt-1); dp=(pp2-pp1)/(np-1)
do iir=1,nr
rr(iir)=rr1+(iir-1)*dr
end do
do iit=1,nt
tt(iit)=tt1+(iit-1)*dt
end do
do iip=1,np
pp(iip)=pp1+(iip-1)*dp
end do
! -------- inversion multigrid ----------
dinvr=(invr2-invr1)/(ninvr-1); dinvt=(invt2-invt1)/(ninvt-1); dinvp=(invp2-invp1)/(ninvp-1)
do igrid=1,ngrid
do iir=1,ninvr
invr(igrid,iir)=invr1+(iir-1)*dinvr-(igrid-1)*dinvr/ngrid
end do
do iit=1,ninvt
invt(igrid,iit)=invt1+(iit-1)*dinvt-(igrid-1)*dinvt/ngrid
end do
do iip=1,ninvp
invp(igrid,iip)=invp1+(iip-1)*dinvp-(igrid-1)*dinvp/ngrid
end do
end do
! ######################### 构建背景模型 build the synthetic and true model #####################################
do iir=1,nr
do iit=1,nt
do iip=1,np
! synthetic (initial) model
eta(iir,iit,iip)=0.0;
xi(iir,iit,iip)=0.0;
zeta(iir,iit,iip)=gamma*sqrt(eta(iir,iit,iip)**2+xi(iir,iit,iip)**2)
! if (rr(iir)>6351) then ! 6371 - 6351 20 km
! fun(iir,iit,iip) = 1.0/(5.8+(6371-rr(iir))/20.0*0.7)
! elseif (rr(iir)>6336) then ! 6351 - 6336 15 km
! fun(iir,iit,iip) = 1.0/(6.5+(6351-rr(iir))/15.0*0.6)
! elseif (rr(iir)>6251) then ! 6336 - 6251 85 km
! fun(iir,iit,iip) = 1.0/(8.04+(6336-rr(iir))/85.0*0.01)
! elseif (rr(iir)>6161) then ! 6251 - 6161 90 km
! fun(iir,iit,iip) = 1.0/(8.05+(6251-rr(iir))/90.0*0.25)
! elseif (rr(iir)>5961) then ! 6161 - 5961 200 km
! fun(iir,iit,iip) = 1.0/(8.30+(6161-rr(iir))/200.0*0.73)
! else
! fun(iir,iit,iip) = 1.0/9.03
! end if
if (rr(iir)>6351) then ! 6371 - 6351 20 km
fun(iir,iit,iip) = 1.0/(5.8+(6371-rr(iir))/20.0*0.7)
elseif (rr(iir)>6336) then ! 6351 - 6336 15 km
fun(iir,iit,iip) = 1.0/(6.5+(6351-rr(iir))/15.0*0.6)
elseif (rr(iir)>5961) then ! 6351 - 6336 15 km
fun(iir,iit,iip) = 1.0/(8.0+(6336-rr(iir))/375.0*1)
else
fun(iir,iit,iip) = 1.0/9.0
end if
!read(100,*) xi(iir,iit,iip)
!read(101,*) eta(iir,iit,iip)
!read(102,*) fun(iir,iit,iip)
a(iir,iit,iip)=1.0+2*zeta(iir,iit,iip);
b(iir,iit,iip)=1.0-2*xi(iir,iit,iip);
c(iir,iit,iip)=1.0+2*xi(iir,iit,iip);
f(iir,iit,iip)=-2*eta(iir,iit,iip);
Table(iir,iit,iip) = 0
! true (target) model
if (tt(iit)>=30.0/180*pi .and. tt(iit)<=50.0/180*pi .and. &
& pp(iip)>=15.0/180*pi .and. pp(iip)<=40.0/180*pi .and. &
& rr(iir)>=6211.0 .and. rr(iir)<=6371.0 ) then
sigma1 = sin(4*pi*(tt(iit)-30.0/180*pi)/(20.0/180*pi))* &
& sin(4*pi*(pp(iip)-15.0/180*pi)/(25.0/180*pi))* &
& sin(2*pi*(rr(iir)-6211)/160.0)
else
sigma1 = 0.0
end if
if (sigma1<0) then
psi = 60.0/180*pi
elseif (sigma1 > 0) then
psi = 150.0/180*pi
else
psi = 0
end if
etaT(iir,iit,iip)=ani_p*abs(sigma1)*sin(2*psi);
xiT(iir,iit,iip)=ani_p*abs(sigma1)*cos(2*psi);
zetaT(iir,iit,iip)=gamma*sqrt(etaT(iir,iit,iip)**2+xiT(iir,iit,iip)**2)
aT(iir,iit,iip)=1.0+2*zetaT(iir,iit,iip);
bT(iir,iit,iip)=1.0-2*xiT(iir,iit,iip);
cT(iir,iit,iip)=1.0+2*xiT(iir,iit,iip);
fT(iir,iit,iip)=-2*etaT(iir,iit,iip);
funT(iir,iit,iip) = fun(iir,iit,iip)/(1+sigma1*slow_p)
!fun(iir,iit,iip) = funT(iir,iit,iip)
!eta(iir,iit,iip)=etaT(iir,iit,iip);
!xi(iir,iit,iip)=xiT(iir,iit,iip);
!zeta(iir,iit,iip)=zetaT(iir,iit,iip)
!a(iir,iit,iip)=aT(iir,iit,iip)
!b(iir,iit,iip)=bT(iir,iit,iip)
!c(iir,iit,iip)=cT(iir,iit,iip)
!f(iir,iit,iip)=fT(iir,iit,iip)
TableT(iir,iit,iip) = 0
u(iir,iit,iip) = 0
end do
end do
end do
! ---- 记录到 matlab 数据中 matlab record ----
if (myid==0) then
open(100,file='ega5/output/model_true')
open(101,file='ega5/output/model_init')
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& funT(iir,iit,iip),xiT(iir,iit,iip),etaT(iir,iit,iip)
write(101,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& fun(iir,iit,iip),xi(iir,iit,iip),eta(iir,iit,iip)
end do
end do
end do
close(100);close(101)
! --------- 多重网格 multiple grid ------
do igrid=1,Ngrid
select case(igrid)
case (1:9)
write(form,'(I1)') igrid
case (10:99)
write(form,'(I2)') igrid
end select
open(100,file='ega5/output/multigrid'//trim(form))
do iir=1,ninvr
do iit=1,ninvt
do iip=1,ninvp
write(100,'(f13.7,f13.7,f13.7)') &
& invr(igrid,iir),invt(igrid,iit),invp(igrid,iip)
end do
end do
end do
close(100)
end do
end if
! ######################### 计算真实到时 calculate true traveltimes ######################
call mpi_barrier(mpi_comm_world,ierr)
allocate(TtimeT(nsou,nrec)) ! 初始化真实到时表 initiate true traveltimes
allocate(Ttime(nsou,nrec)) ! 初始化合成到时表 initiate syn traveltimes
allocate(sourceADJ(nrec)) ! 初始化伴随源 initiate adjoint source
if (myid==0) then
print *, ' '
print *, '----------------- calculating true timetable ... ----------------'
print *, ' '
end if
do i=1,nsou ! loop sources (STATIONS)
! -------- 求解程函方程 solve eikonal equations ------------
call mpi_barrier(mpi_comm_world,ierr)
!rsou(i)=6371.0; tsou(i)=30.5/180.0*pi; psou(i)=15.5/180.0*pi
call FSM_WENO3_PS_sphe_3d_mul_mpi(rr,tt,pp,nr,nt,np,aT,bT,cT,fT,TableT,funT,rsou(i),tsou(i),psou(i),u)
call mpi_barrier(mpi_comm_world,ierr)
! -------- 得到真实走时 calculate true arrival time at receiver --------
call Linear_Interp_3D(rr,tt,pp,TableT,nr,nt,np,rrec,trec,prec,TtimeT(i,:),nrec)
!if ((myid.eq.0) .and. 1>0) then
! print *, rsou(i),tsou(i)/pi*180,psou(i)/pi*180
! open(100,file='ega5/output/arrivaltime')
! do j=1,nrec
! write(100,'(i5.3,f8.2,f6.2,f6.2,f8.3)') j, rrec(j),trec(j)/pi*180,prec(j)/pi*180,TtimeT(i,j)
! end do
! close(100)
!end if
end do
print *, '----------------- calculating true timetable over ---------------- '
! ######################## 反演开始 inversion start ##########################
! ----- 初始化反演参数 initiate inversion parameters ----
stepsize = 0.01 ! 迭代步长 stepsize
old_obj = 0; obj = 0 ! 目标函数 objective function
if (myid .eq. 0) then
print *, ' '
print *, '----------------- inversion start ... ----------------'
print *, ' '
end if
do iter = 1,MaxIter
call mpi_barrier(mpi_comm_world,ierr)
if (myid .eq. 0) then
print *, '----------------- iteration ',iter,' starting ... ----------------'
end if
! ----- 初始化参数 initiate parameters ------
all_Ks = 0; all_Kxi = 0; all_Keta = 0;
obj = 0;
if (myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/misfit_step'//trim(form)
open(998, file=trim(filename))
end if
do i=1,nsou ! loop sources (STATIONS)
! ######################## 计算合成走时场 calculate synthetic timetable ########################
if (myid .eq. 0) then
print *, '----------------- calculating synthetic timetable ... ----------------'
end if
Table = 20
call mpi_barrier(mpi_comm_world,ierr)
call FSM_WENO3_PS_sphe_3d_mul_mpi(rr,tt,pp,nr,nt,np,a,b,c,f,Table,fun,rsou(i),tsou(i),psou(i),u)
call mpi_barrier(mpi_comm_world,ierr)
! -------- 得到合成走时 calculate synthetic arrival time at receiver --------
call Linear_Interp_3D(rr,tt,pp,Table,nr,nt,np,rrec,trec,prec,Ttime(i,:),nrec)
! -------- 构造伴随源 build adjoint source -------
call Adjoint_Source_Dt(Ttime(i,:),TtimeT(i,:),nrec,sourceADJ,sou_obj) ! absolute traveltime difference
if (myid .eq. 0) then
do j=1,nrec
write(998,'(f10.5)') Ttime(i,j)-TtimeT(i,j)
end do
end if
! weighting adjoint source
if (weight_rec_bool) then
do j=1,nrec
sourceADJ(j) = sourceADJ(j) * weight_rec(j)
end do
end if
if (1>0 .and. (myid .eq. 0)) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
select case (i)
case (1:9)
write(form2,'(I1)') i
case (10:99)
write(form2,'(I2)') i
end select
filename='ega5/output/syn_step'//trim(form)//'_event'//trim(form2)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7)') Table(iir,iit,iip)
end do
end do
end do
close(100)
end if
!
!print *, Ttime(i,:),TtimeT(i,:)
!call Adjoint_Source_Ddt(Ttime(i,:),TtimeT(i,:),nrec,sourceADJ,sou_obj) ! double difference traveltime
!do j=1,nrec-1
! do k=j,nrec
! write(998,'(f10.5)') (Ttime(i,j)-Ttime(i,k))-(TtimeT(i,j)-TtimeT(i,k))
! end do
!end do
! ######################## 计算伴随场 adjoint field ########################
if (myid .eq. 0) then
! print *, '----------------- calculating adjoint field ... ----------------'
end if
call FSM_O1_Adj_sphe_3d(rr,tt,pp,nr,nt,np,Table,TableADJ,zeta,xi,eta,nrec,rrec,trec,prec,sourceADJ)
!call FSM_O1_Adj_PS_sphe_3d(rr,tt,pp,nr,nt,np,T0para,tau,TableADJ,zeta,xi,eta,nrec,rrec,trec,prec,sourceADJ)
! ---- 记录到 matlab 数据中 matlab record (adjoint field) ----
if (1>0 .and. (myid .eq. 0)) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
select case (i)
case (1:9)
write(form2,'(I1)') i
case (10:99)
write(form2,'(I2)') i
end select
filename='ega5/output/adj_step'//trim(form)//'_event'//trim(form2)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7)') TableADJ(iir,iit,iip)
end do
end do
end do
close(100)
end if
! ######################## 计算敏感核 sensitivity kernel ########################
!print *, '----------------- calculating kernel ... ----------------'
call Sensitivity_Kernel(rr,tt,pp,nr,nt,np,Table,TableADJ,gamma,xi,eta,fun,Ks,Kxi,Keta)
! ------- 抹去伴随源处的大函数值 mask the source -------
!print *, '----------------- kernel mask ----------------'
!call Kernel_Mask(rr,tt,pp,nr,nt,np,Ks,rsou(i),tsou(i),psou(i),radius)
!call Kernel_Mask(rr,tt,pp,nr,nt,np,Kxi,rsou(i),tsou(i),psou(i),radius)
!call Kernel_Mask(rr,tt,pp,nr,nt,np,Keta,rsou(i),tsou(i),psou(i),radius)
call Kernel_Mask_new(rr,tt,pp,nr,nt,np,Ks,rsou(i),tsou(i),psou(i))
call Kernel_Mask_new(rr,tt,pp,nr,nt,np,Kxi,rsou(i),tsou(i),psou(i))
call Kernel_Mask_new(rr,tt,pp,nr,nt,np,Keta,rsou(i),tsou(i),psou(i))
! ---- 记录到 matlab 数据中 matlab record (adjoint field) ----
if (1<0 .and. myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
select case (i)
case (1:9)
write(form2,'(I1)') i
case (10:99)
write(form2,'(I2)') i
end select
filename='ega5/output/kernel_step'//trim(form)//'_event'//trim(form2)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& Ks(iir,iit,iip),Kxi(iir,iit,iip),Keta(iir,iit,iip)
end do
end do
end do
close(100)
end if
! --------- 敏感核,obj叠加 sum kernels and objective function -------
if (weight_sou_bool) then ! no weight
all_Ks = all_Ks + Ks * weight_sou(i);
all_Kxi = all_Kxi + Kxi * weight_sou(i);
all_Keta = all_Keta + Keta * weight_sou(i);
obj = obj + sou_obj !* weight_sou(i)
else ! source weighted
all_Ks = all_Ks + Ks;
all_Kxi = all_Kxi + Kxi;
all_Keta = all_Keta + Keta;
obj = obj + sou_obj
end if
end do
close(998)
! ---- 记录到 matlab 数据中 matlab record (kernel) ----
if (1>0 .and. myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/kernel_step'//trim(form)//'_sum'
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& all_Ks(iir,iit,iip),all_Kxi(iir,iit,iip),all_Keta(iir,iit,iip)
end do
end do
end do
close(100)
end if
! ##################### 模型更新 model update ####################
print *, '----------------- model updating ... ----------------'
all_Kernel(:,:,:,1) = all_Ks;
all_Kernel(:,:,:,2) = all_Kxi;
all_Kernel(:,:,:,3) = all_Keta;
! ------------ 更新速度(慢度) update velocity (slowness) ------------
call Parameter_Update_Multigrid(rr,tt,pp,nr,nt,np,all_Kernel,nk, &
& invr,invt,invp,ninvr,ninvt,ninvp,ngrid,stepsize,update_value)
if (1<0 .and. myid .eq. 0) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/model_update_step'//trim(form)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& -fun(iir,iit,iip)*update_value(iir,iit,iip,1), &
& -update_value(iir,iit,iip,2),-update_value(iir,iit,iip,3)
end do
end do
end do
close(100)
end if
do iir=1,nr
do iit=1,nt
do iip=1,np
fun(iir,iit,iip) = fun(iir,iit,iip)*(1-update_value(iir,iit,iip,1))
!fun(iir,iit,iip) = fun(iir,iit,iip)
end do
end do
end do
! ------------ 更新xi update xi ------------
do iir=1,nr
do iit=1,nt
do iip=1,np
xi(iir,iit,iip) = xi(iir,iit,iip)-update_value(iir,iit,iip,2)
end do
end do
end do
! ------------ 更新eta update eta ------------
do iir=1,nr
do iit=1,nt
do iip=1,np
eta(iir,iit,iip) = eta(iir,iit,iip)-update_value(iir,iit,iip,3)
end do
end do
end do
! ----------- 更新 update eikonal solver paramater -----------------
do iir=1,nr
do iit=1,nt
do iip=1,np
b(iir,iit,iip)=1.0-2*xi(iir,iit,iip);
c(iir,iit,iip)=1.0+2*xi(iir,iit,iip);
f(iir,iit,iip)=-2*eta(iir,iit,iip);
end do
end do
end do
! ##################### 调整下降步长 modify stepsize #############
if (myid .eq. 0) then
print *, ' '
end if
if (1>0 .and. (myid .eq. 0)) then
open(999,file='ega5/output/obj',access='append')
write(999,'(f9.2,f9.6)') obj, stepsize
close(999)
end if
if (iter == 1 ) then
if (myid .eq. 0) then
write(*,'(a,f9.2)') 'iter 1, obj is', obj
write(*,'(a,f9.6)') 'iter 1, stepsize is', stepsize
end if
elseif (iter >= 2 .and. obj < old_obj) then
!stepsize = min(0.01,stepsize*1.2)
if (myid .eq. 0) then
write(*,'(a,f9.2,a,f9.2)') 'objective function decreases, from', old_obj, ' to', obj
write(*,'(a,f9.6)') 'new stepsize is ', stepsize
end if
elseif (iter >= 2 .and. obj >= old_obj) then
!stepsize = max(0.002,stepsize*0.5)
if (myid .eq. 0) then
write(*,'(a,f9.2,a,f9.2)') 'objective function increases, from', old_obj, ' to', obj
write(*,'(a,f9.6)') 'new stepsize is ', stepsize
end if
end if
print *, '----------------- iteration ',iter,' over ----------------'
print *, ' '
print *, ' '
old_obj = obj
! ---- 记录到 matlab 数据中 matlab record ----
if (1>0 .and. (myid .eq. 0)) then
select case (iter)
case (1:9)
write(form,'(I1)') iter
case (10:99)
write(form,'(I2)') iter
end select
filename='ega5/output/model_step'//trim(form)
open(100,file=trim(filename))
do iir=1,nr
do iit=1,nt
do iip=1,np
write(100,'(f13.7,f13.7,f13.7,f13.7,f13.7,f13.7)') &
& rr(iir),tt(iit),pp(iip), &
& fun(iir,iit,iip),xi(iir,iit,iip),eta(iir,iit,iip)
end do
end do
end do
close(100)
end if
if (myid .eq. 0) then
call CPU_TIME(time_end)
write(*,'(f10.2)') time_end - time_begin
end if
end do
call mpi_finalize(ierr)
end program eikonal_2d

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [11,10,10] # number of the base inversion grid points
min_max_dep_inv : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat_inv : [30.0,50.0] # latitude in degree
min_max_lon_inv : [15.0,40.0] # longitude in degree
#smooth_method : 1 # 0: multigrid parametrization, 1: laplacian smoothing with CG
#l_smooth_rtp : [0.9,0.9,0.9] # smoothing coefficients for each direction
max_iterations_inv : 1 # maximum number of inversion iterations
step_size : 0.01 # step size for inversion
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
use_gpu : 0
calculation :
convergence_tolerance : 1e-5
max_iterations : 1000
stencil_order : 3 # 1 or 3
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_setting :
is_output_source_field : 1 # 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
inv_strategy :
is_inv_slowness : 1
is_inv_azi_ani : 1
is_inv_rad_ani : 1

View File

@@ -0,0 +1,54 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [11,10,10] # number of the base inversion grid points
min_max_dep_inv : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat_inv : [30.0,50.0] # latitude in degree
min_max_lon_inv : [15.0,40.0] # longitude in degree
#smooth_method : 1 # 0: multigrid parametrization, 1: laplacian smoothing with CG
#l_smooth_rtp : [0.9,0.9,0.9] # smoothing coefficients for each direction
max_iterations_inv : 1 # maximum number of inversion iterations
step_size : 0.01 # step size for inversion
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,1,1] # number of subdomains
nproc_sub : 1 # number of subprocess used for each subdomain
use_gpu : 0
calculation :
convergence_tolerance : 1e-5
max_iterations : 1000
stencil_order : 3 # 1 or 3
sweep_type : 1 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_setting :
it_output_suorce_field : 1
is_output_model_dat : 1
inv_strategy :
is_inv_slowness : 1
is_inv_azi_ani : 1
is_inv_rad_ani : 1

View File

@@ -0,0 +1,40 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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,2,2] # number of subdomains
nproc_sub : 2 # 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_setting :
is_output_source_field : 1 # 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,36 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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 : 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

View File

@@ -0,0 +1,279 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"R_earth = 6371.0 #6378.1370\n",
"\n",
"rr1=6070\n",
"rr2=6400\n",
"tt1=(30.0-1.5)/180*math.pi\n",
"tt2=(50.0+1.5)/180*math.pi\n",
"pp1=(15.0-1.5)/180*math.pi\n",
"pp2=(40.0+1.5)/180*math.pi\n",
"\n",
"n_rtp = [55,55,55]\n",
"dr = (rr2-rr1)/(n_rtp[0]-1)\n",
"dt = (tt2-tt1)/(n_rtp[1]-1)\n",
"dp = (pp2-pp1)/(n_rtp[2]-1)\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[0])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[2])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"#s0 = 1.0/6.0\n",
"slow_p=0.04\n",
"ani_p=0.03\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ir,it,ip] = 0.0\n",
" #xi_init[ir,it,ip] = 0.0\n",
" zeta_init[ir,it,ip] = gamma*math.sqrt(eta_init[ir,it,ip]**2 + xi_init[ir,it,ip]**2)\n",
" \n",
" if (rr[ir]>6351):\n",
" fun_init[ir,it,ip] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)\n",
" elif (rr[ir]>6336):\n",
" fun_init[ir,it,ip] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)\n",
" elif (rr[ir]>5961):\n",
" fun_init[ir,it,ip] = 1.0/(8.0+(6336-rr[ir])/375.0*1) \n",
" else:\n",
" fun_init[ir,it,ip] = 1.0/9.0\n",
"\n",
" vel_init[ir,it,ip] = 1.0/fun_init[ir,it,ip]\n",
"\n",
" # true model\n",
" if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \\\n",
" and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \\\n",
" and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):\n",
" c+=1\n",
" sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \\\n",
" *math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \\\n",
" *math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 150.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ir,it,ip] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ir,it,ip] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ir,it,ip] = gamma*math.sqrt(eta_true[ir,it,ip]**2 + xi_true[ir,it,ip]**2)\n",
" fun_true[ir,it,ip] = fun_init[ir,it,ip]/(1.0+sigma*slow_p)\n",
" vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip] \n",
"\n",
"\n",
"r_earth = R_earth #6378.1370\n",
"print(\"depminmax {} {}\".format(r_earth-rr1,r_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out\n",
"import h5py\n",
"\n",
"fout_init = h5py.File('test_model_init.h5', 'w')\n",
"fout_true = h5py.File('test_model_true.h5', 'w')\n",
"\n",
"# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init\n",
"fout_init.create_dataset('eta', data=eta_init)\n",
"fout_init.create_dataset('xi', data=xi_init)\n",
"fout_init.create_dataset('zeta',data=zeta_init)\n",
"fout_init.create_dataset('vel', data=vel_init)\n",
"\n",
"# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true\n",
"fout_true.create_dataset('eta', data=eta_true)\n",
"fout_true.create_dataset('xi', data=xi_true)\n",
"fout_true.create_dataset('zeta',data=zeta_true)\n",
"fout_true.create_dataset('vel', data=vel_true)\n",
"\n",
"fout_init.close()\n",
"fout_true.close()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(123456789)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 1\n",
"n_rec = [1 for x in range(n_src)]\n",
"\n",
"\n",
"lines = []\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"dep_srcs=[12.902894]\n",
"lon_srcs=[16.794572]\n",
"lat_srcs=[37.503373]\n",
"\n",
"elev_recs = [0.0]\n",
"lon_recs = [29.812050]\n",
"lat_recs = [36.472809]\n",
"\n",
"\n",
"# create dummy src\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" dep = dep_srcs[i_src]\n",
" lon = lon_srcs[i_src]\n",
" lat = lat_srcs[i_src]\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" #elev_rec = random.uniform(0.0,-10.0) # elevation in m\n",
" #lon_rec = random.uniform(pp1deg,pp2deg)\n",
" #lat_rec = random.uniform(tt1deg,tt2deg)\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy+\"_\"+str(i_rec), lat_recs[i_rec], lon_recs[i_rec], elev_recs[i_rec], phase_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_recs[i_rec],lat_recs[i_rec],elev_recs[i_rec]])\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,215 @@
# %% [markdown]
# # notebook for create init and true test model
# %%
import numpy as np
import math
# grid
R_earth = 6371.0 #6378.1370
rr1=6070
rr2=6400
tt1=(30.0-1.5)/180*math.pi
tt2=(50.0+1.5)/180*math.pi
pp1=(15.0-1.5)/180*math.pi
pp2=(40.0+1.5)/180*math.pi
n_rtp = [55,55,55]
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.04
ani_p=0.03
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[2]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[0]):
#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)
if (rr[ir]>6351):
fun_init[ir,it,ip] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)
elif (rr[ir]>6336):
fun_init[ir,it,ip] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)
elif (rr[ir]>5961):
fun_init[ir,it,ip] = 1.0/(8.0+(6336-rr[ir])/375.0*1)
else:
fun_init[ir,it,ip] = 1.0/9.0
vel_init[ir,it,ip] = 1.0/fun_init[ir,it,ip]
# true model
if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \
and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \
and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):
c+=1
sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \
*math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \
*math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)
else:
sigma = 0.0
if sigma < 0:
psi = 60.0/180.0*math.pi
elif sigma > 0:
psi = 150.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] = fun_init[ir,it,ip]/(1.0+sigma*slow_p)
vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip]
r_earth = R_earth #6378.1370
print("depminmax {} {}".format(r_earth-rr1,r_earth-rr2))
print(c)
# %%
# write out
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
#
# ```
# 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(123456789)
# 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
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_src = 1
n_rec = [1 for x in range(n_src)]
lines = []
pos_src=[]
pos_rec=[]
dep_srcs=[12.902894]
lon_srcs=[16.794572]
lat_srcs=[37.503373]
elev_recs = [0.0]
lon_recs = [29.812050]
lat_recs = [36.472809]
# create dummy src
for i_src in range(n_src):
# define one point in the domain (rr1 bottom, rr2 top)
dep = dep_srcs[i_src]
lon = lon_srcs[i_src]
lat = lat_srcs[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]
lines.append(src)
pos_src.append([lon,lat,dep])
# create dummy station
for i_rec in range(n_rec[i_src]):
#elev_rec = random.uniform(0.0,-10.0) # elevation in m
#lon_rec = random.uniform(pp1deg,pp2deg)
#lat_rec = random.uniform(tt1deg,tt2deg)
rec = [i_src, i_rec, st_name_dummy+"_"+str(i_rec), lat_recs[i_rec], lon_recs[i_rec], elev_recs[i_rec], phase_dummy, arriv_t_dummy]
lines.append(rec)
pos_rec.append([lon_recs[i_rec],lat_recs[i_rec],elev_recs[i_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,14 @@
# Inversion test
This is a test setup for inversion calculation.
1. Run all cells of `make_test_model.ipynb` for creating
- source, receiver file
- true model
- initial model
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
-> this will output src_rec_result.dat file which includes the arrival time at each station
3. run TOMOATT in inversion mode with `input_params.yml`.

View File

@@ -0,0 +1,66 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# check the change of objective values\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"fpath='objective_function.txt'\n",
"\n",
"objs=[]\n",
"\n",
"with open(fpath) as f:\n",
" lines = f.readlines()\n",
"\n",
" for l in lines:\n",
" if(l.startswith('i_inv')):\n",
" continue\n",
" objs.append(float(l.strip().split(',')[1]))\n",
"\n",
"\n",
"plt.xlabel('iteration')\n",
"plt.ylabel('objective function value')\n",
"plt.plot(objs)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,185 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# read src_rec file and check its arrival time and distance from src to rec\n",
"import numpy as np\n",
"\n",
"def read_src_rec_file(fpath):\n",
"\n",
" with open(fpath, \"r\") as f:\n",
" lines = f.readlines()\n",
"\n",
" # list to store src lon lat\n",
" src_pos = []\n",
" # list to store rec lon lat\n",
" rec_pos_tmp=[]\n",
" rec_pos = []\n",
"\n",
" for line in lines:\n",
" # src line if there are 13 elements\n",
" if len(line.split()) == 13:\n",
" # store source lon lat dep\n",
" stlon = float(line.split()[8])\n",
" stlat = float(line.split()[7])\n",
" src_pos.append([stlon, stlat])\n",
"\n",
" nrec = float(line.split()[11])\n",
" # rec line if there are 9 elements\n",
" elif len(line.split()) == 9:\n",
" # store receiver lon lat dep\n",
" rclon = float(line.split()[4])\n",
" rclat = float(line.split()[3])\n",
" rctime= float(line.split()[8])\n",
" # calc epicentral distance from src\n",
" dist = np.sqrt((stlon-rclon)**2 + (stlat-rclat)**2)\n",
" rec_pos_tmp.append([rclon, rclat, rctime, dist])\n",
"\n",
" nrec-=1\n",
" else:\n",
" raise ValueError(\"src_rec_test_out.dat file is not correct\")\n",
"\n",
" if nrec==0:\n",
" rec_pos.append(rec_pos_tmp)\n",
" # remove all rec_pos_tmp\n",
" rec_pos_tmp = []\n",
"\n",
"\n",
"\n",
" src_pos = np.array(src_pos)\n",
" rec_pos = np.array(rec_pos)\n",
"\n",
" return src_pos, rec_pos"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"src_pos_true, rec_pos_true = read_src_rec_file(\"./src_rec_test_out.dat\")\n",
"src_pos_try, rec_pos_try = read_src_rec_file(\"./src_rec_test_out_out.dat\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot rec_pos for each src_pos with color by 3rd element\n",
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"def plot_srcrec(src_pos, rec_pos):\n",
"\n",
" # selected source\n",
" id_src = 1\n",
" \n",
" fig, axs = plt.subplots(2,1,figsize=(10,10))\n",
" \n",
" # plot arrival time\n",
" # src\n",
" axs[0].scatter(src_pos[id_src,0], src_pos[id_src,1], c='r', marker='o', s=100)\n",
" # rec\n",
" axs[0].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,2], s=10, marker='o')\n",
" \n",
" # colorbar\n",
" cbar = plt.colorbar(axs[0].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,2], s=100, marker='o'))\n",
" cbar.set_label('arrival time')\n",
" \n",
" # plot epicentral distance\n",
" # src\n",
" axs[1].scatter(src_pos[id_src,0], src_pos[id_src,1], c='r', marker='o', s=100)\n",
" # rec\n",
" axs[1].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,3], s=100, marker='o')\n",
" \n",
" # colorbar\n",
" cbar = plt.colorbar(axs[1].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,3], s=10, marker='o'))\n",
" cbar.set_label('epicentral distance')\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_srcrec(src_pos_true, rec_pos_true)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_srcrec(src_pos_try, rec_pos_try)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos_diff = rec_pos_true[:][:][2]-rec_pos_try[:][:][2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos_diff.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos_true.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
},
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,51 @@
version : 2
domain :
#min_max_dep : [-2.863,17.137] # depth in km
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_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test_out.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_type : '' # 'fd' (input file) or '1d_ak135'
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 : 0 # optimization method. 0 : "grad_descent", 1 : "lbfgs", 2 : "halve-stepping"
smooth_method : 0 # 0: multigrid parametrization, 1: laplacian smoothing with CG
max_iterations_inv : 100 # maximum number of inversion iterations
step_size : 0.01 # 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
# parameters for laplacian smoothing
l_smooth_rtp : [10,10,10] # smoothing coefficients for each direction
regularization_weight : 1.0 # regularization weight NOTWORKING
# parameter for halving-stepping or lbfgs
max_sub_iterations : 100 # maximum number of sub-iterations
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
use_gpu : 0 # 0: CPU, 1: GPU
calculation :
convergence_tolerance : 1e-6
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,37 @@
version : 2
domain :
#min_max_dep : [-2.863,17.137] # depth in km
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_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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_type : '' # 'fd' (input file) or '1d_ak135'
init_model_path : './test_model_true.dat' # 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 : [2,1,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-6
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization
output_file_format : 1 # 0: hdf5, 1: ascii

View File

@@ -0,0 +1,338 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"#R_earth = 6378.1370\n",
"R_earth = 6371.0\n",
"\n",
"rr1=6361 \n",
"rr2=6381\n",
"tt1=(38.0-0.3)/180*math.pi\n",
"tt2=(42.0+0.3)/180*math.pi\n",
"pp1=(23.0-0.3)/180*math.pi\n",
"pp2=(27.0+0.3)/180*math.pi\n",
"\n",
"n_rtp = [10,50,50]\n",
"n_rtp.reverse()\n",
"dr = (rr2-rr1)/(n_rtp[2]-1)\n",
"dt = (tt2-tt1)/(n_rtp[1]-1)\n",
"dp = (pp2-pp1)/(n_rtp[0]-1)\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[2])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[0])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"s0 = 1.0/6.0\n",
"slow_p=0.06\n",
"ani_p=0.04\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"a_init = np.zeros(n_rtp)\n",
"b_init = np.zeros(n_rtp)\n",
"c_init = np.zeros(n_rtp)\n",
"f_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"a_true = np.zeros(n_rtp)\n",
"b_true = np.zeros(n_rtp)\n",
"c_true = np.zeros(n_rtp)\n",
"f_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ip,it,ir] = 0.0\n",
" #xi_init[ip,it,ir] = 0.0\n",
" zeta_init[ip,it,ir] = gamma*math.sqrt(eta_init[ip,it,ir]**2 + xi_init[ip,it,ir]**2)\n",
" fun_init[ip,it,ir] = s0\n",
" vel_init[ip,it,ir] = 1.0/s0\n",
" a_init[ip,it,ir] = 1.0 + 2.0*zeta_init[ip,it,ir]\n",
" b_init[ip,it,ir] = 1.0 - 2.0*xi_init[ip,it,ir]\n",
" c_init[ip,it,ir] = 1.0 + 2.0*xi_init[ip,it,ir]\n",
" f_init[ip,it,ir] = -2.0 * eta_init[ip,it,ir]\n",
"\n",
" # true model\n",
" if (tt[it] >= 38.0/180.0*math.pi and tt[it] <= 42.0/180.0*math.pi \\\n",
" and pp[ip] >= 23.0/180.0*math.pi and pp[ip] <= 27.0/180.0*math.pi):\n",
" c+=1\n",
" 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))\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 120.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ip,it,ir] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ip,it,ir] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ip,it,ir] = gamma*math.sqrt(eta_true[ip,it,ir]**2 + xi_true[ip,it,ir]**2)\n",
" fun_true[ip,it,ir] = s0/(1.0+sigma*slow_p)\n",
" vel_true[ip,it,ir] = 1.0/fun_true[ip,it,ir] \n",
" a_true[ip,it,ir] = 1.0 + 2.0*zeta_true[ip,it,ir]\n",
" b_true[ip,it,ir] = 1.0 - 2.0*xi_true[ip,it,ir]\n",
" c_true[ip,it,ir] = 1.0 + 2.0*xi_true[ip,it,ir]\n",
" f_true[ip,it,ir] = -2.0 * eta_true[ip,it,ir]\n",
"\n",
"\n",
"\n",
"#r_earth = 6378.1370\n",
"print(\"depminmax {} {}\".format(R_earth-rr1,R_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out in ASCIII\n",
"\n",
"#\n",
"\n",
"fname_init = 'test_model_init.dat'\n",
"fname_true = 'test_model_true.dat'\n",
"\n",
"\n",
"# write init model\n",
"with open(fname_init, 'w') as f:\n",
" # write nodes in rtp\n",
" for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" # write out eta xi zeta fun fac_a fac_b fac_c fac_f\n",
" f.write(\"{} {} {} {} {} {} {} {} {}\\n\".format(eta_init[ip,it,ir],xi_init[ip,it,ir],zeta_init[ip,it,ir],fun_init[ip,it,ir],vel_init[ip,it,ir],a_init[ip,it,ir],b_init[ip,it,ir],c_init[ip,it,ir],f_init[ip,it,ir]))\n",
"\n",
"\n",
"# write true model\n",
"with open(fname_true, 'w') as f:\n",
" # write nodes in rtp\n",
" for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" # write out eta xi zeta fun fac_a fac_b fac_c fac_f\n",
" f.write(\"{} {} {} {} {} {} {} {} {}\\n\".format(eta_true[ip,it,ir],xi_true[ip,it,ir],zeta_true[ip,it,ir],fun_true[ip,it,ir],vel_true[ip,it,ir],a_true[ip,it,ir],b_true[ip,it,ir],c_true[ip,it,ir],f_true[ip,it,ir]))\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(1145141919810)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"dist_dummy = 100.0\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 500\n",
"n_rec = [30 for x in range(n_src)]\n",
"\n",
"\n",
"lines = []\n",
"\n",
"nij_src = math.sqrt(n_src)\n",
"nij_rec = math.sqrt(n_rec[0])\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"\n",
"# create receiver coordinates\n",
"elev_recs=[]\n",
"lon_recs=[]\n",
"lat_recs=[]\n",
"rec_names=[]\n",
"for i in range(n_rec[0]):\n",
" #elev_recs.append(random.uniform(-100.0,-100.0)) # elevation in m\n",
" #elev_recs.append(0) # elevation in m\n",
" #lon_recs .append(random.uniform(pp1deg*1.1,pp2deg*0.9))\n",
" #lat_recs .append(random.uniform(tt1deg*1.1,tt2deg*0.9))\n",
" rec_names.append(i)\n",
" # regularly\n",
" elev_recs.append(0.0)\n",
" tmp_ilon = i%nij_rec\n",
" tmp_ilat = int(i/nij_rec)\n",
" lon_recs.append(pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec)\n",
" lat_recs.append(tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec)\n",
"\n",
"\n",
"\n",
"# create dummy src\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" # random\n",
" #dep = random.uniform((R_earth-rr1)*0.5,(R_earth-rr1)*0.98)\n",
" #lon = random.uniform(pp1deg,pp2deg)\n",
" #lat = random.uniform(tt1deg,tt2deg)\n",
"\n",
" # regularl\n",
" dep = (R_earth-rr1)*0.9\n",
" tmp_ilon = i_src%nij_src\n",
" tmp_ilat = int(i_src/nij_src)\n",
" lon = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_src\n",
" lat = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_src\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" #elev_rec = 0.0 #random.uniform(0.0,-10.0) # elevation in m\n",
" #lon_rec = random.uniform(pp1deg,pp2deg)\n",
" #lat_rec = random.uniform(tt1deg,tt2deg)\n",
" # regularly\n",
" #elev_rec = -10.0\n",
" #tmp_ilon = i_rec%nij_rec\n",
" #tmp_ilat = int(i_rec/nij_rec)\n",
" #lon_rec = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec\n",
" #lat_rec = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec\n",
"\n",
" # \n",
" elev_rec = elev_recs[i_rec]\n",
" lon_rec = lon_recs[i_rec]\n",
" lat_rec = lat_recs[i_rec]\n",
" st_name_dummy = rec_names[i_rec]\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy, lat_rec, lon_rec, elev_rec, phase_dummy, dist_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_rec,lat_rec,elev_rec])\n",
"\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "fbd0b2a7df497f398d93ab2f589d8a5daa3108cfb7ff2b90736653cca3aeadc0"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np \n",
"import sys\n",
"sys.path.append(\"../../utils/\")\n",
"\n",
"from tomoatt_data_retrieval import get_data_from_ascii\n",
"\n",
"#\n",
"# plot calculated travel time field\n",
"\n",
"# number of grids\n",
"nx = 50 \n",
"ny = 50\n",
"nz = 10\n",
"\n",
"# read coordiantes from file\n",
"fname_grid = \"OUTPUT_FILES/out_grid.out\"\n",
"\n",
"\n",
"# read data\n",
"_src_id = 0\n",
"_inv_id = 0\n",
"\n",
"# filling 0 for digit\n",
"inv_id = str(_inv_id).zfill(4)\n",
"src_id = str(_src_id).zfill(4)\n",
"fname_data = \"OUTPUT_FILES/T_res_inv_{}_src_{}.dat\".format(inv_id, src_id)\n",
"\n",
"data = get_data_from_ascii(fname_data, fname_grid, nz, ny, nx, 2, 1,2, verbose=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot\n",
"import matplotlib.pyplot as plt\n",
"\n",
"fig, axs = plt.subplots(3, 1, figsize=(15, 5))\n",
"\n",
"axs[0].imshow(data[5,:,:], cmap='jet', interpolation='nearest')\n",
"axs[0].set_title('lon-lat')\n",
"\n",
"axs[1].imshow(data[:,25,:], cmap='jet', interpolation='nearest')\n",
"axs[1].set_title('r-lon')\n",
"\n",
"axs[2].imshow(data[:,:,25], cmap='jet', interpolation='nearest')\n",
"axs[2].set_title('r-lat')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,30 @@
# Inversion test
This is a test setup for inversion calculation.
1. Run all cells of `make_test_model.ipynb` or `make_test_model.py` for creating
- source, receiver file (src_rec_test.dat)
- true model (test_model_true.h5)
- initial model (test_model_init.h5)
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
-> this will output src_rec_test_out.dat file which includes the true arrival times
```bash
mpirun --oversubscribe -np 8 ../../build/TOMOATT ./input_params_pre.yml
```
3. run TOMOATT in inversion mode with `input_params.yml`.
-> this will output src_rec_test_out.dat file which includes the true arrival times
```bash
mpirun --oversubscribe -np 8 ../../build/TOMOATT ./input_params_pre.yml
```
4. for visualizing the result files
```bash
paraview out_data_sim_0.xmf
```
0 is the source id. The kernel and model fields are output in the file of 0th source.

View File

@@ -0,0 +1,44 @@
version : 2
domain :
min_max_dep : [-2.863,17.137] # 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 : [20,50,50] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test_out.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 0 # swap source and receiver (1: yes, 0: no)
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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
n_inversion_grid : 4 # number of inversion grid sets
n_inv_dep_lat_lon : [5,10,10] # number of the base inversion grid points
optim_method : 0 # optimization method. 0 : "grad_descent" or 1 : "lbfgs"
max_iterations_inv : 2 # maximum number of inversion iterations
step_size : 0.01 # initial step size for inversion
# parameters for laplacian iterative smoothing
l_smooth_rtp : [0.9,0.9,0.9] # smoothing coefficients for each direction
# parameters for lbfgs
regularization_weight : 20.0 # regularization weight
max_sub_iterations : 1 # maximum number of sub-iterations
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-10
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,35 @@
version : 2
domain :
min_max_dep : [-2.863,17.137] # 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 : [20,50,50] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 0 # swap source and receiver (1: yes, 0: no)
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-10
max_iterations : 200
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,319 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"R_earth = 6378.1370\n",
"\n",
"rr1=6361 \n",
"rr2=6381\n",
"tt1=(38.0-0.3)/180*math.pi\n",
"tt2=(42.0+0.3)/180*math.pi\n",
"pp1=(23.0-0.3)/180*math.pi\n",
"pp2=(27.0+0.3)/180*math.pi\n",
"\n",
"n_rtp = [20,50,50]\n",
"n_rtp.reverse()\n",
"dr = (rr2-rr1)/n_rtp[2]\n",
"dt = (tt2-tt1)/n_rtp[1]\n",
"dp = (pp2-pp1)/n_rtp[0]\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[2])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[0])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"s0 = 1.0/6.0\n",
"slow_p=0.06\n",
"ani_p=0.04\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"a_init = np.zeros(n_rtp)\n",
"b_init = np.zeros(n_rtp)\n",
"c_init = np.zeros(n_rtp)\n",
"f_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"a_true = np.zeros(n_rtp)\n",
"b_true = np.zeros(n_rtp)\n",
"c_true = np.zeros(n_rtp)\n",
"f_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ip,it,ir] = 0.0\n",
" #xi_init[ip,it,ir] = 0.0\n",
" zeta_init[ip,it,ir] = gamma*math.sqrt(eta_init[ip,it,ir]**2 + xi_init[ip,it,ir]**2)\n",
" fun_init[ip,it,ir] = s0\n",
" vel_init[ip,it,ir] = 1.0/s0\n",
" a_init[ip,it,ir] = 1.0 + 2.0*zeta_init[ip,it,ir]\n",
" b_init[ip,it,ir] = 1.0 - 2.0*xi_init[ip,it,ir]\n",
" c_init[ip,it,ir] = 1.0 + 2.0*xi_init[ip,it,ir]\n",
" f_init[ip,it,ir] = -2.0 * eta_init[ip,it,ir]\n",
"\n",
" # true model\n",
" if (tt[it] >= 38.0/180.0*math.pi and tt[it] <= 42.0/180.0*math.pi \\\n",
" and pp[ip] >= 23.0/180.0*math.pi and pp[ip] <= 27.0/180.0*math.pi):\n",
" c+=1\n",
" 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))\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 120.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ip,it,ir] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ip,it,ir] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ip,it,ir] = gamma*math.sqrt(eta_true[ip,it,ir]**2 + xi_true[ip,it,ir]**2)\n",
" fun_true[ip,it,ir] = s0/(1.0+sigma*slow_p)\n",
" vel_true[ip,it,ir] = 1.0/fun_true[ip,it,ir] \n",
" a_true[ip,it,ir] = 1.0 + 2.0*zeta_true[ip,it,ir]\n",
" b_true[ip,it,ir] = 1.0 - 2.0*xi_true[ip,it,ir]\n",
" c_true[ip,it,ir] = 1.0 + 2.0*xi_true[ip,it,ir]\n",
" f_true[ip,it,ir] = -2.0 * eta_true[ip,it,ir]\n",
"\n",
"\n",
"\n",
"r_earth = 6378.1370\n",
"print(\"depminmax {} {}\".format(r_earth-rr1,r_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out\n",
"import h5py\n",
"\n",
"fout_init = h5py.File('test_model_init.h5', 'w')\n",
"fout_true = h5py.File('test_model_true.h5', 'w')\n",
"\n",
"# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init\n",
"fout_init.create_dataset('eta', data=eta_init.T)\n",
"fout_init.create_dataset('xi', data=xi_init.T)\n",
"fout_init.create_dataset('zeta', data=zeta_init.T)\n",
"fout_init.create_dataset('fun', data=fun_init.T)\n",
"fout_init.create_dataset('fac_a', data=a_init.T)\n",
"fout_init.create_dataset('fac_b', data=b_init.T)\n",
"fout_init.create_dataset('fac_c', data=c_init.T)\n",
"fout_init.create_dataset('fac_f', data=f_init.T)\n",
"fout_init.create_dataset('vel', data=vel_init.T)\n",
"\n",
"# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true\n",
"fout_true.create_dataset('eta', data=eta_true.T)\n",
"fout_true.create_dataset('xi', data=xi_true.T)\n",
"fout_true.create_dataset('zeta', data=zeta_true.T)\n",
"fout_true.create_dataset('fun', data=fun_true.T)\n",
"fout_true.create_dataset('fac_a', data=a_true.T)\n",
"fout_true.create_dataset('fac_b', data=b_true.T)\n",
"fout_true.create_dataset('fac_c', data=c_true.T)\n",
"fout_true.create_dataset('fac_f', data=f_true.T)\n",
"fout_true.create_dataset('vel', data=vel_true.T)\n",
"\n",
"fout_init.close()\n",
"fout_true.close()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(1145141919810)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"dist_dummy = 100.0\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 1\n",
"n_rec = [1 for x in range(n_src)]\n",
"\n",
"\n",
"lines = []\n",
"\n",
"nij_src = math.sqrt(n_src)\n",
"nij_rec = math.sqrt(n_rec[0])\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"# create dummy src\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" # random\n",
" #dep = random.uniform((R_earth-rr1)*0.95,(R_earth-rr1)*0.98)\n",
" #lon = random.uniform(pp1deg,pp2deg)\n",
" #lat = random.uniform(tt1deg,tt2deg)\n",
" # regularl\n",
" dep = (R_earth-rr1)*0.9\n",
" tmp_ilon = i_src%nij_src\n",
" tmp_ilat = int(i_src/nij_src)\n",
" lon = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_src\n",
" lat = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_src\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" elev_rec = random.uniform(0.0,-10.0) # elevation in m\n",
" lon_rec = random.uniform(pp1deg,pp2deg)\n",
" lat_rec = random.uniform(tt1deg,tt2deg)\n",
" # regularly\n",
" #elev_rec = -10.0\n",
" #tmp_ilon = i_rec%nij_rec\n",
" #tmp_ilat = int(i_rec/nij_rec)\n",
" #lon_rec = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec\n",
" #lat_rec = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy+str(i_rec), lat_rec, lon_rec, elev_rec, phase_dummy, dist_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_rec,lat_rec,elev_rec])\n",
"\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "fbd0b2a7df497f398d93ab2f589d8a5daa3108cfb7ff2b90736653cca3aeadc0"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,246 @@
# %% [markdown]
# # notebook for create init and true test model
# %%
import numpy as np
import math
# grid
R_earth = 6378.1370
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 = [20,50,50]
n_rtp.reverse()
dr = (rr2-rr1)/n_rtp[2]
dt = (tt2-tt1)/n_rtp[1]
dp = (pp2-pp1)/n_rtp[0]
rr = np.array([rr1 + x*dr for x in range(n_rtp[2])])
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[0])])
# 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)
a_init = np.zeros(n_rtp)
b_init = np.zeros(n_rtp)
c_init = np.zeros(n_rtp)
f_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)
a_true = np.zeros(n_rtp)
b_true = np.zeros(n_rtp)
c_true = np.zeros(n_rtp)
f_true = np.zeros(n_rtp)
c=0
for ir in range(n_rtp[2]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[0]):
#eta_init[ip,it,ir] = 0.0
#xi_init[ip,it,ir] = 0.0
zeta_init[ip,it,ir] = gamma*math.sqrt(eta_init[ip,it,ir]**2 + xi_init[ip,it,ir]**2)
fun_init[ip,it,ir] = s0
vel_init[ip,it,ir] = 1.0/s0
a_init[ip,it,ir] = 1.0 + 2.0*zeta_init[ip,it,ir]
b_init[ip,it,ir] = 1.0 - 2.0*xi_init[ip,it,ir]
c_init[ip,it,ir] = 1.0 + 2.0*xi_init[ip,it,ir]
f_init[ip,it,ir] = -2.0 * eta_init[ip,it,ir]
# 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[ip,it,ir] = ani_p*abs(sigma)*math.sin(2.0*psi)
xi_true[ip,it,ir] = ani_p*abs(sigma)*math.cos(2.0*psi)
zeta_true[ip,it,ir] = gamma*math.sqrt(eta_true[ip,it,ir]**2 + xi_true[ip,it,ir]**2)
fun_true[ip,it,ir] = s0/(1.0+sigma*slow_p)
vel_true[ip,it,ir] = 1.0/fun_true[ip,it,ir]
a_true[ip,it,ir] = 1.0 + 2.0*zeta_true[ip,it,ir]
b_true[ip,it,ir] = 1.0 - 2.0*xi_true[ip,it,ir]
c_true[ip,it,ir] = 1.0 + 2.0*xi_true[ip,it,ir]
f_true[ip,it,ir] = -2.0 * eta_true[ip,it,ir]
r_earth = 6378.1370
print("depminmax {} {}".format(r_earth-rr1,r_earth-rr2))
print(c)
# %%
# %%
# write out
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.T)
fout_init.create_dataset('xi', data=xi_init.T)
fout_init.create_dataset('zeta', data=zeta_init.T)
fout_init.create_dataset('fun', data=fun_init.T)
fout_init.create_dataset('fac_a', data=a_init.T)
fout_init.create_dataset('fac_b', data=b_init.T)
fout_init.create_dataset('fac_c', data=c_init.T)
fout_init.create_dataset('fac_f', data=f_init.T)
fout_init.create_dataset('vel', data=vel_init.T)
# 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.T)
fout_true.create_dataset('xi', data=xi_true.T)
fout_true.create_dataset('zeta', data=zeta_true.T)
fout_true.create_dataset('fun', data=fun_true.T)
fout_true.create_dataset('fac_a', data=a_true.T)
fout_true.create_dataset('fac_b', data=b_true.T)
fout_true.create_dataset('fac_c', data=c_true.T)
fout_true.create_dataset('fac_f', data=f_true.T)
fout_true.create_dataset('vel', data=vel_true.T)
fout_init.close()
fout_true.close()
# %% [markdown]
# # prepare src station file
#
# ```
# 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'
dist_dummy = 100.0
arriv_t_dummy = 0.0
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_src = 1
n_rec = [60 for x in range(n_src)]
lines = []
nij_src = math.sqrt(n_src)
nij_rec = math.sqrt(n_rec[0])
pos_src=[]
pos_rec=[]
# create dummy src
for i_src in range(n_src):
# define one point in the domain (rr1 bottom, rr2 top)
# random
#dep = random.uniform((R_earth-rr1)*0.95,(R_earth-rr1)*0.98)
#lon = random.uniform(pp1deg,pp2deg)
#lat = random.uniform(tt1deg,tt2deg)
# regularl
dep = (R_earth-rr1)*0.9
tmp_ilon = i_src%nij_src
tmp_ilat = int(i_src/nij_src)
lon = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_src
lat = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_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]
lines.append(src)
pos_src.append([lon,lat,dep])
# create dummy station
for i_rec in range(n_rec[i_src]):
#elev_rec = random.uniform(0.0,-10.0) # elevation in m
#lon_rec = random.uniform(pp1deg,pp2deg)
#lat_rec = random.uniform(tt1deg,tt2deg)
# regularly
elev_rec = -10.0
tmp_ilon = i_rec%nij_rec
tmp_ilat = int(i_rec/nij_rec)
lon_rec = pp1deg + tmp_ilon*(pp2deg-pp1deg)/nij_rec
lat_rec = tt1deg + tmp_ilat*(tt2deg-tt1deg)/nij_rec
rec = [i_src, i_rec, st_name_dummy, lat_rec, lon_rec, elev_rec, phase_dummy, dist_dummy, arriv_t_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,136 @@
0.000, 5.8000
20.000, 5.8000
20.000, 6.5000
35.000, 6.5000
35.000, 8.0400
77.500, 8.0450
120.000, 8.0500
165.000, 8.1750
210.000, 8.3000
210.000, 8.3000
260.000, 8.4825
310.000, 8.6650
360.000, 8.8475
410.000, 9.0300
410.000, 9.3600
460.000, 9.5280
510.000, 9.6960
560.000, 9.8640
610.000, 10.0320
660.000, 10.2000
660.000, 10.7900
710.000, 10.9229
760.000, 11.0558
809.500, 11.1353
859.000, 11.2221
908.500, 11.3068
958.000, 11.3896
1007.500, 11.4705
1057.000, 11.5495
1106.500, 11.6269
1156.000, 11.7026
1205.500, 11.7766
1255.000, 11.8491
1304.500, 11.9200
1354.000, 11.9895
1403.500, 12.0577
1453.000, 12.1245
1502.500, 12.1912
1552.000, 12.2550
1601.500, 12.3185
1651.000, 12.3819
1700.500, 12.4426
1750.000, 12.5031
1799.500, 12.5631
1849.000, 12.6221
1898.500, 12.6804
1948.000, 12.7382
1997.500, 12.7956
2047.000, 12.8526
2096.500, 12.9096
2146.000, 12.9668
2195.500, 13.0222
2245.000, 13.0783
2294.500, 13.1336
2344.000, 13.1894
2393.500, 13.2465
2443.000, 13.3018
2492.500, 13.3585
2542.000, 13.4156
2591.500, 13.4741
2640.000, 13.5312
2690.000, 13.5900
2740.000, 13.6494
2740.000, 13.6494
2789.670, 13.6530
2839.330, 13.6566
2891.500, 13.6602
2891.500, 8.0000
2939.330, 8.0382
2989.660, 8.1283
3039.990, 8.2213
3090.320, 8.3122
3140.660, 8.4001
3190.990, 8.4861
3241.320, 8.5692
3291.650, 8.6496
3341.980, 8.7283
3392.310, 8.8036
3442.640, 8.8761
3492.970, 8.9461
3543.300, 9.0138
3593.640, 9.0792
3643.970, 9.1426
3694.300, 9.2042
3744.630, 9.2634
3794.960, 9.3205
3845.290, 9.3760
3895.620, 9.4297
3945.950, 9.4814
3996.280, 9.5306
4046.620, 9.5777
4096.950, 9.6232
4147.280, 9.6673
4197.610, 9.7100
4247.940, 9.7513
4298.270, 9.7914
4348.600, 9.8304
4398.930, 9.8682
4449.260, 9.9051
4499.600, 9.9410
4549.930, 9.9761
4600.260, 10.0103
4650.590, 10.0439
4700.920, 10.0768
4801.580, 10.1415
4851.910, 10.1739
4902.240, 10.2049
4952.580, 10.2329
5002.910, 10.2565
5053.240, 10.2745
5103.570, 10.2854
5153.500, 10.2890
5153.500, 11.0427
5204.610, 11.0585
5255.320, 11.0718
5306.040, 11.0850
5356.750, 11.0983
5407.460, 11.1166
5458.170, 11.1316
5508.890, 11.1457
5559.600, 11.1590
5610.310, 11.1715
5661.020, 11.1832
5711.740, 11.1941
5813.160, 11.2134
5863.870, 11.2219
5914.590, 11.2295
5965.300, 11.2364
6016.010, 11.2424
6066.720, 11.2477
6117.440, 11.2521
6168.150, 11.2557
6218.860, 11.2586
6269.570, 11.2606
6320.290, 11.2618
6371.000, 11.2622

View File

@@ -0,0 +1,158 @@
5463, 11.3059
5473, 11.2888
5483, 11.2717
5493, 11.2546
5503, 11.2375
5513, 11.2203
5523, 11.2028
5533, 11.1853
5543, 11.1677
5553, 11.1502
5563, 11.1329
5573, 11.1168
5583, 11.1008
5593, 11.0847
5603, 11.0686
5613, 11.0505
5623, 11.0239
5633, 10.9973
5643, 10.9707
5653, 10.9442
5663, 10.9176
5673, 10.891
5683, 10.8644
5693, 10.8378
5703, 10.8113
5713, 10.1933
5723, 10.1597
5733, 10.1261
5743, 10.0925
5753, 10.0589
5763, 10.0253
5773, 9.99168
5783, 9.95808
5793, 9.92448
5803, 9.89088
5813, 9.85728
5823, 9.82368
5833, 9.79008
5843, 9.75648
5853, 9.72288
5863, 9.68928
5873, 9.65568
5883, 9.62208
5893, 9.58848
5903, 9.55488
5913, 9.52128
5923, 9.48768
5933, 9.45408
5943, 9.42048
5953, 9.38688
5963, 9.0227
5973, 8.9862
5983, 8.9497
5993, 8.9132
6003, 8.8767
6013, 8.8402
6023, 8.8037
6033, 8.7672
6043, 8.7307
6053, 8.6942
6063, 8.6577
6073, 8.6212
6083, 8.5847
6093, 8.5482
6103, 8.5117
6113, 8.4752
6123, 8.4387
6133, 8.4022
6143, 8.3657
6153, 8.3292
6163, 8.29444
6173, 8.26667
6183, 8.23889
6193, 8.21111
6203, 8.18333
6213, 8.15556
6223, 8.12778
6233, 8.1
6243, 8.07222
6253, 8.04976
6263, 8.04859
6273, 8.04741
6283, 8.04624
6293, 8.04506
6303, 8.04388
6313, 8.04271
6323, 8.04153
6333, 8.04035
6343, 6.5
6353, 5.8
6363, 5.8
6373, 5.8
6383, 5.8
6393, 5.8
6403, 5.8
6413, 5.8
6423, 5.8
6433, 5.8
6443, 5.8
6453, 5.8
6463, 5.8
6473, 5.8
6483, 5.8
6493, 5.8
6503, 5.8
6513, 5.8
6523, 5.8
6533, 5.8
6543, 5.8
6553, 5.8
6563, 5.8
6573, 5.8
6583, 5.8
6593, 5.8
6603, 5.8
6613, 5.8
6623, 5.8
6633, 5.8
6643, 5.8
6653, 5.8
6663, 5.8
6673, 5.8
6683, 5.8
6693, 5.8
6703, 5.8
6713, 5.8
6723, 5.8
6733, 5.8
6743, 5.8
6753, 5.8
6763, 5.8
6773, 5.8
6783, 5.8
6793, 5.8
6803, 5.8
6813, 5.8
6823, 5.8
6833, 5.8
6843, 5.8
6853, 5.8
6863, 5.8
6873, 5.8
6883, 5.8
6893, 5.8
6903, 5.8
6913, 5.8
6923, 5.8
6933, 5.8
6943, 5.8
6953, 5.8
6963, 5.8
6973, 5.8
6983, 5.8
6993, 5.8
7003, 5.8
7013, 5.8
7023, 5.8
7033, 5.8

View File

@@ -0,0 +1,30 @@
# Inversion test
This is a test setup for inversion calculation with teleseismic events.
1. Run all cells of `make_test_model.ipynb` for creating
- source, receiver file (src_rec_test.dat)
- true model (test_model_true.h5)
- initial model (test_model_init.h5)
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
At first, TOMOATT calculates 2d traveltime field for each teleseismic event.
TOMOATT will find the event source is teleseismic if the event origin is outside of the simulation domain.
Calculated 2d traveltime field is saved in OUTPUT_FILES directory with 2d_travel_time_field_{src_id}.h5
2D solver run will be skipped if this file is found by TOMOATT.
Result travel time at the stations is saved in the file `src_rec_test_out.dat`
Following command will run the forward simulation with the true model
``` bash
mpirun -n 8 ../../build/TOMOATT -i input_params_pre.yml
```
Volumetric output data is saved in the file `OUTPUT_FILES/out_data_sim_0.h5`.
This file may be visualized by paraview with opening the index file `OUTPUT_FILES/out_data_sim_0.xmf`.
3. run TOMOATT in inversion mode with `input_params.yml`, by the command
``` bash
mpirun -n 8 ../../build/TOMOATT -i input_params.yml
```
The volumetric output data is saved in the file `OUTPUT_FILES/out_data_sim_0.h5`.
4. For retrieving the output data from *.h5, please use the python script `utils/tomoatt_data_retrieval.py`

View File

@@ -0,0 +1,111 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot 1d_model.txt\n",
"fname_gen='1d_model.txt'\n",
"fname_ori='1d_ak135.txt'\n",
"\n",
"r_earth = 6371.0\n",
"\n",
"# read file\n",
"\n",
"dep_gen=[]\n",
"vp_gen=[]\n",
"\n",
"with open(fname_gen, 'r') as f:\n",
" lines = f.readlines()\n",
"\n",
" for line in lines:\n",
" line = line.strip()\n",
" if line.startswith('#'):\n",
" continue\n",
" else:\n",
" line = line.split(\",\")\n",
" dep_gen.append(r_earth-float(line[0]))\n",
" vp_gen.append(float(line[1]))\n",
"\n",
"dep_ori=[]\n",
"vp_ori=[]\n",
"\n",
"with open(fname_ori,'r') as f:\n",
" lines = f.readlines()\n",
"\n",
" for line in lines:\n",
" line = line.strip()\n",
" if line.startswith('#'):\n",
" continue\n",
" else:\n",
" line = line.split(\",\")\n",
" dep_ori.append(float(line[0]))\n",
" vp_ori.append(float(line[1]))\n",
"\n",
"\n",
"# plot dep and vp\n",
"import matplotlib.pyplot as plt\n",
"\n",
"plt.plot(dep_gen, vp_gen, linewidth=10)\n",
"plt.plot(dep_ori, vp_ori)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# read 2D traveltime field and plot\n",
"import h5py\n",
"import matplotlib.pyplot as plt\n",
"\n",
"fname_Tfield='OUTPUT_FILES/2d_travel_time_field_0.h5'\n",
"\n",
"with h5py.File(fname_Tfield, 'r') as f:\n",
" T_2d = f['T'][:,:]\n",
" t_1d = f['t'][:]\n",
" r_1d = f['r'][:]\n",
"\n",
"plt.imshow(T_2d, extent=[t_1d[0], t_1d[-1], r_1d[0], r_1d[-1]], aspect='auto') \n",
"plt.colorbar()\n",
"#plt.imshow(T_2d)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,201 @@
200
11.802 0.000 120.430
10.977 0.000 112.347
14.799 0.000 116.441
13.870 0.000 114.593
2.238 0.000 118.621
18.077 0.000 111.279
15.485 0.000 128.750
5.138 0.000 129.964
1.021 0.000 117.016
16.461 0.000 124.992
12.131 0.000 127.582
1.691 0.000 129.371
14.213 0.000 120.983
12.474 0.000 125.122
10.740 0.000 129.356
15.138 0.000 119.121
16.849 0.000 113.748
10.421 0.000 127.899
8.083 0.000 113.566
7.194 0.000 127.568
15.695 0.000 129.820
15.755 0.000 128.741
4.287 0.000 119.474
3.368 0.000 116.248
16.400 0.000 110.836
2.200 0.000 126.318
8.136 0.000 128.447
14.206 0.000 127.036
11.432 0.000 126.942
8.027 0.000 118.581
2.233 0.000 126.321
2.856 0.000 128.286
15.194 0.000 111.542
19.468 0.000 114.427
18.235 0.000 116.594
11.378 0.000 117.484
7.172 0.000 113.442
15.956 0.000 125.590
2.810 0.000 114.026
12.895 0.000 127.486
8.131 0.000 125.399
9.603 0.000 127.463
9.059 0.000 127.470
15.437 0.000 117.213
4.344 0.000 120.949
8.399 0.000 112.079
6.747 0.000 114.103
8.264 0.000 119.535
8.660 0.000 125.041
12.518 0.000 111.975
1.344 0.000 115.458
14.245 0.000 122.863
14.446 0.000 127.582
7.296 0.000 123.609
15.986 0.000 118.914
2.741 0.000 128.433
2.776 0.000 114.310
10.058 0.000 118.660
4.767 0.000 112.640
6.614 0.000 123.114
18.459 0.000 128.929
5.942 0.000 112.869
9.770 0.000 123.277
11.403 0.000 128.818
10.440 0.000 127.002
11.587 0.000 122.665
13.228 0.000 127.416
2.504 0.000 110.861
3.837 0.000 120.637
15.225 0.000 112.534
12.590 0.000 123.332
9.117 0.000 122.897
15.230 0.000 125.084
6.218 0.000 129.723
17.309 0.000 125.024
2.178 0.000 120.731
13.611 0.000 112.946
2.805 0.000 123.454
4.944 0.000 115.870
14.004 0.000 125.492
4.209 0.000 125.665
13.779 0.000 123.429
2.183 0.000 118.440
5.357 0.000 123.154
13.240 0.000 116.284
18.648 0.000 121.295
19.219 0.000 115.919
1.486 0.000 121.474
2.457 0.000 119.333
16.288 0.000 127.138
5.268 0.000 121.570
5.623 0.000 122.193
12.494 0.000 112.512
1.649 0.000 120.953
18.253 0.000 113.672
4.109 0.000 115.474
15.850 0.000 121.814
6.920 0.000 115.925
3.525 0.000 127.491
7.125 0.000 127.679
8.291 0.000 129.702
2.453 0.000 116.388
10.126 0.000 114.561
16.671 0.000 115.128
9.499 0.000 115.955
7.057 0.000 114.557
9.537 0.000 118.136
17.129 0.000 127.229
13.159 0.000 123.202
18.156 0.000 112.430
12.148 0.000 127.744
4.707 0.000 118.976
12.066 0.000 113.261
9.917 0.000 112.249
4.562 0.000 115.574
9.033 0.000 111.773
2.664 0.000 115.781
3.620 0.000 113.157
8.536 0.000 124.149
12.984 0.000 118.287
11.377 0.000 114.723
14.438 0.000 117.563
6.770 0.000 117.346
19.103 0.000 122.253
11.890 0.000 120.057
1.882 0.000 125.606
6.826 0.000 120.949
1.447 0.000 124.624
11.237 0.000 114.481
18.727 0.000 124.695
16.117 0.000 125.042
9.385 0.000 111.953
2.156 0.000 110.976
17.274 0.000 110.739
11.901 0.000 116.806
3.311 0.000 112.308
16.118 0.000 129.010
14.839 0.000 111.311
14.383 0.000 114.445
4.545 0.000 110.627
6.887 0.000 111.142
15.771 0.000 129.508
16.464 0.000 111.184
5.103 0.000 113.133
5.517 0.000 111.094
11.793 0.000 121.722
9.895 0.000 127.312
2.327 0.000 117.660
9.218 0.000 127.343
17.444 0.000 120.635
13.747 0.000 115.551
14.244 0.000 112.432
7.793 0.000 123.270
2.825 0.000 128.950
17.617 0.000 127.288
2.807 0.000 126.756
15.653 0.000 126.819
17.047 0.000 120.984
5.550 0.000 128.964
18.377 0.000 111.008
9.899 0.000 124.873
17.878 0.000 126.725
9.937 0.000 121.221
9.665 0.000 127.646
11.705 0.000 118.606
8.598 0.000 123.095
9.381 0.000 112.372
12.011 0.000 111.390
9.745 0.000 126.383
6.575 0.000 112.135
1.758 0.000 125.892
14.843 0.000 114.231
2.378 0.000 115.137
13.871 0.000 121.657
17.999 0.000 127.665
11.245 0.000 120.451
2.764 0.000 112.762
15.920 0.000 111.560
12.590 0.000 115.623
10.907 0.000 128.019
14.613 0.000 125.835
11.296 0.000 120.752
5.326 0.000 115.745
8.918 0.000 125.743
14.636 0.000 122.201
10.490 0.000 126.751
13.210 0.000 129.310
14.389 0.000 122.314
10.010 0.000 112.866
2.412 0.000 122.699
10.634 0.000 129.658
15.328 0.000 116.282
17.949 0.000 117.036
10.058 0.000 129.116
10.862 0.000 126.679
5.712 0.000 113.093
7.001 0.000 119.322
17.848 0.000 129.814
2.726 0.000 123.738
2.228 0.000 123.016

View File

@@ -0,0 +1,31 @@
30
93.754 0.000 167.742 90.000 47.742
91.741 0.000 76.894 270.000 43.106
28.520 0.000 192.245 90.000 72.245
99.877 0.000 171.239 90.000 51.239
29.960 0.000 68.069 270.000 51.931
63.202 0.000 57.747 270.000 62.253
25.908 0.000 199.894 90.000 79.894
60.869 0.000 72.681 270.000 47.319
58.767 0.000 77.051 270.000 42.949
12.108 0.000 189.167 90.000 69.167
46.008 0.000 43.608 270.000 76.392
10.170 0.000 74.481 270.000 45.519
89.800 0.000 175.250 90.000 55.250
31.693 0.000 166.363 90.000 46.363
93.750 0.000 68.855 270.000 51.145
51.260 0.000 193.542 90.000 73.542
86.110 0.000 172.078 90.000 52.078
10.661 0.000 191.059 90.000 71.059
22.843 0.000 56.609 270.000 63.391
61.437 0.000 176.890 90.000 56.890
62.972 0.000 58.230 270.000 61.770
39.053 0.000 185.517 90.000 65.517
32.690 0.000 167.737 90.000 47.737
78.764 0.000 190.265 90.000 70.265
76.323 0.000 184.958 90.000 64.958
33.802 0.000 47.777 270.000 72.223
25.489 0.000 62.227 270.000 57.773
51.580 0.000 195.428 90.000 75.428
64.127 0.000 171.087 90.000 51.087
92.574 0.000 73.692 270.000 46.308

View File

@@ -0,0 +1,41 @@
40
0.000 0.000 110.250
0.000 0.000 110.750
0.000 0.000 111.250
0.000 0.000 111.750
0.000 0.000 112.250
0.000 0.000 112.750
0.000 0.000 113.250
0.000 0.000 113.750
0.000 0.000 114.250
0.000 0.000 114.750
0.000 0.000 115.250
0.000 0.000 115.750
0.000 0.000 116.250
0.000 0.000 116.750
0.000 0.000 117.250
0.000 0.000 117.750
0.000 0.000 118.250
0.000 0.000 118.750
0.000 0.000 119.250
0.000 0.000 119.750
0.000 0.000 120.250
0.000 0.000 120.750
0.000 0.000 121.250
0.000 0.000 121.750
0.000 0.000 122.250
0.000 0.000 122.750
0.000 0.000 123.250
0.000 0.000 123.750
0.000 0.000 124.250
0.000 0.000 124.750
0.000 0.000 125.250
0.000 0.000 125.750
0.000 0.000 126.250
0.000 0.000 126.750
0.000 0.000 127.250
0.000 0.000 127.750
0.000 0.000 128.250
0.000 0.000 128.750
0.000 0.000 129.250
0.000 0.000 129.750

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,89 @@
88
0.00 5.80000 3.20000 2.60000 1456.0 600.0
15.00 5.80000 3.20000 2.60000 1456.0 600.0
15.00 6.80000 3.90000 2.90000 1350.0 600.0
24.40 6.80000 3.90000 2.90000 1350.0 600.0
24.40 8.11061 4.49094 3.38076 1446.0 600.0
40.00 8.10119 4.48486 3.37906 1446.0 600.0
60.00 8.08907 4.47715 3.37688 1447.0 600.0
80.00 8.07688 4.46953 3.37471 195.0 80.0
115.00 8.05540 4.45643 3.37091 195.0 80.0
150.00 8.03370 4.44361 3.36710 195.0 80.0
185.00 8.01180 4.43108 3.36330 195.0 80.0
220.00 7.98970 4.41885 3.35950 195.0 80.0
220.00 8.55896 4.64391 3.43578 362.0 143.0
265.00 8.64552 4.67540 3.46264 365.0 143.0
310.00 8.73209 4.70690 3.48951 367.0 143.0
355.00 8.81867 4.73840 3.51639 370.0 143.0
400.00 8.90522 4.76989 3.54325 372.0 143.0
400.00 9.13397 4.93259 3.72378 366.0 143.0
450.00 9.38990 5.07842 3.78678 365.0 143.0
500.00 9.64588 5.22428 3.84980 364.0 143.0
550.00 9.90185 5.37014 3.91282 363.0 143.0
600.00 10.15782 5.51602 3.97584 362.0 143.0
635.00 10.21203 5.54311 3.98399 362.0 143.0
670.00 10.26622 5.57020 3.99214 362.0 143.0
670.00 10.75131 5.94508 4.38071 759.0 312.0
721.00 10.91005 6.09418 4.41241 744.0 312.0
771.00 11.06557 6.24046 4.44317 730.0 312.0
871.00 11.24490 6.31091 4.50372 737.0 312.0
971.00 11.41560 6.37813 4.56307 743.0 312.0
1071.00 11.57828 6.44232 4.62129 750.0 312.0
1171.00 11.73357 6.50370 4.67844 755.0 312.0
1271.00 11.88209 6.56250 4.73460 761.0 312.0
1371.00 12.02445 6.61891 4.78983 766.0 312.0
1471.00 12.16126 6.67317 4.84422 770.0 312.0
1571.00 12.29316 6.72548 4.89783 775.0 312.0
1671.00 12.42075 6.77606 4.95073 779.0 312.0
1771.00 12.54466 6.82512 5.00299 784.0 312.0
1871.00 12.66550 6.87289 5.05469 788.0 312.0
1971.00 12.78389 6.91957 5.10590 792.0 312.0
2071.00 12.90045 6.96538 5.15669 795.0 312.0
2171.00 13.01579 7.01053 5.20713 799.0 312.0
2271.00 13.13055 7.05525 5.25729 803.0 312.0
2371.00 13.24532 7.09974 5.30724 807.0 312.0
2471.00 13.36074 7.14423 5.35706 811.0 312.0
2571.00 13.47742 7.18892 5.40681 815.0 312.0
2671.00 13.59597 7.23403 5.45657 819.0 312.0
2741.00 13.68041 7.26597 5.49145 822.0 312.0
2771.00 13.68753 7.26575 5.50642 823.0 312.0
2871.00 13.71168 7.26486 5.55641 826.0 312.0
2891.00 13.71660 7.26466 5.56645 826.0 312.0
2891.00 8.06482 0.00000 9.90349 57822.0 0.0
2971.00 8.19939 0.00000 10.02940 57822.0 0.0
3071.00 8.36019 0.00000 10.18134 57822.0 0.0
3171.00 8.51298 0.00000 10.32726 57822.0 0.0
3271.00 8.65805 0.00000 10.46727 57822.0 0.0
3371.00 8.79573 0.00000 10.60152 57822.0 0.0
3471.00 8.92632 0.00000 10.73012 57822.0 0.0
3571.00 9.05015 0.00000 10.85321 57822.0 0.0
3671.00 9.16752 0.00000 10.97091 57822.0 0.0
3771.00 9.27867 0.00000 11.08335 57822.0 0.0
3871.00 9.38418 0.00000 11.19067 57822.0 0.0
3971.00 9.48409 0.00000 11.29298 57822.0 0.0
4071.00 9.57881 0.00000 11.39042 57822.0 0.0
4171.00 9.66865 0.00000 11.48311 57822.0 0.0
4271.00 9.75393 0.00000 11.57119 57822.0 0.0
4371.00 9.83496 0.00000 11.65478 57822.0 0.0
4471.00 9.91206 0.00000 11.73401 57822.0 0.0
4571.00 9.98554 0.00000 11.80900 57822.0 0.0
4671.00 10.05572 0.00000 11.87990 57822.0 0.0
4771.00 10.12291 0.00000 11.94682 57822.0 0.0
4871.00 10.18743 0.00000 12.00989 57822.0 0.0
4971.00 10.24959 0.00000 12.06924 57822.0 0.0
5071.00 10.30971 0.00000 12.12500 57822.0 0.0
5149.50 10.35568 0.00000 12.16634 57822.0 0.0
5149.50 11.02827 3.50432 12.76360 445.0 85.0
5171.00 11.03643 3.51002 12.77493 445.0 85.0
5271.00 11.07249 3.53522 12.82501 443.0 85.0
5371.00 11.10542 3.55823 12.87073 440.0 85.0
5471.00 11.13521 3.57905 12.91211 439.0 85.0
5571.00 11.16186 3.59767 12.94912 437.0 85.0
5671.00 11.18538 3.61411 12.98178 436.0 85.0
5771.00 11.20576 3.62835 13.01009 434.0 85.0
5871.00 11.22301 3.64041 13.03404 433.0 85.0
5971.00 11.23712 3.65027 13.05364 432.0 85.0
6071.00 11.24809 3.65794 13.06888 432.0 85.0
6171.00 11.25593 3.66342 13.07977 431.0 85.0
6271.00 11.26064 3.66670 13.08630 431.0 85.0
6371.00 11.26220 3.66780 13.08848 431.0 85.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'src_rec_test_out.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 1 # swap source and receiver
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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 : 2 # optimization method. 0 : "grad_descent", 1 : "lbfgs", 2 : "halve-stepping"
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [11,10,10] # number of the base inversion grid points
#min_max_dep_inv : [-29.0, 301.0] # depth in km with R = 6371.0
#min_max_lat_inv : [30.0,50.0] # latitude in degree
#min_max_lon_inv : [15.0,40.0] # longitude in degree
max_sub_iterations : 100 # maximum number of sub-iterations
#smooth_method : 1 # 0: multigrid parametrization, 1: laplacian smoothing with CG
#l_smooth_rtp : [0.9,0.9,0.9] # smoothing coefficients for each direction
max_iterations_inv : 100 # maximum number of inversion iterations
step_size : 0.01 # step size for inversion
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,4] # number of subdomains
nproc_sub : 1 # number of subprocess used for each subdomain
use_gpu : 0
calculation :
convergence_tolerance : 1e-3
max_iterations : 100
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,36 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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 : [2,2,2] # number of subdomains
nproc_sub : 1 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-4
max_iterations : 100
stencil_order : 3 # 1 or 3
sweep_type : 2 # 0: legacy, 1: cuthill-mckee with shm parallelization

View File

@@ -0,0 +1,352 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"R_earth = 6371.0 #6378.1370\n",
"\n",
"rr1=6070\n",
"rr2=6400\n",
"tt1=(30.0-1.5)/180*math.pi\n",
"tt2=(50.0+1.5)/180*math.pi\n",
"pp1=(15.0-1.5)/180*math.pi\n",
"pp2=(40.0+1.5)/180*math.pi\n",
"\n",
"n_rtp = [55,55,55]\n",
"dr = (rr2-rr1)/(n_rtp[0]-1)\n",
"dt = (tt2-tt1)/(n_rtp[1]-1)\n",
"dp = (pp2-pp1)/(n_rtp[2]-1)\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[0])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[2])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"#s0 = 1.0/6.0\n",
"slow_p=0.04\n",
"ani_p=0.03\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"a_init = np.zeros(n_rtp)\n",
"b_init = np.zeros(n_rtp)\n",
"c_init = np.zeros(n_rtp)\n",
"f_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"a_true = np.zeros(n_rtp)\n",
"b_true = np.zeros(n_rtp)\n",
"c_true = np.zeros(n_rtp)\n",
"f_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ir,it,ip] = 0.0\n",
" #xi_init[ir,it,ip] = 0.0\n",
" zeta_init[ir,it,ip] = gamma*math.sqrt(eta_init[ir,it,ip]**2 + xi_init[ir,it,ip]**2)\n",
" \n",
" if (rr[ir]>6351):\n",
" fun_init[ir,it,ip] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)\n",
" elif (rr[ir]>6336):\n",
" fun_init[ir,it,ip] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)\n",
" elif (rr[ir]>5961):\n",
" fun_init[ir,it,ip] = 1.0/(8.0+(6336-rr[ir])/375.0*1) \n",
" else:\n",
" fun_init[ir,it,ip] = 1.0/9.0\n",
"\n",
" vel_init[ir,it,ip] = 1.0/fun_init[ir,it,ip]\n",
" a_init[ir,it,ip] = 1.0 + 2.0*zeta_init[ir,it,ip]\n",
" b_init[ir,it,ip] = 1.0 - 2.0*xi_init[ir,it,ip]\n",
" c_init[ir,it,ip] = 1.0 + 2.0*xi_init[ir,it,ip]\n",
" f_init[ir,it,ip] = -2.0 * eta_init[ir,it,ip]\n",
"\n",
" # true model\n",
" if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \\\n",
" and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \\\n",
" and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):\n",
" c+=1\n",
" sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \\\n",
" *math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \\\n",
" *math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 150.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ir,it,ip] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ir,it,ip] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ir,it,ip] = gamma*math.sqrt(eta_true[ir,it,ip]**2 + xi_true[ir,it,ip]**2)\n",
" fun_true[ir,it,ip] = fun_init[ir,it,ip]/(1.0+sigma*slow_p)\n",
" vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip] \n",
" a_true[ir,it,ip] = 1.0 + 2.0*zeta_true[ir,it,ip]\n",
" b_true[ir,it,ip] = 1.0 - 2.0*xi_true[ir,it,ip]\n",
" c_true[ir,it,ip] = 1.0 + 2.0*xi_true[ir,it,ip]\n",
" f_true[ir,it,ip] = -2.0 * eta_true[ir,it,ip]\n",
"\n",
"\n",
"\n",
"r_earth = R_earth #6378.1370\n",
"print(\"depminmax {} {}\".format(r_earth-rr1,r_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out\n",
"import h5py\n",
"\n",
"fout_init = h5py.File('test_model_init.h5', 'w')\n",
"fout_true = h5py.File('test_model_true.h5', 'w')\n",
"\n",
"# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init\n",
"fout_init.create_dataset('eta', data=eta_init)\n",
"fout_init.create_dataset('xi', data=xi_init)\n",
"fout_init.create_dataset('zeta',data=zeta_init)\n",
"fout_init.create_dataset('fun', data=fun_init)\n",
"fout_init.create_dataset('fac_a', data=a_init)\n",
"fout_init.create_dataset('fac_b', data=b_init)\n",
"fout_init.create_dataset('fac_c', data=c_init)\n",
"fout_init.create_dataset('fac_f', data=f_init)\n",
"fout_init.create_dataset('vel', data=vel_init)\n",
"\n",
"# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true\n",
"fout_true.create_dataset('eta', data=eta_true)\n",
"fout_true.create_dataset('xi', data=xi_true)\n",
"fout_true.create_dataset('zeta',data=zeta_true)\n",
"fout_true.create_dataset('fun', data=fun_true)\n",
"fout_true.create_dataset('fac_a', data=a_true)\n",
"fout_true.create_dataset('fac_b', data=b_true)\n",
"fout_true.create_dataset('fac_c', data=c_true)\n",
"fout_true.create_dataset('fac_f', data=f_true)\n",
"fout_true.create_dataset('vel', data=vel_true)\n",
"\n",
"fout_init.close()\n",
"fout_true.close()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(123456789)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"dist_dummy = 100.0\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 1\n",
"n_rec = [1 for x in range(n_src)]\n",
"\n",
"\n",
"lines = []\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"# one source outside of the region\n",
"dep_srcs=[]\n",
"lon_srcs=[]\n",
"lat_srcs=[]\n",
"\n",
"# teleseismic events\n",
"n_src_tele = 10\n",
"center_lon = (pp2deg+pp1deg)/2.0\n",
"center_lat = (tt2deg+tt1deg)/2.0\n",
"r_src = 40 # deg\n",
"d_r = 360.0/n_src_tele\n",
"\n",
"for i in range(n_src_tele):\n",
" dep = 50.0\n",
" lon = math.cos(d_r*i/180.0*math.pi)*r_src + center_lon\n",
" lat = math.sin(d_r*i/180.0*math.pi)*r_src + center_lat\n",
" dep_srcs.append(dep)\n",
" lon_srcs.append(lon)\n",
" lat_srcs.append(lat)\n",
"\n",
"# regional events\n",
"n_src_reg = 0\n",
"for i in range(n_src_reg):\n",
" dep = random.uniform(r_earth-rr1,r_earth-rr2)\n",
" lon = random.uniform(pp1deg,pp2deg)\n",
" lat = random.uniform(tt1deg,tt2deg)\n",
" dep_srcs.append(dep)\n",
" lon_srcs.append(lon)\n",
" lat_srcs.append(lat)\n",
"\n",
"n_src = n_src_tele + n_src_reg\n",
"\n",
"# create receiver coordinates\n",
"n_rec = [20 for i in range(n_src)]\n",
"elev_recs=[]\n",
"lon_recs=[]\n",
"lat_recs=[]\n",
"rec_names=[]\n",
"for i in range(n_rec[0]):\n",
" #elev_recs.append(random.uniform(-100.0,-100.0)) # elevation in m\n",
" elev_recs.append(0) # elevation in m\n",
" lon_recs .append(random.uniform(pp1deg*1.1,pp2deg*0.9))\n",
" lat_recs .append(random.uniform(tt1deg*1.1,tt2deg*0.9))\n",
" rec_names.append(i)\n",
"\n",
"\n",
"\n",
"# create dummy src\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" dep = dep_srcs[i_src]\n",
" lon = lon_srcs[i_src]\n",
" lat = lat_srcs[i_src]\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" #elev_rec = random.uniform(0.0,-10.0) # elevation in m\n",
" #lon_rec = random.uniform(pp1deg,pp2deg)\n",
" #lat_rec = random.uniform(tt1deg,tt2deg)\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy+\"_\"+str(i_rec), lat_recs[i_rec], lon_recs[i_rec], elev_recs[i_rec], phase_dummy, dist_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_recs[i_rec],lat_recs[i_rec],elev_recs[i_rec]])\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,136 @@
0.000, 5.8000
20.000, 5.8000
20.000, 6.5000
35.000, 6.5000
35.000, 8.0400
77.500, 8.0450
120.000, 8.0500
165.000, 8.1750
210.000, 8.3000
210.000, 8.3000
260.000, 8.4825
310.000, 8.6650
360.000, 8.8475
410.000, 9.0300
410.000, 9.3600
460.000, 9.5280
510.000, 9.6960
560.000, 9.8640
610.000, 10.0320
660.000, 10.2000
660.000, 10.7900
710.000, 10.9229
760.000, 11.0558
809.500, 11.1353
859.000, 11.2221
908.500, 11.3068
958.000, 11.3896
1007.500, 11.4705
1057.000, 11.5495
1106.500, 11.6269
1156.000, 11.7026
1205.500, 11.7766
1255.000, 11.8491
1304.500, 11.9200
1354.000, 11.9895
1403.500, 12.0577
1453.000, 12.1245
1502.500, 12.1912
1552.000, 12.2550
1601.500, 12.3185
1651.000, 12.3819
1700.500, 12.4426
1750.000, 12.5031
1799.500, 12.5631
1849.000, 12.6221
1898.500, 12.6804
1948.000, 12.7382
1997.500, 12.7956
2047.000, 12.8526
2096.500, 12.9096
2146.000, 12.9668
2195.500, 13.0222
2245.000, 13.0783
2294.500, 13.1336
2344.000, 13.1894
2393.500, 13.2465
2443.000, 13.3018
2492.500, 13.3585
2542.000, 13.4156
2591.500, 13.4741
2640.000, 13.5312
2690.000, 13.5900
2740.000, 13.6494
2740.000, 13.6494
2789.670, 13.6530
2839.330, 13.6566
2891.500, 13.6602
2891.500, 8.0000
2939.330, 8.0382
2989.660, 8.1283
3039.990, 8.2213
3090.320, 8.3122
3140.660, 8.4001
3190.990, 8.4861
3241.320, 8.5692
3291.650, 8.6496
3341.980, 8.7283
3392.310, 8.8036
3442.640, 8.8761
3492.970, 8.9461
3543.300, 9.0138
3593.640, 9.0792
3643.970, 9.1426
3694.300, 9.2042
3744.630, 9.2634
3794.960, 9.3205
3845.290, 9.3760
3895.620, 9.4297
3945.950, 9.4814
3996.280, 9.5306
4046.620, 9.5777
4096.950, 9.6232
4147.280, 9.6673
4197.610, 9.7100
4247.940, 9.7513
4298.270, 9.7914
4348.600, 9.8304
4398.930, 9.8682
4449.260, 9.9051
4499.600, 9.9410
4549.930, 9.9761
4600.260, 10.0103
4650.590, 10.0439
4700.920, 10.0768
4801.580, 10.1415
4851.910, 10.1739
4902.240, 10.2049
4952.580, 10.2329
5002.910, 10.2565
5053.240, 10.2745
5103.570, 10.2854
5153.500, 10.2890
5153.500, 11.0427
5204.610, 11.0585
5255.320, 11.0718
5306.040, 11.0850
5356.750, 11.0983
5407.460, 11.1166
5458.170, 11.1316
5508.890, 11.1457
5559.600, 11.1590
5610.310, 11.1715
5661.020, 11.1832
5711.740, 11.1941
5813.160, 11.2134
5863.870, 11.2219
5914.590, 11.2295
5965.300, 11.2364
6016.010, 11.2424
6066.720, 11.2477
6117.440, 11.2521
6168.150, 11.2557
6218.860, 11.2586
6269.570, 11.2606
6320.290, 11.2618
6371.000, 11.2622

View File

@@ -0,0 +1,789 @@
5463, 11.3081
5465, 11.3046
5467, 11.3012
5469, 11.2978
5471, 11.2944
5473, 11.291
5475, 11.2876
5477, 11.2842
5479, 11.2807
5481, 11.2773
5483, 11.2739
5485, 11.2705
5487, 11.2671
5489, 11.2637
5491, 11.2603
5493, 11.2568
5495, 11.2534
5497, 11.25
5499, 11.2466
5501, 11.2431
5503, 11.2395
5505, 11.2359
5507, 11.2323
5509, 11.2288
5511, 11.2252
5513, 11.2216
5515, 11.218
5517, 11.2144
5519, 11.2108
5521, 11.2072
5523, 11.2037
5525, 11.2001
5527, 11.1965
5529, 11.1929
5531, 11.1893
5533, 11.1857
5535, 11.1821
5537, 11.1785
5539, 11.175
5541, 11.1714
5543, 11.1678
5545, 11.1642
5547, 11.1606
5549, 11.157
5551, 11.1534
5553, 11.1499
5555, 11.1463
5557, 11.1427
5559, 11.1391
5561, 11.1355
5563, 11.1319
5565, 11.1283
5567, 11.1247
5569, 11.1212
5571, 11.1176
5573, 11.114
5575, 11.1104
5577, 11.1068
5579, 11.1032
5581, 11.0996
5583, 11.0961
5585, 11.0925
5587, 11.0889
5589, 11.0853
5591, 11.0817
5593, 11.0781
5595, 11.0745
5597, 11.0709
5599, 11.0674
5601, 11.0625
5603, 11.0562
5605, 11.05
5607, 11.0438
5609, 11.0376
5611, 11.0314
5613, 11.0251
5615, 11.0189
5617, 11.0127
5619, 11.0065
5621, 11.0003
5623, 10.994
5625, 10.9878
5627, 10.9816
5629, 10.9754
5631, 10.9691
5633, 10.9629
5635, 10.9567
5637, 10.9505
5639, 10.9443
5641, 10.938
5643, 10.9318
5645, 10.9256
5647, 10.9194
5649, 10.9132
5651, 10.9069
5653, 10.9007
5655, 10.8945
5657, 10.8883
5659, 10.882
5661, 10.8758
5663, 10.8696
5665, 10.8634
5667, 10.8571
5669, 10.8509
5671, 10.8447
5673, 10.8385
5675, 10.8322
5677, 10.826
5679, 10.8198
5681, 10.8136
5683, 10.8073
5685, 10.8011
5687, 10.7949
5689, 10.7887
5691, 10.7824
5693, 10.7762
5695, 10.77
5697, 10.7638
5699, 10.7575
5701, 10.7513
5703, 10.2631
5705, 10.26
5707, 10.2569
5709, 10.2538
5711, 10.2507
5713, 10.2476
5715, 10.2445
5717, 10.2414
5719, 10.2384
5721, 10.2353
5723, 10.2322
5725, 10.2291
5727, 10.226
5729, 10.2229
5731, 10.2198
5733, 10.2167
5735, 10.2136
5737, 10.2105
5739, 10.2074
5741, 10.2043
5743, 10.2012
5745, 10.1981
5747, 10.195
5749, 10.1919
5751, 10.1888
5753, 10.1857
5755, 10.1826
5757, 10.1795
5759, 10.1764
5761, 10.1733
5763, 10.1702
5765, 10.1671
5767, 10.164
5769, 10.1609
5771, 10.1578
5773, 10.1476
5775, 10.1373
5777, 10.1271
5779, 10.1169
5781, 10.1066
5783, 10.0964
5785, 10.0861
5787, 10.0759
5789, 10.0657
5791, 10.0554
5793, 10.0452
5795, 10.035
5797, 10.0247
5799, 10.0145
5801, 10.0042
5803, 9.994
5805, 9.98376
5807, 9.97352
5809, 9.96328
5811, 9.95304
5813, 9.94281
5815, 9.93257
5817, 9.92233
5819, 9.91209
5821, 9.90185
5823, 9.89161
5825, 9.88137
5827, 9.87113
5829, 9.86089
5831, 9.85066
5833, 9.84042
5835, 9.83018
5837, 9.81994
5839, 9.8097
5841, 9.79946
5843, 9.78922
5845, 9.77898
5847, 9.76875
5849, 9.75851
5851, 9.74827
5853, 9.73803
5855, 9.72779
5857, 9.71755
5859, 9.70731
5861, 9.69707
5863, 9.68684
5865, 9.6766
5867, 9.66636
5869, 9.65612
5871, 9.64588
5873, 9.63564
5875, 9.6254
5877, 9.61516
5879, 9.60492
5881, 9.59468
5883, 9.58444
5885, 9.57421
5887, 9.56397
5889, 9.55373
5891, 9.54349
5893, 9.53325
5895, 9.52301
5897, 9.51277
5899, 9.50253
5901, 9.49229
5903, 9.48205
5905, 9.47181
5907, 9.46157
5909, 9.45134
5911, 9.4411
5913, 9.43086
5915, 9.42062
5917, 9.41038
5919, 9.40014
5921, 9.3899
5923, 9.37966
5925, 9.36943
5927, 9.35919
5929, 9.34895
5931, 9.33871
5933, 9.32848
5935, 9.31824
5937, 9.308
5939, 9.29777
5941, 9.28753
5943, 9.27729
5945, 9.26705
5947, 9.25682
5949, 9.24658
5951, 9.23634
5953, 9.2261
5955, 9.21587
5957, 9.20563
5959, 9.19539
5961, 9.18516
5963, 9.17492
5965, 9.16468
5967, 9.15444
5969, 9.14421
5971, 9.13397
5973, 8.90137
5975, 8.89753
5977, 8.89368
5979, 8.88983
5981, 8.88599
5983, 8.88214
5985, 8.87829
5987, 8.87445
5989, 8.8706
5991, 8.86675
5993, 8.86291
5995, 8.85906
5997, 8.85521
5999, 8.85137
6001, 8.84752
6003, 8.84367
6005, 8.83983
6007, 8.83598
6009, 8.83213
6011, 8.82829
6013, 8.82444
6015, 8.82059
6017, 8.81675
6019, 8.8129
6021, 8.80905
6023, 8.8052
6025, 8.80135
6027, 8.79751
6029, 8.79366
6031, 8.78981
6033, 8.78596
6035, 8.78211
6037, 8.77827
6039, 8.77442
6041, 8.77057
6043, 8.76672
6045, 8.76287
6047, 8.75903
6049, 8.75518
6051, 8.75133
6053, 8.74748
6055, 8.74363
6057, 8.73979
6059, 8.73594
6061, 8.73209
6063, 8.72824
6065, 8.72439
6067, 8.72055
6069, 8.7167
6071, 8.71285
6073, 8.709
6075, 8.70516
6077, 8.70131
6079, 8.69746
6081, 8.69361
6083, 8.68977
6085, 8.68592
6087, 8.68207
6089, 8.67822
6091, 8.67438
6093, 8.67053
6095, 8.66668
6097, 8.66283
6099, 8.65899
6101, 8.65514
6103, 8.65129
6105, 8.64744
6107, 8.6436
6109, 8.63975
6111, 8.6359
6113, 8.63206
6115, 8.62821
6117, 8.62436
6119, 8.62051
6121, 8.61667
6123, 8.61282
6125, 8.60897
6127, 8.60513
6129, 8.60128
6131, 8.59743
6133, 8.59358
6135, 8.58974
6137, 8.58589
6139, 8.58204
6141, 8.5782
6143, 8.57435
6145, 8.5705
6147, 8.56665
6149, 8.56281
6151, 8.55896
6153, 7.99096
6155, 7.99223
6157, 7.99349
6159, 7.99475
6161, 7.99601
6163, 7.99728
6165, 7.99854
6167, 7.9998
6169, 8.00107
6171, 8.00233
6173, 8.00359
6175, 8.00485
6177, 8.00612
6179, 8.00738
6181, 8.00864
6183, 8.00991
6185, 8.01117
6187, 8.01243
6189, 8.01368
6191, 8.01493
6193, 8.01618
6195, 8.01743
6197, 8.01868
6199, 8.01993
6201, 8.02119
6203, 8.02244
6205, 8.02369
6207, 8.02494
6209, 8.02619
6211, 8.02744
6213, 8.02869
6215, 8.02995
6217, 8.0312
6219, 8.03245
6221, 8.0337
6223, 8.03494
6225, 8.03618
6227, 8.03742
6229, 8.03866
6231, 8.0399
6233, 8.04114
6235, 8.04238
6237, 8.04362
6239, 8.04486
6241, 8.0461
6243, 8.04734
6245, 8.04858
6247, 8.04982
6249, 8.05106
6251, 8.0523
6253, 8.05354
6255, 8.05478
6257, 8.05601
6259, 8.05724
6261, 8.05847
6263, 8.0597
6265, 8.06092
6267, 8.06215
6269, 8.06338
6271, 8.06461
6273, 8.06583
6275, 8.06706
6277, 8.06829
6279, 8.06952
6281, 8.07074
6283, 8.07197
6285, 8.0732
6287, 8.07443
6289, 8.07565
6291, 8.07688
6293, 8.0781
6295, 8.07932
6297, 8.08054
6299, 8.08176
6301, 8.08297
6303, 8.08419
6305, 8.08541
6307, 8.08663
6309, 8.08785
6311, 8.08907
6313, 8.09028
6315, 8.09149
6317, 8.09271
6319, 8.09392
6321, 8.09513
6323, 8.09634
6325, 8.09755
6327, 8.09877
6329, 8.09998
6331, 8.10119
6333, 8.1024
6335, 8.10361
6337, 8.10481
6339, 8.10602
6341, 8.10723
6343, 8.10844
6345, 8.10964
6347, 6.8
6349, 6.8
6351, 6.8
6353, 6.8
6355, 6.8
6357, 5.8
6359, 5.8
6361, 5.8
6363, 5.8
6365, 5.8
6367, 5.8
6369, 5.8
6371, 5.8
6373, 5.8
6375, 5.8
6377, 5.8
6379, 5.8
6381, 5.8
6383, 5.8
6385, 5.8
6387, 5.8
6389, 5.8
6391, 5.8
6393, 5.8
6395, 5.8
6397, 5.8
6399, 5.8
6401, 5.8
6403, 5.8
6405, 5.8
6407, 5.8
6409, 5.8
6411, 5.8
6413, 5.8
6415, 5.8
6417, 5.8
6419, 5.8
6421, 5.8
6423, 5.8
6425, 5.8
6427, 5.8
6429, 5.8
6431, 5.8
6433, 5.8
6435, 5.8
6437, 5.8
6439, 5.8
6441, 5.8
6443, 5.8
6445, 5.8
6447, 5.8
6449, 5.8
6451, 5.8
6453, 5.8
6455, 5.8
6457, 5.8
6459, 5.8
6461, 5.8
6463, 5.8
6465, 5.8
6467, 5.8
6469, 5.8
6471, 5.8
6473, 5.8
6475, 5.8
6477, 5.8
6479, 5.8
6481, 5.8
6483, 5.8
6485, 5.8
6487, 5.8
6489, 5.8
6491, 5.8
6493, 5.8
6495, 5.8
6497, 5.8
6499, 5.8
6501, 5.8
6503, 5.8
6505, 5.8
6507, 5.8
6509, 5.8
6511, 5.8
6513, 5.8
6515, 5.8
6517, 5.8
6519, 5.8
6521, 5.8
6523, 5.8
6525, 5.8
6527, 5.8
6529, 5.8
6531, 5.8
6533, 5.8
6535, 5.8
6537, 5.8
6539, 5.8
6541, 5.8
6543, 5.8
6545, 5.8
6547, 5.8
6549, 5.8
6551, 5.8
6553, 5.8
6555, 5.8
6557, 5.8
6559, 5.8
6561, 5.8
6563, 5.8
6565, 5.8
6567, 5.8
6569, 5.8
6571, 5.8
6573, 5.8
6575, 5.8
6577, 5.8
6579, 5.8
6581, 5.8
6583, 5.8
6585, 5.8
6587, 5.8
6589, 5.8
6591, 5.8
6593, 5.8
6595, 5.8
6597, 5.8
6599, 5.8
6601, 5.8
6603, 5.8
6605, 5.8
6607, 5.8
6609, 5.8
6611, 5.8
6613, 5.8
6615, 5.8
6617, 5.8
6619, 5.8
6621, 5.8
6623, 5.8
6625, 5.8
6627, 5.8
6629, 5.8
6631, 5.8
6633, 5.8
6635, 5.8
6637, 5.8
6639, 5.8
6641, 5.8
6643, 5.8
6645, 5.8
6647, 5.8
6649, 5.8
6651, 5.8
6653, 5.8
6655, 5.8
6657, 5.8
6659, 5.8
6661, 5.8
6663, 5.8
6665, 5.8
6667, 5.8
6669, 5.8
6671, 5.8
6673, 5.8
6675, 5.8
6677, 5.8
6679, 5.8
6681, 5.8
6683, 5.8
6685, 5.8
6687, 5.8
6689, 5.8
6691, 5.8
6693, 5.8
6695, 5.8
6697, 5.8
6699, 5.8
6701, 5.8
6703, 5.8
6705, 5.8
6707, 5.8
6709, 5.8
6711, 5.8
6713, 5.8
6715, 5.8
6717, 5.8
6719, 5.8
6721, 5.8
6723, 5.8
6725, 5.8
6727, 5.8
6729, 5.8
6731, 5.8
6733, 5.8
6735, 5.8
6737, 5.8
6739, 5.8
6741, 5.8
6743, 5.8
6745, 5.8
6747, 5.8
6749, 5.8
6751, 5.8
6753, 5.8
6755, 5.8
6757, 5.8
6759, 5.8
6761, 5.8
6763, 5.8
6765, 5.8
6767, 5.8
6769, 5.8
6771, 5.8
6773, 5.8
6775, 5.8
6777, 5.8
6779, 5.8
6781, 5.8
6783, 5.8
6785, 5.8
6787, 5.8
6789, 5.8
6791, 5.8
6793, 5.8
6795, 5.8
6797, 5.8
6799, 5.8
6801, 5.8
6803, 5.8
6805, 5.8
6807, 5.8
6809, 5.8
6811, 5.8
6813, 5.8
6815, 5.8
6817, 5.8
6819, 5.8
6821, 5.8
6823, 5.8
6825, 5.8
6827, 5.8
6829, 5.8
6831, 5.8
6833, 5.8
6835, 5.8
6837, 5.8
6839, 5.8
6841, 5.8
6843, 5.8
6845, 5.8
6847, 5.8
6849, 5.8
6851, 5.8
6853, 5.8
6855, 5.8
6857, 5.8
6859, 5.8
6861, 5.8
6863, 5.8
6865, 5.8
6867, 5.8
6869, 5.8
6871, 5.8
6873, 5.8
6875, 5.8
6877, 5.8
6879, 5.8
6881, 5.8
6883, 5.8
6885, 5.8
6887, 5.8
6889, 5.8
6891, 5.8
6893, 5.8
6895, 5.8
6897, 5.8
6899, 5.8
6901, 5.8
6903, 5.8
6905, 5.8
6907, 5.8
6909, 5.8
6911, 5.8
6913, 5.8
6915, 5.8
6917, 5.8
6919, 5.8
6921, 5.8
6923, 5.8
6925, 5.8
6927, 5.8
6929, 5.8
6931, 5.8
6933, 5.8
6935, 5.8
6937, 5.8
6939, 5.8
6941, 5.8
6943, 5.8
6945, 5.8
6947, 5.8
6949, 5.8
6951, 5.8
6953, 5.8
6955, 5.8
6957, 5.8
6959, 5.8
6961, 5.8
6963, 5.8
6965, 5.8
6967, 5.8
6969, 5.8
6971, 5.8
6973, 5.8
6975, 5.8
6977, 5.8
6979, 5.8
6981, 5.8
6983, 5.8
6985, 5.8
6987, 5.8
6989, 5.8
6991, 5.8
6993, 5.8
6995, 5.8
6997, 5.8
6999, 5.8
7001, 5.8
7003, 5.8
7005, 5.8
7007, 5.8
7009, 5.8
7011, 5.8
7013, 5.8
7015, 5.8
7017, 5.8
7019, 5.8
7021, 5.8
7023, 5.8
7025, 5.8
7027, 5.8
7029, 5.8
7031, 5.8
7033, 5.8
7035, 5.8
7037, 5.8
7039, 5.8

View File

@@ -0,0 +1,2 @@
1
50.0 40.0 67.5

View File

@@ -0,0 +1,19 @@
# Inversion test
This is a test setup for inversion calculation.
1. Run all cells of `make_test_model.ipynb` for creating
- source, receiver file
- true model
- initial model
2. then run TOMOATT forward with `input_params_pre.yml` for calculating the true arrival times at the stations
-> this will output src_rec_result.dat file which includes the arrival time at each station
3. run TOMOATT in inversion mode with `input_params.yml`.
4. at first, TOMOATT calculates 2d traveltime field for each teleseismic event.
TOMOATT will find the event source is teleseismic if the event origin is outside of the simulation domain.
Calculated 2d traveltime field is saved in OUTPUT_FILES directory with 2d_travel_time_field_{src_id}.h5
2D solver run will be skipped if this file is found by TOMOATT.

View File

@@ -0,0 +1,51 @@
50
0.0 39.48283902145424 29.281513864182138
0.0 43.998782050303745 37.19643899137363
0.0 37.30760565117001 33.11401338760367
0.0 41.68653979748724 35.934639928020964
0.0 36.61537788634567 23.78498599183464
0.0 39.53372622366508 23.841070463667265
0.0 40.35236327081236 19.52357011656586
0.0 40.521021601341126 15.382805946506043
0.0 40.652338638485574 15.43974831654911
0.0 36.06181789303116 31.492644232896822
0.0 40.220383199721056 30.131592405768828
0.0 32.690556139214564 29.12155270260603
0.0 41.38557105851774 21.887079844236876
0.0 31.5803169410531 15.828284584124932
0.0 39.72076150617663 29.444060586520337
0.0 39.153291824326395 15.348344308914173
0.0 37.3196743759749 24.882795770531047
0.0 45.38532464248119 31.54872211314764
0.0 35.027710629652205 20.71225367598449
0.0 34.73430718282967 30.761114486702205
0.0 41.62771310002017 20.964465183242254
0.0 41.96541753785979 22.638041556854436
0.0 34.18819520502442 31.526202657153434
0.0 33.289630995715136 26.11544195974523
0.0 44.99003971165912 31.18999369792465
0.0 43.71764805530941 27.09889711083143
0.0 39.149408331767305 24.672389827246107
0.0 40.94054916696042 19.539882515019904
0.0 39.55054219303491 17.883860634990157
0.0 45.51670367081901 35.889274144396786
0.0 45.09106334932971 23.658196610348384
0.0 45.3510270418072 33.647693941540325
0.0 38.04870033400669 25.845480891830285
0.0 40.2502568580665 27.674022408814878
0.0 38.91110035012384 23.488821700130032
0.0 33.038736736209884 31.45966132466628
0.0 45.13288373382176 32.43630443882502
0.0 38.95996799830328 24.837368712391495
0.0 43.491229999719096 29.79312700226344
0.0 35.465004203274056 33.62459653703114
0.0 40.21403161430093 17.72710938876384
0.0 39.55239238847392 19.234971464234178
0.0 35.94933583184151 22.513051849149996
0.0 44.119556199620654 20.89644919626955
0.0 35.522471813078226 19.309847752271143
0.0 41.32129208930305 29.532291144989525
0.0 38.64267131605151 25.351066793111908
0.0 34.925624689463994 33.227497100537946
0.0 33.199759796131325 22.212825309023625
0.0 34.47881106709583 28.51463648501263

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
1
50.0 40.0 67.5

View File

@@ -0,0 +1,51 @@
50
0 39.48283902145424 29.281513864182138
0 43.998782050303745 37.19643899137363
0 37.30760565117001 33.11401338760367
0 41.68653979748724 35.934639928020964
0 36.61537788634567 23.78498599183464
0 39.53372622366508 23.841070463667265
0 40.35236327081236 19.52357011656586
0 40.521021601341126 15.382805946506043
0 40.652338638485574 15.43974831654911
0 36.06181789303116 31.492644232896822
0 40.220383199721056 30.131592405768828
0 32.690556139214564 29.12155270260603
0 41.38557105851774 21.887079844236876
0 31.5803169410531 15.828284584124932
0 39.72076150617663 29.444060586520337
0 39.153291824326395 15.348344308914173
0 37.3196743759749 24.882795770531047
0 45.38532464248119 31.54872211314764
0 35.027710629652205 20.71225367598449
0 34.73430718282967 30.761114486702205
0 41.62771310002017 20.964465183242254
0 41.96541753785979 22.638041556854436
0 34.18819520502442 31.526202657153434
0 33.289630995715136 26.11544195974523
0 44.99003971165912 31.18999369792465
0 43.71764805530941 27.09889711083143
0 39.149408331767305 24.672389827246107
0 40.94054916696042 19.539882515019904
0 39.55054219303491 17.883860634990157
0 45.51670367081901 35.889274144396786
0 45.09106334932971 23.658196610348384
0 45.3510270418072 33.647693941540325
0 38.04870033400669 25.845480891830285
0 40.2502568580665 27.674022408814878
0 38.91110035012384 23.488821700130032
0 33.038736736209884 31.45966132466628
0 45.13288373382176 32.43630443882502
0 38.95996799830328 24.837368712391495
0 43.491229999719096 29.79312700226344
0 35.465004203274056 33.62459653703114
0 40.21403161430093 17.72710938876384
0 39.55239238847392 19.234971464234178
0 35.94933583184151 22.513051849149996
0 44.119556199620654 20.89644919626955
0 35.522471813078226 19.309847752271143
0 41.32129208930305 29.532291144989525
0 38.64267131605151 25.351066793111908
0 34.925624689463994 33.227497100537946
0 33.199759796131325 22.212825309023625
0 34.47881106709583 28.51463648501263

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,89 @@
88
0.00 5.80000 3.20000 2.60000 1456.0 600.0
15.00 5.80000 3.20000 2.60000 1456.0 600.0
15.00 6.80000 3.90000 2.90000 1350.0 600.0
24.40 6.80000 3.90000 2.90000 1350.0 600.0
24.40 8.11061 4.49094 3.38076 1446.0 600.0
40.00 8.10119 4.48486 3.37906 1446.0 600.0
60.00 8.08907 4.47715 3.37688 1447.0 600.0
80.00 8.07688 4.46953 3.37471 195.0 80.0
115.00 8.05540 4.45643 3.37091 195.0 80.0
150.00 8.03370 4.44361 3.36710 195.0 80.0
185.00 8.01180 4.43108 3.36330 195.0 80.0
220.00 7.98970 4.41885 3.35950 195.0 80.0
220.00 8.55896 4.64391 3.43578 362.0 143.0
265.00 8.64552 4.67540 3.46264 365.0 143.0
310.00 8.73209 4.70690 3.48951 367.0 143.0
355.00 8.81867 4.73840 3.51639 370.0 143.0
400.00 8.90522 4.76989 3.54325 372.0 143.0
400.00 9.13397 4.93259 3.72378 366.0 143.0
450.00 9.38990 5.07842 3.78678 365.0 143.0
500.00 9.64588 5.22428 3.84980 364.0 143.0
550.00 9.90185 5.37014 3.91282 363.0 143.0
600.00 10.15782 5.51602 3.97584 362.0 143.0
635.00 10.21203 5.54311 3.98399 362.0 143.0
670.00 10.26622 5.57020 3.99214 362.0 143.0
670.00 10.75131 5.94508 4.38071 759.0 312.0
721.00 10.91005 6.09418 4.41241 744.0 312.0
771.00 11.06557 6.24046 4.44317 730.0 312.0
871.00 11.24490 6.31091 4.50372 737.0 312.0
971.00 11.41560 6.37813 4.56307 743.0 312.0
1071.00 11.57828 6.44232 4.62129 750.0 312.0
1171.00 11.73357 6.50370 4.67844 755.0 312.0
1271.00 11.88209 6.56250 4.73460 761.0 312.0
1371.00 12.02445 6.61891 4.78983 766.0 312.0
1471.00 12.16126 6.67317 4.84422 770.0 312.0
1571.00 12.29316 6.72548 4.89783 775.0 312.0
1671.00 12.42075 6.77606 4.95073 779.0 312.0
1771.00 12.54466 6.82512 5.00299 784.0 312.0
1871.00 12.66550 6.87289 5.05469 788.0 312.0
1971.00 12.78389 6.91957 5.10590 792.0 312.0
2071.00 12.90045 6.96538 5.15669 795.0 312.0
2171.00 13.01579 7.01053 5.20713 799.0 312.0
2271.00 13.13055 7.05525 5.25729 803.0 312.0
2371.00 13.24532 7.09974 5.30724 807.0 312.0
2471.00 13.36074 7.14423 5.35706 811.0 312.0
2571.00 13.47742 7.18892 5.40681 815.0 312.0
2671.00 13.59597 7.23403 5.45657 819.0 312.0
2741.00 13.68041 7.26597 5.49145 822.0 312.0
2771.00 13.68753 7.26575 5.50642 823.0 312.0
2871.00 13.71168 7.26486 5.55641 826.0 312.0
2891.00 13.71660 7.26466 5.56645 826.0 312.0
2891.00 8.06482 0.00000 9.90349 57822.0 0.0
2971.00 8.19939 0.00000 10.02940 57822.0 0.0
3071.00 8.36019 0.00000 10.18134 57822.0 0.0
3171.00 8.51298 0.00000 10.32726 57822.0 0.0
3271.00 8.65805 0.00000 10.46727 57822.0 0.0
3371.00 8.79573 0.00000 10.60152 57822.0 0.0
3471.00 8.92632 0.00000 10.73012 57822.0 0.0
3571.00 9.05015 0.00000 10.85321 57822.0 0.0
3671.00 9.16752 0.00000 10.97091 57822.0 0.0
3771.00 9.27867 0.00000 11.08335 57822.0 0.0
3871.00 9.38418 0.00000 11.19067 57822.0 0.0
3971.00 9.48409 0.00000 11.29298 57822.0 0.0
4071.00 9.57881 0.00000 11.39042 57822.0 0.0
4171.00 9.66865 0.00000 11.48311 57822.0 0.0
4271.00 9.75393 0.00000 11.57119 57822.0 0.0
4371.00 9.83496 0.00000 11.65478 57822.0 0.0
4471.00 9.91206 0.00000 11.73401 57822.0 0.0
4571.00 9.98554 0.00000 11.80900 57822.0 0.0
4671.00 10.05572 0.00000 11.87990 57822.0 0.0
4771.00 10.12291 0.00000 11.94682 57822.0 0.0
4871.00 10.18743 0.00000 12.00989 57822.0 0.0
4971.00 10.24959 0.00000 12.06924 57822.0 0.0
5071.00 10.30971 0.00000 12.12500 57822.0 0.0
5149.50 10.35568 0.00000 12.16634 57822.0 0.0
5149.50 11.02827 3.50432 12.76360 445.0 85.0
5171.00 11.03643 3.51002 12.77493 445.0 85.0
5271.00 11.07249 3.53522 12.82501 443.0 85.0
5371.00 11.10542 3.55823 12.87073 440.0 85.0
5471.00 11.13521 3.57905 12.91211 439.0 85.0
5571.00 11.16186 3.59767 12.94912 437.0 85.0
5671.00 11.18538 3.61411 12.98178 436.0 85.0
5771.00 11.20576 3.62835 13.01009 434.0 85.0
5871.00 11.22301 3.64041 13.03404 433.0 85.0
5971.00 11.23712 3.65027 13.05364 432.0 85.0
6071.00 11.24809 3.65794 13.06888 432.0 85.0
6171.00 11.25593 3.66342 13.07977 431.0 85.0
6271.00 11.26064 3.66670 13.08630 431.0 85.0
6371.00 11.26220 3.66780 13.08848 431.0 85.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
src_rec_file : 'OUTPUT_FILES/src_rec_file_forward.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 0 # swap source and receiver
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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
n_inversion_grid : 5 # number of inversion grid sets
n_inv_dep_lat_lon : [11,10,10] # number of the base inversion grid points
min_max_dep_inv : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat_inv : [30.0,50.0] # latitude in degree
min_max_lon_inv : [15.0,40.0] # longitude in degree
#smooth_method : 1 # 0: multigrid parametrization, 1: laplacian smoothing with CG
#l_smooth_rtp : [0.9,0.9,0.9] # smoothing coefficients for each direction
max_iterations_inv : 100 # maximum number of inversion iterations
step_size : 0.01 # step size for inversion
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [1,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
use_gpu : 0
calculation :
convergence_tolerance : 1e-5
max_iterations : 100
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

View File

@@ -0,0 +1,34 @@
version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [55,55,55] # 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 : 0 # swap source and receiver
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,2,2] # number of subdomains
nproc_sub : 2 # number of subprocess used for each subdomain
calculation :
convergence_tolerance : 1e-5
max_iterations : 1000
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

View File

@@ -0,0 +1,412 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notebook for create init and true test model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import math\n",
"\n",
"# grid\n",
"R_earth = 6371.0 #6378.1370\n",
"\n",
"rr1=6070\n",
"rr2=6400\n",
"tt1=(30.0-1.5)/180*math.pi\n",
"tt2=(50.0+1.5)/180*math.pi\n",
"pp1=(15.0-1.5)/180*math.pi\n",
"pp2=(40.0+1.5)/180*math.pi\n",
"\n",
"n_rtp = [55,55,55]\n",
"dr = (rr2-rr1)/(n_rtp[0]-1)\n",
"dt = (tt2-tt1)/(n_rtp[1]-1)\n",
"dp = (pp2-pp1)/(n_rtp[2]-1)\n",
"rr = np.array([rr1 + x*dr for x in range(n_rtp[0])])\n",
"tt = np.array([tt1 + x*dt for x in range(n_rtp[1])])\n",
"pp = np.array([pp1 + x*dp for x in range(n_rtp[2])])\n",
"\n",
"# initial model\n",
"gamma = 0.0\n",
"#s0 = 1.0/6.0\n",
"slow_p=0.04\n",
"ani_p=0.03\n",
"\n",
"eta_init = np.zeros(n_rtp)\n",
"xi_init = np.zeros(n_rtp)\n",
"zeta_init = np.zeros(n_rtp)\n",
"fun_init = np.zeros(n_rtp)\n",
"vel_init = np.zeros(n_rtp)\n",
"\n",
"# true model\n",
"eta_true = np.zeros(n_rtp)\n",
"xi_true = np.zeros(n_rtp)\n",
"zeta_true = np.zeros(n_rtp)\n",
"fun_true = np.zeros(n_rtp)\n",
"vel_true = np.zeros(n_rtp)\n",
"\n",
"c=0\n",
"for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" #eta_init[ir,it,ip] = 0.0\n",
" #xi_init[ir,it,ip] = 0.0\n",
" zeta_init[ir,it,ip] = gamma*math.sqrt(eta_init[ir,it,ip]**2 + xi_init[ir,it,ip]**2)\n",
" \n",
" if (rr[ir]>6351):\n",
" fun_init[ir,it,ip] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)\n",
" elif (rr[ir]>6336):\n",
" fun_init[ir,it,ip] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)\n",
" elif (rr[ir]>5961):\n",
" fun_init[ir,it,ip] = 1.0/(8.0+(6336-rr[ir])/375.0*1) \n",
" else:\n",
" fun_init[ir,it,ip] = 1.0/9.0\n",
"\n",
" vel_init[ir,it,ip] = 1.0/fun_init[ir,it,ip]\n",
"\n",
" # true model\n",
" if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \\\n",
" and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \\\n",
" and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):\n",
" c+=1\n",
" sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \\\n",
" *math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \\\n",
" *math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)\n",
" else:\n",
" sigma = 0.0\n",
"\n",
" if sigma < 0:\n",
" psi = 60.0/180.0*math.pi\n",
" elif sigma > 0:\n",
" psi = 150.0/180.0*math.pi\n",
" else:\n",
" psi = 0.0\n",
"\n",
" eta_true[ir,it,ip] = ani_p*abs(sigma)*math.sin(2.0*psi)\n",
" xi_true[ir,it,ip] = ani_p*abs(sigma)*math.cos(2.0*psi)\n",
" zeta_true[ir,it,ip] = gamma*math.sqrt(eta_true[ir,it,ip]**2 + xi_true[ir,it,ip]**2)\n",
" fun_true[ir,it,ip] = fun_init[ir,it,ip]/(1.0+sigma*slow_p)\n",
" vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip] \n",
"\n",
"\n",
"\n",
"r_earth = R_earth #6378.1370\n",
"print(\"depminmax {} {}\".format(r_earth-rr1,r_earth-rr2))\n",
"print(c)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out\n",
"import h5py\n",
"\n",
"fout_init = h5py.File('test_model_init.h5', 'w')\n",
"fout_true = h5py.File('test_model_true.h5', 'w')\n",
"\n",
"# write out the arrays eta_init, xi_init, zeta_init, fun_init, a_init, b_init, c_init, f_init\n",
"fout_init.create_dataset('eta', data=eta_init)\n",
"fout_init.create_dataset('xi', data=xi_init)\n",
"fout_init.create_dataset('zeta',data=zeta_init)\n",
"fout_init.create_dataset('vel', data=vel_init)\n",
"\n",
"# writeout the arrays eta_true, xi_true, zeta_true, fun_true, a_true, b_true, c_true, f_true\n",
"fout_true.create_dataset('eta', data=eta_true)\n",
"fout_true.create_dataset('xi', data=xi_true)\n",
"fout_true.create_dataset('zeta',data=zeta_true)\n",
"fout_true.create_dataset('vel', data=vel_true)\n",
"\n",
"fout_init.close()\n",
"fout_true.close()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# prepare src station file\n",
"\n",
"```\n",
" 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\n",
" 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\n",
" 26 2 MRPI 1.6125 99.3172 1100.0000 P 50.84 19.400\n",
" 26 3 HUTI 2.3153 98.9711 1600.0000 P 57.84 19.200\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"random.seed(123456789)\n",
"\n",
"# dummys\n",
"year_dummy = 1998\n",
"month_dummy = 1\n",
"day_dummy = 1\n",
"hour_dummy = 0\n",
"minute_dummy = 0\n",
"second_dummy = 0\n",
"mag_dummy = 3.0\n",
"id_dummy = 1000\n",
"st_name_dummy = 'AAAA'\n",
"phase_dummy = 'P'\n",
"dist_dummy = 100.0\n",
"arriv_t_dummy = 0.0\n",
"\n",
"tt1deg = tt1 * 180.0/math.pi\n",
"tt2deg = tt2 * 180.0/math.pi\n",
"pp1deg = pp1 * 180.0/math.pi\n",
"pp2deg = pp2 * 180.0/math.pi\n",
"\n",
"\n",
"n_src = 1\n",
"n_rec = [1 for x in range(n_src)]\n",
"\n",
"\n",
"lines = []\n",
"\n",
"pos_src=[]\n",
"pos_rec=[]\n",
"\n",
"# teleseismic events\n",
"n_src_tele = 1\n",
"center_lon = (pp2deg+pp1deg)/2.0\n",
"center_lat = (tt2deg+tt1deg)/2.0\n",
"r_src = 40 # deg\n",
"d_r = 360.0/n_src_tele\n",
"\n",
"# use fixed coordinate for test\n",
"dep_srcs = [50.0]\n",
"lon_srcs = [67.5]\n",
"lat_srcs = [40.0]\n",
"\n",
"elev_recs = []\n",
"lon_recs = []\n",
"lat_recs = []\n",
"\n",
"# read STATIONS\n",
"f = open('fortran_code/ega5/input/STATIONS', 'r')\n",
"for line in f:\n",
" lines.append(line)\n",
"f.close()\n",
"\n",
"n_rec_tmp=0\n",
"for l in lines:\n",
" if l[0] == '#':\n",
" continue\n",
" else:\n",
" items = l.split()\n",
" if (len(items) == 3):\n",
" elev_recs.append(float(items[0]))\n",
" lat_recs.append(float(items[1]))\n",
" lon_recs.append(float(items[2]))\n",
" n_rec_tmp += 1\n",
"\n",
"n_rec[0] = n_rec_tmp\n",
"\n",
"#for i in range(n_src_tele):\n",
"# dep = 50.0\n",
"# lon = math.cos(d_r*i/180.0*math.pi)*r_src + center_lon\n",
"# lat = math.sin(d_r*i/180.0*math.pi)*r_src + center_lat\n",
"# dep_srcs.append(dep)\n",
"# lon_srcs.append(lon)\n",
"# lat_srcs.append(lat)\n",
"#\n",
"## regional events\n",
"#n_src_reg = 0\n",
"#for i in range(n_src_reg):\n",
"# dep = random.uniform(r_earth-rr1,r_earth-rr2)\n",
"# lon = random.uniform(pp1deg,pp2deg)\n",
"# lat = random.uniform(tt1deg,tt2deg)\n",
"# dep_srcs.append(dep)\n",
"# lon_srcs.append(lon)\n",
"# lat_srcs.append(lat)\n",
"#\n",
"#n_src = n_src_tele + n_src_reg\n",
"#\n",
"## create receiver coordinates\n",
"#n_rec = [50 for i in range(n_src)]\n",
"#elev_recs=[]\n",
"#lon_recs=[]\n",
"#lat_recs=[]\n",
"#rec_names=[]\n",
"#for i in range(n_rec[0]):\n",
"# #elev_recs.append(random.uniform(-100.0,-100.0)) # elevation in m\n",
"# elev_recs.append(0) # elevation in m\n",
"# lon_recs .append(random.uniform(pp1deg*1.1,pp2deg*0.9))\n",
"# lat_recs .append(random.uniform(tt1deg*1.1,tt2deg*0.9))\n",
"# rec_names.append(i)\n",
"\n",
"\n",
"\n",
"# create dummy src\n",
"lines=[]\n",
"for i_src in range(n_src):\n",
" # define one point in the domain (rr1 bottom, rr2 top)\n",
" dep = dep_srcs[i_src]\n",
" lon = lon_srcs[i_src]\n",
" lat = lat_srcs[i_src]\n",
"\n",
" 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]\n",
" lines.append(src)\n",
"\n",
" pos_src.append([lon,lat,dep])\n",
"\n",
" # create dummy station\n",
" for i_rec in range(n_rec[i_src]):\n",
" #elev_rec = random.uniform(0.0,-10.0) # elevation in m\n",
" #lon_rec = random.uniform(pp1deg,pp2deg)\n",
" #lat_rec = random.uniform(tt1deg,tt2deg)\n",
"\n",
" rec = [i_src, i_rec, st_name_dummy+\"_\"+str(i_rec), lat_recs[i_rec], lon_recs[i_rec], elev_recs[i_rec], phase_dummy, dist_dummy, arriv_t_dummy]\n",
" lines.append(rec)\n",
"\n",
" pos_rec.append([lon_recs[i_rec],lat_recs[i_rec],elev_recs[i_rec]])\n",
"\n",
"# write out ev_arrivals file\n",
"fname = 'src_rec_test.dat'\n",
"\n",
"with open(fname, 'w') as f:\n",
" for line in lines:\n",
" for elem in line:\n",
" f.write('{} '.format(elem))\n",
" f.write('\\n')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# draw src and rec positions\n",
"import matplotlib.pyplot as plt\n",
"\n",
"for i_src in range(n_src):\n",
" plt.scatter(pos_src[i_src][1],pos_src[i_src][0],c='r',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot receivers\n",
"for i_rec in range(n_rec[0]):\n",
" plt.scatter(pos_rec[i_rec][1],pos_rec[i_rec][0],c='b',marker='o')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# output source and receiver file for fortran code\n",
"fname_source = \"EARTHQUAKES_tele\"\n",
"fname_station=\"STATIONS\"\n",
"\n",
"# write out number of sources\n",
"with open(fname_source, 'w') as f:\n",
" f.write('{}\\n'.format(n_src))\n",
" # write out depth lat lon \n",
" for i_src in range(n_src):\n",
" f.write('{} {} {}\\n'.format(dep_srcs[i_src],lat_srcs[i_src],lon_srcs[i_src]))\n",
"\n",
"\n",
"# write out number of stations\n",
"with open(fname_station, 'w') as f:\n",
" f.write('{}\\n'.format(n_rec[0]))\n",
" # write out depth lat lon (convert elevation to depth)\n",
" for i_rec in range(n_rec[0]):\n",
" f.write('{} {} {}\\n'.format(elev_recs[i_rec],lat_recs[i_rec],lon_recs[i_rec]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# write out in ASCIII\n",
"\n",
"#\n",
"\n",
"fname_init = 'test_model_init.dat'\n",
"fname_true = 'test_model_true.dat'\n",
"\n",
"\n",
"# write init model\n",
"with open(fname_init, 'w') as f:\n",
" # write nodes in rtp\n",
" for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" # write out eta xi zeta fun fac_a fac_b fac_c fac_f\n",
" f.write(\"{:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f}\\n\".format(eta_init[ir,it,ip],xi_init[ir,it,ip],zeta_init[ir,it,ip],fun_init[ir,it,ip],vel_init[ir,it,ip],a_init[ir,it,ip],b_init[ir,it,ip],c_init[ir,it,ip],f_init[ir,it,ip]))\n",
"\n",
"\n",
"# write true model\n",
"with open(fname_true, 'w') as f:\n",
" # write nodes in rtp\n",
" for ir in range(n_rtp[2]):\n",
" for it in range(n_rtp[1]):\n",
" for ip in range(n_rtp[0]):\n",
" # write out eta xi zeta fun fac_a fac_b fac_c fac_f\n",
" f.write(\"{:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f}\\n\".format(eta_true[ir,it,ip],xi_true[ir,it,ip],zeta_true[ir,it,ip],fun_true[ir,it,ip],vel_true[ir,it,ip],a_true[ir,it,ip],b_true[ir,it,ip],c_true[ir,it,ip],f_true[ir,it,ip]))\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
},
"vscode": {
"interpreter": {
"hash": "fbd0b2a7df497f398d93ab2f589d8a5daa3108cfb7ff2b90736653cca3aeadc0"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,331 @@
# %% [markdown]
# # notebook for create init and true test model
# %%
import numpy as np
import math
# grid
R_earth = 6371.0 #6378.1370
rr1=6070
rr2=6400
tt1=(30.0-1.5)/180*math.pi
tt2=(50.0+1.5)/180*math.pi
pp1=(15.0-1.5)/180*math.pi
pp2=(40.0+1.5)/180*math.pi
n_rtp = [55,55,55]
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.04
ani_p=0.03
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[2]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[0]):
#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)
if (rr[ir]>6351):
fun_init[ir,it,ip] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)
elif (rr[ir]>6336):
fun_init[ir,it,ip] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)
elif (rr[ir]>5961):
fun_init[ir,it,ip] = 1.0/(8.0+(6336-rr[ir])/375.0*1)
else:
fun_init[ir,it,ip] = 1.0/9.0
vel_init[ir,it,ip] = 1.0/fun_init[ir,it,ip]
# true model
if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \
and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \
and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):
c+=1
sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \
*math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \
*math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)
else:
sigma = 0.0
if sigma < 0:
psi = 60.0/180.0*math.pi
elif sigma > 0:
psi = 150.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] = fun_init[ir,it,ip]/(1.0+sigma*slow_p)
vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip]
r_earth = R_earth #6378.1370
print("depminmax {} {}".format(r_earth-rr1,r_earth-rr2))
print(c)
# %%
# write out
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
#
# ```
# 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(123456789)
# 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
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_src = 1
n_rec = [1 for x in range(n_src)]
lines = []
pos_src=[]
pos_rec=[]
# teleseismic events
n_src_tele = 1
center_lon = (pp2deg+pp1deg)/2.0
center_lat = (tt2deg+tt1deg)/2.0
r_src = 40 # deg
d_r = 360.0/n_src_tele
# use fixed coordinate for test
dep_srcs = [50.0]
lon_srcs = [67.5]
lat_srcs = [40.0]
elev_recs = []
lon_recs = []
lat_recs = []
# read STATIONS
f = open('fortran_code/ega5/input/STATIONS', 'r')
for line in f:
lines.append(line)
f.close()
n_rec_tmp=0
for l in lines:
if l[0] == '#':
continue
else:
items = l.split()
if (len(items) == 3):
elev_recs.append(float(items[0]))
lat_recs.append(float(items[1]))
lon_recs.append(float(items[2]))
n_rec_tmp += 1
n_rec[0] = n_rec_tmp
#for i in range(n_src_tele):
# dep = 50.0
# lon = math.cos(d_r*i/180.0*math.pi)*r_src + center_lon
# lat = math.sin(d_r*i/180.0*math.pi)*r_src + center_lat
# dep_srcs.append(dep)
# lon_srcs.append(lon)
# lat_srcs.append(lat)
#
## regional events
#n_src_reg = 0
#for i in range(n_src_reg):
# dep = random.uniform(r_earth-rr1,r_earth-rr2)
# lon = random.uniform(pp1deg,pp2deg)
# lat = random.uniform(tt1deg,tt2deg)
# dep_srcs.append(dep)
# lon_srcs.append(lon)
# lat_srcs.append(lat)
#
#n_src = n_src_tele + n_src_reg
#
## create receiver coordinates
#n_rec = [50 for i in range(n_src)]
#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)
# create dummy src
lines=[]
for i_src in range(n_src):
# define one point in the domain (rr1 bottom, rr2 top)
dep = dep_srcs[i_src]
lon = lon_srcs[i_src]
lat = lat_srcs[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]
lines.append(src)
pos_src.append([lon,lat,dep])
# create dummy station
for i_rec in range(n_rec[i_src]):
#elev_rec = random.uniform(0.0,-10.0) # elevation in m
#lon_rec = random.uniform(pp1deg,pp2deg)
#lat_rec = random.uniform(tt1deg,tt2deg)
rec = [i_src, i_rec, st_name_dummy+"_"+str(i_rec), lat_recs[i_rec], lon_recs[i_rec], elev_recs[i_rec], phase_dummy, arriv_t_dummy]
lines.append(rec)
pos_rec.append([lon_recs[i_rec],lat_recs[i_rec],elev_recs[i_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')
# %%
# output source and receiver file for fortran code
fname_source = "EARTHQUAKES_tele"
fname_station="STATIONS"
# write out number of sources
with open(fname_source, 'w') as f:
f.write('{}\n'.format(n_src))
# write out depth lat lon
for i_src in range(n_src):
f.write('{} {} {}\n'.format(dep_srcs[i_src],lat_srcs[i_src],lon_srcs[i_src]))
# write out number of stations
with open(fname_station, 'w') as f:
f.write('{}\n'.format(n_rec[0]))
# write out depth lat lon (convert elevation to depth)
for i_rec in range(n_rec[0]):
f.write('{} {} {}\n'.format(elev_recs[i_rec],lat_recs[i_rec],lon_recs[i_rec]))
# %%
# write out in ASCIII
#
fname_init = 'test_model_init.dat'
fname_true = 'test_model_true.dat'
# write init model
with open(fname_init, 'w') as f:
# write nodes in rtp
for ir in range(n_rtp[2]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[0]):
# write out eta xi zeta fun fac_a fac_b fac_c fac_f
f.write("{:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f}\n".format(eta_init[ir,it,ip],xi_init[ir,it,ip],zeta_init[ir,it,ip],fun_init[ir,it,ip],vel_init[ir,it,ip],a_init[ir,it,ip],b_init[ir,it,ip],c_init[ir,it,ip],f_init[ir,it,ip]))
# write true model
with open(fname_true, 'w') as f:
# write nodes in rtp
for ir in range(n_rtp[2]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[0]):
# write out eta xi zeta fun fac_a fac_b fac_c fac_f
f.write("{:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f} {:.16f}\n".format(eta_true[ir,it,ip],xi_true[ir,it,ip],zeta_true[ir,it,ip],fun_true[ir,it,ip],vel_true[ir,it,ip],a_true[ir,it,ip],b_true[ir,it,ip],c_true[ir,it,ip],f_true[ir,it,ip]))
# %%

View File

@@ -0,0 +1,52 @@
# Example for Solver only mode
This example shows how to use the Solver only mode of the tool.
## compile TOMOATT with solver_only executable
Uncomment "src/TOMOATT_solver_only.cxx" and "src/TOMOATT_2d_precalc.cxx" in CMakeLists.txt to compile the solver_only executable as below.
```cmake
# add one by one
set(APP_SOURCES
src/TOMOATT.cxx
src/TOMOATT_solver_only.cxx
src/TOMOATT_2d_precalc.cxx
#src/SrcRecWeight.cxx
)
```
Then recompile the code in the build directory.
## pre calculation of source boudary conditions
As the 2d solver is not parallelized for one single teleseismic source yet, what user can do is calculate multiple teleseismic sources at the same time using simultaneous run.
The precalculation of source boundary conditions can be done by running the following command:
```bash
mpirun -n 8 ../../build/bin/TOMOATT_2d_precalc -i input_params_pre.yml
```
## run the solver_only executable
Before running the solver_only executable, you need to prepare the input files by running:
```python
python make_test_model.py
```
This creates a src_only_test.dat which includes 8 sources without any receiver.
Then run the solver_only executable as below.
```bash
mpirun -n 8 ../../build/bin/TOMOATT_solver_only -i src_only_test.dat
```
## check the output files
The result file can be visualize with paraview:
```bash
paraview OUTPUT_FILES/out_data_sim.xmf
```
or directly open with python etc. Please refer the check_3d_out.ipynb for more details.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
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_only_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 0 # swap source and receiver # SHOLD BE 0 FOR SOURCE ONLY RUN
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
parallel :
n_sims : 1 # number of simultaneous run
ndiv_rtp : [2,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 : 1 # 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,33 @@
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_only_test.dat' # source receiver file (if found, src_dep_lat_lon is ignored)
swap_src_rec : 0 # swap source and receiver # SHOLD BE 0 FOR SOURCE ONLY RUN
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
parallel : # no mean for 2d pre calculation
n_sims : 8 # number of simultaneous run. use as much as possible for 2d source preparation
ndiv_rtp : [1,1,1] # number of subdomains
nproc_sub : 1 # 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 : 1 # 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,200 @@
# %% [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
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 = 8 # source will be placed around the domain
r_src = 15 # radius of the source in degree
lines = []
#nij_rec = math.sqrt(n_rec[0])
pos_src=[]
#pos_rec=[]
# center of the domain
lon_c = (pp1deg+pp2deg)/2.0
lat_c = (tt1deg+tt2deg)/2.0
# step of angle in degree = 360.0/n_srcs
d_deg = 360.0/n_srcs
for i_src in range(n_srcs):
i_deg = i_src*d_deg
lon = lon_c + r_src*math.cos(i_deg/180.0*math.pi)
lat = lat_c + r_src*math.sin(i_deg/180.0*math.pi)
# depth of the source
dep = 10.0 + 0.5*i_src
src = [i_src, year_dummy, month_dummy, day_dummy, hour_dummy, minute_dummy, second_dummy, lat, lon, dep, mag_dummy, 0, id_dummy]
lines.append(src)
pos_src.append([lon,lat,dep])
# write out ev_arrivals file
fname = 'src_only_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_srcs):
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')
# %%

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,145 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# read src_rec file and check its arrival time and distance from src to rec\n",
"import numpy as np\n",
"\n",
"# read file\n",
"fpath = \"./src_rec_test_out.dat\"\n",
"\n",
"with open(fpath, \"r\") as f:\n",
" lines = f.readlines()\n",
"\n",
" # list to store src lon lat\n",
" src_pos = []\n",
" # list to store rec lon lat\n",
" rec_pos_tmp=[]\n",
" rec_pos = []\n",
"\n",
" for line in lines:\n",
" # src line if there are 13 elements\n",
" if len(line.split()) == 13:\n",
" # store source lon lat dep\n",
" stlon = float(line.split()[8])\n",
" stlat = float(line.split()[7])\n",
" src_pos.append([stlon, stlat])\n",
"\n",
" nrec = float(line.split()[11])\n",
" # rec line if there are 9 elements\n",
" elif len(line.split()) == 9:\n",
" # store receiver lon lat dep\n",
" rclon = float(line.split()[4])\n",
" rclat = float(line.split()[3])\n",
" rctime= float(line.split()[8])\n",
" # calc epicentral distance from src\n",
" dist = np.sqrt((stlon-rclon)**2 + (stlat-rclat)**2)\n",
" rec_pos_tmp.append([rclon, rclat, rctime, dist])\n",
"\n",
" nrec-=1\n",
" else:\n",
" raise ValueError(\"src_rec_test_out.dat file is not correct\")\n",
"\n",
" if nrec==0:\n",
" rec_pos.append(rec_pos_tmp)\n",
" # remove all rec_pos_tmp\n",
" rec_pos_tmp = []\n",
"\n",
"\n",
"\n",
"src_pos = np.array(src_pos)\n",
"rec_pos = np.array(rec_pos)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plot rec_pos for each src_pos with color by 3rd element\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# selected source\n",
"id_src = 0\n",
"\n",
"fig, axs = plt.subplots(2,1,figsize=(10,10))\n",
"\n",
"# plot arrival time\n",
"# src\n",
"axs[0].scatter(src_pos[id_src,0], src_pos[id_src,1], c='r', marker='o', s=100)\n",
"# rec\n",
"axs[0].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,2], s=10, marker='o')\n",
"\n",
"# colorbar\n",
"cbar = plt.colorbar(axs[0].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,2], s=10, marker='o'))\n",
"cbar.set_label('arrival time')\n",
"\n",
"# plot epicentral distance\n",
"# src\n",
"axs[1].scatter(src_pos[id_src,0], src_pos[id_src,1], c='r', marker='o', s=100)\n",
"# rec\n",
"\n",
"axs[1].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,3], s=10, marker='o')\n",
"\n",
"# colorbar\n",
"cbar = plt.colorbar(axs[1].scatter(rec_pos[id_src][:,0], rec_pos[id_src][:,1], c=rec_pos[id_src][:,3], s=10, marker='o'))\n",
"cbar.set_label('epicentral distance')\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rec_pos.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"min(rec_pos[id_src][:,2])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "02f83e1f4cd9619657a6845405e2dd67c4de23753ba48bca5dce2ebf57b3813a"
},
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9.1')",
"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.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,59 @@
iteration 0: 2.68606, 6.23229, 0.226239
iteration 1: 2.66762, 4.63719, 0.214316
iteration 2: 2.73238, 4.08102, 0.213379
iteration 3: 2.77977, 4.02757, 0.215531
iteration 4: 2.75503, 3.96133, 0.213489
iteration 5: 2.70629, 3.89322, 0.215038
iteration 6: 2.64874, 3.82701, 0.228276
iteration 7: 2.58487, 3.76405, 0.212526
iteration 8: 2.5151, 3.70497, 0.210962
iteration 9: 2.43957, 3.65005, 0.212779
iteration 10: 2.35845, 3.59922, 0.215859
iteration 11: 2.27194, 3.55211, 0.218057
iteration 12: 2.18033, 3.50805, 0.223463
iteration 13: 2.08403, 3.46617, 0.218698
iteration 14: 1.98362, 3.42552, 0.215489
iteration 15: 1.87984, 3.38526, 0.21415
iteration 16: 1.77353, 3.34488, 0.211472
iteration 17: 1.66557, 3.30434, 0.214
iteration 18: 1.55685, 3.26406, 0.221782
iteration 19: 1.44815, 3.22471, 0.21206
iteration 20: 1.34022, 3.18704, 0.216203
iteration 21: 1.23371, 3.15168, 0.212569
iteration 22: 1.12917, 3.11898, 0.213464
iteration 23: 1.02721, 3.08897, 0.213914
iteration 24: 0.928483, 3.06131, 0.214082
iteration 25: 0.833576, 3.03521, 0.214501
iteration 26: 0.742987, 3.00939, 0.213422
iteration 27: 0.657363, 2.98204, 0.221331
iteration 28: 0.577238, 2.95076, 0.215693
iteration 29: 0.502953, 2.9126, 0.223062
iteration 30: 0.434765, 2.86425, 0.217287
iteration 31: 0.372809, 2.811, 0.22508
iteration 32: 0.317086, 2.74301, 0.213147
iteration 33: 0.267455, 2.65645, 0.213563
iteration 34: 0.223675, 2.55053, 0.214785
iteration 35: 0.185412, 2.42585, 0.214462
iteration 36: 0.152346, 2.28442, 0.213213
iteration 37: 0.124075, 2.12939, 0.215673
iteration 38: 0.100158, 1.96561, 0.214523
iteration 39: 0.080066, 1.76634, 0.213322
iteration 40: 0.0633697, 1.58065, 0.248635
iteration 41: 0.0496571, 1.41768, 0.227537
iteration 42: 0.0385206, 1.26136, 0.214846
iteration 43: 0.0295813, 1.06553, 0.212869
iteration 44: 0.0224539, 0.922364, 0.215505
iteration 45: 0.0168533, 0.801121, 0.215831
iteration 46: 0.012518, 0.676654, 0.222596
iteration 47: 0.00919207, 0.572065, 0.212897
iteration 48: 0.00666999, 0.473973, 0.215161
iteration 49: 0.00478044, 0.388867, 0.214475
iteration 50: 0.00338263, 0.313598, 0.212979
iteration 51: 0.00236278, 0.246673, 0.213896
iteration 52: 0.00162948, 0.185409, 0.216258
iteration 53: 0.00111072, 0.122625, 0.220116
iteration 54: 0.000747838, 0.0897312, 0.214795
iteration 55: 0.000496874, 0.0652654, 0.214746
iteration 56: 0.000325716, 0.0467522, 0.214539
iteration 57: 0.000210643, 0.0329173, 0.222138
iteration 58: 0.000134388, 0.0227652, 0.216016

View File

@@ -0,0 +1,100 @@
iteration 0: 2.43339, 3.96179, 0.159862
iteration 1: 2.44192, 3.78108, 0.154897
iteration 2: 2.5263, 3.76444, 0.154628
iteration 3: 2.63063, 3.75984, 0.155039
iteration 4: 2.67147, 3.74936, 0.154697
iteration 5: 2.69534, 3.72929, 0.15431
iteration 6: 2.71752, 3.70022, 0.153941
iteration 7: 2.73461, 3.70193, 0.153911
iteration 8: 2.739, 3.95594, 0.152974
iteration 9: 2.72188, 4.19984, 0.153161
iteration 10: 2.67363, 4.43216, 0.153304
iteration 11: 2.5887, 4.64604, 0.153101
iteration 12: 2.46947, 4.72927, 0.152961
iteration 13: 2.32484, 4.78864, 0.153142
iteration 14: 2.16648, 4.85847, 0.152842
iteration 15: 2.00464, 4.78123, 0.152974
iteration 16: 1.84584, 4.55547, 0.153136
iteration 17: 1.69311, 4.41426, 0.153256
iteration 18: 1.54733, 4.18296, 0.152845
iteration 19: 1.40845, 4.0995, 0.153227
iteration 20: 1.27643, 4.03077, 0.152958
iteration 21: 1.15168, 3.96649, 0.152978
iteration 22: 1.03503, 3.90766, 0.153147
iteration 23: 0.927456, 3.87121, 0.153028
iteration 24: 0.829742, 3.77373, 0.15331
iteration 25: 0.742219, 3.6127, 0.153352
iteration 26: 0.664713, 3.40771, 0.153238
iteration 27: 0.596583, 3.17937, 0.152994
iteration 28: 0.536932, 2.9447, 0.153596
iteration 29: 0.484754, 2.71571, 0.153629
iteration 30: 0.439041, 2.49966, 0.15342
iteration 31: 0.398856, 2.30025, 0.153487
iteration 32: 0.363395, 2.11871, 0.153484
iteration 33: 0.331981, 1.95478, 0.153198
iteration 34: 0.304034, 1.80739, 0.152914
iteration 35: 0.27906, 1.67506, 0.153539
iteration 36: 0.256656, 1.55623, 0.152955
iteration 37: 0.236486, 1.44935, 0.153024
iteration 38: 0.218247, 1.35301, 0.153084
iteration 39: 0.201717, 1.26594, 0.15378
iteration 40: 0.186682, 1.187, 0.154371
iteration 41: 0.172982, 1.11523, 0.15392
iteration 42: 0.16048, 1.04978, 0.153982
iteration 43: 0.14905, 0.989915, 0.153204
iteration 44: 0.138585, 0.924638, 0.153238
iteration 45: 0.128997, 0.856952, 0.153877
iteration 46: 0.120206, 0.810159, 0.152934
iteration 47: 0.112133, 0.767564, 0.152937
iteration 48: 0.104707, 0.728427, 0.153035
iteration 49: 0.097869, 0.692264, 0.15315
iteration 50: 0.0915679, 0.658715, 0.152971
iteration 51: 0.0857542, 0.6275, 0.153151
iteration 52: 0.0803839, 0.598383, 0.153117
iteration 53: 0.075418, 0.571163, 0.153092
iteration 54: 0.0708228, 0.545663, 0.153108
iteration 55: 0.0665671, 0.521722, 0.152929
iteration 56: 0.0626222, 0.499192, 0.153113
iteration 57: 0.0589632, 0.477937, 0.15294
iteration 58: 0.0555681, 0.457812, 0.15317
iteration 59: 0.0524166, 0.440694, 0.153242
iteration 60: 0.0494894, 0.420541, 0.153075
iteration 61: 0.046768, 0.400276, 0.152928
iteration 62: 0.0442361, 0.383639, 0.153059
iteration 63: 0.0418792, 0.368117, 0.153116
iteration 64: 0.0396837, 0.353607, 0.153163
iteration 65: 0.0376369, 0.339252, 0.152713
iteration 66: 0.0357276, 0.324887, 0.152917
iteration 67: 0.0339456, 0.312162, 0.153061
iteration 68: 0.0322809, 0.300005, 0.153249
iteration 69: 0.0307245, 0.288393, 0.153127
iteration 70: 0.0292682, 0.277323, 0.153116
iteration 71: 0.0279043, 0.266659, 0.153007
iteration 72: 0.026626, 0.256528, 0.152774
iteration 73: 0.0254269, 0.246895, 0.152918
iteration 74: 0.0243012, 0.237501, 0.153007
iteration 75: 0.0232433, 0.228719, 0.153019
iteration 76: 0.0222484, 0.219205, 0.152934
iteration 77: 0.0213118, 0.203637, 0.153179
iteration 78: 0.0204296, 0.195446, 0.152973
iteration 79: 0.0195979, 0.187844, 0.152942
iteration 80: 0.0188131, 0.180718, 0.152817
iteration 81: 0.0180721, 0.174, 0.15292
iteration 82: 0.0173716, 0.167641, 0.152875
iteration 83: 0.0167088, 0.161606, 0.153251
iteration 84: 0.016081, 0.155857, 0.152889
iteration 85: 0.0154857, 0.150374, 0.153223
iteration 86: 0.0149207, 0.145136, 0.153109
iteration 87: 0.014384, 0.140125, 0.153087
iteration 88: 0.0138737, 0.135328, 0.152957
iteration 89: 0.0133879, 0.130732, 0.152905
iteration 90: 0.0129251, 0.126323, 0.153395
iteration 91: 0.0124838, 0.122094, 0.153812
iteration 92: 0.0120626, 0.118033, 0.153761
iteration 93: 0.0116603, 0.114132, 0.153533
iteration 94: 0.0112756, 0.110382, 0.153376
iteration 95: 0.0109075, 0.106777, 0.153344
iteration 96: 0.010555, 0.103309, 0.153178
iteration 97: 0.0102171, 0.0999714, 0.153041
iteration 98: 0.00989304, 0.0967585, 0.153617
iteration 99: 0.00958196, 0.0936645, 0.153021

View File

@@ -0,0 +1,478 @@
==24162== Memcheck, a memory error detector
==24162== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==24162== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==24162== Command: ../../build/TOMOATT -i input_params_100-100-100_1-1-1-1_gpu.yml
==24162== Parent PID: 24158
==24162==
==24162== Warning: noted but unhandled ioctl 0x30000001 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x27 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x25 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x37 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x17 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: set address range perms: large range [0x200000000, 0x300200000) (noaccess)
==24162== Warning: set address range perms: large range [0x8fa5000, 0x28fa4000) (noaccess)
==24162== Warning: noted but unhandled ioctl 0x19 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: set address range perms: large range [0x10006000000, 0x10106000000) (noaccess)
==24162== Warning: noted but unhandled ioctl 0x49 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x21 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x1b with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: noted but unhandled ioctl 0x44 with no size/direction hints.
==24162== This could cause spurious value errors to appear.
==24162== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==24162== Warning: set address range perms: large range [0x10006000000, 0x10106000000) (noaccess)
==24162==
==24162== HEAP SUMMARY:
==24162== in use at exit: 1,079,727 bytes in 174 blocks
==24162== total heap usage: 108,062 allocs, 107,888 frees, 2,182,558,459 bytes allocated
==24162==
==24162== 1 bytes in 1 blocks are definitely lost in loss record 1 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x53C960E: strdup (strdup.c:42)
==24162== by 0x75E2534: ???
==24162== by 0x75DB373: ???
==24162== by 0x568F61F: mca_base_framework_components_register (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x568F9B5: mca_base_framework_register (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x568FA13: mca_base_framework_open (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x503CBD3: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 5 bytes in 1 blocks are definitely lost in loss record 4 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x53C960E: strdup (strdup.c:42)
==24162== by 0x5690090: opal_argv_append_nosize (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x56901B8: opal_argv_append (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x5690351: opal_argv_split_inter (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75F3FA7: ???
==24162== by 0x75F5B26: ???
==24162== by 0x56A76B1: mca_btl_base_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75C91B7: ???
==24162== by 0x4FED533: mca_bml_base_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CBB3: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162==
==24162== 8 bytes in 1 blocks are definitely lost in loss record 8 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x56A9469: dlopen_open (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75A955F: ???
==24162== by 0x75D434D: ???
==24162== by 0x56A76B1: mca_btl_base_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75C91B7: ???
==24162== by 0x4FED533: mca_bml_base_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CBB3: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 8 bytes in 1 blocks are definitely lost in loss record 9 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x56A9469: dlopen_open (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75A955F: ???
==24162== by 0x75F5834: ???
==24162== by 0x56A76B1: mca_btl_base_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75C91B7: ???
==24162== by 0x4FED533: mca_bml_base_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CBB3: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 13 bytes in 1 blocks are definitely lost in loss record 10 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x53C960E: strdup (strdup.c:42)
==24162== by 0x75A95EC: ???
==24162== by 0x75D434D: ???
==24162== by 0x56A76B1: mca_btl_base_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75C91B7: ???
==24162== by 0x4FED533: mca_bml_base_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CBB3: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 13 bytes in 1 blocks are definitely lost in loss record 11 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x53C960E: strdup (strdup.c:42)
==24162== by 0x75A95EC: ???
==24162== by 0x75F5834: ???
==24162== by 0x56A76B1: mca_btl_base_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x75C91B7: ???
==24162== by 0x4FED533: mca_bml_base_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CBB3: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 72 bytes in 1 blocks are possibly lost in loss record 59 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x79BE805: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7893A0A: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC07B9: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162==
==24162== 72 bytes in 1 blocks are possibly lost in loss record 60 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x7890E34: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7892B41: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78932B9: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC12D7: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162==
==24162== 79 (64 direct, 15 indirect) bytes in 1 blocks are definitely lost in loss record 61 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x75C117A: ???
==24162== by 0x568544E: mca_base_framework_components_open (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x56F3E45: mca_mpool_base_open (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x568FA88: mca_base_framework_open (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libopen-pal.so.40.30.2)
==24162== by 0x503CB74: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 93 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC044A: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162== by 0x1FECA9: main (main.cpp:42)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 94 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0479: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162== by 0x1FECA9: main (main.cpp:42)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 95 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7A12519: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7A1264D: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7A00E5B: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0827: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 96 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7A12519: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7A1264D: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7A00E81: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0827: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 97 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0C01: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162== by 0x1FECA9: main (main.cpp:42)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 98 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7893021: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78932D4: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC12D7: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 99 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0CB2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162== by 0x1FECA9: main (main.cpp:42)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 100 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0D4C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162== by 0x1FECA9: main (main.cpp:42)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 101 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x799F135: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0DC7: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 102 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x799F155: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0DC7: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162==
==24162== 152 bytes in 1 blocks are possibly lost in loss record 103 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x794043C: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x799F175: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC0DC7: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2C8370: cudaGetDeviceCount (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x1FE548: initialize_cuda() (cuda_initialize.cuh:39)
==24162==
==24162== 320 bytes in 1 blocks are possibly lost in loss record 114 of 151
==24162== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x40147D9: calloc (rtld-malloc.h:44)
==24162== by 0x40147D9: allocate_dtv (dl-tls.c:375)
==24162== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634)
==24162== by 0x53B6834: allocate_stack (allocatestack.c:430)
==24162== by 0x53B6834: pthread_create@@GLIBC_2.34 (pthread_create.c:647)
==24162== by 0x789EC26: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x794C75E: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x7AC1A49: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x78AAAA2: ??? (in /usr/lib/x86_64-linux-gnu/libcuda.so.515.65.01)
==24162== by 0x2A8482: __cudart516 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x2A8547: __cudart1336 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x53BAF67: __pthread_once_slow (pthread_once.c:116)
==24162== by 0x2F6AE8: __cudart1612 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162== by 0x29F0E6: __cudart514 (in /home/masarunagaso/workspace/TomoATT/build/TOMOATT)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 122 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EAB3: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 123 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EAB3: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 124 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EB7A: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 125 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EB7A: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 126 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EC26: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 127 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EC26: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 128 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9ECD4: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 129 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9ECD4: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 130 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EE36: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 131 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EE36: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 132 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EF96: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 133 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9EF96: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 134 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x502A9B6: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9F0F4: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== 688 bytes in 1 blocks are definitely lost in loss record 135 of 151
==24162== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==24162== by 0x756D41B: ???
==24162== by 0x502ACAE: ompi_op_base_op_select (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4F9F0F4: ompi_op_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x503CB0D: ompi_mpi_init (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x4FD0878: PMPI_Init_thread (in /home/masarunagaso/workspace/TomoATT/external_libs/local_mpi_hdf5/lib/libmpi.so.40.30.3)
==24162== by 0x20EE52: initialize_mpi() (mpi_funcs.h:68)
==24162== by 0x1FEC1D: main (main.cpp:28)
==24162==
==24162== LEAK SUMMARY:
==24162== definitely lost: 9,744 bytes in 21 blocks
==24162== indirectly lost: 15 bytes in 1 blocks
==24162== possibly lost: 2,136 bytes in 14 blocks
==24162== still reachable: 1,067,832 bytes in 138 blocks
==24162== suppressed: 0 bytes in 0 blocks
==24162== Reachable blocks (those to which a pointer was found) are not shown.
==24162== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==24162==
==24162== For lists of detected and suppressed errors, rerun with: -s
==24162== ERROR SUMMARY: 35 errors from 35 contexts (suppressed: 0 from 0)

View File

@@ -0,0 +1,298 @@
# %% [markdown]
# # notebook for create init and true test model
# %%
import numpy as np
import math
if __name__ == "__main__":
# get arguments
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--n_rtp", type=int, nargs=3, default=[55,55,55])
# n_sweep
parser.add_argument("--n_sweep", type=int, default=1)
# ndiv_rtp
parser.add_argument("--ndiv_rtp", type=int, nargs=3, default=[1,1,1])
# use_gpu
parser.add_argument("--use_gpu", type=int, default=0)
n_rtp = parser.parse_args().n_rtp
n_sweep = parser.parse_args().n_sweep
ndiv_rtp = parser.parse_args().ndiv_rtp
use_gpu = parser.parse_args().use_gpu
#
# create model file if not exists
#
# filename
str_nrtp = str(n_rtp[0])+"-"+str(n_rtp[1])+"-"+str(n_rtp[2])
fname_init = 'test_model_init_{}.h5'.format(str_nrtp)
fname_true = 'test_model_true_{}.h5'.format(str_nrtp)
# grid params
R_earth = 6371.0 #6378.1370
rr1=6070
rr2=6400
tt1=(30.0-1.5)/180*math.pi
tt2=(50.0+1.5)/180*math.pi
pp1=(15.0-1.5)/180*math.pi
pp2=(40.0+1.5)/180*math.pi
import os
if not os.path.exists(fname_true):
#n_rtp = [55,55,55]
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.04
ani_p=0.03
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[2]):
for it in range(n_rtp[1]):
for ip in range(n_rtp[0]):
#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)
if (rr[ir]>6351):
fun_init[ir,it,ip] = 1.0/(5.8+(6371-rr[ir])/20.0*0.7)
elif (rr[ir]>6336):
fun_init[ir,it,ip] = 1.0/(6.5+(6351-rr[ir])/15.0*0.6)
elif (rr[ir]>5961):
fun_init[ir,it,ip] = 1.0/(8.0+(6336-rr[ir])/375.0*1)
else:
fun_init[ir,it,ip] = 1.0/9.0
vel_init[ir,it,ip] = 1.0/fun_init[ir,it,ip]
# true model
if (tt[it] >= 30.0/180.0*math.pi and tt[it] <= 50.0/180.0*math.pi \
and pp[ip] >= 15.0/180.0*math.pi and pp[ip] <= 40.0/180.0*math.pi \
and rr[ir] >= 6211.0 and rr[ir] <= 6371.0):
c+=1
sigma = math.sin(4.0*math.pi*(tt[it]-30.0/180.0*math.pi)/(20.0/180.0*math.pi)) \
*math.sin(4.0*math.pi*(pp[ip]-15.0/180.0*math.pi)/(25.0/180.0*math.pi)) \
*math.sin(2.0*math.pi*(rr[ir]-6211.0)/160.0)
else:
sigma = 0.0
if sigma < 0:
psi = 60.0/180.0*math.pi
elif sigma > 0:
psi = 150.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] = fun_init[ir,it,ip]/(1.0+sigma*slow_p)
vel_true[ir,it,ip] = 1.0/fun_true[ir,it,ip]
r_earth = R_earth #6378.1370
print("depminmax {} {}".format(r_earth-rr1,r_earth-rr2))
print(c)
# %%
# write out
import h5py
# n_rtp to storing
fout_init = h5py.File(fname_init, 'w')
fout_true = h5py.File(fname_true, '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()
#
# create src rec file
# %% [markdown]
# # prepare src station file
#
# ```
# 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(123456789)
# 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
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_src = 1
n_rec = [1 for x in range(n_src)]
lines = []
pos_src=[]
pos_rec=[]
dep_srcs=[12.902894]
lon_srcs=[16.794572]
lat_srcs=[37.503373]
elev_recs = [0.0]
lon_recs = [29.812050]
lat_recs = [36.472809]
# create dummy src
for i_src in range(n_src):
# define one point in the domain (rr1 bottom, rr2 top)
dep = dep_srcs[i_src]
lon = lon_srcs[i_src]
lat = lat_srcs[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]
lines.append(src)
pos_src.append([lon,lat,dep])
# create dummy station
for i_rec in range(n_rec[i_src]):
#elev_rec = random.uniform(0.0,-10.0) # elevation in m
#lon_rec = random.uniform(pp1deg,pp2deg)
#lat_rec = random.uniform(tt1deg,tt2deg)
rec = [i_src, i_rec, st_name_dummy+"_"+str(i_rec), lat_recs[i_rec], lon_recs[i_rec], elev_recs[i_rec], phase_dummy, arriv_t_dummy]
lines.append(rec)
pos_rec.append([lon_recs[i_rec],lat_recs[i_rec],elev_recs[i_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')
str_input_file = """version : 2
domain :
#min_max_dep : [-21.863,308.8137] # depth in km
min_max_dep : [-29.0, 301.0] # depth in km with R = 6371.0
min_max_lat : [28.5,51.5] # latitude in degree
min_max_lon : [13.5,41.5] # longitude in degree
n_rtp : [{},{},{}] # number of nodes
source :
#src_dep_lat_lon : [5.0,40.0,24.0] # source depth in km, latitude, longitude in degree
#src_dep_lat_lon : [5750.6370,46.0,36.0] # source depth in km, latitude, longitude in degree
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
model :
init_model_type : '' # 'fd' (input file) or '1d_ak135'
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 : [{},{},{}] # number of subdomains
nproc_sub : {} # number of subprocess used for each subdomain
use_gpu : {}
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_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
""".format(n_rtp[0],n_rtp[1],n_rtp[2],n_rtp[0],n_rtp[1],n_rtp[2], ndiv_rtp[0],ndiv_rtp[1],ndiv_rtp[2], n_sweep, use_gpu)
str_nsweep_ndiv_rtp = str(n_sweep) + '-' + str(ndiv_rtp[0]) + '-' + str(ndiv_rtp[1]) + '-' + str(ndiv_rtp[2])
# write out
with open('input_params_{}_{}.yml'.format(str_nrtp, str_nsweep_ndiv_rtp), 'w') as f:
f.write(str_input_file)

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,139 @@
from paraview.simple import *
if __name__ == '__main__':
# get args
args = sys.argv
if len(args) != 3:
print("Usage: pvpython draw_slice.py <data_file> <dataset_name>")
sys.exit(1)
# get data
fpath = args[1]
name_dset = args[2]
#fpath = "OUTPUT_FILES/out_data_sim_0.xmf"
#name_dset = 'fun_inv_0000'
# create a new 'XDMF Reader'
out_data_sim_0xmf = XDMFReader(registrationName=fpath.split('/')[-1], FileNames=[fpath])
# Limit the data array to be read
# Properties modified on out_data_sim_0xmf
out_data_sim_0xmf.PointArrayStatus = [name_dset]
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
## show data in view
#out_data_sim_0xmfDisplay = Show(out_data_sim_0xmf, renderView1, 'UnstructuredGridRepresentation')
## trace defaults for the display properties.
#out_data_sim_0xmfDisplay.Representation = 'Surface'
# reset view to fit data
#renderView1.ResetCamera(False)
# get the material library
materialLibrary1 = GetMaterialLibrary()
# get color transfer function/color map for 'T_res_src_0_inv_0000'
name_dsetLUT = GetColorTransferFunction(name_dset)
# get opacity transfer function/opacity map for 'T_res_src_0_inv_0000'
name_dsetPWF = GetOpacityTransferFunction(name_dset)
# show color bar/color legend
#out_data_sim_0xmfDisplay.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
#renderView1.Update()
# create a new 'Slice'
slice1 = Slice(registrationName='Slice1', Input=out_data_sim_0xmf)
# Properties modified on slice1.SliceType
slice1.SliceType.Normal = [0.0, 0.0, 1.0]
# show data in view
slice1Display = Show(slice1, renderView1, 'GeometryRepresentation')
# trace defaults for the display properties.
slice1Display.Representation = 'Surface'
# hide data in view
Hide(out_data_sim_0xmf, renderView1)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# trace defaults for the display properties.
slice1Display.Representation = 'Surface'
# rescale color and/or opacity maps used to include current data range
slice1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
#
# change the position of color bar
#
# Properties modified on slice1Display.DataAxesGrid
slice1Display.DataAxesGrid.GridAxesVisibility = 1
# get color legend/bar for t_res_src_0_inv_0000LUT in view renderView1
name_dsetLUTColorBar = GetScalarBar(name_dsetLUT, renderView1)
# change scalar bar placement
name_dsetLUTColorBar.Orientation = 'Horizontal'
name_dsetLUTColorBar.WindowLocation = 'Any Location'
name_dsetLUTColorBar.Position = [0.33262344353799916, 0.24363636363636363]
name_dsetLUTColorBar.ScalarBarLength = 0.3299999999999998
# update the view to ensure updated data information
#renderView1.Update()
#
# axis options
#
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=slice1.SliceType)
# Properties modified on slice1Display.DataAxesGrid
slice1Display.DataAxesGrid.GridAxesVisibility = 1
#
# window layout and camera settings
#
layout1 = GetLayout()
#--------------------------------
# saving layout sizes for layouts
# layout/tab size in pixels
layout1.SetSize(1280, 980)
#-----------------------------------
# saving camera placements for views
# current camera placement for renderView1
renderView1.CameraPosition = [6086.06543558693, 0.0, 7825.811009542308]
renderView1.CameraFocalPoint = [6086.06543558693, 0.0, -3.410605131648481e-13]
renderView1.CameraViewUp = [1.0, 2.220446049250313e-16, 0.0]
renderView1.CameraParallelScale = 2025.468932642534
# save screenshot
SaveScreenshot('test_screenshot.png', renderView1, ImageResolution=[2560,1280])
Render()
Interact()

View File

@@ -0,0 +1,115 @@
# trace generated using paraview version 5.10.1
#import paraview
#paraview.compatibility.major = 5
#paraview.compatibility.minor = 10
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'XDMF Reader'
out_data_sim_0xmf = XDMFReader(registrationName='out_data_sim_0.xmf', FileNames=['/home/masarunagaso/workspace/TomoATT/test/solver_performance/OUTPUT_FILES/out_data_sim_0.xmf'])
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# show data in view
out_data_sim_0xmfDisplay = Show(out_data_sim_0xmf, renderView1, 'UnstructuredGridRepresentation')
# trace defaults for the display properties.
out_data_sim_0xmfDisplay.Representation = 'Surface'
# reset view to fit data
renderView1.ResetCamera(False)
# get the material library
materialLibrary1 = GetMaterialLibrary()
# show color bar/color legend
out_data_sim_0xmfDisplay.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# get color transfer function/color map for 'procid'
procidLUT = GetColorTransferFunction('procid')
# get opacity transfer function/opacity map for 'procid'
procidPWF = GetOpacityTransferFunction('procid')
# create a new 'Slice'
slice1 = Slice(registrationName='Slice1', Input=out_data_sim_0xmf)
# show data in view
slice1Display = Show(slice1, renderView1, 'GeometryRepresentation')
# trace defaults for the display properties.
slice1Display.Representation = 'Surface'
# hide data in view
Hide(out_data_sim_0xmf, renderView1)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# Properties modified on slice1.SliceType
slice1.SliceType.Normal = [0.0, 0.0, 1.0]
# update the view to ensure updated data information
renderView1.Update()
# set scalar coloring
ColorBy(slice1Display, ('POINTS', 'T_res_src_0_inv_0000'))
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(procidLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
slice1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'T_res_src_0_inv_0000'
t_res_src_0_inv_0000LUT = GetColorTransferFunction('T_res_src_0_inv_0000')
# get opacity transfer function/opacity map for 'T_res_src_0_inv_0000'
t_res_src_0_inv_0000PWF = GetOpacityTransferFunction('T_res_src_0_inv_0000')
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=slice1.SliceType)
# Properties modified on slice1Display.DataAxesGrid
slice1Display.DataAxesGrid.GridAxesVisibility = 1
#================================================================
# addendum: following script captures some of the application
# state to faithfully reproduce the visualization during playback
#================================================================
# get layout
layout1 = GetLayout()
#--------------------------------
# saving layout sizes for layouts
# layout/tab size in pixels
layout1.SetSize(2329, 1650)
#-----------------------------------
# saving camera placements for views
# current camera placement for renderView1
renderView1.CameraPosition = [6086.06543558693, 0.0, 7825.811009542308]
renderView1.CameraFocalPoint = [6086.06543558693, 0.0, -3.410605131648481e-13]
renderView1.CameraViewUp = [1.0, 2.220446049250313e-16, 0.0]
renderView1.CameraParallelScale = 2025.468932642534
#--------------------------------------------
# uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).

View File

@@ -0,0 +1,106 @@
# trace generated using paraview version 5.10.1
#import paraview
#paraview.compatibility.major = 5
#paraview.compatibility.minor = 10
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'XDMF Reader'
out_data_sim_0xmf = XDMFReader(registrationName='out_data_sim_0.xmf', FileNames=['/home/masarunagaso/workspace/TomoATT/test/solver_performance/OUTPUT_FILES/out_data_sim_0.xmf'])
# Properties modified on out_data_sim_0xmf
out_data_sim_0xmf.PointArrayStatus = ['T_res_src_0_inv_0000']
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# show data in view
out_data_sim_0xmfDisplay = Show(out_data_sim_0xmf, renderView1, 'UnstructuredGridRepresentation')
# trace defaults for the display properties.
out_data_sim_0xmfDisplay.Representation = 'Surface'
# reset view to fit data
renderView1.ResetCamera(False)
# get the material library
materialLibrary1 = GetMaterialLibrary()
# show color bar/color legend
out_data_sim_0xmfDisplay.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# get color transfer function/color map for 'T_res_src_0_inv_0000'
t_res_src_0_inv_0000LUT = GetColorTransferFunction('T_res_src_0_inv_0000')
# get opacity transfer function/opacity map for 'T_res_src_0_inv_0000'
t_res_src_0_inv_0000PWF = GetOpacityTransferFunction('T_res_src_0_inv_0000')
# create a new 'Slice'
slice1 = Slice(registrationName='Slice1', Input=out_data_sim_0xmf)
# Properties modified on slice1.SliceType
slice1.SliceType.Normal = [0.0, 0.0, 1.0]
# show data in view
slice1Display = Show(slice1, renderView1, 'GeometryRepresentation')
# trace defaults for the display properties.
slice1Display.Representation = 'Surface'
# hide data in view
Hide(out_data_sim_0xmf, renderView1)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=slice1.SliceType)
# Properties modified on slice1Display.DataAxesGrid
slice1Display.DataAxesGrid.GridAxesVisibility = 1
# get color legend/bar for t_res_src_0_inv_0000LUT in view renderView1
t_res_src_0_inv_0000LUTColorBar = GetScalarBar(t_res_src_0_inv_0000LUT, renderView1)
# change scalar bar placement
t_res_src_0_inv_0000LUTColorBar.Orientation = 'Horizontal'
t_res_src_0_inv_0000LUTColorBar.WindowLocation = 'Any Location'
t_res_src_0_inv_0000LUTColorBar.Position = [0.33262344353799916, 0.34363636363636363]
t_res_src_0_inv_0000LUTColorBar.ScalarBarLength = 0.3299999999999998
#================================================================
# addendum: following script captures some of the application
# state to faithfully reproduce the visualization during playback
#================================================================
# get layout
layout1 = GetLayout()
#--------------------------------
# saving layout sizes for layouts
# layout/tab size in pixels
layout1.SetSize(2329, 1650)
#-----------------------------------
# saving camera placements for views
# current camera placement for renderView1
renderView1.CameraPosition = [6086.06543558693, 0.0, 7825.811009542308]
renderView1.CameraFocalPoint = [6086.06543558693, 0.0, -3.410605131648481e-13]
renderView1.CameraViewUp = [1.0, 2.220446049250313e-16, 0.0]
renderView1.CameraParallelScale = 2025.468932642534
#--------------------------------------------
# uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More