{
  "title": "ModeSortSpec",
  "public_path": "flex_rf.tidy3d.ModeSortSpec",
  "lookup_path": "tidy3d.ModeSortSpec",
  "slug": "flex_rf/tidy3d/ModeSortSpec",
  "public_url": "/rf/latest/autogenerated/flex_rf/tidy3d/modesortspec/",
  "object_kind": "class",
  "introduction": "Specification for filtering and sorting modes within each frequency.",
  "notes": "First, an optional filtering step splits the modes into two groups based on a threshold\napplied to `filter_key`: modes \"over\" or \"under\" `filter_reference` are placed first,\nwith the remaining modes placed next. Second, an optional sorting step orders modes within\neach group according to `sort_key`, optionally with respect to `sort_reference` and in\nthe specified `sort_order`. If `keep_modes` is set to \"filtered\", the modes that do\nnot meet the filter criterion are removed instead of being appended as a second group. If\n`keep_modes` is set to an integer, that is the number of modes that will be kept.",
  "examples": "",
  "references": "",
  "signature": "class ModeSortSpec(Tidy3dBaseModel)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/components/mode_spec.py",
    "url": "",
    "lineno": 86,
    "endlineno": 225
  },
  "bases": [
    "Tidy3dBaseModel"
  ],
  "parameter_rows": [
    {
      "name": "filter_key",
      "annotation": "MODE_DATA_KEYS | None",
      "default": "None",
      "description": "Quantity used to filter modes into two groups before sorting.",
      "origin": "declared"
    },
    {
      "name": "filter_reference",
      "annotation": "float",
      "default": "0.0",
      "description": "Reference value used in the filtering stage.",
      "origin": "declared"
    },
    {
      "name": "filter_order",
      "annotation": "Literal['over', 'under']",
      "default": "'over'",
      "description": "Select whether the first group contains values over or under the reference.",
      "origin": "declared"
    },
    {
      "name": "bounding_box",
      "annotation": "Box | None",
      "default": "None",
      "description": "Regular 3D tidy3d `Box` used by metrics such as `'fill_fraction_box'`. The extent along the propagation axis is ignored for the metric, but the box must still intersect the monitor plane. Required when filtering or sorting with that key.",
      "origin": "declared"
    },
    {
      "name": "keep_modes",
      "annotation": "Literal['all'] | Literal['filtered'] | PositiveInt",
      "default": "'all'",
      "description": "If `filtered`, modes that do not satisfy the filter criterion are removed entirely instead of being appended after the filtered group. Only modes passing the filter at every tracked frequency are kept. If a positive integer is given, that is the number of modes which will be kept.",
      "origin": "declared"
    },
    {
      "name": "sort_key",
      "annotation": "MODE_DATA_KEYS",
      "default": "'n_eff'",
      "description": "Quantity used to sort modes within each filtered group.",
      "origin": "declared"
    },
    {
      "name": "sort_reference",
      "annotation": "float | None",
      "default": "None",
      "description": "If provided, sorting is based on the absolute difference to this reference value.",
      "origin": "declared"
    },
    {
      "name": "sort_order",
      "annotation": "Literal['ascending', 'descending'] | None",
      "default": "None",
      "description": "_build_sort_order_description()",
      "origin": "declared"
    },
    {
      "name": "track_freq",
      "annotation": "TrackFreq | None",
      "default": "'central'",
      "description": "If provided, enables cross-frequency mode tracking. Can be 'lowest', 'central', or 'highest', which refers to the frequency **index** in the list of frequencies. The mode sorting would then be exact at the specified frequency, while at other frequencies it can change depending on the mode tracking.",
      "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"
    }
  ],
  "members": [
    {
      "name": "has_custom_sort_or_filter",
      "kind": "attribute",
      "signature": "has_custom_sort_or_filter: bool",
      "description": "Whether this sort spec has custom sorting/filtering beyond the default."
    }
  ],
  "group": "flex_rf.tidy3d"
}
