diff --git "a/Datasets-Construction/OpenSWI-shallow/0.2-10s-Aug/00_OpenSWI-shallow-example.ipynb" "b/Datasets-Construction/OpenSWI-shallow/0.2-10s-Aug/00_OpenSWI-shallow-example.ipynb" new file mode 100644--- /dev/null +++ "b/Datasets-Construction/OpenSWI-shallow/0.2-10s-Aug/00_OpenSWI-shallow-example.ipynb" @@ -0,0 +1,129 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import sys\n", + "sys.path.append(\"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/OpenSWI/Datasets/OpenSWI\")\n", + "from SWIDP.process_1d_shallow import augment_workflow\n", + "from SWIDP.dispersion import generate_mixed_samples,calculate_dispersion,transform_vp_to_vs,transform_vs_to_vel_model\n", + "from p_tqdm import p_map" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9b2734ae566a4f548951689179afedd5", + "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_vp = np.loadtxt(\"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/OpenSWI/Datasets/OpenSWI/Datasets-Construction/OpenSWI-shallow/0.2-10s-Aug/vp_demo.txt\")\n", + "depth = depth_vp[:,0]\n", + "vp = depth_vp[:,1]\n", + "\n", + "# step2: generate velocity model (depth, vp, vs, rho)\n", + "vs = transform_vp_to_vs(vp)\n", + "\n", + "# step3: vs model augmentation\n", + "augment_nums = 100\n", + "vs_perturbation = 0.05 # relative ratio\n", + "thickness_perturbation = 0.1 # relative ratio\n", + "vel_threshold = 0.05 # km/s\n", + "thickness_threshold = 0.01 # km\n", + "min_layers_num = 3 \n", + "smooth_vel = False\n", + "smoothnodes = 10\n", + "vs_augmented = augment_workflow(vs,depth,\n", + " perturb_num = augment_nums,\n", + " vs_perturbation=vs_perturbation,\n", + " thickness_perturbation=thickness_perturbation,\n", + " vel_threshold=vel_threshold,\n", + " thickness_threshold=thickness_threshold,\n", + " min_layers_num=min_layers_num,\n", + " smooth_vel=smooth_vel,\n", + " smooth_nodes=smoothnodes)\n", + "\n", + "# step4: generate velocity model (depth, vp, vs, rho)\n", + "vel_model_augmented = p_map(transform_vs_to_vel_model,list(vs_augmented),[depth]*len(vs_augmented))\n", + "\n", + "# step5: generate dispersion curves [t,phase velocity, group velocity]\n", + "t = generate_mixed_samples(num_samples=100,start=0.2,end=10,uniform_num=50,log_num=20,random_num=30)\n", + "disp = p_map(calculate_dispersion,vel_model_augmented,[t]*len(vel_model_augmented))\n", + "\n", + "\n", + "import matplotlib.pyplot as plt\n", + "plt.figure(figsize=(10,5))\n", + "plt.subplot(121)\n", + "for i in range(len(vel_model_augmented)):\n", + " plt.step(vel_model_augmented[i][:,2],depth,c='silver',alpha=0.5)\n", + "plt.step(vel_model_augmented[0][:,2],depth,c='k')\n", + "plt.gca().invert_yaxis()\n", + "\n", + "plt.subplot(122)\n", + "for i in range(len(disp)):\n", + " plt.scatter(disp[i][:,0],disp[i][:,1],s=10,c='pink',alpha=0.5)\n", + " plt.scatter(disp[i][:,0],disp[i][:,2],s=10,c='lightblue',alpha=0.5)\n", + "plt.scatter(disp[0][:,0],disp[0][:,1],s=10,c='r')\n", + "plt.scatter(disp[0][:,0],disp[0][:,2],s=10,c='b')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}