Skip to content

visualdynamics.plot.shocks

shocks

The shock windows, marked on the time history they were found in.

The averaging overlay has a hard job: frames overlap, so it has to say which sample belongs to which average and how heavily. This one does not. A shock window is a span, the spans do not overlap, and each is one event — so the mark is a shaded region with a number on it, and the number is the point. shock 3 in a table of spectra means nothing until you can see which of the four events on the trace it was.

The regions are draggable, because detection is a good guess and not an oracle: a window that opened a little late, or closed before the ringdown was done, is fixed by pulling its edge rather than by arguing with a threshold. locked turns that off, for a report or a plot rendered to a file — there is nobody on the other end of a drag there.

Classes:

Name Description
ShockOverlay

The windows on one plot, and the dragging of 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,
)

The windows on one plot, and the dragging of them.

Owns nothing but its own items: the shocks themselves live on the time history, and this is told about them and reports back when one is dragged. changed is a callback rather than a Qt signal because the overlay is not a QObject — it is a handful of items on somebody else's plot, and it goes away when they do.

Methods:

Name Description
set_shocks

Show these instead, without going through a redraw of 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) -> None:
    self.plot: Any = plot
    self.shocks: tuple[Any, ...] = tuple(shocks)
    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

Show these instead, without going through a redraw of the plot.

Source code in src/visualdynamics/plot/shocks.py
def set_shocks(self, shocks: Sequence[Shock]) -> None:
    """Show these instead, without going through a redraw of the plot."""
    shocks = tuple(shocks)
    if shocks == self.shocks:
        return
    self.remove()
    self.shocks = shocks
    self.regions, self.labels = [], []
    self._draw()