visualdynamics.core.channel_table¶
channel_table
¶
Channel table: per-channel test metadata (sensor, DOF, engineering units).
The table has one fixed set of columns, each with a type and a rule for what it accepts, and a source's other columns are dropped. Because every column says what it holds, a direction can be offered as a drop-down, a unit can be limited by the channel's type, and an expiration is read as a date.
A file and an edit are checked differently:
- A file is read leniently. A value that cannot be read takes the
column's default (blank for most columns) and the import goes on,
because refusing the import would leave the user nothing to correct,
and this table is where they correct it.
validate.dofsdoes the same for DOFs. - An edit is refused. When a person types a value the column cannot
hold,
set_cellraises with the reason and writes nothing.
Classes:
| Name | Description |
|---|---|
Spec |
What one column holds, and what it accepts. |
Environment |
One control loop of a run: the channels the controller read as |
ChannelTable |
Per-channel metadata, in one fixed set of typed columns. |
Functions:
| Name | Description |
|---|---|
title_of |
The header shown for a column, in the window and in the report. |
COLUMNS_KIND |
What kind of value a column holds, its |
CHOICES_FOR |
The values a column is limited to, empty when it is not limited. |
canonical_name |
A source's column name as this schema spells it. |
Classes¶
Spec
¶
Bases: NamedTuple
What one column holds, and what it accepts.
kind is how a value is read ('int', 'index', 'float', 'choice',
'flag', 'date', 'unit' or 'text'), default fills a missing or
unreadable cell, choices limits a 'choice' column, minimum
bounds a numeric one, and unique makes the column a key.
Environment
dataclass
¶
Environment(controls: list[int] = list(), drives: list[int] = list(), response_transformation: ndarray | None = None, reference_transformation: ndarray | None = None)
One control loop of a run: the channels the controller read as its control channels, the ones it drove, and the transformations it put over them, if any.
Channels are named by number (the channel column, the table's
join key), so the record survives a row deleted elsewhere in the
table. The controller's order is kept, because a transformation's
columns are the controls, or the drives, in that order.
Attributes:
| Name | Type | Description |
|---|---|---|
controls |
list of int
|
The control channels' numbers, in the controller's order. |
drives |
list of int
|
The drive channels' numbers, in the controller's order. |
response_transformation |
ndarray or None
|
|
reference_transformation |
ndarray or None
|
|
Methods:
| Name | Description |
|---|---|
matrix |
The 'response' or the 'reference' transformation. |
ChannelTable
¶
ChannelTable(columns: Mapping[str, Any] | DataFrame, environments: Mapping[str, Environment] | None = None)
Per-channel metadata, in one fixed set of typed columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns
|
mapping or DataFrame
|
The columns, by name, each with one entry per channel. Names are
read through |
required |
environments
|
mapping of str to Environment
|
The run's control loops by name, each checked as
|
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a column in |
Attributes:
| Name | Type | Description |
|---|---|---|
frame |
DataFrame
|
The table, one row per channel, columns in |
environments |
dict of str to Environment
|
The control loops, in the order they were set. Empty for a
table that describes no controller run. While a table has
any, its Control column is the union of their control
channels and is set through them ( |
Methods:
| Name | Description |
|---|---|
set_cell |
Write one cell, or refuse a value the column cannot hold. |
units_for |
The units to offer for this channel, given its declared type. |
add_channels |
Add blank channels at the end of the table, numbered on from |
chosen |
The rows of the channels |
choices |
The |
delete_channels |
Remove the given rows in place. At least one row must remain. |
orientation |
One channel's measured direction on a geometry. |
derived_cells |
The derived columns' cells for one row, as text. |
dof_strings |
Each channel's degree of freedom, as '101Z+' strings: the node |
rename_dof |
Give the channel at coordinate |
identities |
Each row as the (DOF, quantity) channel of |
roles |
Each channel's declared role ('reference', 'response' or |
controls |
Which channels are control channels, as a boolean per row. |
controls_for |
The control channels a reference over |
drives |
Which channels the environment drove, as a boolean per row. |
rows_of |
The rows of the given channel numbers, in the given order. |
set_environment |
Record a control loop, or replace the one of that name. |
remove_environment |
Forget a control loop. The Control column keeps what it |
set_control |
Check or clear Control on one channel for one environment. |
transformation |
A control loop's transformation as a labeled matrix. |
types |
Each channel's type (what it measures), '' where undeclared. |
sensitivities |
Each channel's sensitivity in mV per engineering unit, NaN where |
daq_ranges |
Each channel's DAQ input range in volts, NaN where unstated. |
sensor_ranges |
Each sensor's full-scale output in volts, NaN where unstated. |
clip_ranges |
The level each channel clips at, in volts: the smaller of its |
save |
Write the table to a file of its own, in the |
Source code in src/visualdynamics/core/channel_table.py
Attributes¶
column_names
property
¶
The table's column names, in order (title_of gives the
headers shown).
Methods:¶
set_cell
¶
Write one cell, or refuse a value the column cannot hold.
A unit that is not of the channel's declared type is refused;
change the type first. Changing the type clears a unit of another
kind. A model in the sensor catalog (core.sensor_catalog) fills
a blank Make with its maker; a make already written is kept. A
triaxial accelerometer's model or serial number is written once:
the other acceleration rows at its node, its other legs, get its
Make, Model and Serial Number where theirs are blank (and their
model is blank or the same). A row of another type at that node,
a force gauge, is never filled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The column to write. |
required |
row
|
int
|
Which channel. |
required |
value
|
object
|
The value, refused if the column cannot hold it. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If there is no column |
ValueError
|
If the value cannot be read for that column, repeats a channel number, or disagrees with the channel's type. |
Source code in src/visualdynamics/core/channel_table.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | |
units_for
¶
The units to offer for this channel, given its declared type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
Which channel. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
The shortlist for the declared type, or every unit in every shortlist when the type is blank. |
Source code in src/visualdynamics/core/channel_table.py
add_channels
¶
Add blank channels at the end of the table, numbered on from the highest channel in it (from 1 in an empty table).
Every other cell takes its column's default, so the node, direction and unit are blank until they are typed in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
How many channels to add. |
1
|
Returns:
| Type | Description |
|---|---|
list of int
|
The new channels' numbers. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/visualdynamics/core/channel_table.py
chosen
¶
The rows of the channels choice picks, in table order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
choice
|
str
|
One of |
'all'
|
Returns:
| Type | Description |
|---|---|
list of int
|
The rows. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/visualdynamics/core/channel_table.py
choices
¶
The CHANNEL_CHOICES that pick a channel, in that order:
'all' always, then 'control' when a channel has Control checked,
then each role a channel holds.
Source code in src/visualdynamics/core/channel_table.py
delete_channels
¶
Remove the given rows in place. At least one row must remain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
sequence of int
|
Which rows to remove. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
IndexError
|
If an index is out of range. |
ValueError
|
If every row would be removed. |
Source code in src/visualdynamics/core/channel_table.py
orientation
¶
One channel's measured direction on a geometry.
The row's DOF (node and direction) is read through the coordinate
system its node is measured in (Geometry.dof_direction). The
result is that direction as a unit vector in the geometry's
global system, the signed global axis nearest it ('X+', 'Z-'),
and the angle between the two in degrees. These are the values
the derived columns show.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
The channel's row. |
required |
geometry
|
Geometry
|
The geometry the channel is measured on. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
(vector, axis, angle), each None when the geometry is None or cannot place the channel: the node is not on it, the direction is missing, or the node is measured in a coordinate system that turns with position. |
Source code in src/visualdynamics/core/channel_table.py
derived_cells
¶
The derived columns' cells for one row, as text.
The three components of the direction to three decimals, the nearest axis, and the angle to a tenth of a degree; all empty when the geometry cannot place the channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
The channel's row. |
required |
geometry
|
Geometry
|
The geometry the channel is measured on. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
One cell per |
Source code in src/visualdynamics/core/channel_table.py
dof_strings
¶
Each channel's degree of freedom, as '101Z+' strings: the node and direction cells joined, so a missing one is left out.
Source code in src/visualdynamics/core/channel_table.py
rename_dof
¶
Give the channel at coordinate old the coordinate new, in
place, by rewriting its node and direction cells.
This is the same correction as DataArray.rename_dof, made in the
table that names the channels. Only the channels at old that
match quantity are changed, not every channel at the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
str
|
The coordinate as the table has it, '101Z+'. |
required |
new
|
str
|
The coordinate to give it: a node number then a direction, normalized as every DOF is. It is refused if either part is missing, although a table row may lack one. |
required |
quantity
|
str
|
Which channel at |
None
|
Returns:
| Type | Description |
|---|---|
int
|
How many channels changed; 0 when |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/visualdynamics/core/channel_table.py
identities
¶
Each row as the (DOF, quantity) channel of history it names.
The row's channel type is the quantity, the same word a time
history's ordinate_dim uses. A row with no channel type names
the history's channel at its DOF when there is exactly one
there. A row that names none of the history's channels is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
TimeHistory
|
The recording the table describes. Without one, each row's own (DOF, type) is returned. |
None
|
Returns:
| Type | Description |
|---|---|
list of (str, str) or None
|
One entry per row. |
Source code in src/visualdynamics/core/channel_table.py
roles
¶
Each channel's declared role ('reference', 'response' or 'monitor'), '' where undeclared.
controls
¶
Which channels are control channels, as a boolean per row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
str
|
One of |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
True where the channel is a control channel, one per row. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no environment of that name. |
Source code in src/visualdynamics/core/channel_table.py
controls_for
¶
The control channels a reference over dofs was held at, as
a boolean per row.
A reference belongs to the loop that controlled what it is
over: a transformed loop's rows ('1', '2', ...), or another
loop's control channels. With no environments, or one, that is
the Control column (controls). With several, it is the one
loop the DOFs name; where none or more than one is named, no
channel is flagged, so a reader falls back to the reference's
own pairing rather than taking every loop's controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dofs
|
sequence
|
The reference's DOFs, compared as text. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
True where the channel is a control channel of that loop. |
Source code in src/visualdynamics/core/channel_table.py
drives
¶
Which channels the environment drove, as a boolean per row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
str
|
One of |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
True where the channel is one of that loop's drives. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no environment of that name. |
Source code in src/visualdynamics/core/channel_table.py
rows_of
¶
The rows of the given channel numbers, in the given order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numbers
|
sequence of int
|
Channel numbers (the |
required |
Returns:
| Type | Description |
|---|---|
list of int
|
Their rows. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a number is no channel of the table. |
Source code in src/visualdynamics/core/channel_table.py
set_environment
¶
set_environment(name: str, environment: Environment) -> None
Record a control loop, or replace the one of that name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The environment's name, as the controller names it. |
required |
environment
|
Environment
|
Its channels and matrices. Every channel number must be a channel of the table, listed once; a response transformation must be two-dimensional with one column per control channel, and a reference transformation one per drive. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the name is blank or any of that fails. Nothing is recorded then. |
Source code in src/visualdynamics/core/channel_table.py
remove_environment
¶
Forget a control loop. The Control column keeps what it showed, which a table without environments may then edit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The environment to forget. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no environment of that name. |
Source code in src/visualdynamics/core/channel_table.py
set_control
¶
Check or clear Control on one channel for one environment.
A channel checked joins the loop's control channels, after the ones it has; cleared, it leaves them. The Control column follows as the union.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
str
|
Which loop. |
required |
row
|
int
|
Which channel. |
required |
value
|
object
|
True or False, in any spelling |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no such environment, the flag cannot be read, or
the environment transforms its control channels: the
matrix's columns are those channels, so it is set with them
( |
Source code in src/visualdynamics/core/channel_table.py
transformation
¶
A control loop's transformation as a labeled matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
str
|
Which loop. |
required |
form
|
str
|
'response' for the matrix over its control channels, applied to what they measure, or 'reference' for the one over its drives, applied to the drive signals. |
'response'
|
Returns:
| Type | Description |
|---|---|
MatrixAt
|
The rows numbered from 1, as the controller's records of them are named, and a column per control (or drive) channel headed by its DOF, in the controller's order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no such environment, or it holds no such transformation. |
Source code in src/visualdynamics/core/channel_table.py
types
¶
sensitivities
¶
Each channel's sensitivity in mV per engineering unit, NaN where undeclared.
daq_ranges
¶
sensor_ranges
¶
clip_ranges
¶
The level each channel clips at, in volts: the smaller of its DAQ range and its sensor range, whichever is stated, NaN where neither is.
Source code in src/visualdynamics/core/channel_table.py
save
¶
Write the table to a file of its own, in the .vdyn format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
Where to write it; |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/visualdynamics/core/channel_table.py
Functions:¶
title_of
¶
The header shown for a column, in the window and in the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The column name, such as 'serial_number'. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The header, from |
Source code in src/visualdynamics/core/channel_table.py
COLUMNS_KIND
¶
What kind of value a column holds, its Spec.kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The column name. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The kind, such as 'int', 'choice' or 'text'. |
Source code in src/visualdynamics/core/channel_table.py
CHOICES_FOR
¶
The values a column is limited to, empty when it is not limited.
A flag column such as 'control' returns ('True', 'False'), since a spreadsheet treats it as a choice of two.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The column name. |
required |
Returns:
| Type | Description |
|---|---|
tuple of str
|
The allowed values. |
Source code in src/visualdynamics/core/channel_table.py
canonical_name
¶
A source's column name as this schema spells it.
The name is lower-cased, spaces and hyphens become underscores, and
a trailing colon and anything from an opening parenthesis on are
dropped; then ChannelTable.ALIASES maps the words that differ.
Dropping the parenthetical unit reads this table's own headers back
('Sensitivity (mV/Unit)'), and a calibration sheet's
('Sensitivity (mV/g)') into the same column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The column name as the source wrote it. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The schema's name for it, or the tidied name if it has none. |