Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: added 2D and 3D infrasound examples based off of real topography #12

Merged
merged 12 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Examples: added a top-down plotting option for the infrasound example
  • Loading branch information
EdCaunt committed Dec 2, 2022
commit 5a1ebc57da6fd0b13e0f08db0f30a8bdd1219ab5
10 changes: 6 additions & 4 deletions examples/infrasound/3d_infrasound_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from model import InfrasoundModel
from propagator import InfrasoundPropagator
from plotting import plot_st_helens
from plotting import plot_st_helens, plot_top_down

src_coords = np.array([4800., 4800., 2250.])[np.newaxis, :]
rec_coords = np.array([[4800., 1400., 1400.],
Expand All @@ -21,8 +21,8 @@
[2400., 7200., 1550.],
[7200., 7200., 1500.]])

# Original time is 13s
t0, tn, dt = 0., 14., 0.021 # Courant number ~0.25
# Original time is 14s
t0, tn, dt = 0., 3., 0.021 # Courant number ~0.25
src_f = 1.

sdf_data = -np.load('surface_files/mt_st_helens_3d.npy')
Expand All @@ -34,7 +34,7 @@
plt.show()
model = InfrasoundModel(dims=3, shape=(321, 321, 171),
extent=(9600., 9600., 5100.),
space_order=2,
space_order=4,
src_coords=src_coords, rec_coords=rec_coords,
t0=t0, tn=tn, dt=dt, src_f=src_f, sdf_data=sdf_data,
boundary=True)
Expand Down Expand Up @@ -96,3 +96,5 @@

plot_st_helens(model.zsc.data[-1], src_coords, rec_coords,
np.array([-4800., -4800., 0.]), (30, 30, 30))

plot_top_down(model.zsc.data[-1], -4800., 4800., -4800., 4800.)
32 changes: 11 additions & 21 deletions examples/infrasound/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pyvista as pv
import numpy as np
import matplotlib.pyplot as plt


def plot_st_helens(data, src_loc, rec_loc, origin, spacing):
Expand All @@ -28,8 +29,8 @@ def plot_st_helens(data, src_loc, rec_loc, origin, spacing):
surface = pv.read("surface_files/mt_st_helens.ply")

plotter = pv.Plotter()
plotter.add_mesh(slicex, opacity=0.95)
plotter.add_mesh(slicey, opacity=0.95)
plotter.add_mesh(slicex, opacity=1.)
plotter.add_mesh(slicey, opacity=1.)
plotter.add_mesh(surface)

for src in src_loc:
Expand All @@ -45,23 +46,12 @@ def plot_st_helens(data, src_loc, rec_loc, origin, spacing):
plotter.show()


def main():
data = np.random.rand(321, 321, 171)
def plot_top_down(data, xmin, xmax, ymin, ymax):
"""Plot a top-down view of the dataset"""
extent = (xmin, xmax, ymin, ymax)
dmax = np.amax(data, axis=-1)

origin = np.array([-4800., -4800., 0.])
src_loc = np.array([4800., 4800., 2250.])[np.newaxis, :]
rec_loc = np.array([[4800., 1400., 1400.],
[8200., 4800., 1500.],
[1400., 4800., 1500.],
[4800., 8200., 1650.],
[2400., 2400., 1400.],
[7200., 2400., 1500.],
[2400., 7200., 1550.],
[7200., 7200., 1500.]])

spacing = (30, 30, 30)
plot_st_helens(data, src_loc, rec_loc, origin, spacing)


if __name__ == "__main__":
main()
plt.imshow(dmax.T, extent=extent, origin='lower')
plt.xlabel("E-W (km)")
plt.ylabel("N-S (km)")
plt.show()