One way of visualizing your 3D volume data in a 2D plot is with a slice. Use interpolate_to_points to interpolate your volume data to any set of coordinates:
from spectre.IO.Exporter import interpolate_to_points
# Coordinates of a regular grid in the xy plane
x, y = np.meshgrid(np.linspace(-15, 15, 300), np.linspace(-15, 15, 300))
z = np.zeros(x.shape)
# Interpolation can be slow, so it's useful to cache the result. Remember to
/var/folders/xp/5t2ny359187c4ljckf8sz3m80000gn/T/ipykernel_19858/3375439396.py:2: RuntimeWarning: invalid value encountered in subtract
plt.contourf(x, y, np.log(1 - lapse))
png
Plot individual elements
You can also iterate over elements in your volume data to plot things like element boundaries, collocation points, etc. Use iter_elements:
from spectre.IO.H5.IterElements import iter_elements
# Create a 3D plot
ax = plt.gcf().add_subplot(111, projection="3d")
ax.axis("off")
# Iterate over elements
for element in iter_elements(
open_volfiles(h5files, subfile_name),
obs_ids=obs_ids[0],
element_patterns=["B3,*"], # Only plot elements in block 3
):
# Draw outline of the element by mapping the edges of the logical cube to