tidy3d.FieldData#

class FieldData[source]#

Bases: FieldDataset, ElectromagneticFieldData

Data associated with a FieldMonitor: scalar components of E and H fields.

Parameters:
  • attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • Ex (Optional[ScalarFieldDataArray] = None) – Spatial distribution of the x-component of the electric field.

  • Ey (Optional[ScalarFieldDataArray] = None) – Spatial distribution of the y-component of the electric field.

  • Ez (Optional[ScalarFieldDataArray] = None) – Spatial distribution of the z-component of the electric field.

  • Hx (Optional[ScalarFieldDataArray] = None) – Spatial distribution of the x-component of the magnetic field.

  • Hy (Optional[ScalarFieldDataArray] = None) – Spatial distribution of the y-component of the magnetic field.

  • Hz (Optional[ScalarFieldDataArray] = None) – Spatial distribution of the z-component of the magnetic field.

  • monitor (FieldMonitor) – Frequency-domain field monitor associated with the data.

  • symmetry (Tuple[Literal[0, -1, 1], Literal[0, -1, 1], Literal[0, -1, 1]] = (0, 0, 0)) – Symmetry eigenvalues of the original simulation in x, y, and z.

  • symmetry_center (Optional[Tuple[float, float, float]] = None) – Center of the symmetry planes of the original simulation in x, y, and z. Required only if any of the symmetry field are non-zero.

  • grid_expanded (Optional[Grid] = None) – Grid discretization of the associated monitor in the simulation which created the data. Required if symmetries are present, as well as in order to use some functionalities like getting Poynting vector and flux.

  • grid_primal_correction (Union[float, FreqDataArray, TimeDataArray, FreqModeDataArray, EMEFreqModeDataArray] = 1.0) – Correction factor that needs to be applied for data corresponding to a 2D monitor to take into account the finite grid in the normal direction in the simulation in which the data was computed. The factor is applied to fields defined on the primal grid locations along the normal direction.

  • grid_dual_correction (Union[float, FreqDataArray, TimeDataArray, FreqModeDataArray, EMEFreqModeDataArray] = 1.0) – Correction factor that needs to be applied for data corresponding to a 2D monitor to take into account the finite grid in the normal direction in the simulation in which the data was computed. The factor is applied to fields defined on the dual grid locations along the normal direction.

Notes

The data is stored as a DataArray object using the xarray package.

This dataset can contain all electric and magnetic field components: Ex, Ey, Ez, Hx, Hy, and Hz.

Example

>>> from tidy3d import ScalarFieldDataArray
>>> x = [-1,1,3]
>>> y = [-2,0,2,4]
>>> z = [-3,-1,1,3,5]
>>> f = [2e14, 3e14]
>>> coords = dict(x=x[:-1], y=y[:-1], z=z[:-1], f=f)
>>> grid = Grid(boundaries=Coords(x=x, y=y, z=z))
>>> scalar_field = ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)
>>> monitor = FieldMonitor(
...     size=(2,4,6), freqs=[2e14, 3e14], name='field', fields=['Ex', 'Hz'], colocate=True
... )
>>> data = FieldData(monitor=monitor, Ex=scalar_field, Hz=scalar_field, grid_expanded=grid)

Attributes

Methods

make_adjoint_sources(dataset_names)

Converts a FieldData to a list of adjoint current or point sources.

normalize(source_spectrum_fn)

Return copy of self after normalization is applied using source spectrum function.

to_adjoint_field_sources()

Create adjoint custom field sources if this field data has some dimensionality.

to_adjoint_point_sources()

Create adjoint point dipole source if this field data contains one item.

to_source(source_time,Β center[,Β size])

Create a CustomFieldSource from the fields stored in the FieldData.

Inherited Common Usage

monitor#
normalize(source_spectrum_fn)[source]#

Return copy of self after normalization is applied using source spectrum function.

to_source(source_time, center, size=None, **kwargs)[source]#

Create a CustomFieldSource from the fields stored in the FieldData.

Parameters:
  • source_time (SourceTime) – Specification of the source time-dependence.

  • center (Tuple[float, float, float]) – Source center in x, y and z.

  • size (Tuple[float, float, float]) – Source size in x, y, and z. If not provided, the size of the monitor associated to the data is used.

  • **kwargs – Extra keyword arguments passed to CustomFieldSource.

Returns:

Source injecting the fields stored in the FieldData, with other settings as provided in the input arguments.

Return type:

CustomFieldSource

make_adjoint_sources(dataset_names)[source]#

Converts a FieldData to a list of adjoint current or point sources.

to_adjoint_point_sources()[source]#

Create adjoint point dipole source if this field data contains one item.

to_adjoint_field_sources()[source]#

Create adjoint custom field sources if this field data has some dimensionality.

__hash__()#

Hash method.