Skip to content

flex_rf.tidy3d.ModeSortSpec

Type: class Base(s): Tidy3dBaseModel

Specification for filtering and sorting modes within each frequency.

First, an optional filtering step splits the modes into two groups based on a threshold applied to filter_key: modes “over” or “under” filter_reference are placed first, with the remaining modes placed next. Second, an optional sorting step orders modes within each group according to sort_key, optionally with respect to sort_reference and in the specified sort_order. If keep_modes is set to “filtered”, the modes that do not meet the filter criterion are removed instead of being appended as a second group. If keep_modes is set to an integer, that is the number of modes that will be kept.

filter_key [MODE_DATA_KEYS | None] = None

Quantity used to filter modes into two groups before sorting.

filter_reference [float] = 0.0

Reference value used in the filtering stage.

filter_order [Literal['over', 'under']] = 'over'

Select whether the first group contains values over or under the reference.

bounding_box [Box | None] = None

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.

keep_modes [Literal['all'] | Literal['filtered'] | PositiveInt] = 'all'

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.

sort_key [MODE_DATA_KEYS] = 'n_eff'

Quantity used to sort modes within each filtered group.

sort_reference [float | None] = None

If provided, sorting is based on the absolute difference to this reference value.

sort_order [Literal['ascending', 'descending'] | None] = None

_build_sort_order_description()

track_freq [TrackFreq | None] = 'central'

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.

has_custom_sort_or_filter [bool]

Whether this sort spec has custom sorting/filtering beyond the default.