{
  "title": "DiffractionData",
  "public_path": "flex_rf.tidy3d.DiffractionData",
  "lookup_path": "tidy3d.DiffractionData",
  "slug": "flex_rf/tidy3d/DiffractionData",
  "public_url": "/rf/latest/autogenerated/flex_rf/tidy3d/diffractiondata/",
  "object_kind": "class",
  "introduction": "Data for a `DiffractionMonitor`: complex components of diffracted far fields.",
  "notes": "The diffraction data are separated into S and P polarizations. At normal incidence when\nS and P are undefined, P(S) corresponds to `Ey`(`Ez`) polarization for monitor normal\nto x, P(S) corresponds to `Ex`(`Ez`) polarization for monitor normal to y, and P(S)\ncorresponds to `Ex`(`Ey`) polarization for monitor normal to z.\n\nThe power amplitudes per polarization and diffraction order, and correspondingly the power\nper diffraction order, correspond to the power carried by each diffraction order in the\nmonitor normal direction. They are not to be confused with power carried by plane waves\nin the propagation direction of each diffraction order, which can be obtained from the\nspherical-coordinate fields which are also stored. The power definition is such that the\ngrating efficiency is the recorded power over the input source power, and the direct sum\nover the power in all orders should equal the total power flowing through the monitor.",
  "examples": "```python\nfrom tidy3d import DiffractionDataArray\nf = np.linspace(1e14, 2e14, 10)\norders_x = list(range(-4, 5))\norders_y = list(range(-6, 7))\npol = [\"s\", \"p\"]\ncoords = dict(orders_x=orders_x, orders_y=orders_y, f=f)\nvalues = (1+1j) * np.random.random((len(orders_x), len(orders_y), len(f)))\nfield = DiffractionDataArray(values, coords=coords)\nmonitor = DiffractionMonitor(\n    center=(1,2,3), size=(np.inf,np.inf,0), freqs=f, name='diffraction'\n)\ndata = DiffractionData(\n    monitor=monitor, sim_size=[1,1], bloch_vecs=[1,2],\n    Etheta=field, Ephi=field, Er=field,\n    Htheta=field, Hphi=field, Hr=field,\n)\n```",
  "references": "",
  "signature": "class DiffractionData(AbstractFieldProjectionData)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/components/data/monitor_data.py",
    "url": "",
    "lineno": 4568,
    "endlineno": 4889
  },
  "bases": [
    "AbstractFieldProjectionData"
  ],
  "parameter_rows": [
    {
      "name": "monitor",
      "annotation": "DiffractionMonitor",
      "default": "",
      "description": "Diffraction monitor associated with the data.",
      "origin": "declared"
    },
    {
      "name": "Er",
      "annotation": "DiffractionDataArray",
      "default": "",
      "description": "Spatial distribution of r-component of the electric field.",
      "origin": "declared"
    },
    {
      "name": "Etheta",
      "annotation": "DiffractionDataArray",
      "default": "",
      "description": "Spatial distribution of the theta-component of the electric field.",
      "origin": "declared"
    },
    {
      "name": "Ephi",
      "annotation": "DiffractionDataArray",
      "default": "",
      "description": "Spatial distribution of phi-component of the electric field.",
      "origin": "declared"
    },
    {
      "name": "Hr",
      "annotation": "DiffractionDataArray",
      "default": "",
      "description": "Spatial distribution of r-component of the magnetic field.",
      "origin": "declared"
    },
    {
      "name": "Htheta",
      "annotation": "DiffractionDataArray",
      "default": "",
      "description": "Spatial distribution of theta-component of the magnetic field.",
      "origin": "declared"
    },
    {
      "name": "Hphi",
      "annotation": "DiffractionDataArray",
      "default": "",
      "description": "Spatial distribution of phi-component of the magnetic field.",
      "origin": "declared"
    },
    {
      "name": "sim_size",
      "annotation": "tuple[float, float]",
      "default": "",
      "description": "Size of the near field in the local x and y directions.",
      "origin": "declared"
    },
    {
      "name": "bloch_vecs",
      "annotation": "tuple[float, float] | tuple[ArrayFloat1D, ArrayFloat1D]",
      "default": "",
      "description": "Bloch vectors along the local x and y directions in units of `2 * pi / (simulation size along the respective dimension)`.",
      "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": "medium",
      "annotation": "MediumType",
      "default": "factory: Medium",
      "description": "Background medium through which to project fields.",
      "origin": "inherited"
    },
    {
      "name": "is_2d_simulation",
      "annotation": "bool",
      "default": "False",
      "description": "Indicates whether the monitor data is for a 2D simulation.",
      "origin": "inherited"
    }
  ],
  "members": [
    {
      "name": "adjoint_source_amp",
      "kind": "function",
      "signature": "adjoint_source_amp(amp: DataArray, fwidth: float)",
      "description": "Generate an adjoint `PlaneWave` for a single amplitude."
    },
    {
      "name": "amps",
      "kind": "attribute",
      "signature": "amps: DataArray",
      "description": "Complex power amplitude in each order for 's' and 'p' polarizations, normalized so that the power carried by the wave of that order and polarization equals `abs(amps)^2`."
    },
    {
      "name": "angles",
      "kind": "attribute",
      "signature": "angles: tuple[DataArray]",
      "description": "The (theta, phi) angles corresponding to each allowed pair of diffraction orders storeds as data arrays. Disallowed angles are set to `np.nan`."
    },
    {
      "name": "compute_angles",
      "kind": "function",
      "signature": "compute_angles(reciprocal_vectors: tuple[np.ndarray, np.ndarray])",
      "description": "Compute the polar and azimuth angles associated with the given reciprocal vectors."
    },
    {
      "name": "coords_spherical",
      "kind": "attribute",
      "signature": "coords_spherical: dict[str, np.ndarray]",
      "description": "Coordinates grid for the fields in the spherical system."
    },
    {
      "name": "fields_cartesian",
      "kind": "attribute",
      "signature": "fields_cartesian: xr.Dataset",
      "description": "Get all field components in Cartesian coordinates relative to the monitor's local origin for all allowed diffraction orders and frequencies specified in the `DiffractionMonitor`."
    },
    {
      "name": "fields_spherical",
      "kind": "attribute",
      "signature": "fields_spherical: xr.Dataset",
      "description": "Get all field components in spherical coordinates relative to the monitor's local origin for all allowed diffraction orders and frequencies specified in the `DiffractionMonitor`."
    },
    {
      "name": "orders_x",
      "kind": "attribute",
      "signature": "orders_x: np.ndarray",
      "description": "Allowed orders along x."
    },
    {
      "name": "orders_y",
      "kind": "attribute",
      "signature": "orders_y: np.ndarray",
      "description": "Allowed orders along y."
    },
    {
      "name": "power",
      "kind": "attribute",
      "signature": "power: DataArray",
      "description": "Total power in each order, summed over both polarizations."
    },
    {
      "name": "radar_cross_section",
      "kind": "attribute",
      "signature": "radar_cross_section: DataArray",
      "description": "Radar cross section in units of incident power."
    },
    {
      "name": "reciprocal_coords",
      "kind": "function",
      "signature": "reciprocal_coords(orders: np.ndarray, size: float, bloch_vec: float | np.ndarray, f: float, medium: MediumType)",
      "description": "Get the normalized \"u\" reciprocal coords for a vector of orders, size, and bloch vec."
    },
    {
      "name": "reciprocal_vectors",
      "kind": "attribute",
      "signature": "reciprocal_vectors: tuple[np.ndarray, np.ndarray]",
      "description": "Get the normalized \"ux\" and \"uy\" reciprocal vectors."
    },
    {
      "name": "shifted_orders",
      "kind": "function",
      "signature": "shifted_orders(orders: tuple[int, ...], bloch_vec: float | np.ndarray)",
      "description": "Diffraction orders shifted by the Bloch vector."
    },
    {
      "name": "ux",
      "kind": "attribute",
      "signature": "ux: np.ndarray",
      "description": "Normalized wave vector along x relative to `local_origin` and oriented with respect to `monitor.normal_dir`, normalized by the wave number in the projection medium."
    },
    {
      "name": "uy",
      "kind": "attribute",
      "signature": "uy: np.ndarray",
      "description": "Normalized wave vector along y relative to `local_origin` and oriented with respect to `monitor.normal_dir`, normalized by the wave number in the projection medium."
    }
  ],
  "group": "flex_rf.tidy3d"
}
