{
  "title": "SimulationData",
  "public_path": "flex_rf.tidy3d.SimulationData",
  "lookup_path": "tidy3d.SimulationData",
  "slug": "flex_rf/tidy3d/SimulationData",
  "public_url": "/rf/latest/autogenerated/flex_rf/tidy3d/simulationdata/",
  "object_kind": "class",
  "introduction": "Stores data from a collection of `Monitor` objects in a `Simulation`.",
  "notes": "The `SimulationData` objects store a copy of the original `Simulation`:, so it can be recovered if the\n`SimulationData` is loaded in a new session and the `Simulation` is no longer in memory.\n\nMore importantly, the `SimulationData` contains a reference to the data for each of the monitors within the\noriginal `Simulation`. This data can be accessed directly using the name given to the monitors initially.",
  "examples": "Standalone example:\n\n```python\nimport tidy3d as td\nnum_modes = 5\nx = [-1,1,3]\ny = [-2,0,2,4]\nz = [-3,-1,1,3,5]\nf = [2e14, 3e14]\ncoords = dict(x=x[:-1], y=y[:-1], z=z[:-1], f=f)\ngrid = td.Grid(boundaries=td.Coords(x=x, y=y, z=z))\nscalar_field = td.ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)\nfield_monitor = td.FieldMonitor(\n    size=(2,4,6),\n    freqs=[2e14, 3e14],\n    name='field',\n    fields=['Ex'],\n    colocate=True,\n)\nsim = td.Simulation(\n    size=(2, 4, 6),\n    grid_spec=td.GridSpec(wavelength=1.0),\n    monitors=[field_monitor],\n    run_time=2e-12,\n    sources=[\n        td.UniformCurrentSource(\n            size=(0, 0, 0),\n            center=(0, 0.5, 0),\n            polarization=\"Hx\",\n            source_time=td.GaussianPulse(\n                freq0=2e14,\n                fwidth=4e13,\n            ),\n            current_amplitude_definition=\"total\",\n        )\n    ],\n)\nfield_data = td.FieldData(monitor=field_monitor, Ex=scalar_field, grid_expanded=grid)\nsim_data = td.SimulationData(simulation=sim, data=(field_data,))\n```\n\nTo save and load the `SimulationData` object.\n\n```python\nsim_data.to_file(fname='path/to/file.hdf5') # Save a SimulationData object to a HDF5 file\nsim_data = SimulationData.from_file(fname='path/to/file.hdf5') # Load a SimulationData object from a HDF5 file.\n```\n\nOptionally, the simulation data can be loaded in a lazy mode, which only holds a reference until a field is accessed\nor a method is applied. This is useful to save I/O operations and memory.\n\n```python\nsim_data = SimulationData.from_file(fname='path/to/file.hdf5', lazy=True) # Does not contain data until accessed.\n```",
  "references": "",
  "signature": "class SimulationData(AbstractYeeGridSimulationData)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/components/data/sim_data.py",
    "url": "",
    "lineno": 1119,
    "endlineno": 1679
  },
  "bases": [
    "AbstractYeeGridSimulationData"
  ],
  "parameter_rows": [
    {
      "name": "simulation",
      "annotation": "Simulation",
      "default": "",
      "description": "Original `Simulation` associated with the data.",
      "origin": "declared"
    },
    {
      "name": "data",
      "annotation": "tuple[discriminated_union(MonitorDataType), ...]",
      "default": "",
      "description": "List of `MonitorData` instances associated with the monitors of the original `Simulation`.",
      "origin": "declared"
    },
    {
      "name": "diverged",
      "annotation": "bool",
      "default": "False",
      "description": "A boolean flag denoting whether the simulation run diverged.",
      "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": "log",
      "annotation": "str | None",
      "default": "None",
      "description": "A string containing the log information from the simulation run.",
      "origin": "inherited"
    }
  ],
  "members": [
    {
      "name": "field_decay",
      "kind": "function",
      "signature": "field_decay()",
      "description": "Returns a TimeDataArray of field decay values over time steps."
    },
    {
      "name": "final_decay_value",
      "kind": "attribute",
      "signature": "final_decay_value: float",
      "description": "Returns value of the field decay at the final time step."
    },
    {
      "name": "renormalize",
      "kind": "function",
      "signature": "renormalize(normalize_index: int)",
      "description": "Return a copy of the `SimulationData` with a different source used for the normalization."
    },
    {
      "name": "source_spectrum",
      "kind": "function",
      "signature": "source_spectrum(source_index: int)",
      "description": "Get a spectrum normalization function for a given source index."
    }
  ],
  "group": "flex_rf.tidy3d"
}
