hertzforge.core.report_caption¶
report_caption
¶
The caption a report plot of a spectrum carries, read off the record.
A spectrum in a report is evidence only when a reader who was not at the test can say what it is. That takes a few lines of text under the plot, and they are the same lines on every plot of a kind: which channel, at which location and in which axis; which run, and which stretch of it; how the spectrum was estimated; the line spacing it was computed at; the window and the overlap of its frames; the degrees of freedom of its average; and the requirement drawn on it. The line spacing and the degrees of freedom are not formalities. A resonance's peak height in an autospectrum depends on the spacing, and how far a line may sit from the reference by chance depends on the degrees of freedom, so without them no two plots can be compared and no excursion can be judged.
Every one of those facts is already held by the record or the objects
around it, so none of them has to be typed. record_caption reads
them into a RecordCaption:
- the channel is the record's DOF and quantity, and the channel table's row for it gives the channel number and its comment; the DOF gives the node and the direction measured, and a geometry gives the global axis that direction is nearest;
- the estimate, the line spacing and the equivalent degrees of freedom
are the spectrum's own (
Psd.statistical_dof, stamped when the spectrum was averaged); a banded spectrum carries the line spacing of the narrowband spectrum it was banded from, and its degrees of freedom are those of the lines each band sums: Satterthwaite's count for a sum of correlated lines, each weighted by the power it puts in the band, with the window's correlation between lines (Averaging.line_correlation), the rulechancejudges summed lines by; - the window, the overlap, the frames and the stretch of the record
are the
Averagingthe spectrum was made with, which a spectrum does not carry itself (Project.averaging_ofgives it from the provenance); - the requirement is the specification drawn with the spectrum: which limits it has, and the overall rms the record measured (and, where the comparison scales the measurement, the rms as drawn) beside the one the specification calls for, over the band it is written.
A shock response spectrum, a sine level and a time history carry
captions of their own kind (caption_kind). srs_caption gives an
SRS's Q, its spacing in lines per octave, the kind of peak, the filters
its run came through, the run's sample rate, and each record drawn
against the points rule in each polarity the project holds.
sine_caption gives a sine level's sweep as the requirement specifies
it, the detector it was extracted with and the distortion check already
made of its tone. time_caption gives a time history's span, the
stretch its averaging reads, its sample rate and each channel's range.
Each caption names its rows (ROWS) and the rows that belong to one
channel (CHANNEL_ROWS), so a grid states the others once.
A fact nothing records is written as "not recorded" rather than left
out, so a reader sees the gap instead of assuming the line was never
needed. Project.caption_of gathers the record's surroundings from a
project and returns the caption; the report draws it under a plot
block that asks for it, and plot.plot_captioned under a saved plot.
Classes:
| Name | Description |
|---|---|
CaptionChannel |
One channel a caption names. |
RecordCaption |
The facts a report plot of a spectrum carries, read off its |
PointsCount |
One measured SRS record against the points rule, as |
SrsCaption |
The facts a report plot of a shock response spectrum carries, |
SineCaption |
The facts a report plot of a sine sweep's extracted level |
TimeCaption |
The facts a report plot of a time history carries, read off its |
Functions:
| Name | Description |
|---|---|
band_dof |
The equivalent degrees of freedom of each band of a banded |
caption_channel |
The channel one record of a spectrum is measured at, with what a |
record_caption |
The caption a report plot of a spectrum carries, read off the |
caption_kind |
Which caption a record carries: 'spectrum' for a measured |
lines_per_octave |
The lines per octave of a geometrically spaced axis, as an SRS's |
srs_caption |
The caption a report plot of a shock response spectrum carries, |
sweep_segments |
Each segment of a specified tone in words: 'logarithmic, 1 oct/min, |
sine_caption |
The caption a report plot of a sine sweep's extracted level |
time_caption |
The caption a report plot of a time history carries, read off the |
Classes¶
CaptionChannel
dataclass
¶
CaptionChannel(dof: str, quantity: str, channel: int | None = None, node: int | None = None, direction: str = '', description: str = '', nearest_axis: str | None = None, axis_angle: float | None = None, against: CaptionChannel | None = None)
One channel a caption names.
dof is the record's DOF string and quantity what it measures
('acceleration'). channel is the channel table's number for it,
and description the table's comment (empty when there is none, or
when it only repeats the DOF); both are None or empty without a
table. node and direction are read from the DOF. nearest_axis
is the signed global axis the measured direction is nearest on the
geometry ('Z+') and axis_angle how far off it the direction sits,
in degrees; both None without a geometry that places the channel.
against is the reference channel of a cross term, read the same
way; None for an autospectrum.
Methods:
| Name | Description |
|---|---|
name |
'channel 3, 110Z+ acceleration', or the DOF and quantity |
place |
The location and the axis: 'node 110 (bracket), Z+ (nearest |
Methods:¶
name
¶
'channel 3, 110Z+ acceleration', or the DOF and quantity alone when no channel table numbers it; a cross term names its reference after it, '1Z+ acceleration against 2Z+ acceleration'.
place
¶
The location and the axis: 'node 110 (bracket), Z+ (nearest global Z+)', and a cross term's reference after it.
RecordCaption
dataclass
¶
RecordCaption(channels: tuple[CaptionChannel, ...], kind: str, run: str | None = None, stretch: tuple[float, float] | None = None, line_spacing: float | None = None, per_octave: int | None = None, window: str | None = None, overlap: float | None = None, frame_length: int | None = None, frames: int | None = None, pooled: tuple[int, ...] | None = None, dof: tuple[float, ...] | None = None, nominal_dof: tuple[int, ...] | None = None, band_dof: tuple[float, float] | None = None, requirement: str | None = None, limits: tuple[str, ...] = (), measured_rms: float | None = None, reference_rms: float | None = None, rms_unit: str = '', rms_band: tuple[float, float] | None = None, scale_db: int = 0, drawn_rms: float | None = None, averaging: Any = None, not_compared: str | None = None)
The facts a report plot of a spectrum carries, read off its
record by record_caption.
Attributes:
| Name | Type | Description |
|---|---|---|
channels |
tuple of CaptionChannel
|
The channels drawn, one per record captioned. |
kind |
str
|
'ASD' for an autospectrum, 'CPSD' for a cross term, 'ASD and CPSD' for a mixture. |
run |
str or None
|
The run the spectrum was computed from: the time history's name or the record's block label. |
stretch |
tuple of float or None
|
The (start, stop) of the stretch of the run averaged, in seconds on the run's clock. |
line_spacing |
float or None
|
The line spacing in Hz; None when the lines are not evenly spaced (and, for a banded spectrum, when the narrowband spectrum it came from is not known). |
per_octave |
int or None
|
Bands per octave of a banded spectrum, None for a narrowband one. |
window |
str or None
|
The window each frame was weighted by. |
overlap |
float or None
|
The overlap of successive frames, a fraction of a frame. |
frame_length |
int or None
|
The samples in a frame. |
frames |
int or None
|
Frames averaged in each record. |
pooled |
tuple of int or None
|
Records of each channel pooled into its average, as a capture saved one record per average is, one count per channel; the channels of one figure need not have the same. |
dof |
tuple of float or None
|
The equivalent statistical degrees of freedom of each channel's average, discounted for overlap; for a banded spectrum, of each narrowband line it was banded from. |
band_dof |
tuple of float or None
|
For a banded spectrum, the (lowest, highest) equivalent degrees
of freedom of its bands over the records captioned
( |
nominal_dof |
tuple of int or None
|
Two per frame averaged, the count without the discount. |
requirement |
str or None
|
The name of the specification drawn, None when none is. |
limits |
tuple of str
|
Which of the specification's limit pairs are drawn: 'warning', 'abort', or both. |
measured_rms, reference_rms |
float or None
|
The overall rms of the one record captioned, as measured, and
the rms the specification calls for, both over the band the
comparison judged ( |
drawn_rms |
float or None
|
The measured rms scaled as it is drawn and judged, where the
comparison scales it ( |
rms_unit |
str
|
The display unit of the two rms values. |
rms_band |
tuple of float or None
|
The (low, high) band in Hz the two rms values are taken over. |
scale_db |
int
|
The decibels the measured curve is drawn scaled by against the
specification ( |
averaging |
Averaging or None
|
The averaging the spectrum was made with, whose |
not_compared |
str or None
|
Why the one record captioned has no rms against the
specification drawn, in words ( |
Methods:
| Name | Description |
|---|---|
rows |
The caption as (label, text) rows, one per |
text |
The caption as one paragraph: each row as 'Label: text', the |
PointsCount
dataclass
¶
PointsCount(kind: str, event: str | None, points: int, inside: int, inside_outer: int | None, passed: bool | None, reason: str | None, missing: int)
One measured SRS record against the points rule, as
compliance.srs_tolerance judged it: its polarity, its event, the
points judged, how many lie inside the inner band and inside the
outer one (None without an outer band), whether it passed (None when
nothing was judged), why no point was judged when none was
(reason), and how many of its points are not a number, which no
rule judges (missing).
Methods:
| Name | Description |
|---|---|
text |
'maximax, shock 1: 40 of 44 points inside the inner band and |
SrsCaption
dataclass
¶
SrsCaption(channels: tuple[CaptionChannel, ...], run: str | None = None, events: tuple[str, ...] = (), q: float = 10.0, kind: str = 'maximax', per_octave: float | None = None, band: tuple[float, float] | None = None, filters: tuple[str, ...] | None = None, sample_rate: float | None = None, requirement: str | None = None, rule: str = '', points: tuple[PointsCount, ...] = (), not_compared: str | None = None)
The facts a report plot of a shock response spectrum carries,
read off its records by srs_caption.
Attributes:
| Name | Type | Description |
|---|---|---|
channels |
tuple of CaptionChannel
|
The channels drawn, each once. |
run |
str or None
|
The time history the spectrum was computed from. |
events |
tuple of str
|
The events of the records drawn, by their block labels. |
q |
float
|
The oscillators' amplification. |
kind |
str
|
Which peak each point is: 'maximax', 'positive' or 'negative'. |
per_octave |
float or None
|
Natural-frequency lines per octave; None when they are not geometrically spaced. |
band |
tuple of float or None
|
The first and last natural frequency, in Hz. |
filters |
tuple of str or None
|
Each filter applied in the project on the way to the run, in the order applied; empty for none, None when the run is not known. |
sample_rate |
float or None
|
The run's sample rate in Hz. |
requirement |
str or None
|
The name of the requirement drawn, None when none is. |
rule |
str
|
The points rule in words, with the band it judges against. |
points |
tuple of PointsCount
|
Each record drawn against the requirement, in each polarity the project holds, the one drawn first. |
not_compared |
str or None
|
Why no record could be read against the requirement drawn. |
Methods:
| Name | Description |
|---|---|
rows |
The caption as (label, text) rows, one per |
text |
The caption as one paragraph, 'Label: text' rows joined by |
SineCaption
dataclass
¶
SineCaption(channels: tuple[CaptionChannel, ...], tone: str = '', run: str | None = None, onset: float | None = None, sweep: tuple[str, ...] | None = None, drift_hz: float = 0.0, cycles: float | None = None, distortion: Any = None)
The facts a report plot of a sine sweep's extracted level
carries, read off its records by sine_caption.
Attributes:
| Name | Type | Description |
|---|---|---|
channels |
tuple of CaptionChannel
|
The control channels drawn. |
tone |
str
|
The tone the level was extracted for. |
run |
str or None
|
The time history the level was extracted from. |
onset |
float or None
|
Seconds into the run where the tone's sweep was found. |
sweep |
tuple of str or None
|
Each segment of the tone as specified, in words: its law, its rate and units, its direction and its span, or a dwell's frequency and duration; None without the requirement. |
drift_hz |
float
|
The sweep-clock correction the extraction applied at the end of the tone, in Hz; 0 for none. |
cycles |
float or None
|
The Vold-Kalman smoothing the level was read with, in cycles of the tone's own frequency; None when it is not recorded. |
distortion |
object
|
The distortion check of this tone ( |
Methods:
| Name | Description |
|---|---|
rows |
The caption as (label, text) rows, one per |
text |
The caption as one paragraph, 'Label: text' rows joined by |
TimeCaption
dataclass
¶
TimeCaption(channels: tuple[CaptionChannel, ...], run: str | None = None, span: tuple[float, float] | None = None, stretch: tuple[float, float] | None = None, sample_rate: float | None = None, ranges: tuple[str, ...] | None = None)
The facts a report plot of a time history carries, read off its
records by time_caption.
Attributes:
| Name | Type | Description |
|---|---|---|
channels |
tuple of CaptionChannel
|
The channels drawn. |
run |
str or None
|
The run: the time history's name. |
span |
tuple of float or None
|
The first and last instant recorded, in seconds. |
stretch |
tuple of float or None
|
The (start, stop) of the stretch analyzed (the record's averaging), in seconds; None when no averaging is set. |
sample_rate |
float or None
|
The sample rate in Hz; None for fewer than two samples or a record not evenly sampled. |
ranges |
tuple of str or None
|
Each channel's measurement range, in words: its full scale from the channel table, or why it has none; None without a table. |
Methods:
| Name | Description |
|---|---|
rows |
The caption as (label, text) rows, one per |
text |
The caption as one paragraph, 'Label: text' rows joined by |
Functions:¶
band_dof
¶
band_dof(frequencies: Any, values: Any, dof: float, correlation: Any, left: Any, right: Any) -> ndarray
The equivalent degrees of freedom of each band of a banded autospectrum, from the narrowband lines it sums.
Each line counts in a band with the power it puts there: its value
times the part of its bin inside the band (octave.resample's
rule). Lines dof each whose estimates vary together by
correlation at 0, 1, 2, ... lines apart (Averaging.line_correlation)
sum to Satterthwaite's count, the rule chance judges summed lines
by: N times dof for N equal, independent lines, fewer under any
window but a rectangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
array_like
|
The narrowband lines, evenly spaced, and the autospectrum on them. |
required |
values
|
array_like
|
The narrowband lines, evenly spaced, and the autospectrum on them. |
required |
dof
|
float
|
The equivalent degrees of freedom of one line. |
required |
correlation
|
array_like
|
The correlation between line estimates, starting at 1. |
required |
left
|
array_like
|
The bands' edges in Hz ( |
required |
right
|
array_like
|
The bands' edges in Hz ( |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
One count per band; NaN for a band no line with power reaches. |
caption_channel
¶
caption_channel(spectrum: Any, record: int, channel_table: Any = None, geometry: Any = None) -> CaptionChannel
The channel one record of a spectrum is measured at, with what a channel table and a geometry add about it.
The table's row is the one whose DOF and channel type match the record's; a row of the right DOF whose type is blank answers when no row matches both, since a drive point's force channel shares its DOF with the acceleration channel beside it and only the type tells them apart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrum
|
DataArray
|
The spectrum. |
required |
record
|
int
|
Which record. |
required |
channel_table
|
ChannelTable
|
The test's channel table. |
None
|
geometry
|
Geometry
|
The geometry the channel is measured on. |
None
|
Returns:
| Type | Description |
|---|---|
CaptionChannel
|
|
record_caption
¶
record_caption(spectrum: Any, records: int | Sequence[int] = 0, *, averaging: Any = None, run: str | None = None, sample_rate: float | None = None, origin: float = 0.0, channel_table: Any = None, geometry: Any = None, narrowband: Any = None, per_octave: int | None = None, specification: Any = None, requirement: str | None = None, scale_db: int | None = None, unit_system: Any = None) -> RecordCaption
The caption a report plot of a spectrum carries, read off the record and the objects around it.
caption = record_caption(psds, 2, averaging=averaging,
run='Run 6', channel_table=table)
caption.text()
Nothing in it is typed: each row is read from the record, its
averaging, the channel table, the geometry and the specification.
Whatever is not given is written as "not recorded" in its row.
Project.caption_of gathers all of these from a project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrum
|
Psd
|
The measured spectrum: an autospectrum or a cross-spectral density, narrowband or banded. A specification is the requirement, not a measurement, and is refused. |
required |
records
|
int or sequence of int
|
The records the plot draws; the caption names each channel and states the settings they share. |
0
|
averaging
|
Averaging
|
The averaging the spectrum was made with (for a banded spectrum, the narrowband one's). It gives the window, the overlap, the frames and the nominal degrees of freedom. |
None
|
run
|
str
|
The run the spectrum was computed from. Defaults to the record's block label, when the records have one. |
None
|
sample_rate
|
float
|
The run's sample rate in Hz; with |
None
|
origin
|
float
|
The run's first instant in seconds, for a run whose clock does not begin at zero. |
0.0
|
channel_table
|
ChannelTable
|
The test's channel table: the channel number and comment. |
None
|
geometry
|
Geometry
|
The geometry the channels are measured on: the global axis each measured direction is nearest. |
None
|
narrowband
|
Psd
|
For a banded spectrum, the narrowband spectrum it was banded from, record for record: its line spacing and degrees of freedom. |
None
|
per_octave
|
int
|
Bands per octave of a banded spectrum; read from its band centers when omitted. |
None
|
specification
|
Specification
|
The requirement drawn with the spectrum. |
None
|
requirement
|
str
|
The specification's name; 'specification' when omitted. |
None
|
scale_db
|
int
|
The decibels the measured curve is drawn scaled by; resolved
the way every comparison resolves it when omitted
( |
None
|
unit_system
|
UnitSystem
|
The display units the rms values are written in; the default system when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
RecordCaption
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If a record is not one of the spectrum's. |
caption_kind
¶
Which caption a record carries: 'spectrum' for a measured Psd,
'srs' for a measured Srs, 'sine' for a SineLevel or a
SineLevelSet, 'time' for a measured TimeHistory; None for
anything else, a requirement among them, since a requirement is
what a measurement is read against and not a measurement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
object
|
The object a figure draws. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
|
lines_per_octave
¶
The lines per octave of a geometrically spaced axis, as an SRS's
natural frequencies are (srs.octave_frequencies), else None: for
an axis of fewer than two lines, one that does not rise from above
zero, or one whose steps are not one ratio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
abscissa
|
array_like
|
The natural frequencies in Hz. |
required |
Returns:
| Type | Description |
|---|---|
float or None
|
|
srs_caption
¶
srs_caption(srs: Any, records: int | Sequence[int] = 0, *, run: str | None = None, sample_rate: float | None = None, filters: Sequence[str] | None = None, channel_table: Any = None, geometry: Any = None, specification: Any = None, requirement: str | None = None, polarities: Sequence[Any] = ()) -> SrsCaption
The caption a report plot of a shock response spectrum carries, read off the records drawn and the objects around them.
caption = srs_caption(srs, [0, 1], run='Drop 3',
specification=spec)
caption.text()
The Q, the kind of peak and the natural frequencies are the
spectrum's own; the run, its sample rate and the filters applied on
the way to it are what Project.caption_of reads from the
provenance. Against a requirement each record drawn is judged by
the points rule as the SRS points check judges it
(compliance.srs_tolerance, paired as compliance.srs_tolerance_all
pairs, its bands read from the requirement's limit curves where it
has them), once in each polarity given: the spectrum drawn, then
each of polarities, a spectrum of the same events at the same Q
holding another peak, record for record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
srs
|
Srs
|
The measured spectrum; a requirement is refused. |
required |
records
|
int or sequence of int
|
The records the plot draws. |
0
|
run
|
str
|
The time history the spectrum was computed from. |
None
|
sample_rate
|
float
|
The run's sample rate in Hz. |
None
|
filters
|
sequence of str
|
Each filter applied on the way to the run, in words; empty for none, None when it is not known. |
None
|
channel_table
|
ChannelTable
|
The channel number and comment. |
None
|
geometry
|
Geometry
|
The global axis each measured direction is nearest. |
None
|
specification
|
ShockSpecification
|
The requirement drawn. |
None
|
requirement
|
str
|
Its name; 'specification' when omitted. |
None
|
polarities
|
sequence of Srs
|
The same records in other polarities; one with another count of records is not the same records, and is passed over. |
()
|
Returns:
| Type | Description |
|---|---|
SrsCaption
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If a record is not one of the spectrum's, or none is asked for. |
sweep_segments
¶
Each segment of a specified tone in words: 'logarithmic, 1 oct/min, ascending 5 Hz to 500 Hz', or 'dwell at 40 Hz for 30 s'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tone
|
SineTone
|
The tone as specified. |
required |
Returns:
| Type | Description |
|---|---|
tuple of str
|
|
sine_caption
¶
sine_caption(levels: Any, records: int | Sequence[int] = 0, *, tone: str | None = None, run: str | None = None, channel_table: Any = None, geometry: Any = None, specification: Any = None, distortion: Any = None) -> SineCaption
The caption a report plot of a sine sweep's extracted level carries, read off the records drawn and the objects around them.
caption = sine_caption(levels, 0, tone='Up', run='Run 2',
specification=spec)
caption.text()
The sweep is the tone as the requirement specifies it, segment by
segment, with the correction the extraction made to its clock; the
detector is the Vold-Kalman filter the extraction tracks each tone
with, and the smoothing a set of levels was read with
(SineLevelSet.cycles). The distortion is a check already made
(sine_distortion.check_distortion), passed in: it rebuilds every
tone on every channel, which is too slow to make for a caption, so
a caption with none says it was not checked. Which sweep of a run's
several this was is not held by a level, so the caption does not
say.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
levels
|
SineLevel or SineLevelSet
|
The extracted level, or the set holding it. |
required |
records
|
int or sequence of int
|
The records (control channels) the plot draws. |
0
|
tone
|
str
|
For a set, the tone drawn; its first when omitted. |
None
|
run
|
str
|
The time history the level was extracted from. |
None
|
channel_table
|
ChannelTable
|
The channel number and comment. |
None
|
geometry
|
Geometry
|
The global axis each measured direction is nearest. |
None
|
specification
|
SineSweepSpecification
|
The requirement drawn, which specifies the sweep. |
None
|
distortion
|
DistortionCheck or str
|
The distortion check of the tone, or why it could not be judged. |
None
|
Returns:
| Type | Description |
|---|---|
SineCaption
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
KeyError
|
If the set holds no tone |
IndexError
|
If a record is not one of the level's, or none is asked for. |
time_caption
¶
time_caption(history: Any, records: int | Sequence[int] = 0, *, run: str | None = None, channel_table: Any = None, geometry: Any = None, unit_system: Any = None) -> TimeCaption
The caption a report plot of a time history carries, read off the records drawn and the objects around them.
caption = time_caption(history, [0, 1], run='Run 4',
channel_table=table)
caption.text()
The span and the sample rate are the record's own, and the stretch
analyzed is its averaging. The range of each channel is its full
scale from the channel table, the level it clips at in its own
units (overload.table_full_scales), so a reader can set a trace's
peaks against it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
TimeHistory
|
The measured record; a transient specification is refused. |
required |
records
|
int or sequence of int
|
The records the plot draws. |
0
|
run
|
str
|
The run's name. |
None
|
channel_table
|
ChannelTable
|
The channel number, comment and range. |
None
|
geometry
|
Geometry
|
The global axis each measured direction is nearest. |
None
|
unit_system
|
UnitSystem
|
The display units the ranges are written in. |
None
|
Returns:
| Type | Description |
|---|---|
TimeCaption
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If a record is not one of the history's, or none is asked for. |