Skip to content

visualdynamics.gui.dwell_panel

dwell_panel

The dwell readout: a held tone's build-up and ring-down, read in the sine view.

A dwell's level against frequency is one point, so the sine view's levels say nothing of it. When the specification beside the record holds a dwell, this readout sits under the extraction's settings and reads the dwell against time (core.dwell.read_dwell): on a channel chosen here (a response by default, since a control is held at its level and does not build), with the peak over each cycle, the steady level the dwell reached, the cycles it took to reach the share set here (95 % by default), and the cycles after the stop for the level to fall to the rest of it. The small plot under the numbers is the level against time with the steady level and the two shares drawn, the same drawing plot_dwell makes (plot.dwell.draw_dwell).

It is a reading, not an act: nothing is made, so there is no button, and an edit reads again at once. Every number shown is the reading's.

Classes:

Name Description
DwellPlot

The level against time, small: linear on both axes, since time

DwellPanel

The channel and the share, then what the reading found.

Classes

DwellPlot

DwellPlot(parent: QWidget | None = None)

Bases: PreviewPlot

The level against time, small: linear on both axes, since time and a share of a level are both read linearly.

Methods:

Name Description
show_reading

Draw reading, or clear the plot when it is None.

Source code in src/visualdynamics/gui/dwell_panel.py
def __init__(self, parent: QWidget | None = None) -> None:
    super().__init__(parent)
    self.plot.setLogMode(x=False, y=False)
    self.items: list[Any] = []
Methods:
show_reading
show_reading(reading: Any, unit_system: Any) -> None

Draw reading, or clear the plot when it is None.

Source code in src/visualdynamics/gui/dwell_panel.py
def show_reading(self, reading: Any, unit_system: Any) -> None:
    """Draw `reading`, or clear the plot when it is None."""
    from ..plot.dwell import draw_dwell

    for item in self.items:
        self.plot.removeItem(item)
    self.items = []
    if reading is not None:
        self.items = draw_dwell(self.plot, reading,
                                unit_system=unit_system,
                                colors=self.colors, legend=False)

DwellPanel

DwellPanel(parent: QWidget | None = None)

Bases: QWidget

The channel and the share, then what the reading found.

Methods:

Name Description
show_dwell

Read the dwell specification holds on history and show it;

settings

The reading's arguments as read_dwell takes them: 'channel'

apply_theme

Redraw the small plot in a new theme's colors.

Source code in src/visualdynamics/gui/dwell_panel.py
def __init__(self, parent: QWidget | None = None) -> None:
    super().__init__(parent)
    grid = QGridLayout(self)
    grid.setContentsMargins(0, 4, 0, 0)
    grid.setHorizontalSpacing(8)
    grid.setVerticalSpacing(4)
    rule = QFrame()
    rule.setFrameShape(QFrame.Shape.HLine)
    rule.setFrameShadow(QFrame.Shadow.Sunken)
    grid.addWidget(rule, 0, 0, 1, 2)
    self.title: QLabel = QLabel('Dwell')
    font = self.title.font()
    font.setBold(True)
    self.title.setFont(font)
    grid.addWidget(self.title, 1, 0, 1, 2)
    #: what is being read, and the reading last made of it
    self._history: Any = None
    self._specification: Any = None
    self._unit_system: Any = None
    self._key: tuple | None = None
    self.reading: Any = None
    self._loading = False

    self.channel_box: QComboBox = QComboBox()
    self.channel_box.setToolTip(
        'The channel read. A response builds at a resonance; the '
        'control is held at its level by the controller')
    self.share_box: DoubleSpinBox = DoubleSpinBox()
    self.share_box.setRange(50.0, 99.9)
    self.share_box.setDecimals(1)
    self.share_box.setSingleStep(1.0)
    self.share_box.setSuffix(' %')
    self.share_box.setValue(100.0 * DWELL_SHARE)
    self.share_box.setToolTip(
        'The share of the steady level the build-up is read to; the '
        'ring-down is read down to the rest of it. A resonance '
        'reaches 95 % in about Q cycles')
    self.names, self.editors = add_keyed_settings(grid, [
        ('channel', 'Channel', self.channel_box),
        ('share', 'Share', self.share_box)], first_row=2)
    made = add_derived(grid, (('frequency', 'Frequency'),
                              ('steady', 'Steady'),
                              ('built', 'Build-up'),
                              ('rung', 'Ring-down'),
                              ('settled', 'Settled')), 4)
    self.derived: dict[str, QLabel] = {key: value for key, (_name, value)
                                       in made.items()}
    self.derived_names: dict[str, QLabel] = {
        key: name for key, (name, _value) in made.items()}
    self.notes: QLabel = QLabel('')
    self.notes.setWordWrap(True)
    self.notes.setAlignment(Qt.AlignmentFlag.AlignLeft)
    grid.addWidget(self.notes, 9, 0, 1, 2)
    self.preview: DwellPlot = DwellPlot()
    grid.addWidget(self.preview, 10, 0, 1, 2)
    commit_on_enter(self.share_box)
    self.channel_box.currentIndexChanged.connect(self._edited)
    self.share_box.valueChanged.connect(self._edited)
    self._name_shares()
Methods:
show_dwell
show_dwell(history: Any, specification: Any, unit_system: Any = None) -> Any

Read the dwell specification holds on history and show it; hide, and return None, when no tone of it holds a dwell (principle 3). The channel box lists the record's channels and keeps the one chosen while the record keeps it. Returns the reading, or None when there is none or it was refused (the refusal is shown).

Source code in src/visualdynamics/gui/dwell_panel.py
def show_dwell(self, history: Any, specification: Any,
               unit_system: Any = None) -> Any:
    """Read the dwell `specification` holds on `history` and show it;
    hide, and return None, when no tone of it holds a dwell (principle
    3). The channel box lists the record's channels and keeps the one
    chosen while the record keeps it. Returns the reading, or None when
    there is none or it was refused (the refusal is shown)."""
    if not any(tone.dwell_segments() for tone in specification.tones):
        self.hide()
        self.reading = None
        return None
    dofs = [str(dof) for dof in history.response_dof]
    held = self.channel_box.currentText()
    self._loading = True
    try:
        if [self.channel_box.itemText(i)
                for i in range(self.channel_box.count())] != dofs:
            self.channel_box.clear()
            self.channel_box.addItems(dofs)
            held = held if held in dofs else self._default(history,
                                                           specification)
        self.channel_box.setCurrentIndex(dofs.index(held) if held in dofs
                                         else 0)
    finally:
        self._loading = False
    self._history, self._specification = history, specification
    self._unit_system = unit_system
    self.show()
    self._read()
    return self.reading
settings
settings() -> dict[str, Any]

The reading's arguments as read_dwell takes them: 'channel' and 'share' (a fraction).

Source code in src/visualdynamics/gui/dwell_panel.py
def settings(self) -> dict[str, Any]:
    """The reading's arguments as `read_dwell` takes them: 'channel'
    and 'share' (a fraction)."""
    return {'channel': self.channel_box.currentText() or None,
            'share': round(self.share_box.value() / 100.0, 6)}
apply_theme
apply_theme(colors: Mapping[str, str]) -> None

Redraw the small plot in a new theme's colors.

Source code in src/visualdynamics/gui/dwell_panel.py
def apply_theme(self, colors: Mapping[str, str]) -> None:
    """Redraw the small plot in a new theme's colors."""
    self.preview.apply_theme(colors)
    self.preview.show_reading(self.reading, self._unit_system)

Functions: