initial upload
This commit is contained in:
119
test/old_tests/inversion_2/check_src_rec_file.ipynb
Normal file
119
test/old_tests/inversion_2/check_src_rec_file.ipynb
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user