tidy3d.components.data.sim_data.AbstractYeeGridSimulationData#
- class AbstractYeeGridSimulationData[source]#
Bases:
AbstractSimulationData,ABCData from an
AbstractYeeGridSimulationinvolving electromagnetic fields on a Yee grid.- Parameters:
simulation (
AbstractSimulation) – OriginalAbstractSimulationassociated with the data.data (tuple[
AbstractMonitorData, …]) – List ofAbstractMonitorDatainstances associated with the monitors of the originalAbstractSimulation.log (Optional[str] = None) – A string containing the log information from the simulation run.
Notes
The
SimulationDataobjects store a copy of the originalSimulation:, so it can be recovered if theSimulationDatais loaded in a new session and theSimulationis no longer in memory.More importantly, the
SimulationDatacontains a reference to the data for each of the monitors within the originalSimulation. This data can be accessed directly using the name given to the monitors initially.Attributes
simulationdatalogMethods
apply_phase(data[, phase])Apply a phase to xarray data.
at_boundaries(field_monitor_name)Return xarray.Dataset representation of field monitor data colocated at Yee cell boundaries.
at_centers(field_monitor_name)Return xarray.Dataset representation of field monitor data colocated at Yee cell centers.
get_intensity(field_monitor_name)return xarray.DataArray of the intensity of a field monitor at Yee cell centers.
get_poynting_vector(field_monitor_name)return
xarray.Datasetof the Poynting vector at Yee cell centers.load_field_monitor(monitor_name)Load monitor and raise exception if not a field monitor.
mnt_data_from_file(fname, mnt_name, ...)Loads data for a specific monitor from a .hdf5 file with data for a
SimulationData.plot_field(field_monitor_name, field_name[, ...])Plot the field data for a monitor with simulation plot overlaid.
plot_field_monitor_data(field_monitor_data, ...)Plot the field data for a monitor with simulation plot overlaid.
plot_scalar_array(field_data, axis, position)Plot the field data for a monitor with simulation plot overlaid.
- at_centers(field_monitor_name)[source]#
Return xarray.Dataset representation of field monitor data colocated at Yee cell centers.
- Parameters:
field_monitor_name (str) – Name of field monitor used in the original
Simulation.- Returns:
Dataset containing all of the fields in the data interpolated to center locations on the Yee grid.
- Return type:
- at_boundaries(field_monitor_name)[source]#
Return xarray.Dataset representation of field monitor data colocated at Yee cell boundaries.
- Parameters:
field_monitor_name (str) – Name of field monitor used in the original
Simulation.- Returns:
Dataset containing all of the fields in the data interpolated to boundary locations on the Yee grid.
- Return type:
- get_poynting_vector(field_monitor_name)[source]#
return
xarray.Datasetof the Poynting vector at Yee cell centers.Calculated values represent the instantaneous Poynting vector for time-domain fields and the complex vector for frequency-domain:
S = 1/2 E × conj(H).Only the available components are returned, e.g., if the indicated monitor doesn’t include field component “Ex”, then “Sy” and “Sz” will not be calculated.
- Parameters:
field_monitor_name (str) – Name of field monitor used in the original
Simulation.- Returns:
DataArray containing the Poynting vector calculated based on the field components colocated at the center locations of the Yee grid.
- Return type:
- get_intensity(field_monitor_name)[source]#
return xarray.DataArray of the intensity of a field monitor at Yee cell centers.
- Parameters:
field_monitor_name (str) – Name of field monitor used in the original
Simulation.- Returns:
DataArray containing the electric intensity of the field-like monitor. Data is interpolated to the center locations on Yee grid.
- Return type:
- classmethod mnt_data_from_file(fname, mnt_name, **model_validate_kwargs)[source]#
Loads data for a specific monitor from a .hdf5 file with data for a
SimulationData.- Parameters:
fname (PathLike) – Full path to an hdf5 file containing
SimulationDatadata.mnt_name (str, optional) –
.nameof the monitor to load the data from.**model_validate_kwargs – Keyword arguments passed to pydantic’s
model_validatemethod when loading model.
- Returns:
Monitor data corresponding to the
mnt_nametype.- Return type:
Example
>>> field_data = your_simulation_data.from_file(fname='folder/data.hdf5', mnt_name="field")
- plot_field_monitor_data(field_monitor_data, field_name, val='real', scale='lin', eps_alpha=0.2, phase=0.0, robust=True, vmin=None, vmax=None, ax=None, shading='flat', cmap=None, **sel_kwargs)[source]#
Plot the field data for a monitor with simulation plot overlaid.
- Parameters:
field_monitor_data (AbstractFieldData) – Field monitor data to plot.
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', 'phase'] = '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).
phase (float = 0.0) – Optional phase (radians) to apply to the fields. Only has an effect on frequency-domain fields.
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.
shading (str = 'flat') – Shading argument for Xarray plot method (‘flat’,’nearest’,’goraud’)
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) ormode_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(field_monitor_name, field_name, val='real', scale='lin', eps_alpha=0.2, phase=0.0, robust=True, vmin=None, vmax=None, ax=None, shading='flat', cmap=None, **sel_kwargs)[source]#
Plot the field data for a monitor with simulation plot overlaid.
- Parameters:
field_monitor_name (str) – Name of
FieldMonitor,FieldTimeData, orModeSolverDatato plot.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', 'phase'] = '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).
phase (float = 0.0) – Optional phase (radians) to apply to the fields. Only has an effect on frequency-domain fields.
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.
shading (str = 'flat') – Shading argument for Xarray plot method (‘flat’,’nearest’,’goraud’)
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) ormode_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_scalar_array(field_data, axis, position, freq=None, eps_alpha=0.2, robust=True, vmin=None, vmax=None, cmap_type='divergent', cmap=None, ax=None, **kwargs)[source]#
Plot the field data for a monitor with simulation plot overlaid.
- Parameters:
field_data (xr.DataArray) – DataArray with the field data to plot. Must be a scalar field.
axis (Axis) – Axis normal to the plotting plane.
position (float) – Position along the axis.
freq (float = None) – Frequency at which the permittivity is evaluated at (if dispersive). By default, chooses permittivity as frequency goes to infinity.
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.
cmap_type (Literal["divergent", "sequential", "cyclic"] = "divergent") – Type of color map to use for plotting.
cmap (Optional[Union[str, Colormap]] = None) – Colormap for visualizing the field values.
Noneuses the default which infers it from the data. Overrides inferred colormap from cmap_type.ax (matplotlib.axes._subplots.Axes = None) – matplotlib axes to plot on, if not specified, one is created.
**kwargs (Extra arguments to
DataArray.plot.)
- Returns:
The supplied or created matplotlib axes.
- Return type:
matplotlib.axes._subplots.Axes