liufeng commited on
Commit
584b440
·
1 Parent(s): 106533a

update: datasets links

Browse files
Files changed (22) hide show
  1. .gitignore +2 -0
  2. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_1_OpenFWI-FlatVel-A.ipynb +0 -0
  3. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_2_OpenFWI-FlatFault-A.ipynb +0 -0
  4. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_3_OpenFWI-CurveVel-A.ipynb +0 -0
  5. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_4_OpenFWI-CurveFault-A.ipynb +0 -0
  6. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_5_OpenFWI-Stylel-A.ipynb +0 -0
  7. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/readme.md +0 -5
  8. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/00_DataDistributionStatistic.ipynb +0 -0
  9. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_0_OpenFWI-A.ipynb +0 -0
  10. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_1_OpenFWI-FlatVel-A.ipynb +0 -282
  11. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_2_OpenFWI-FlatFault-A.ipynb +0 -0
  12. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_3_OpenFWI-CurveVel-A.ipynb +0 -0
  13. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_4_OpenFWI-CurveFault-A.ipynb +0 -310
  14. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_5_OpenFWI-Stylel-A.ipynb +0 -0
  15. Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/02_1_OpenFWI-FlatVel-B.ipynb +0 -0
  16. SWIDP/__pycache__/__init__.cpython-310.pyc +0 -0
  17. SWIDP/__pycache__/diffusion_aug_2d.cpython-310.pyc +0 -0
  18. SWIDP/__pycache__/dispersion.cpython-310.pyc +0 -0
  19. SWIDP/__pycache__/process_1d_deep.cpython-310.pyc +0 -0
  20. SWIDP/__pycache__/process_1d_shallow.cpython-310.pyc +0 -0
  21. SWIDP/__pycache__/velocity_aug_1d.cpython-310.pyc +0 -0
  22. SWIDP/__pycache__/velocity_aug_1d_deep.cpython-310.pyc +0 -0
.gitignore CHANGED
@@ -1,4 +1,6 @@
 
1
  backup/
 
2
  Article-Figures/
3
  python/
4
  Figures/
 
1
+ __pycache__/
2
  backup/
3
+ # Backup/
4
  Article-Figures/
5
  python/
