hertzforge.service.views¶
views
¶
Builders for the viz kit's views (schema/PROTOCOL.md, "Views").
Arrays are placed in the view as numpy arrays; the codec (frames.pack)
turns each into an {"$array": id} reference on the way out.
Functions:
| Name | Description |
|---|---|
axis |
A view's axis: its label, unit (None when undefined) and scale. |
series |
One curve. f64 is kept for spectra, which are short. |
drawable |
A |
shaped |
A curve drawn as |
spectrum |
A |
region |
A span of x behind a spectrum's curves: a |
dragging |
What makes a region draggable: the operation that sets the span, |
picking |
What a click in a |
row |
One row of a |
notes |
A |
reading |
A |
gizmo |
Arrows and rings at |
shape3d |
A mesh and its modes. Nodes and shapes are f32 [N, 3]; triangles and |
image |
An |
waterfall |
A |
staged |
A |
pathed |
A |
mode |
One mode of a |
matrix |
A |
table |
A |
editing |
What makes a |
bars |
A |
grouped |
A |
Functions:¶
axis
¶
A view's axis: its label, unit (None when undefined) and scale.
series
¶
series(name: str, role: Role, x: Any, y: Any, shape: Shape = 'line', edges: Any = None, follows: int | None = None) -> dict[str, Any]
One curve. f64 is kept for spectra, which are short.
shape is how the points mean to be drawn (schema/PROTOCOL.md, Views);
'steps' needs edges, one more than there are values. follows makes
the curve a follower of the view's series at that index: a model's
prediction of that measurement, drawn dashed in its colour.
drawable
¶
drawable(name: str, role: Any, x: Any, y: Any, positive: bool = False, x_above_zero: bool = False) -> dict[str, Any]
A series with the points that cannot be drawn left out: not a
number anywhere, and at or under zero on a log axis, positive for
the values and x_above_zero for the abscissa.
shaped
¶
A curve drawn as data calls for.
The shape is plot.drawing_shape's: a density per bin is
stepped across its bin, with plot.bin_edges (the object's own
band edges when it has them); a breakpoint law is resampled along its
power law with plot.as_power_law; anything else is a line.
x and y are the lines to draw, already cut to what is shown.
spectrum
¶
spectrum(title: str, x: dict, y: dict, lines: Sequence[dict], link: str | None = None, regions: Sequence[dict] = (), handles: Sequence[dict] = ()) -> dict[str, Any]
A spectrum view of lines on the axes x and y. Panes with
the same link share a cursor position on x; regions are shaded
behind the curves.
region
¶
region(x0: float, x1: float, kind: Literal['frame', 'cut', 'span', 'over', 'under'], label: str | None = None, drag: dict[str, Any] | None = None, window: Sequence[float] | None = None, level: int = 0, rows: int = 1, snap: dict[str, float] | None = None) -> dict[str, Any]
A span of x behind a spectrum's curves: a frame averaged from, a
cut left out, a span (its edges drawn, nothing shaded), or lines over or
under an abort limit, shaded in the limit's color. With
drag (dragging) it is moved on the plot: its middle slides it and
an edge moves that edge. A frame with window (its weights from 0 to 1,
evenly spaced from x0 to x1) has that window drawn on a rail above the
curves and its shading follow it; level is its row on the rail, of
rows, since frames that overlap cannot share one. A dragged span of frames
carries snap: a frame's length (frame) and the step from one frame to the
next (hop), in x, and the record's ends (low, high), so the plot can
draw the whole frames a drag would leave while it is still being dragged.
dragging
¶
What makes a region draggable: the operation that sets the span,
run with params and the new x0 as low and, when high is given,
the new x1 as high. Without high only the whole span slides.
picking
¶
picking(op: str, params: dict[str, Any], target: Literal['point', 'nodes', 'faces'], hint: str, **fields: Any) -> dict[str, Any]
What a click in a shape3d view does: run op with params and
what was clicked. A 'point' click sends the place it lands as x, y
and z, on the model's surface or plane. ids is the node id of each
of the first rows, the model's own nodes. A 'nodes' click picks the
node under it of those, and count of them (0: as many as wanted,
then Enter) go as param, a list such as '4, 7, 9'. A 'faces' click
toggles the surface its
triangle belongs to (faces, one owner a triangle, -1 for none): a
surface in kept is named in the out param, any other in back.
hint says what a click does.
row
¶
One row of a reading view. A non-finite float is a ValueError:
a value that could not be read is sent as words, never as NaN or
inf.
notes
¶
A row per note, each as a sentence; an empty note is no row.
reading
¶
A reading view: a titled table of rows.
gizmo
¶
gizmo(origin: Sequence[float], axes: Sequence[Sequence[float]], slide: dict[str, Any], turn: dict[str, Any]) -> dict[str, Any]
Arrows and rings at origin, along the three axes, to drag in a shape3d view:
letting go runs slide or turn, each {'op', 'params', 'values', 'adds'}: values names
the param a drag along an axis goes in, in meters or degrees, and adds (optional) the
other params that axis adds.
shape3d
¶
shape3d(title: str, unit: str, nodes: ndarray, modes: Sequence[dict], triangles: ndarray | None = None, lines: ndarray | None = None, **extra: Any) -> dict[str, Any]
A mesh and its modes. Nodes and shapes are f32 [N, 3]; triangles and
lines u32 [T, 3] and [L, 2]. extra fields ride along (the schema
allows them), such as how the shapes are normalized, or node_ids,
the drawn nodes' ids (u32 [N]) for the view's hover captions.
image
¶
An image view: a photo as its encoded bytes (png or jpeg), never
re-encoded, titled by its name. The shell draws it at its own aspect.
waterfall
¶
waterfall(title: str, x: dict, z: dict, records: Sequence[str], curves: Sequence[tuple[Any, Any]], x_range: tuple[float, float], z_range: tuple[float, float] | None = None, page: dict[str, int] | None = None) -> dict[str, Any]
A waterfall view: each record a polyline at its own depth.
curves is one (x, z) pair per record, front to back, in display
units and not logged (the shell takes the log when an axis reads
log); a NaN is a gap. They go out as two flat f32 arrays and the u32
offsets where each record starts, which is what the shell uploads
to the GPU as one geometry. x_range is the span where something
is drawn, z_range a level range the object pins (a coherence's 0
to 1.05), and page which page of how many this is, of how many
records.
staged
¶
staged(view: dict[str, Any], stations: Sequence[str], depths: Sequence[int], roles: Sequence[str], zones: Sequence[dict] = (), exceed: Sequence[dict] = (), walls: Sequence[Any] = (), surface: bool = False) -> dict[str, Any]
A waterfall view turned into one of the stages: its
records stand at named stations (depths, one station index a
record, so two records can share one) and are drawn by roles (a
'measured' record colored by level, any other in its role's color).
zones are a station's limit bands, each {station, kind 'warning' or
'abort', side 'upper' or 'lower', x, inner, outer}, with no outer
when the band runs to the stage's top or floor. exceed are the lines
a measurement went past an abort limit, each {station, side, x0, x1,
z}: one rectangle a line from its limit to the top or the floor.
walls are curves of one abscissa a station, drawn as translucent
walls from floor to top (a scalogram's cone of influence). surface
draws the records as one surface, every record on the same abscissa.
pathed
¶
pathed(view: dict[str, Any], y: dict, y_values: Any, y_range: tuple[float, float], roles: Sequence[str], zones: Sequence[dict] = (), exceed: Sequence[dict] = ()) -> dict[str, Any]
A waterfall view whose records are paths: each point at a depth of
its own on the axis y (y_values, one a point, y_range the span),
rather than at its record's station, as the sine stage places a tone
through time. zones carry y beside x and exceed carries y0
and y1, so the bands and the rectangles follow the path.
mode
¶
mode(index: int, frequency_hz: float, damping: float | None, shape: ndarray, label: str | None = None) -> dict[str, Any]
One mode of a shape3d view: its 1-based index, frequency,
damping (None when not stated) and its [N, 3] shape. A complex shape
travels as its real part in shape and its imaginary part in
shape_imag, both f32; a real one, or a complex one whose imaginary
part is all zero, carries shape alone. label names a shape that is
not a mode, shown in place of "Mode
matrix
¶
matrix(title: str, rows: dict[str, Any], columns: dict[str, Any], values: ndarray, value_label: str, value_range: tuple[float, float]) -> dict[str, Any]
A matrix view: one value per (row, column) cell, f32 [R, C], drawn
as a colored grid. rows and columns are each {"label", "ticks"},
one tick per row or column, and "indices" when the axis shows some of
an object's items: each row's or column's index in the object, which a
pick on the grid names it by. value_range pins the color scale, so two
matrices of the same quantity read alike.
table
¶
table(title: str, columns: Sequence[str], rows: Sequence[Sequence[str]], edit: dict[str, Any] | None = None) -> dict[str, Any]
A table view: rows of text under column headings, one cell per
column. With edit ({'op', 'params', 'columns'}, see editing) its
cells are typed into in place.
editing
¶
editing(op: str, params: dict[str, Any], columns: Sequence[str | None], choices: dict[str, list[str]] | None = None, kinds: dict[str, str] | None = None) -> dict[str, Any]
What makes a table view's cells editable: the operation that sets
one (taking row from 1, column and value beside params), each
column's key, or None for a column that is read only, what a column
offers by key, a shortlist the cell can still be typed past, and how a
column is edited (kinds, by key: 'choice' from its list, 'flag' by a
check box, 'date' in a date field, 'unit' from a shortlist, 'number'
or 'text' typed).
bars
¶
bars(title: str, label: str, unit: str | None, labels: Sequence[str], values: Sequence[float | None], *, under: float | None = None, over: float | None = None, at_limit: Literal['in', 'out'] = 'in', missing: Literal['none', 'under'] = 'none', notes: Sequence[str | None] | None = None, baseline: float = 0.0, floor: float | None = None) -> dict[str, Any]
A bars view: a bar a row, judged here against its thresholds.
A value under under is 'under' and one over over is 'over'; at a
threshold exactly it is in, or out with at_limit 'out' (a waveform
error at its ceiling has failed it). A row with no number (None or not
finite) draws no bar and is not judged, or is 'under' with missing
'under': a signal-to-noise with no signal above its noise is the worst
reading there is. notes are said along their rows; baseline is
where the bars grow from (a kurtosis from its Gaussian 3); floor
keeps the axis above it (a share cannot be negative).
grouped
¶
A spectrum whose series are shown a set at a time, chosen from a
list: each group a {'label', 'series', 'readouts'?}, series the
indices into the view's series, readouts the
{'label', 'text', 'status'} readings that go with it. The axes span
every group, so choosing another does not move them.