numpy
or xarray
. To remedy this, Salvus contains a lightweight
WavefieldOutput
class that enables the simple extraction of stored
quantities to regular grids. Let's dive in and take a look.import os
import numpy as np
import salvus.namespace as sn
from salvus.mesh import layered_meshing as lm
from salvus.toolbox.helpers import wavefield_output
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
layered_meshing
API. The use of this API, however, is not
required to use the functionality presented herein, and any volumetric
simulation output from a Salvus simulation will suffice.material = lm.material.elastic.Velocity.from_params(
rho=1.0, vp=1.0, vs=np.sqrt(1 / 3)
)
mesh_2d = lm.mesh_from_domain(
sn.domain.dim2.BoxDomain(x0=0, x1=1, y0=0, y1=1),
material,
sn.MeshResolution(reference_frequency=10.0, elements_per_wavelength=2.0),
)
mesh_2d
<salvus.mesh.unstructured_mesh.UnstructuredMesh at 0x7fd60af85e10>
stf = sn.simple_config.stf.Ricker(center_frequency=2.5)
src_2d = sn.simple_config.source.cartesian.VectorPoint2D(
x=0.5, y=1.0, fx=0.0, fy=-1.0, source_time_function=stf
)
w_2d = sn.simple_config.simulation.Waveform(
mesh=mesh_2d, sources=src_2d, end_time_in_seconds=2.0
)
w_2d