fdtdx.plot_field_slice

fdtdx.plot_field_slice#

fdtdx.plot_field_slice(E, H, filename=None, axs=None, plot_legend=True)[source]#

Creates a visualization of electromagnetic field components.

Generates a 2x3 subplot showing all six components of the electromagnetic field (Ex, Ey, Ez, Hx, Hy, Hz) in a single figure.

Parameters:
  • E (jnp.ndarray) – Electric field array of shape (3, nx, ny, nz) or (3, w, h)

  • H (jnp.ndarray) – Magnetic field array of shape (3, nx, ny, nz) or (3, w, h)

  • filename (str | Path | None, optional) – If provided, saves the plot to this file

  • axs (Any | None, optional) – Optional matplotlib axes to plot on. If None, creates new figure

  • plot_legend (bool, optional) – Whether to add colorbar legends

Returns:

The generated figure object

Return type:

Figure

Raises:

ValueError – If arrays have incorrect shapes or contain invalid values

Note

For 4D inputs (3, nx, ny, nz), exactly one of nx, ny, nz must be 1. The function will automatically squeeze out the singleton dimension.