{
  "title": "ModeData",
  "public_path": "flex_rf.tidy3d.ModeData",
  "lookup_path": "tidy3d.ModeData",
  "slug": "flex_rf/tidy3d/ModeData",
  "public_url": "/rf/latest/autogenerated/flex_rf/tidy3d/modedata/",
  "object_kind": "class",
  "introduction": "Data associated with a `ModeMonitor`: modal amplitudes, propagation indices and mode profiles.",
  "notes": "The data is stored as a [DataArray](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.html)\nobject using the [xarray](https://docs.xarray.dev/en/stable/index.html) package.\n\nThe mode monitor data contains the complex effective indices and the complex mode amplitudes at the monitor\nposition calculated by mode decomposition. The data structure of the complex effective\nindices :attr`n_complex` contains two coordinates: `f` and `mode_index`, both of which are specified when\ndefining the `ModeMonitor` in the simulation.\n\nBesides the effective index, `ModeMonitor` is primarily used to calculate the transmission of\ncertain modes in certain directions. We can extract the complex amplitude and square it to compute the mode\ntransmission power.",
  "examples": "```python\nfrom tidy3d import ModeSpec\nfrom tidy3d import ModeAmpsDataArray, ModeIndexDataArray\ndirection = [\"+\", \"-\"]\nf = [1e14, 2e14, 3e14]\nmode_index = np.arange(5)\nindex_coords = dict(f=f, mode_index=mode_index)\nindex_data = ModeIndexDataArray((1+1j) * np.random.random((3, 5)), coords=index_coords)\namp_coords = dict(direction=direction, f=f, mode_index=mode_index)\namp_data = ModeAmpsDataArray((1+1j) * np.random.random((2, 3, 5)), coords=amp_coords)\nmonitor = ModeMonitor(\n   size=(2,0,6),\n   freqs=[2e14, 3e14],\n   mode_spec=ModeSpec(num_modes=5),\n   name='mode',\n)\ndata = ModeData(monitor=monitor, amps=amp_data, n_complex=index_data)\n```",
  "references": "",
  "signature": "class ModeData(ModeSolverDataset, AbstractOverlapData)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/components/data/monitor_data.py",
    "url": "",
    "lineno": 2451,
    "endlineno": 3376
  },
  "bases": [
    "ModeSolverDataset",
    "AbstractOverlapData"
  ],
  "parameter_rows": [
    {
      "name": "monitor",
      "annotation": "ModeMonitor",
      "default": "",
      "description": "Monitor associated with the data.",
      "origin": "declared"
    },
    {
      "name": "eps_spec",
      "annotation": "list[EpsSpecType] | None",
      "default": "None",
      "description": "Characterization of the permittivity profile on the plane where modes are computed. Possible values are 'diagonal', 'tensorial_real', 'tensorial_complex'.",
      "origin": "declared"
    },
    {
      "name": "attrs",
      "annotation": "dict",
      "default": "factory: dict",
      "description": "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.model_dump_json()`.",
      "origin": "inherited"
    },
    {
      "name": "Ex",
      "annotation": "ScalarModeFieldDataArray | None",
      "default": "None",
      "description": "Spatial distribution of the x-component of the electric field of the mode.",
      "origin": "inherited"
    },
    {
      "name": "Ey",
      "annotation": "ScalarModeFieldDataArray | None",
      "default": "None",
      "description": "Spatial distribution of the y-component of the electric field of the mode.",
      "origin": "inherited"
    },
    {
      "name": "Ez",
      "annotation": "ScalarModeFieldDataArray | None",
      "default": "None",
      "description": "Spatial distribution of the z-component of the electric field of the mode.",
      "origin": "inherited"
    },
    {
      "name": "Hx",
      "annotation": "ScalarModeFieldDataArray | None",
      "default": "None",
      "description": "Spatial distribution of the x-component of the magnetic field of the mode.",
      "origin": "inherited"
    },
    {
      "name": "Hy",
      "annotation": "ScalarModeFieldDataArray | None",
      "default": "None",
      "description": "Spatial distribution of the y-component of the magnetic field of the mode.",
      "origin": "inherited"
    },
    {
      "name": "Hz",
      "annotation": "ScalarModeFieldDataArray | None",
      "default": "None",
      "description": "Spatial distribution of the z-component of the magnetic field of the mode.",
      "origin": "inherited"
    },
    {
      "name": "symmetry",
      "annotation": "tuple[Symmetry, Symmetry, Symmetry]",
      "default": "(0, 0, 0)",
      "description": "Symmetry eigenvalues of the original simulation in x, y, and z.",
      "origin": "inherited"
    },
    {
      "name": "symmetry_center",
      "annotation": "Coordinate | None",
      "default": "None",
      "description": "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.",
      "origin": "inherited"
    },
    {
      "name": "grid_expanded",
      "annotation": "Grid | None",
      "default": "None",
      "description": "`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.",
      "origin": "inherited"
    },
    {
      "name": "grid_primal_correction",
      "annotation": "GRID_CORRECTION_TYPE",
      "default": "1.0",
      "description": "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.",
      "origin": "inherited"
    },
    {
      "name": "grid_dual_correction",
      "annotation": "GRID_CORRECTION_TYPE",
      "default": "1.0",
      "description": "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.",
      "origin": "inherited"
    },
    {
      "name": "amps",
      "annotation": "ModeAmpsDataArray",
      "default": "",
      "description": "Complex-valued amplitudes of the overlap decomposition.",
      "origin": "inherited"
    },
    {
      "name": "n_complex",
      "annotation": "ModeIndexDataArray",
      "default": "",
      "description": "Complex-valued effective propagation constants associated with the mode.",
      "origin": "inherited"
    },
    {
      "name": "n_group_raw",
      "annotation": "GroupIndexDataArray | None",
      "default": "None",
      "description": "Index associated with group velocity of the mode.",
      "origin": "inherited"
    },
    {
      "name": "dispersion_raw",
      "annotation": "ModeDispersionDataArray | None",
      "default": "None",
      "description": "Dispersion parameter for the mode.",
      "origin": "inherited"
    }
  ],
  "members": [
    {
      "name": "eps_spec_match_mode_spec",
      "kind": "function",
      "signature": "eps_spec_match_mode_spec()",
      "description": "Raise validation error if frequencies in eps_spec does not match frequency list"
    },
    {
      "name": "modes_info",
      "kind": "attribute",
      "signature": "modes_info: xr.Dataset",
      "description": "Dataset collecting various properties of the stored modes."
    },
    {
      "name": "overlap_sort",
      "kind": "function",
      "signature": "overlap_sort(track_freq: TrackFreq, overlap_thresh: float = 0.9)",
      "description": "Starting from the base frequency defined by parameter `track_freq`, sort modes at each frequency according to their overlap values with the modes at the previous frequency. That is, it attempts to rearrange modes in such a way that a given `mode_index` corresponds to physically the same mode at all frequencies. Modes with overlap values over `overlap_thresh` are considered matching and not rearranged."
    },
    {
      "name": "pol_fraction",
      "kind": "function",
      "signature": "pol_fraction()",
      "description": "Compute the TE and TM polarization fraction defined as the field intensity along the first or the second of the two tangential axes. More precisely, if $E_1$ and $E_2$ are the electric field components along the two tangential axes, the TE fraction is defined as:"
    },
    {
      "name": "pol_fraction_waveguide",
      "kind": "function",
      "signature": "pol_fraction_waveguide()",
      "description": "Compute the TE and TM polarization fraction using the waveguide definition. If $n$ is the propagation direction, the TE fraction is defined as:"
    },
    {
      "name": "solver_field_bounds",
      "kind": "attribute",
      "signature": "solver_field_bounds: BoundOptional",
      "description": "Per-axis bounds where solver field data is physically valid."
    },
    {
      "name": "sort_modes",
      "kind": "function",
      "signature": "sort_modes(sort_spec: ModeSortSpec | None = None, track_freq: TrackFreq | None = None)",
      "description": "Sort modes per frequency according to `sort_spec`."
    },
    {
      "name": "TE_fraction",
      "kind": "attribute",
      "signature": "TE_fraction: xr.DataArray",
      "description": "Alias for `pol_fraction.te`."
    },
    {
      "name": "TM_fraction",
      "kind": "attribute",
      "signature": "TM_fraction: xr.DataArray",
      "description": "Alias for `pol_fraction.tm`."
    },
    {
      "name": "to_dataframe",
      "kind": "function",
      "signature": "to_dataframe()",
      "description": "xarray-like method to export the `modes_info` into a pandas dataframe which is e.g. simple to visualize as a table."
    },
    {
      "name": "wg_TE_fraction",
      "kind": "attribute",
      "signature": "wg_TE_fraction: xr.DataArray",
      "description": "Alias for `pol_fraction_waveguide.te`."
    },
    {
      "name": "wg_TM_fraction",
      "kind": "attribute",
      "signature": "wg_TM_fraction: xr.DataArray",
      "description": "Alias for `pol_fraction_waveguide.tm`."
    }
  ],
  "group": "flex_rf.tidy3d"
}
