Skip to content

Commit

Permalink
import numpy as np like a normal person
Browse files Browse the repository at this point in the history
  • Loading branch information
keurfonluu committed Feb 17, 2022
1 parent 493f911 commit 1910c58
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/sample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy
import numpy as np
import pyvista

from fteikpy import Eikonal2D, grid_to_meshio
Expand All @@ -9,14 +9,14 @@
def ray2line(ray):
"""Convert a ray array to PolyData."""
nr = len(ray)
points = numpy.column_stack((ray[:, 1], numpy.zeros(nr), -ray[:, 0]))
lines = numpy.column_stack((numpy.full(nr - 1, 2), numpy.arange(nr - 1), numpy.arange(1, nr)))
points = np.column_stack((ray[:, 1], np.zeros(nr), -ray[:, 0]))
lines = np.column_stack((np.full(nr - 1, 2), np.arange(nr - 1), np.arange(1, nr)))

return pyvista.PolyData(points, lines=lines)


# Import Marmousi velocity model
vel = numpy.load("marmousi.npy")
vel = np.load("marmousi.npy")

# Calculate traveltime grid for one source point
eik = Eikonal2D(vel * 1.0e-3, gridsize=(0.01, 0.01))
Expand All @@ -26,8 +26,8 @@ def ray2line(ray):

# Trace rays for 100 locations
nrays = 100
end_points = numpy.zeros((nrays, 2))
end_points[:, 1] = numpy.linspace(4.4, eik.xaxis[-1], nrays)
end_points = np.zeros((nrays, 2))
end_points[:, 1] = np.linspace(4.4, eik.xaxis[-1], nrays)
rays = tt.raytrace(end_points)
trays = [tt(ray) for ray in rays]

Expand Down Expand Up @@ -96,8 +96,8 @@ def ray2line(ray):

# Update isochrones and rays
nframes = 48
nisos = numpy.linspace(1, 100, nframes)
times = numpy.linspace(0.0, ttgrid.max(), nframes)
nisos = np.linspace(1, 100, nframes)
times = np.linspace(0.0, ttgrid.max(), nframes)

p.open_movie("sample.mp4", framerate=12)
for n, t in zip(nisos, times):
Expand Down

0 comments on commit 1910c58

Please sign in to comment.