Skip to content

visualdynamics.plot.averaging

averaging

The frames, drawn on the record they will be cut from.

A list of five numbers does not tell you whether the analysis sits on the part of the record you meant. Drawn, it does.

Above the trace is the rail: one slot per frame carrying that frame's window, shaded under the curve, so the window is read where it is set rather than over the data it is applied to. Frames that overlap cannot share a slot without running through each other, so each takes the lowest slot whose last frame has already ended — one line at no overlap, two at half, four at three quarters.

Under each frame's slot, its band falls to the foot of the plot. The height is what says which slot a frame is in, so where two frames share record you see two heights and the step between them: the overlap has a shape rather than only a shade.

The span is one draggable region. Take it by the middle to slide the analysis along the record; take it by an edge to add or drop frames — and only whole frames, because half a frame is not an average, so the edge snaps back to where the last whole frame ends.

A capture the controller already cut into frames has nothing to drag: the frame is the record, and the region is drawn locked around it.

Classes:

Name Description
AveragingOverlay

The averaging parameters as marks on a time history plot.

Classes

AveragingOverlay

AveragingOverlay(
    plot: Any,
    averaging: Averaging,
    sample_rate: float,
    samples: int,
    colors: Mapping[str, str],
    locked: bool = False,
    parent: Any = None,
)

Bases: QObject

The averaging parameters as marks on a time history plot.

Owns every item it adds and takes them all away again on remove, so a redraw cannot leave a band behind. It reports a drag and does not act on it: what a new averaging means — storing it, redrawing the table — belongs to whoever put the overlay up.

Methods:

Name Description
remove

Take every mark off the plot. The overlay is finished after.

set_averaging

Draw a different averaging — what the table's edits arrive as.

Source code in src/visualdynamics/plot/averaging.py
def __init__(self, plot: Any, averaging: Averaging, sample_rate: float,
             samples: int, colors: Mapping[str, str],
             locked: bool = False, parent: Any = None) -> None:
    super().__init__(parent)
    self.plot: Any = plot
    self.averaging: Averaging = averaging
    self.sample_rate: float = float(sample_rate)
    self.samples: int = int(samples)
    self.colors: dict[str, str] = colors
    self.locked: bool = bool(locked)
    self.bands: list[Any] = []
    self.glyphs: list[Any] = []
    self.caps: list[Any] = []
    self.region: Any = None
    self._snapping = False
    #: the plot's own y limits, put back when the marks come off
    self._locked = None
    self._draw()
    # connected before the room is made, so that the marks follow the
    # range they are about to be given rather than the one they were
    # drawn against
    plot.getViewBox().sigYRangeChanged.connect(self._rescale)
    self._make_room()
Methods:
remove
remove() -> None

Take every mark off the plot. The overlay is finished after.

Source code in src/visualdynamics/plot/averaging.py
def remove(self) -> None:
    """Take every mark off the plot. The overlay is finished after."""
    try:
        self.plot.getViewBox().sigYRangeChanged.disconnect(self._rescale)
    except (RuntimeError, TypeError):
        # the view went first, which is the usual way a pane is torn
        # down; there is nothing left to disconnect from
        pass
    self._clear_items()
    try:
        # the room was for the rail; with the rail gone the trace
        # has the height, and the lock its own ceiling again
        view = self.plot.getViewBox()
        if self._locked is not None:
            view.setLimits(yMin=self._locked[0], yMax=self._locked[1])
            self._locked = None
        view.enableAutoRange(axis='y')
    except RuntimeError:
        pass
set_averaging
set_averaging(averaging: Averaging) -> None

Draw a different averaging — what the table's edits arrive as.

Source code in src/visualdynamics/plot/averaging.py
def set_averaging(self, averaging: Averaging) -> None:
    """Draw a different averaging — what the table's edits arrive as."""
    self.averaging = averaging
    self._redraw_marks()
    if self.region is not None:
        self._snap()

Functions: