Skip to content

hertzforge.drawing.viz.waterfall

waterfall

Drawing decisions for waterfall: what a figure needs to know, with none of the code that draws it.

Functions:

Name Description
waterfall_groups

Every (dimension, hint) group among records (all of them when

waterfall_group

Which of the requested records are drawn together, and which are

records_per_page

How many records fit in one scene, from the vertices each one

quantity_label

The word the quantity box shows for one (dimension, hint) group.

waterfall_arrays

The waterfall's numbers, before VTK is involved.

nice_axis

(low, high, label count): the range widened to round tick values,

drawn_span

(low, high) of the abscissa where something is drawn, over the

stage_curves

The waterfall's curves placed on the stage.

stage_basis

(right, up): the stage's home view, as unit vectors for a

Classes

Functions:

waterfall_groups

waterfall_groups(data: DataArray, records: Sequence[int] | None = None) -> list[tuple[tuple[str, str | None], list[int]]]

Every (dimension, hint) group among records (all of them when None), as [(key, record indices)].

In the object's own order. These are what the quantity box offers, and what waterfall_group chooses from. The grouping key is the 2-D plot's, without the per-plot axis preferences that stacked axes need and a single stage does not.

waterfall_group

waterfall_group(data: DataArray, records: Sequence[int] | None = None, quantity: tuple[str, str | None] | None = None) -> tuple[list[int], list[int]]

Which of the requested records are drawn together, and which are left out.

One vertical axis cannot hold accelerations and volts at once. The 2-D plot uses one stacked axis per quantity; a scene has one stage, so the waterfall draws one (dimension, hint) group, the one quantity names or else the largest (the earliest on a tie), and reports the rest for the quantity box to offer. A quantity that is not present falls back to the largest group instead of raising, because it is a view choice kept from an earlier selection and not a statement about this object.

Returns (drawn, left_out), both in the object's record order.

records_per_page

records_per_page(data: DataArray, drawn_count: int, samples: int, shape: str, budget: int = SCENE_BUDGET, points: int = POINT_BUDGET) -> int

How many records fit in one scene, from the vertices each one costs.

samples is the number of abscissa values and shape the drawing shape (plot.drawing_shape). A stepped record ('steps') costs two points per bin and is never thinned, so a 16k-line PSD is 32k vertices whatever the budget. Any other record is thinned to points first, so it costs at most that. The count comes from vertices and not from a fixed number of records because line counts vary by orders of magnitude: 300 records of 16k lines and 4800 of 1k lines are the same size of scene. budget is the scene's vertex limit, and the result is at most drawn_count.

points must be the decimation budget actually in use, which is not always this module's: the report draws the same stage with a much smaller one.

Never returns zero. One record is always drawn, even when it alone is over the budget.

quantity_label

quantity_label(key: tuple[str, str | None]) -> str

The word the quantity box shows for one (dimension, hint) group.

It is the response quantity of the dimension, in the words the interface uses: a PSD group of acceleration**2/frequency shows 'acceleration', and an FRF group shows what it measures. A group whose units are undefined is named the same way from its hint, with '[units undefined]' after it as the axes show, or is 'units undefined' when it has no hint.

waterfall_arrays

waterfall_arrays(data: DataArray, records: Sequence[int] | None = None, unit_system: UnitSystem | None = None, component: str = 'magnitude', budget: int = POINT_BUDGET, quantity: tuple[str, str | None] | None = None, page: int = 0, scene_budget: int | None = None, exponents: bool = True) -> dict[str, Any]

The waterfall's numbers, before VTK is involved.

Everything the scene draws, in a form a test can check without a render window: the per-record curves in display units, decimated to budget points (a stepped spectrum is not decimated), the log mapping and the labels. component ('magnitude', 'real', 'imag' or 'phase') applies to complex frequency data, as in the 2-D plot. quantity picks the group drawn (waterfall_group). The records are split into pages of as many as fit in scene_budget vertices (SCENE_BUDGET by default, records_per_page), and page picks one, clipped to the pages there are. Returns a dict:

  • curves: one (x, z) pair per drawn record. z is log10 of the value when log_scaled, with non-positive values as NaN gaps, and x is log10 of the abscissa when log_abscissa
  • labels: each drawn record's record_label
  • drawn / left_out: record indices; drawn is this page of the group from waterfall_group
  • log_scaled / log_abscissa: whether z and x are log10 values
  • xlabel / zlabel: axis titles, in plain text for VTK
  • page, pages, per_page: the page drawn, how many there are, and the records on each
  • of_quantity: how many records the group has over all pages

With exponents False, x and z are the values themselves, in display units, for a renderer that takes the log itself (the shell does, so its scale can change without asking again); a non-positive value on a log reading is still a NaN gap, and the flags still say how the object reads, while the titles drop the log10 that only exponents need.

nice_axis

nice_axis(low: float, high: float, budget: float = 0.05) -> tuple[float, float, int]

(low, high, label count): the range widened to round tick values, when that adds little empty axis.

The cube axes place their labels at even divisions of the range, so a 0.4998 s record divided five ways has ticks at 0.125 and 0.375, which a one-decimal format prints as 0.1 and 0.4, values that are not where they are drawn. Widened to 0 to 0.5 with six labels, every tick is round and correct.

The range is widened only when that adds at most budget of the span as empty axis. A 1024 Hz Nyquist would widen to 1200, leaving a fifth of the stage with no data, so it keeps its exact range with five labels, and the label format prints those positions as they are. A range that is empty or not finite is returned unchanged.

drawn_span

drawn_span(curves: Any, default: tuple[float, float] = (0.0, 1.0)) -> tuple[float, float]

(low, high) of the abscissa where something is drawn, over the points whose level is finite, never over the whole abscissa a curve is carried on. A PSD written the way a controller writes a specification (every line to Nyquist, zero outside its band) is drawn only over its band, since zero is a gap on a log level, and the stage spans only that band. curves are (x, z) pairs, and default is returned when nothing is finite.

stage_curves

stage_curves(arrays: dict[str, Any], ordinate_limits: tuple[float, float] | None = None) -> dict[str, Any]

The waterfall's curves placed on the stage.

Takes the output of waterfall_arrays and gives the position of every point in stage coordinates (abscissa across, records receding, level up), the real ranges the stage stands for, and the runs of finite values each curve breaks into. A gap stays a gap, since a polyline drawn through one would show a value that is not there. The abscissa range is widened to round ticks (nice_axis). When ordinate_limits is given and the level is not log-scaled, it fixes the vertical range, as the 2-D plot fixes a coherence to 0 to 1.05.

This is separate from add_waterfall because the report draws the same stage in a canvas, and two normalizations would give two pictures of one measurement. Returns a dict, with no VTK in it:

  • runs: each {'record', 'station', 'points', 'levels', 'first'}, where first is the run's first index in its curve
  • extents: (x0, x1, z0, z1), the real ranges
  • stations: how many records are on the stage
  • x_label_count: how many abscissa labels to draw
  • labels, xlabel, zlabel, log_abscissa: from the arrays
  • xn, zn: functions taking real values to stage coordinates

stage_basis

stage_basis() -> tuple[ndarray, ndarray]

(right, up): the stage's home view, as unit vectors for a parallel projection.

Computed from the camera place_camera sets, so everything that draws the stage without a camera (the app icon's tile, the report's 3-D figure) shows the same view as the app, not a second isometric view that looks similar. It is parallel, not the camera's perspective, because both of those figures are small, and at that size perspective looks like distortion rather than depth.