tidy3d.ModeSimulationData#
- class ModeSimulationData[source]#
Bases:
AbstractYeeGridSimulationDataData associated with a mode solver simulation.
- Parameters:
simulation (
ModeSimulation) – Mode simulation associated with this data.data (tuple[Union[
PermittivityData,MediumData], …] = ()) – List of monitor data associated with the monitors of the originalModeSimulation.log (Optional[str] = None) – A string containing the log information from the simulation run.
modes_raw (Union[
ModeSolverData,MicrowaveModeSolverData]) – Union[ModeSolverData,MicrowaveModeSolverData] containing the field and effective index on unexpanded grid.
Attributes
ModeSolverDatacontaining the field and effective index data.logMethods
plot_field(field_name[, val, scale, ...])Plot the field for a
ModeSolverDatawithSimulationplot overlaid.plot_field_components(field_names[, ...])Plot multiple field components for one or more modes in a single call.
sort_modes(sort_spec)Sort modes per frequency according to
sort_spec.- simulation#
- modes_raw#
- data#
- property modes#
ModeSolverDatacontaining the field and effective index data.
- plot_field(field_name, val='real', scale='lin', eps_alpha=0.2, robust=True, vmin=None, vmax=None, ax=None, cmap=None, **sel_kwargs)[source]#
Plot the field for a
ModeSolverDatawithSimulationplot overlaid.- Parameters:
field_name (str) – Name of
fieldcomponent to plot (eg.'Ex'). Also accepts'E'and'H'to plot the vector magnitudes of the electric and magnetic fields, and'S'for the Poynting vector.val (Literal['real', 'imag', 'abs', 'abs^2', 'dB'] = 'real') – Which part of the field to plot.
eps_alpha (float = 0.2) – Opacity of the structure permittivity. Must be between 0 and 1 (inclusive).
robust (bool = True) – If True and vmin or vmax are absent, uses the 2nd and 98th percentiles of the data to compute the color limits. This helps in visualizing the field patterns especially in the presence of a source.
vmin (float = None) – The lower bound of data range that the colormap covers. If
None, they are inferred from the data and other keyword arguments.vmax (float = None) – The upper bound of data range that the colormap covers. If
None, they are inferred from the data and other keyword arguments.ax (matplotlib.axes._subplots.Axes = None) – matplotlib axes to plot on, if not specified, one is created.
cmap (Optional[Union[str, Colormap]] = None) – Colormap for visualizing the field values.
Noneuses the default which infers it from the data.sel_kwargs (keyword arguments used to perform
.sel()selection in the monitor data.) – These kwargs can select over the spatial dimensions (x,y,z), frequency or time dimensions (f,t) or mode_index, if applicable. For the plotting to work appropriately, the resulting data after selection must contain only two coordinates with len > 1. Furthermore, these should be spatial coordinates (x,y, orz).
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes
- plot_field_components(field_names, mode_indices=None, val='real', scale='lin', eps_alpha=0.2, robust=True, vmin=None, vmax=None, ax=None, cmap=None, figsize=None, titles=True, show_n_eff=False, **sel_kwargs)[source]#
Plot multiple field components for one or more modes in a single call.
- Parameters:
field_names (Union[str, tuple[str, ...]]) – Field components to plot as columns.
mode_indices (Optional[Union[int, tuple[int, ...]]] = None) – Mode indices to plot as rows. If
None, all modes are plotted.val (Literal['real', 'imag', 'abs', 'abs^2', 'dB'] = 'real') – Which part of the field to plot.
scale (Literal['lin', 'dB']) – Plot in linear or logarithmic (dB) scale.
eps_alpha (float = 0.2) – Opacity of the structure permittivity. Must be between 0 and 1 (inclusive).
robust (bool = True) – If True and vmin or vmax are absent, uses the 2nd and 98th percentiles of the data to compute the color limits.
vmin (float = None) – The lower bound of data range that the colormap covers.
vmax (float = None) – The upper bound of data range that the colormap covers.
ax (Any = None) – Optional axes grid to plot on. Must broadcast to shape
(len(mode_indices), len(field_names)).cmap (Optional[Union[str, Colormap]] = None) – Colormap for visualizing the field values. A colorbar is shown for each subplot.
figsize (Optional[tuple[float, float]] = None) – Figure size used when creating a new axes grid.
titles (bool = True) – Whether to label each subplot with the field name and mode index.
show_n_eff (bool = False) – Whether to append the effective index to subplot titles.
sel_kwargs (keyword arguments used to perform
.sel()selection in the monitor data.) – These kwargs can select over the spatial dimensions (x,y,z) and frequency dimension (f), but notmode_indexwhich is controlled bymode_indicesin this method.
- Returns:
The figure and a 2D array of matplotlib axes.
- Return type:
tuple[matplotlib.figure.Figure, np.ndarray]