diff --git "a/Datasets-Construction/OpenSWI-deep/1s-100s-Aug/00_OpenSWI-deep-example.ipynb" "b/Datasets-Construction/OpenSWI-deep/1s-100s-Aug/00_OpenSWI-deep-example.ipynb" deleted file mode 100644--- "a/Datasets-Construction/OpenSWI-deep/1s-100s-Aug/00_OpenSWI-deep-example.ipynb" +++ /dev/null @@ -1,177 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "import sys\n", - "sys.path.append(\"../../../\")\n", - "from SWIDP.process_1d_deep import *\n", - "from SWIDP.dispersion import generate_mixed_samples,calculate_dispersion,transform_vs_to_vel_model\n", - "from p_tqdm import p_map" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "56226f27abbe4d8393a472ed15360766", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/100 [00:00" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# step1: get 1d velocity model (vp model or vs)\n", - "depth_vs = np.loadtxt(\"./vs_demo.txt\")\n", - "depth = depth_vs[:,0]\n", - "vs = depth_vs[:,1]\n", - "\n", - "# step2-1: remove the thin sandwidth layer\n", - "vs = combine_thin_sandwich(vs,\n", - " depth,\n", - " thickness_threshold=12, # km\n", - " uniform_thickness=1, # km (thickness_threshold/uniform_thickness) = max_check_layers\n", - " gradient_threshold=0.05, # km/s (gradient_threshold)\n", - " return_idx=False\n", - " )\n", - "\n", - "# step2-2: smooth the vs model (selectable)\n", - "vs = smooth_vs_by_node_interp(vs,\n", - " depth,\n", - " n_nodes=20,\n", - " method=\"pchip\"\n", - " )\n", - "\n", - "# step3: find moho index\n", - "moho_idx = find_moho_depth(vs,\n", - " depth,\n", - " [5,90], # range of moho index\n", - " gradient_search=False,\n", - " gradient_threshold=0.01)\n", - "\n", - "# step4: augment the vs model\n", - "perturb_nums = 100\n", - "vs_augmented = p_map(augment_crust_moho_mantle,\n", - " [vs]*perturb_nums,\n", - " list(depth.reshape(1,-1))*perturb_nums,\n", - " [moho_idx]*perturb_nums,\n", - " [[-0.1,0.1]]*perturb_nums, # relative ratio\n", - " [[3,8]]*perturb_nums, # nodes for crust\n", - " [[8,15]]*perturb_nums, # nodes for mantle\n", - " [3]*perturb_nums, # km \n", - " [2]*perturb_nums, # km\n", - " [False]*perturb_nums,\n", - " np.random.randint(0,1000000,perturb_nums)\n", - " )\n", - "\n", - "# step5: transform the vs model to vp model\n", - "vel_models = p_map(transform_vs_to_vel_model,list(vs_augmented),[depth]*len(vs_augmented))\n", - "\n", - "# step6: calculate the dispersion curve\n", - "t = generate_mixed_samples(num_samples=300,start=1,end=100,uniform_num=100,log_num=100,random_num=100)\n", - "t = np.ones((len(vel_models),len(t)))*t\n", - "disp_data = p_map(calculate_dispersion, vel_models, list(t))\n", - "disp_data = np.array(disp_data)\n", - "vel_models = np.array(vel_models)\n", - "\n", - "# figure\n", - "import matplotlib.pyplot as plt\n", - "import matplotlib.pyplot as plt\n", - "plt.figure(figsize=(10,5))\n", - "plt.subplot(121)\n", - "plt.step(depth_vs[:,1],depth_vs[:,0],label=\"original\",c=\"k\")\n", - "for i in range(len(vel_models)):\n", - " plt.step(vel_models[i,:,2],vel_models[i,:,0],c=\"lightcoral\",alpha=0.5,linewidth=0.5)\n", - "plt.step(vel_models[10,:,2],vel_models[10,:,0],c=\"b\",alpha=1,label=\"augmented\")\n", - "plt.axhline(y=depth[moho_idx],color=\"r\",linestyle=\"--\",label=\"moho\")\n", - "plt.gca().invert_yaxis()\n", - "plt.legend()\n", - "plt.xlabel(\"Velocity (km/s)\",fontsize=12)\n", - "plt.ylabel(\"Depth (km)\",fontsize=12)\n", - "plt.xticks(fontsize=12)\n", - "plt.yticks(fontsize=12)\n", - "plt.grid(True,linestyle='--',alpha=0.5)\n", - "\n", - "plt.subplot(122)\n", - "for i in range(len(disp_data)):\n", - " plt.scatter(disp_data[i][:,0],disp_data[i][:,1],s=10,c=\"pink\",alpha=0.5)\n", - " plt.scatter(disp_data[i][:,0],disp_data[i][:,2],s=10,c=\"lightblue\",alpha=0.5)\n", - "plt.scatter(disp_data[10][:,0],disp_data[10][:,1],s=10,c=\"r\")\n", - "plt.scatter(disp_data[10][:,0],disp_data[10][:,2],s=10,c=\"b\")\n", - "plt.xlabel(\"Period (s)\",fontsize=12)\n", - "plt.ylabel(\"Velocity (km/s)\",fontsize=12)\n", - "plt.xticks(fontsize=12)\n", - "plt.yticks(fontsize=12)\n", - "plt.grid(True,linestyle='--',alpha=0.5)\n", - "plt.tight_layout()\n", - "plt.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}