experimental.plotter.i_plotter module

Define the base class for all plotters.

Todo

Remove the elts argument??

class IPlotter(elts: ListOfElements | None = None)

Bases: ABC

The base plotting class.

__init__(elts: ListOfElements | None = None) None

Instantiate some base attributes.

_abc_impl = <_abc._abc_data object>
abstract _actual_constant_plot(axes: Any, constant: float, color: str, ls: str, **kwargs) Any

Add one constant to a plot.

abstract _actual_plot(data: Any, ylabel: str, axes: Any, axes_index: int, xlabel: str = 'Synch. position [m]', **plot_kwargs: Any) Any

Create the plot itself.

_grid = True
_legend = True
abstract _plot_sections(axes: Any, elts: ListOfElements, x_axis: str) None

Add the sections on the structure plot.

abstract _plot_structure(axes: Any, elts: ListOfElements | None = None, x_axis: str = 'z_abs') None

Add a plot to show the structure of the linac.

_sections = True
abstract _setup_fig(fignum: int, title: str, **kwargs) Sequence[Any]

Create the figure.

This method should create the figure with figure number fignum, with title title, and eventual keyword arguments. It must return one or several axes where data can be plotted.

_sharex = True
_structure = True
final plot(data: Any, axes: Any | None = None, ref_data: Any | None = None, png_path: Path | None = None, elts: ListOfElements | None = None, fignum: int = 1, axes_index: int = 0, title: str = '', x_axis: str = 'z_abs', **plot_kwargs: Any) Any

Plot the provided data.

Parameters:
  • data (Any) – Data to be plotted. According to the subclass, it can be a numpy array, a pandas dataframe…

  • ref_data (Sequence[float] | None, optional) – Reference data, to plot if provided.

  • png_path (Path | None, optional) – Where the figure will be saved. The default is None, in which case figure is not plotted.

  • elts (ListOfElements | None, optional) – Elements to plot if _structure is True. If not provided, we take default _elts instead. Note that the colour of the failed, compensating, rephased cavities is given by this object. The default is None.

  • fignum (int, optional) – Figure number. The default is 1.

  • axes_index (int, optional) – Axes identifier. The default is 0, corresponding to the topmost sub-axes.

  • title (str, optional) – Title of the figure. The default is an empty string.

  • plot_kwargs (Any, optional) – Other keyword arguments passed to the _actual_plotting().

Returns:

The created axes object(s).

Return type:

Any

final plot_constants(axes: Any, constants: Iterable[float] | float, color: str = 'red', ls: str = 'dashed', **kwargs) Any

Add one or several constants to a plot.

final plot_limits(data: Any, axes: Any, constant_limits: bool, color: str = 'red', ls: str = 'dashed', **kwargs: Any) Any

Represent acceptable lower and upper limits.

abstract save_figure(axes: Any, save_path: Path) None

Save the created figure.