Skip to content

visualdynamics.plot.shocks

shocks

Shock windows marked on the time history they were found in.

A shock window is a span of the record, the windows do not overlap, and each one is a single event. Each is drawn as a shaded region with its number on it, so that "shock 3" in a table of spectra can be matched to one of the events on the time history.

The regions can be dragged, because the detection is an estimate: a window that starts a little late, or ends before the ringdown is over, is corrected by moving its edge instead of changing the threshold. A window is held to its neighbors and cannot be dragged over one. With locked the regions cannot be dragged, which is what a report or a plot saved to a file uses.

Classes:

Name Description
ShockOverlay

The shock windows on one plot, and dragging them.

Classes

ShockOverlay

ShockOverlay(plot: Any, shocks: Sequence[Shock], colors: Mapping[str, str], changed: Callable[..., None] | None = None, locked: bool = False, common: bool = False, limit: float | None = None, origin: float = 0.0)

The shock windows on one plot, and dragging them.

The overlay owns only its own plot items. The shocks are stored on the time history; the overlay is given them and calls changed with the new list when one is dragged. changed is a callback and not a Qt signal because the overlay is not a QObject: it is a few items on another object's plot and is removed with that plot.

With common the series is held at one length, so resizing any window resizes all of them; limit is the end of the record in seconds, which a shared length cannot pass. origin is the time of the record's first sample, the zero the shocks' start times count from.

Methods:

Name Description
set_shocks

Draw these shocks in place of the current ones, without redrawing the plot.

Source code in src/visualdynamics/plot/shocks.py
def __init__(self, plot: Any, shocks: Sequence[Shock],
             colors: Mapping[str, str],
             changed: Callable[..., None] | None = None,
             locked: bool = False, common: bool = False,
             limit: float | None = None, origin: float = 0.0) -> None:
    self.plot: Any = plot
    self.shocks: tuple[Any, ...] = tuple(shocks)
    #: the record's first instant: a shock's start counts from the
    #: record's beginning, the plot's axis is the record's clock
    self.origin: float = float(origin)
    self.colors: dict[str, str] = colors
    self.changed: Callable[..., None] | None = changed
    self.locked: bool = bool(locked)
    #: whether the series is held at one length, so a drag on any
    #: window is a drag on all of them
    self.common: bool = bool(common)
    #: the end of the record in seconds, so a shared length cannot
    #: be widened past it
    self.limit: float | None = limit
    self.regions: list[Any] = []
    self.labels: list[Any] = []
    self._dragging = False
    self._draw()
Methods:
set_shocks
set_shocks(shocks: Sequence[Shock]) -> None

Draw these shocks in place of the current ones, without redrawing the plot.

Source code in src/visualdynamics/plot/shocks.py
def set_shocks(self, shocks: Sequence[Shock]) -> None:
    """Draw these shocks in place of the current ones, without redrawing the plot."""
    shocks = tuple(shocks)
    if shocks == self.shocks:
        return
    self.remove()
    self.shocks = shocks
    self.regions, self.labels = [], []
    self._draw()