Skip to content

Commit

Permalink
fix plot_model
Browse files Browse the repository at this point in the history
  • Loading branch information
xumi1993 committed Jul 14, 2024
1 parent 14a57a4 commit dc9c89b
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions examples/03_checkerboard_2d/plot_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"def to_ani(xi, eta):\n",
" epsilon = np.sqrt(eta**2+xi**2)\n",
" phi = np.zeros_like(epsilon)\n",
" idx = np.where(xi <= 0)\n",
" phi[idx] = 90 + 0.5*np.rad2deg(np.arctan(eta[idx]/xi[idx]))\n",
" idx = np.where((xi > 0) & (eta <= 0))\n",
" phi[idx] = 180 + 0.5*np.rad2deg(np.arctan(eta[idx]/xi[idx]))\n",
" idx = np.where((xi > 0) & (eta > 0))\n",
" phi[idx] = 0.5*np.rad2deg(np.arctan(eta[idx]/xi[idx]))\n",
" return epsilon, phi\n"
]
},
{
"cell_type": "code",
"execution_count": 35,
Expand All @@ -40,11 +22,6 @@
" x = f['x'][:]\n",
" y = f['y'][:]\n",
" periods = f['periods_ph'][:]\n",
" xi = f['xi_ph'][:]\n",
" eta = f['eta_ph'][:]\n",
" epsilon, phi = to_ani(xi, eta)\n",
"with h5py.File('OUTPUT_FILES/model_iter.h5', 'r') as f:\n",
" svel0 = f['vel_rayleigh_000'][:]\n",
"xx, yy = np.meshgrid(x, y)\n"
]
},
Expand Down Expand Up @@ -73,7 +50,7 @@
"region=[x.min(), x.max(), y.min(), y.max()]\n",
"fig = pygmt.Figure()\n",
"fig.basemap(region=region, projection='M4i', frame=True)\n",
"grid = pygmt.surface(z=eta[:,:,num_period].ravel(), x=xx.ravel(),y=yy.ravel(), region=region, spacing='0.01/0.01')\n",
"grid = pygmt.surface(z=svel[:,:,num_period].ravel(), x=xx.ravel(),y=yy.ravel(), region=region, spacing='0.01/0.01')\n",
"fig.grdimage(grid=grid, cmap='seis')\n",
"fig.show()"
]
Expand Down

0 comments on commit dc9c89b

Please sign in to comment.