tidy3d.ModeSortSpec#
- class ModeSortSpec[source]#
Bases:
Tidy3dBaseModelSpecification for filtering and sorting modes within each frequency.
- Parameters:
filter_key (Optional[Literal['n_eff', 'k_eff', 'TE_fraction', 'TM_fraction', 'wg_TE_fraction', 'wg_TM_fraction', 'mode_area', 'fill_fraction_box']] = 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 (Optional[
Box] = None) – Regular 3D tidy3dBoxused 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 (Union[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 (Literal['n_eff', 'k_eff', 'TE_fraction', 'TM_fraction', 'wg_TE_fraction', 'wg_TM_fraction', 'mode_area', 'fill_fraction_box'] = n_eff) – Quantity used to sort modes within each filtered group.
sort_reference (Optional[float] = None) – If provided, sorting is based on the absolute difference to this reference value.
sort_order (Optional[Literal['ascending', 'descending']] = None) – Sort order for the selected key or difference to reference value. If
None, the default depends onsort_keyandsort_reference. Whensort_referenceis provided, defaults to'ascending'(closest to reference first). Otherwise, defaults to the natural order for each key:'descending'forn_eff,TE_fraction,TM_fraction,wg_TE_fraction,wg_TM_fraction,fill_fraction_box(higher values first);'ascending'fork_eff,mode_area(lower values first).track_freq (Optional[Literal['central', 'lowest', 'highest']] = 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.
Notes
First, an optional filtering step splits the modes into two groups based on a threshold applied to
filter_key: modes “over” or “under”filter_referenceare placed first, with the remaining modes placed next. Second, an optional sorting step orders modes within each group according tosort_key, optionally with respect tosort_referenceand in the specifiedsort_order. Ifkeep_modesis set to “filtered”, the modes that do not meet the filter criterion are removed instead of being appended as a second group. Ifkeep_modesis set to an integer, that is the number of modes that will be kept.Attributes
Whether this sort spec has custom sorting/filtering beyond the default.
- filter_key#
- filter_reference#
- filter_order#
- bounding_box#
- keep_modes#
- sort_key#
- sort_reference#
- sort_order#
- track_freq#
- property has_custom_sort_or_filter#
Whether this sort spec has custom sorting/filtering beyond the default.
Returns
Trueif any of the following differ from defaults: -filter_keyis notNone-sort_keyis not'n_eff'-sort_referenceis notNone-sort_orderis not'descending'-keep_modesis not'all'This is used to check compatibility with the deprecated
filter_polfield.