stoner_measurement.plugins.transform.symmetry_decomposition.SymmetryDecompositionPlugin

class stoner_measurement.plugins.transform.symmetry_decomposition.SymmetryDecompositionPlugin(parent=None)[source]

Bases: BranchSplittingMixin, TraceChannelSelectionMixin, TransformPlugin

Decompose selected trace channels into symmetric and antisymmetric parts.

For non-hysteretic data, the plugin interpolates each selected channel and evaluates it at -x. For hysteretic data, it smooths x in acquisition order, locates prominent turning points, splits the trace into monotonic branches, and mirrors each branch against the best-overlapping branch with the opposite direction. Output rows retain the original acquisition order.

The General tab places the instance name and comment first, followed by the input trace, processing mode, channel scope, and output trace names. The Advanced tab configures turning-point detection, interpolation, and out-of-range behaviour. Advanced settings are omitted from JSON when they retain their defaults.

Use this transform to separate even and odd responses, for example the longitudinal and Hall components of a field-dependent signal. Outputs are (y(x) + y(-x)) / 2 and (y(x) - y(-x)) / 2. General selects the independent variable, automatic/non-hysteretic/hysteretic processing, all or selected channels, and output names.

On Advanced, smoothing window/order, turning-point prominence and minimum branch length control branch detection. Interpolation is shape-preserving PCHIP or linear. Missing mirror coverage produces NaN by default, or optionally uses the nearest boundary or extrapolation. The latter choices extend beyond measured overlap. Invalid inputs or settings are logged and produce no output. Results are stored in data under the configured symmetric and antisymmetric names.

Variables:
  • trace_key (str) – Source trace catalogue key.

  • mode (str) – Processing: auto, non_hysteretic or hysteretic.

  • channel_mode (str) – Channel scope: all or selected.

  • x_channel_key (str) – Independent-variable key; “x” uses the source x role.

  • channel_keys (list[str]) – Selected data channels.

  • symmetric_trace_name (str) – Even output name; defaults to symmetric.

  • antisymmetric_trace_name (str) – Odd output name; defaults to antisymmetric.

  • interpolation (str) – Interpolation: pchip or linear.

  • out_of_range (str) – Missing coverage: nan, nearest or extrapolate.

  • instance_name (str) – Inherited Python identifier for this instance in the Script tab and QtConsole.

  • comment (str) – Inherited optional note displayed beside this step.

  • sequence_engine (SequenceEngine | None) – Inherited owning engine and its live namespace; None while detached.

  • data (dict[str, Any]) – Inherited latest output mapping populated by run(), containing scalar and/or TraceData results.

  • smoothing_window (int) – Inherited Savitzky-Golay window length for branch detection.

  • smoothing_polyorder (int) – Inherited order used to smooth the independent variable.

  • turning_point_prominence (float) – Inherited minimum prominence as a fraction of the x span.

  • minimum_branch_length (int) – Inherited minimum accepted branch length in samples.

  • turning_points (list[int]) – Latest detected acquisition turning indices.

  • branch_directions (list[int]) – Latest directions: 1 rising and -1 falling.

Keyword Parameters:

parent (QObject | None) – Optional Qt parent object.

Examples

With a sequence instance named symmetry_decomposition, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:

symmetry_decomposition.mode = "non_hysteretic"
symmetry_decomposition.out_of_range = "nan"
symmetry_decomposition.data
config_tabs(parent: QWidget | None = None) → list[tuple[str, QWidget]][source]

Return configuration tabs for this transform plugin.

Produces a single Data tab that places the instance-name editor (from _general_config_widget()) at the top, followed by a horizontal separator and the data-selection widget returned by _build_data_tab(). An optional About tab is appended when _about_html() returns non-None content.

Subclasses that need additional tabs (e.g. a Fit Function or Parameters tab) should call super().config_tabs(parent) to obtain the base Data tab and then insert their extra tabs before the optional About tab.

Keyword Parameters:

parent (QWidget | None) – Optional Qt parent widget.

Returns:

List of (tab_title, widget) pairs starting with the combined Data tab.

Return type:

(list[tuple[str, QWidget]])

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.transform import TransformPlugin
>>> class _T(TransformPlugin):
...     @property
...     def name(self): return "T"
...     @property
...     def required_inputs(self): return []
...     @property
...     def output_names(self): return []
...     def transform(self, data): return {}
>>> tabs = _T().config_tabs()
>>> tabs[0][0]
'Data'
>>> 'General' not in [t for t, _ in tabs]
True
declared_outputs() → PluginOutputs[source]

Declare typed transform results without repeating output names.

property name: str

Unique human-readable name for this plugin.

property required_inputs: list[str]

Names of input datasets that transform() requires.

validate_inputs() raises ValueError if any of these keys are absent from the data dict passed to transform().

Returns:

Ordered list of required input key names.

Return type:

(list[str])

to_json() → dict[str, Any][source]

Serialise this plugin’s configuration to a JSON-compatible dict.

The returned dict contains at minimum:

  • "type" — the plugin sub-type tag (e.g. "trace", "state").

  • "class" — the fully qualified class path "module:ClassName" used by from_json() to reconstruct the exact subclass.

  • "instance_name" — the current instance_name.

Subclasses should call super().to_json() and then add their own configuration keys to the returned dict.

Returns:

A JSON-serialisable dictionary representing this plugin’s current configuration.

Return type:

(dict[str, Any])

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.trace import DummyPlugin
>>> plugin = DummyPlugin()
>>> d = plugin.to_json()
>>> d["type"]
'trace'
>>> d["instance_name"]
'dummy'
>>> "class" in d
True
transform(data: dict[str, Any]) → dict[str, Any][source]

Return symmetric and antisymmetric copies of the selected trace.