Skip to content

hertzforge.report.plot_conventions

plot_conventions

Plot conventions for a report's figures (report feature plot_conventions, with its option shared_decades).

Three habits a figure in a test report is expected to keep:

  • An ASD or an SRS opens on log-log axes. A specification's breakpoints are joined by straight lines, and its tolerance band has a constant width, only on log-log axes; a narrowband comparison otherwise opens on a linear frequency axis.
  • Curves are told apart by line style as well as color, and a figure of up to END_LABEL_CURVES curves names each one at its end, so the figure survives a monochrome copy and a reader who does not see color.
  • With shared_decades, every figure of a kind (the ASD figures of one quantity and unit, the SRS figures likewise) opens on the same whole decades, so two figures can be compared by eye.

Each acts on the figures already built for the page, so the figure builders are unchanged and a report without the feature is drawn as it always was.

Functions:

Name Description
figure_kind

'asd' for a plot of a power spectral density (a measured PSD, a

apply

Put the page's figures under the conventions, in place.

share_decades

Give every log-log figure of a kind the same opening window, in

Functions:

figure_kind

figure_kind(block: Mapping[str, Any], objects: Mapping[str, Any], object_groups: Sequence[Mapping[str, Any]] | None = None) -> str | None

'asd' for a plot of a power spectral density (a measured PSD, a specification, or the two compared), 'srs' for a plot of a shock response spectrum (with its specification or alone), and None for every other figure.

apply

apply(payload: dict[str, Any], figures: Sequence[tuple[Mapping[str, Any], str | None]], shared: bool = False) -> None

Put the page's figures under the conventions, in place.

payload is the page's data, which carries the line patterns and the end-label limit for the page to draw with. figures is each built block with its kind (figure_kind). An ASD or SRS figure on log ordinates goes to log frequency; a figure already there, or one on linear ordinates (a phase, a ratio in decibels), is left on its axes. With shared, the figures of each kind and unit open on the same whole decades (shared_decades).

share_decades

share_decades(figures: Sequence[tuple[Mapping[str, Any], str | None]]) -> None

Give every log-log figure of a kind the same opening window, in whole decades, in place.

Figures are grouped by kind and by their axis labels, which carry the quantity and the unit: an acceleration ASD in g²/Hz and a force ASD are different scales and are never forced onto one. Within a group the window is the union of each figure's opening window (_opening), widened outward to whole decades, at least one decade on each axis. A figure with nothing finite takes no part.