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 pathlib
import salvus.namespace as sn
from salvus.mesh import layered_meshing as lm
from salvus.mesh.unstructured_mesh_utils import read_model_from_h5
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.domain_2d = sn.domain.dim2.BoxDomain(x0=0, x1=1, y0=0, y1=1)
material = lm.material.elastic.Velocity.from_params(
rho=1.0, vp=1.0, vs=np.sqrt(1 / 3)
)
mesh_2d = lm.mesh_from_domain(
domain=domain_2d,
model=material,
mesh_resolution=sn.MeshResolution(
reference_frequency=10.0, elements_per_wavelength=2.0
),
)
mesh_2d
<salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x7f7aaf584e50>
p_2d = sn.Project.from_domain(
path="project_2d", domain=domain_2d, load_if_exists=True
)
src_2d = sn.simple_config.source.cartesian.VectorPoint2D(
x=0.5,
y=1.0,
fx=0.0,
fy=-1.0,
)
p_2d.add_to_project(sn.Event(event_name="event", sources=[src_2d]))
p_2d.add_to_project(
sn.UnstructuredMeshSimulationConfiguration(
name="sim_2d",
unstructured_mesh=mesh_2d,
event_configuration=sn.EventConfiguration(
wavelet=sn.simple_config.stf.Ricker(center_frequency=2.5),
waveform_simulation_configuration=sn.WaveformSimulationConfiguration(
end_time_in_seconds=2.0
),
),
),
)
p_2d.viz.nb.simulation_setup("sim_2d", events=["event"])