6
  Figures/
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_1_OpenFWI-FlatVel-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_2_OpenFWI-FlatFault-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_3_OpenFWI-CurveVel-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_4_OpenFWI-CurveFault-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/01_5_OpenFWI-Stylel-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s-varyingThickness/readme.md DELETED
@@ -1,5 +0,0 @@
1
-
2
- v1: t range: 0.5-5s, 100 samples
3
- t = generate_mixed_samples(num_samples=100,start=0.5,end=5,uniform_num=30,log_num=30,random_num=40)
4
- v2: t range: 0.01-5s, 120 samples
5
- t = generate_mixed_samples(num_samples=120,start=0.01,end=5,uniform_num=40,log_num=40,random_num=40)
 
 
 
 
 
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/00_DataDistributionStatistic.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_0_OpenFWI-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_1_OpenFWI-FlatVel-A.ipynb DELETED
@@ -1,282 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "## Imshow 1 of the subsets"
8
- ]
9
- },
10
- {
11
- "cell_type": "code",
12
- "execution_count": null,
13
- "metadata": {},
14
- "outputs": [],
15
- "source": [
16
- "import os\n",
17
- "import numpy as np\n",
18
- "import matplotlib.pyplot as plt\n",
19
- "\n",
20
- "\n",
21
- "data_base_path = \"/home/bingxing2/ailab/group/ai4earth/liufeng/OpenFWI/FlatVel_A/model\"\n",
22
- "\n",
23
- "models_list = os.listdir(data_base_path)\n",
24
- "\n",
25
- "models_list = sorted(models_list, key=lambda x: int(x.split(\".\")[0].replace(\"model\", \"\")))\n",
26
- "\n",
27
- "models_path_list = []\n",
28
- "for model_name in models_list:\n",
29
- " model_path = os.path.join(data_base_path, model_name)\n",
30
- " models_path_list.append(model_path)\n",
31
- "\n",
32
- "\n",
33
- "vel_model_subsets0 = np.load(models_path_list[0])\n",
34
- "vel_model_subsets0 = vel_model_subsets0.squeeze()\n",
35
- "nrows = 10\n",
36
- "ncols = 10\n",
37
- "fig,axs = plt.subplots(nrows,ncols,figsize=(10,10))\n",
38
- "for i in range(nrows):\n",
39
- " for j in range(ncols):\n",
40
- " axs[i,j].imshow(vel_model_subsets0[i*ncols+j],cmap=\"jet\")\n",
41
- " axs[i,j].set_xticks([])\n",
42
- " axs[i,j].set_yticks([])\n",
43
- "plt.subplots_adjust(wspace=0.05,hspace=0.05)\n",
44
- "# plt.savefig(\"Datasets/JupyterNotebook/Figures/FlatVel_A_2D.png\",bbox_inches='tight',dpi=300)\n",
45
- "plt.show()\n"
46
- ]
47
- },
48
- {
49
- "cell_type": "markdown",
50
- "metadata": {},
51
- "source": [
52
- "## Datasets Preparing"
53
- ]
54
- },
55
- {
56
- "cell_type": "code",
57
- "execution_count": 2,
58
- "metadata": {},
59
- "outputs": [],
60
- "source": [
61
- "import numpy as np\n",
62
- "from DispFormer.dispersion import *\n",
63
- "from p_tqdm import p_map"
64
- ]
65
- },
66
- {
67
- "cell_type": "code",
68
- "execution_count": null,
69
- "metadata": {},
70
- "outputs": [],
71
- "source": [
72
- "vel_model_subset = np.load(models_path_list[0]).squeeze()\n",
73
- "vel_models0 = transform_vp_to_vel_model(vel_model_subset[100,:,10]/1000)\n",
74
- "vel_models1 = transform_vs_to_vel_model(vel_models0[:,2],depth=vel_models0[:,0])\n",
75
- "disp0 = calculate_dispersion(vel_models0)\n",
76
- "disp1 = calculate_dispersion(vel_models1)\n",
77
- "depth = vel_models0[:,0]\n",
78
- "\n",
79
- "plt.figure(figsize=(10,5))\n",
80
- "plt.subplot(121)\n",
81
- "plt.step(vel_models0[:,2],depth)\n",
82
- "plt.step(vel_models1[:,2],depth)\n",
83
- "plt.gca().invert_yaxis()\n",
84
- "\n",
85
- "\n",
86
- "plt.subplot(122)\n",
87
- "plt.scatter(disp0[:,0],disp0[:,1])\n",
88
- "plt.scatter(disp1[:,0],disp1[:,1])\n",
89
- "plt.show()"
90
- ]
91
- },
92
- {
93
- "cell_type": "code",
94
- "execution_count": null,
95
- "metadata": {},
96
- "outputs": [],
97
- "source": [
98
- "save_base_path = \"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/DispFormer-local/Datasets/OpenSWI/Datasets/OpenSWI-shallow/0.2-10s-Aug/\"\n",
99
- "\n",
100
- "# Initialize empty lists to store data\n",
101
- "disp_data_all = []\n",
102
- "vel_models_all = []\n",
103
- "\n",
104
- "try:\n",
105
- " # Process each model file\n",
106
- " for path in models_path_list:\n",
107
- " # Load and preprocess velocity model\n",
108
- " vel_model_subset = np.load(path).squeeze()\n",
109
- " \n",
110
- " # Convert velocity from m/s to km/s and transform to velocity model\n",
111
- " vel_models = p_map(transform_vp_to_vel_model, vel_model_subset[:,:,10]/1000)\n",
112
- " vel_models = np.array(vel_models)\n",
113
- " vs_models = list(vel_models[:,:,2])\n",
114
- " vel_models = p_map(transform_vs_to_vel_model,vs_models)\n",
115
- "\n",
116
- " # Calculate dispersion curves\n",
117
- " disp_data = p_map(calculate_dispersion, vel_models)\n",
118
- " disp_data = np.array(disp_data)\n",
119
- " \n",
120
- " # Store results\n",
121
- " disp_data_all.append(disp_data)\n",
122
- " vel_models_all.append(vel_models)\n",
123
- "\n",
124
- " # Convert lists to numpy arrays and reshape\n",
125
- " disp_data_all = np.array(disp_data_all).reshape(-1, *np.array(disp_data_all).shape[2:])\n",
126
- " vel_models_all = np.array(vel_models_all).reshape(-1, *np.array(vel_models_all).shape[2:])\n",
127
- " \n",
128
- " # Filter out zero dispersion curves and corresponding velocity models\n",
129
- " valid_indices = ~np.all(disp_data_all == 0, axis=(1,2))\n",
130
- " disp_data_all = disp_data_all[valid_indices]\n",
131
- " vel_models_all = vel_models_all[valid_indices]\n",
132
- "\n",
133
- " # Create output directory if it doesn't exist\n",
134
- " os.makedirs(save_base_path, exist_ok=True)\n",
135
- " \n",
136
- " # Save processed data as compressed npz files\n",
137
- " np.savez_compressed(os.path.join(save_base_path, \"FlatVelA_model.npz\"),\n",
138
- " data=vel_models_all.astype(np.float32))\n",
139
- " np.savez_compressed(os.path.join(save_base_path, \"FlatVelA_disp.npz\"),\n",
140
- " data=disp_data_all.astype(np.float32))\n",
141
- " \n",
142
- "except Exception as e:\n",
143
- " print(f\"An error occurred during processing: {str(e)}\")"
144
- ]
145
- },
146
- {
147
- "cell_type": "markdown",
148
- "metadata": {},
149
- "source": [
150
- "## Datasets Imshow\n"
151
- ]
152
- },
153
- {
154
- "cell_type": "code",
155
- "execution_count": null,
156
- "metadata": {},
157
- "outputs": [],
158
- "source": [
159
- "import matplotlib.pyplot as plt\n",
160
- "def plot_vel_disp(vel_model, disp_data):\n",
161
- " \"\"\"Plot velocity model and dispersion curves\n",
162
- " \n",
163
- " Args:\n",
164
- " vel_model: numpy array with columns [thickness, vp, vs, density]\n",
165
- " disp_data: numpy array with columns [period, phase_vel, group_vel]\n",
166
- " \"\"\"\n",
167
- " fig, axs = plt.subplots(1,2,figsize=(10,6))\n",
168
- " \n",
169
- " depth = vel_model[:,0]\n",
170
- " \n",
171
- " # Left subplot - Velocity model\n",
172
- " axs[0].step(vel_model[:,1], depth, label='P-wave velocity (km/s)', linewidth=2)\n",
173
- " axs[0].step(vel_model[:,2], depth, label='S-wave velocity (km/s)', linewidth=2) \n",
174
- " axs[0].step(vel_model[:,3], depth, label='Density (g/cm³)', linewidth=2)\n",
175
- " axs[0].invert_yaxis()\n",
176
- " axs[0].set_xlabel('Velocity (km/s) / Density (g/cm³)')\n",
177
- " axs[0].set_ylabel('Depth (m)')\n",
178
- " axs[0].set_title('Velocity Model')\n",
179
- " axs[0].grid(True, linestyle='--', alpha=0.7)\n",
180
- " axs[0].legend()\n",
181
- "\n",
182
- " # Right subplot - Dispersion curves\n",
183
- " axs[1].scatter(disp_data[:,0], disp_data[:,1], label='Phase velocity', s=50)\n",
184
- " axs[1].scatter(disp_data[:,0], disp_data[:,2], label='Group velocity', s=50)\n",
185
- " axs[1].set_xlabel('Period (s)')\n",
186
- " axs[1].set_ylabel('Velocity (km/s)')\n",
187
- " axs[1].set_title('Dispersion Curves')\n",
188
- " axs[1].grid(True, linestyle='--', alpha=0.7)\n",
189
- " axs[1].legend()\n",
190
- "\n",
191
- " plt.tight_layout()\n",
192
- " plt.show()\n",
193
- " \n",
194
- "# Test the function\n",
195
- "idx = 1100\n",
196
- "plot_vel_disp(vel_models_all[idx], disp_data_all[idx])"
197
- ]
198
- },
199
- {
200
- "cell_type": "code",
201
- "execution_count": null,
202
- "metadata": {},
203
- "outputs": [],
204
- "source": [
205
- "# Create subplots for Vp, Vs and density\n",
206
- "fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12,5))\n",
207
- "\n",
208
- "# Get depth array from first model\n",
209
- "depth = vel_models_all[0,:,0]\n",
210
- "\n",
211
- "# Plot Vp models with alpha blending\n",
212
- "ax1.step(vel_models_all[:,:,1].T, depth, color='r', alpha=0.01)\n",
213
- "ax1.set_title('P-wave Velocity Models')\n",
214
- "ax1.set_xlabel('Velocity (km/s)')\n",
215
- "ax1.set_ylabel('Depth (m)')\n",
216
- "ax1.invert_yaxis()\n",
217
- "ax1.grid(True)\n",
218
- "\n",
219
- "# Plot Vs models\n",
220
- "ax2.step(vel_models_all[:,:,2].T, depth, color='b', alpha=0.01)\n",
221
- "ax2.set_title('P-wave Velocity Models')\n",
222
- "ax2.set_xlabel('Velocity (km/s)')\n",
223
- "ax2.set_ylabel('Depth (m)')\n",
224
- "ax2.invert_yaxis()\n",
225
- "ax2.grid(True)\n",
226
- "\n",
227
- "# Plot density models\n",
228
- "ax3.step(vel_models_all[:,:,3].T, depth, color='gray', alpha=0.01)\n",
229
- "ax3.set_title('P-wave Velocity Models')\n",
230
- "ax3.set_xlabel('Velocity (km/s)')\n",
231
- "ax3.set_ylabel('Depth (m)')\n",
232
- "ax3.invert_yaxis()\n",
233
- "ax3.grid(True)\n",
234
- "\n",
235
- "plt.tight_layout()\n",
236
- "plt.show()"
237
- ]
238
- },
239
- {
240
- "cell_type": "code",
241
- "execution_count": null,
242
- "metadata": {},
243
- "outputs": [],
244
- "source": [
245
- "import numpy as np\n",
246
- "\n",
247
- "vel_models_all = np.load(\"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/DispFormer-local/Datasets/OpenSWI/Datasets/OpenSWI-shallow/0.2-10s-Aug/FlatVelA_model.npz\")[\"data\"]\n",
248
- "disp_data_all = np.load(\"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/DispFormer-local/Datasets/OpenSWI/Datasets/OpenSWI-shallow/0.2-10s-Aug/FlatVelA_disp.npz\")[\"data\"]\n",
249
- "\n",
250
- "vel_models_all.shape,disp_data_all.shape"
251
- ]
252
- },
253
- {
254
- "cell_type": "code",
255
- "execution_count": null,
256
- "metadata": {},
257
- "outputs": [],
258
- "source": []
259
- }
260
- ],
261
- "metadata": {
262
- "kernelspec": {
263
- "display_name": "ADinversion",
264
- "language": "python",
265
- "name": "python3"
266
- },
267
- "language_info": {
268
- "codemirror_mode": {
269
- "name": "ipython",
270
- "version": 3
271
- },
272
- "file_extension": ".py",
273
- "mimetype": "text/x-python",
274
- "name": "python",
275
- "nbconvert_exporter": "python",
276
- "pygments_lexer": "ipython3",
277
- "version": "3.10.0"
278
- }
279
- },
280
- "nbformat": 4,
281
- "nbformat_minor": 2
282
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_2_OpenFWI-FlatFault-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_3_OpenFWI-CurveVel-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_4_OpenFWI-CurveFault-A.ipynb DELETED
@@ -1,310 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "## Imshow 1 of the subsets"
8
- ]
9
- },
10
- {
11
- "cell_type": "code",
12
- "execution_count": null,
13
- "metadata": {},
14
- "outputs": [],
15
- "source": [
16
- "import os\n",
17
- "import numpy as np\n",
18
- "import matplotlib.pyplot as plt\n",
19
- "\n",
20
- "\n",
21
- "data_base_path = \"/home/bingxing2/ailab/group/ai4earth/liufeng/OpenFWI/CurveFault_A/model\"\n",
22
- "\n",
23
- "models_list = os.listdir(data_base_path)\n",
24
- "\n",
25
- "# models_list = sorted(models_list, key=lambda x: int(x.split(\".\")[0].replace(\"model\", \"\")))\n",
26
- "\n",
27
- "models_path_list = []\n",
28
- "for model_name in models_list:\n",
29
- " model_path = os.path.join(data_base_path, model_name)\n",
30
- " models_path_list.append(model_path)\n",
31
- "\n",
32
- "\n",
33
- "vel_model_subsets0 = np.load(models_path_list[0])\n",
34
- "vel_model_subsets0 = vel_model_subsets0.squeeze()\n",
35
- "nrows = 10\n",
36
- "ncols = 10\n",
37
- "fig,axs = plt.subplots(nrows,ncols,figsize=(10,10))\n",
38
- "for i in range(nrows):\n",
39
- " for j in range(ncols):\n",
40
- " axs[i,j].imshow(vel_model_subsets0[i*ncols+j],cmap=\"jet\")\n",
41
- " axs[i,j].set_xticks([])\n",
42
- " axs[i,j].set_yticks([])\n",
43
- "plt.subplots_adjust(wspace=0.05,hspace=0.05)\n",
44
- "# plt.savefig(\"Datasets/JupyterNotebook/Figures/CurveFault_A_2D.png\",bbox_inches='tight',dpi=300)\n",
45
- "plt.show()\n"
46
- ]
47
- },
48
- {
49
- "cell_type": "markdown",
50
- "metadata": {},
51
- "source": [
52
- "## Datasets Preparing"
53
- ]
54
- },
55
- {
56
- "cell_type": "code",
57
- "execution_count": 2,
58
- "metadata": {},
59
- "outputs": [],
60
- "source": [
61
- "import numpy as np\n",
62
- "from DispFormer.dispersion import *\n",
63
- "from p_tqdm import p_map"
64
- ]
65
- },
66
- {
67
- "cell_type": "code",
68
- "execution_count": null,
69
- "metadata": {},
70
- "outputs": [],
71
- "source": [
72
- "vel_model_subset = np.load(models_path_list[0]).squeeze()\n",
73
- "vel_models0 = transform_vp_to_vel_model(vel_model_subset[80,:,20]/1000)\n",
74
- "vel_models1 = transform_vs_to_vel_model(vel_models0[:,2],depth=vel_models0[:,0])\n",
75
- "disp0 = calculate_dispersion(vel_models0)\n",
76
- "disp1 = calculate_dispersion(vel_models1)\n",
77
- "depth = vel_models0[:,0]\n",
78
- "\n",
79
- "plt.figure(figsize=(10,5))\n",
80
- "plt.subplot(121)\n",
81
- "plt.step(vel_models0[:,2],depth)\n",
82
- "plt.step(vel_models1[:,2],depth)\n",
83
- "plt.gca().invert_yaxis()\n",
84
- "\n",
85
- "\n",
86
- "plt.subplot(122)\n",
87
- "plt.scatter(disp0[:,0],disp0[:,1])\n",
88
- "plt.scatter(disp1[:,0],disp1[:,1])\n",
89
- "plt.show()\n",
90
- "\n",
91
- "vel_models0.dtype"
92
- ]
93
- },
94
- {
95
- "cell_type": "code",
96
- "execution_count": null,
97
- "metadata": {},
98
- "outputs": [],
99
- "source": [
100
- "vel_model_subset = np.load(models_path_list[0]).squeeze()\n",
101
- "\n",
102
- "model_idx = 10\n",
103
- "\n",
104
- "plt.figure()\n",
105
- "plt.subplot(121)\n",
106
- "plt.imshow(vel_model_subset[model_idx])\n",
107
- "for i in range(0,70,2):\n",
108
- " plt.axvline(x=i)\n",
109
- "\n",
110
- "plt.subplot(122)\n",
111
- "depth = np.arange(70)*0.04\n",
112
- "for i in range(0,70,2):\n",
113
- " plt.step(vel_model_subset[model_idx,:,i],depth)\n",
114
- "plt.gca().invert_yaxis()\n",
115
- "plt.show()"
116
- ]
117
- },
118
- {
119
- "cell_type": "code",
120
- "execution_count": null,
121
- "metadata": {},
122
- "outputs": [],
123
- "source": [
124
- "save_base_path = \"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/DispFormer-local/Datasets/OpenSWI/Datasets/OpenSWI-shallow/0.2-10s-Aug/\"\n",
125
- "\n",
126
- "# Initialize empty lists to store data\n",
127
- "disp_data_all = []\n",
128
- "vel_models_all = []\n",
129
- "\n",
130
- "try:\n",
131
- " # Process each model file\n",
132
- " for path in models_path_list:\n",
133
- " # Load and preprocess velocity model\n",
134
- " vel_model_subset = np.load(path).squeeze()\n",
135
- " \n",
136
- " # Convert velocity from m/s to km/s and transform to velocity model\n",
137
- " vel_model_subset = np.swapaxes(vel_model_subset, 1, 2)\n",
138
- " vel_model_subset = vel_model_subset.reshape(-1, vel_model_subset.shape[-1])[::7]\n",
139
- " vel_models = p_map(transform_vp_to_vel_model, vel_model_subset/1000)\n",
140
- " vel_models = np.array(vel_models)\n",
141
- " vs_models = list(vel_models[:,:,2])\n",
142
- " vel_models = p_map(transform_vs_to_vel_model,vs_models)\n",
143
- " \n",
144
- " # Calculate dispersion curves\n",
145
- " disp_data = p_map(calculate_dispersion, vel_models)\n",
146
- " disp_data = np.array(disp_data)\n",
147
- " \n",
148
- " # Store results\n",
149
- " disp_data_all.append(disp_data)\n",
150
- " vel_models_all.append(vel_models)\n",
151
- "\n",
152
- " # Convert lists to numpy arrays and reshape\n",
153
- " disp_data_all = np.array(disp_data_all).reshape(-1, *np.array(disp_data_all).shape[2:])\n",
154
- " vel_models_all = np.array(vel_models_all).reshape(-1, *np.array(vel_models_all).shape[2:])\n",
155
- " \n",
156
- " # Filter out zero dispersion curves and corresponding velocity models\n",
157
- " valid_indices = ~np.all(disp_data_all == 0, axis=(1,2))\n",
158
- " disp_data_all = disp_data_all[valid_indices]\n",
159
- " vel_models_all = vel_models_all[valid_indices]\n",
160
- "\n",
161
- " # Create output directory if it doesn't exist\n",
162
- " os.makedirs(save_base_path, exist_ok=True)\n",
163
- " \n",
164
- " # Save processed data as compressed npz files\n",
165
- " np.savez_compressed(os.path.join(save_base_path, \"CurveFaultA_model.npz\"),\n",
166
- " data=vel_models_all.astype(np.float32))\n",
167
- " np.savez_compressed(os.path.join(save_base_path, \"CurveFaultA_disp.npz\"),\n",
168
- " data=disp_data_all.astype(np.float32))\n",
169
- " \n",
170
- "except Exception as e:\n",
171
- " print(f\"An error occurred during processing: {str(e)}\")"
172
- ]
173
- },
174
- {
175
- "cell_type": "markdown",
176
- "metadata": {},
177
- "source": [
178
- "## Datasets Imshow\n"
179
- ]
180
- },
181
- {
182
- "cell_type": "code",
183
- "execution_count": null,
184
- "metadata": {},
185
- "outputs": [],
186
- "source": [
187
- "import numpy as np\n",
188
- "\n",
189
- "vel_models_all = np.load(\"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/DispFormer-local/Datasets/OpenSWI/Datasets/OpenSWI-shallow/0.2-10s-Aug/CurveFaultA_model.npz\")[\"data\"]\n",
190
- "disp_data_all = np.load(\"/home/bingxing2/ailab/scxlab0055/project/04_Inversion/SurfWaveInv/DispFormer-local/Datasets/OpenSWI/Datasets/OpenSWI-shallow/0.2-10s-Aug/CurveFaultA_disp.npz\")[\"data\"]\n",
191
- "\n",
192
- "vel_models_all.shape,disp_data_all.shape"
193
- ]
194
- },
195
- {
196
- "cell_type": "code",
197
- "execution_count": null,
198
- "metadata": {},
199
- "outputs": [],
200
- "source": [
201
- "import matplotlib.pyplot as plt\n",
202
- "def plot_vel_disp(vel_model, disp_data):\n",
203
- " \"\"\"Plot velocity model and dispersion curves\n",
204
- " \n",
205
- " Args:\n",
206
- " vel_model: numpy array with columns [thickness, vp, vs, density]\n",
207
- " disp_data: numpy array with columns [period, phase_vel, group_vel]\n",
208
- " \"\"\"\n",
209
- " fig, axs = plt.subplots(1,2,figsize=(10,6))\n",
210
- " \n",
211
- " depth = vel_model[:,0]\n",
212
- " \n",
213
- " # Left subplot - Velocity model\n",
214
- " axs[0].step(vel_model[:,1], depth, label='P-wave velocity (km/s)', linewidth=2)\n",
215
- " axs[0].step(vel_model[:,2], depth, label='S-wave velocity (km/s)', linewidth=2) \n",
216
- " axs[0].step(vel_model[:,3], depth, label='Density (g/cm³)', linewidth=2)\n",
217
- " axs[0].invert_yaxis()\n",
218
- " axs[0].set_xlabel('Velocity (km/s) / Density (g/cm³)')\n",
219
- " axs[0].set_ylabel('Depth (m)')\n",
220
- " axs[0].set_title('Velocity Model')\n",
221
- " axs[0].grid(True, linestyle='--', alpha=0.7)\n",
222
- " axs[0].legend()\n",
223
- "\n",
224
- " # Right subplot - Dispersion curves\n",
225
- " axs[1].scatter(disp_data[:,0], disp_data[:,1], label='Phase velocity', s=50)\n",
226
- " axs[1].scatter(disp_data[:,0], disp_data[:,2], label='Group velocity', s=50)\n",
227
- " axs[1].set_xlabel('Period (s)')\n",
228
- " axs[1].set_ylabel('Velocity (km/s)')\n",
229
- " axs[1].set_title('Dispersion Curves')\n",
230
- " axs[1].grid(True, linestyle='--', alpha=0.7)\n",
231
- " axs[1].legend()\n",
232
- "\n",
233
- " plt.tight_layout()\n",
234
- " plt.show()\n",
235
- " \n",
236
- "# Test the function\n",
237
- "idx = 120001\n",
238
- "plot_vel_disp(vel_models_all[idx], disp_data_all[idx])"
239
- ]
240
- },
241
- {
242
- "cell_type": "code",
243
- "execution_count": null,
244
- "metadata": {},
245
- "outputs": [],
246
- "source": [
247
- "# Create subplots for Vp, Vs and density\n",
248
- "fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12,5))\n",
249
- "\n",
250
- "# Get depth array from first model\n",
251
- "depth = vel_models_all[0,:,0]\n",
252
- "\n",
253
- "# Plot Vp models with alpha blending\n",
254
- "ax1.step(vel_models_all[::100,:,1].T, depth, color='r', alpha=0.01)\n",
255
- "ax1.set_title('P-wave Velocity Models')\n",
256
- "ax1.set_xlabel('Velocity (km/s)')\n",
257
- "ax1.set_ylabel('Depth (m)')\n",
258
- "ax1.invert_yaxis()\n",
259
- "ax1.grid(True)\n",
260
- "\n",
261
- "# Plot Vs models\n",
262
- "ax2.step(vel_models_all[::100,:,2].T, depth, color='b', alpha=0.01)\n",
263
- "ax2.set_title('S-wave Velocity Models')\n",
264
- "ax2.set_xlabel('Velocity (km/s)')\n",
265
- "ax2.set_ylabel('Depth (m)')\n",
266
- "ax2.invert_yaxis()\n",
267
- "ax2.grid(True)\n",
268
- "\n",
269
- "# Plot density models\n",
270
- "ax3.step(vel_models_all[::100,:,3].T, depth, color='gray', alpha=0.01)\n",
271
- "ax3.set_title('Density Models')\n",
272
- "ax3.set_xlabel('Density (g/cm³)')\n",
273
- "ax3.set_ylabel('Depth (m)')\n",
274
- "ax3.invert_yaxis()\n",
275
- "ax3.grid(True)\n",
276
- "\n",
277
- "plt.tight_layout()\n",
278
- "plt.show()"
279
- ]
280
- },
281
- {
282
- "cell_type": "code",
283
- "execution_count": null,
284
- "metadata": {},
285
- "outputs": [],
286
- "source": []
287
- }
288
- ],
289
- "metadata": {
290
- "kernelspec": {
291
- "display_name": "ADinversion",
292
- "language": "python",
293
- "name": "python3"
294
- },
295
- "language_info": {
296
- "codemirror_mode": {
297
- "name": "ipython",
298
- "version": 3
299
- },
300
- "file_extension": ".py",
301
- "mimetype": "text/x-python",
302
- "name": "python",
303
- "nbconvert_exporter": "python",
304
- "pygments_lexer": "ipython3",
305
- "version": "3.10.0"
306
- }
307
- },
308
- "nbformat": 4,
309
- "nbformat_minor": 2
310
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/01_5_OpenFWI-Stylel-A.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
Datasets-Construction/OpenSWI-shallow/Backup/0.5-5s/02_1_OpenFWI-FlatVel-B.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
SWIDP/__pycache__/__init__.cpython-310.pyc DELETED
Binary file (218 Bytes)
 
SWIDP/__pycache__/diffusion_aug_2d.cpython-310.pyc DELETED
Binary file (7.41 kB)
 
SWIDP/__pycache__/dispersion.cpython-310.pyc DELETED
Binary file (10.3 kB)
 
SWIDP/__pycache__/process_1d_deep.cpython-310.pyc DELETED
Binary file (10 kB)
 
SWIDP/__pycache__/process_1d_shallow.cpython-310.pyc DELETED
Binary file (6.31 kB)
 
SWIDP/__pycache__/velocity_aug_1d.cpython-310.pyc DELETED
Binary file (8.5 kB)
 
SWIDP/__pycache__/velocity_aug_1d_deep.cpython-310.pyc DELETED
Binary file (6.02 kB)