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

Issue 411 -- Follow-up example/cookbook fixes #445

Merged
merged 14 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions docs/api/mesh/boundaries/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ Boundaries

.. doxygenstruct:: specfem::mesh::boundaries
:members:

.. toctree::
:maxdepth: 1

absorbing_boundaries
acoustic_free_surface
10 changes: 10 additions & 0 deletions docs/api/mesh/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ SPECFEM++ Mesh

.. doxygenstruct:: specfem::mesh::mesh
:members:


.. toctree::
:maxdepth: 1

boundaries/index
control_nodes/index
coupled_interfaces/index
materials/index
tags/index
2 changes: 1 addition & 1 deletion docs/cookbooks/dim2/anisotropic-crystal/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Wave propagration through anistoropic zinc crystal
Wave propagration through anisotropic zinc crystal
==================================================

In this `example
Expand Down
20 changes: 7 additions & 13 deletions docs/cookbooks/dim2/anisotropic-crystal/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import os
import numpy as np
import obspy
import matplotlib

matplotlib.use("agg")


def get_traces(directory):
Expand All @@ -16,19 +13,15 @@ def get_traces(directory):
"S0040",
"S0050",
]
files = [
glob.glob(directory + f"/{stationname}*.sem*")[0]
for stationname in station_name
]
files = []
for station in station_name:
files += glob.glob(directory + f"/??.{station}.S2.BX?.semd")

## iterate over all seismograms
for filename in files:
station_id = os.path.splitext(filename)[0]
station_id = station_id.split("/")[-1]
network = station_id[5:7]
station = station_id[0:5]
location = "00"
component = station_id[7:10]
network, station, location, channel = station_id.split(".")[:4]
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
Expand All @@ -39,7 +32,7 @@ def get_traces(directory):
"network": network,
"station": station,
"location": location,
"channel": component,
"channel": channel,
"starttime": starttime,
"delta": dt,
},
Expand All @@ -52,4 +45,5 @@ def get_traces(directory):


stream = get_traces("OUTPUT_FILES/results")
stream.plot(size=(800, 1000))
stream.select(component="X").plot(size=(1000, 750))
stream.select(component="Z").plot(size=(1000, 750))
28 changes: 28 additions & 0 deletions docs/cookbooks/dim2/fluid-solid-interface/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,31 @@ With the configuration file in place, we can run the solver using the following
.. code:: bash
specfem2d -p specfem_config.yaml
Visualizing the results
-----------------------

The simulation generates seismograms at the stations defined in the
``specfem_config.yaml`` file. You can visualize the seismograms using the
following python script.

.. literalinclude:: plot.py
:language: python
:caption: plot.py


.. figure:: seismograms_X.svg
:alt: X-component seismograms
:width: 800
:align: center

X-component seismograms


.. figure:: seismograms_Z.svg
:alt: Z-component seismograms
:width: 800
:align: center

Z-component seismograms
42 changes: 42 additions & 0 deletions docs/cookbooks/dim2/fluid-solid-interface/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import glob
import os
import numpy as np
import obspy


def get_traces(directory):
traces = []

files = glob.glob(directory + "/AA.S00??.S2.BX?.semd")
files.sort()

## iterate over all seismograms
for filename in files:
station_id = os.path.splitext(filename)[0]
station_id = station_id.split("/")[-1]
network, station, location, channel = station_id.split(".")[:4]
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
traces.append(
obspy.Trace(
trace[:, 1],
{
"network": network,
"station": station,
"location": location,
"channel": channel,
"starttime": starttime,
"delta": dt,
},
)
)

stream = obspy.Stream(traces)

return stream


stream = get_traces("OUTPUT_FILES/seismograms")
stream.select(component="X").plot(size=(1000, 750))
stream.select(component="Z").plot(size=(1000, 750))
Loading