XY Plot

The XYPlotModule class provides methods to interact with XY Plot modules.

Creating and controlling an XY Plot module

The following example demonstrates how to instantiate an XY Plot module, configure its curves and sampling parameters, run an acquisition, and export the resulting data:

xy = project.modules.create(ModuleType.XY_PLOT)
xy.add_curves([("speed_ref", "phase_current")])
xy.set_sampling_frequency(frequency_hz=1000.0)
xy.set_window(window_s=5.0)
xy.play()
# ... run the experiment ...
xy.pause()
xy.export("C:/imperix/captures/data.mat")

API Reference

class imperix.XYPlotModule(cockpit: Cockpit, data: dict[str, Any])
export(path: str | PathLike[str], *, plot: int = 0, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Export acquired data from one plot to a CSV or MAT file.

Parameters:
  • path – Absolute path where the file will be written, as a string or Path. The file extension selects the export format. The supported extensions are .csv and .mat.

  • plot – Index of the plot to export. Defaults to 0 (the first plot).

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot export the acquired data.

stop(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Stops the acquisition.

Parameters:

timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If the acquisition cannot be stopped.

set_window(*, window_s: float, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Set the acquisition window duration.

Parameters:
  • window_s – Window duration in seconds.

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot update the acquisition window.

list_curves(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) Any

Returns the list of variables in a plot.

Parameters:
  • plot – plot index. Defaults to 0.

  • timeout – Maximum time to wait for a response in seconds.

Returns:

A list of variable names on the given plot.

add_curves(curves: Iterable[tuple[str, str] | dict[str, str]], *, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Adds XY curves.

Parameters:
  • curves – Iterable of (x_name, y_name) tuples or {"x": x_name, "y": y_name} dicts.

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot add the curves.

Example:

# Tuples and {"x": ..., "y": ...} dictionaries are equivalent.
xy.add_curves([("speed_ref", "phase_current")])
xy.add_curves([{"x": "speed_ref", "y": "phase_current"}])
remove_curves(curves: Iterable[tuple[str, str] | dict[str, str]], *, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Removes curves from the module.

Parameters:
  • curves – Iterable of (x_name, y_name) tuples or {"x": x_name, "y": y_name} dicts.

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot remove the curves.

Example:

# Remove curves that should no longer appear in the XY view.
xy.remove_curves([("speed_ref", "phase_current")])
set_sampling_frequency(*, frequency_hz: float, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Sets the sampling rate.

Parameters:
  • frequency_hz – Acquisition sampling rate in Hz.

  • timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If Cockpit cannot update the sampling frequency.

play(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Starts or resumes acquisition.

Parameters:

timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If the acquisition cannot be started.

pause(*, timeout: float | None | UseDefaultTimeout = UseDefaultTimeout.TOKEN) None

Pause acquisition without clearing the data.

Parameters:

timeout – Maximum time to wait for a response in seconds.

Raises:

InvalidStateError – If the acquisition cannot be paused.