hertzforge.io.setup_convert¶
setup_convert
¶
Conversions between a control test's tables and the analysis objects they describe, written once, both ways.
The control service is configured in its own forms: a Random profile of
breakpoints in g²/Hz, a Sine profile of rows in g, in/s or inches peak
to peak, an SRS target of points in g, a classical pulse of a shape, a
peak in g and a duration in milliseconds, a TWR reference of samples in
the control channel's unit. The analysis side holds the same
requirements as objects, in SI: a Specification, a
SineSweepSpecification, a ShockSpecification, a ClassicalPulse, a
TransientSpecification. Each function here goes one way between them;
the run converter (io.run_convert) uses the same functions to turn a
run's setup into objects, and the seeds (io.seeds) use their inverses
to fill a test's setup from an object.
Units are never implied. Every scale comes from the package's unit code
(units.si_transform): G is one g in m/s², IPS one inch a second
in m/s, INCH one inch in metres; a profile's value in inches peak to
peak is twice the peak displacement. A band in decibels is a ratio of
amplitudes (20 log10) on a Sine profile and an SRS target, and of
densities (10 log10) on a Random profile, as the control service reads
each.
What a test cannot control to is refused with the reason
(ConversionRefused), never adapted: a Random profile is one
autospectrum, so a specification with cross terms or with channels at
different levels is refused; a Sine test plays one tone at one rate on
one law; the SRS module holds one band over its target, at maximax.
Tolerance: a conversion there and back gives the same numbers within
TOLERANCE (relative) and its bands within DB_TOLERANCE; a recognized
classical pulse is within PULSE_TOLERANCE of the waveform it was read
from, as a share of its peak.
Classes:
| Name | Description |
|---|---|
ConversionRefused |
An object a test cannot control to, or a table no analysis object |
Functions:
| Name | Description |
|---|---|
specification_from_random_profile |
A Random profile (its breakpoints in g²/Hz, a level at every row) |
random_profile |
The Random profile a |
sine_tone |
The tone a Sine test plays, as the analysis holds one: a sweep is |
sine_specification_from_profile |
A Sine profile and its test as a |
sine_profile |
The Sine profile and test a |
shock_specification_from_target |
An SRS target (points in g, at the bands' Q) as a |
srs_target |
The SRS target a |
classical_pulse |
A Classical Shock pulse on the wire as a |
shock_pulse |
A |
pulse_waveform |
(time, acceleration in SI) of |
pulse_of_waveform |
The classical pulse a waveform is, and how far the waveform is |
twr_reference |
A record of a |
transient_from_reference |
A TWR reference (samples in |
mixed_parts |
The Mixed Mode parts a mixed specification asks for: the floor |
limit_profile |
A Random limit channel's ceiling ( |
specification_from_limit |
A Random limit channel's ceiling as a |
mimo_reference |
The MIMO Random reference a |
specification_from_mimo_reference |
An inline MIMO Random reference ( |
Classes¶
ConversionRefused
¶
Bases: ValueError
An object a test cannot control to, or a table no analysis object holds, with the reason in words.
Functions:¶
specification_from_random_profile
¶
specification_from_random_profile(profile: Mapping[str, Any], channels: Sequence[str], comment: str = '') -> Any
A Random profile (its breakpoints in g²/Hz, a level at every row)
as the analysis holds a target: a Specification asked of each of
channels, in SI, its alarm band as the warning limits and its abort
band as the abort limits. A row's bands hold from that row to the
next, the profile's own where a row has none, as the control service
reads them.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
When a row gives no level (a slope row: resolve the profile first) or there are no channels. |
random_profile
¶
The Random profile a Specification asks for: its breakpoints in
g²/Hz and its bands as decibels, the inverse of
specification_from_random_profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
Specification
|
Autospectra of acceleration, with no cross term. |
required |
channel
|
str
|
The channel whose autospectrum is the profile. Needed when the channels' autospectra differ. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For an object that is not a random specification, has cross
terms or (unless |
sine_tone
¶
sine_tone(test: Mapping[str, Any], frequencies: Any, target: Any, limits: Mapping[str, Any], columns: int, name: str = 'Tone 1') -> Any
The tone a Sine test plays, as the analysis holds one: a sweep is
one pass across its band in the direction it starts, at its rate on
its law; a dwell holds its frequency for its time. frequencies (Hz)
and target (SI peak) are the profile at its points, limits the
curves {'warning_lower': values, ...} at the same points, each asked
of columns control channels alike.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For a test that is neither a sweep nor a dwell. |
sine_specification_from_profile
¶
sine_specification_from_profile(profile: Mapping[str, Any], test: Mapping[str, Any], channels: Sequence[str], comment: str = '') -> Any
A Sine profile and its test as a SineSweepSpecification: the
rows' values in SI, the bands (a row's own, else the profile's; a
segment takes its left row's, as the control service reads it) as
the tone's warning and abort curves at the rows.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For rows of more than one quantity, which no one tone holds. |
sine_profile
¶
The Sine profile and test a SineSweepSpecification asks for, the
inverse of sine_specification_from_profile.
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For several tones at once, channels asked for different levels, a sweep that changes law or rate or turns back, a dwell inside a sweep, or a quantity a Sine profile does not hold. |
shock_specification_from_target
¶
shock_specification_from_target(target: Mapping[str, Any], bands: Mapping[str, Any], envelope: Mapping[str, Any] | None, channel: str, comment: str = '') -> Any
An SRS target (points in g, at the bands' Q) as a
ShockSpecification at channel, in SI, maximax, its alarm band as
the warning limits and its abort band as the abort limits (amplitude
decibels; the module's defaults where the envelope gives none).
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For a flat target, which has no points, or per-band bands, which are on the module's analysis bands and not on the target. |
srs_target
¶
The SRS target a ShockSpecification asks for: its points in g,
the band they span and their Q, and its bands in decibels, the
inverse of shock_specification_from_target.
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For an object that is not a shock specification, not maximax, not of acceleration, whose channels differ when none is named, or whose bands vary from point to point. |
classical_pulse
¶
A Classical Shock pulse on the wire as a ClassicalPulse: the
peak signed in SI, the duration in seconds, a trapezoid's edge from
its fractions.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For a shape the analysis has no pulse of (haversine, initial-peak sawtooth, rectangle) or a trapezoid whose rise and fall differ. |
shock_pulse
¶
A ClassicalPulse as the Classical Shock pulse on the wire, the
inverse of classical_pulse: shape, amplitude_g, duration_ms,
polarity, and a trapezoid's rise_frac and fall_frac.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For a sawtooth whose fall takes time: the module's terminal-peak sawtooth falls at once. |
pulse_waveform
¶
(time, acceleration in SI) of pulse sampled at rate_hz, with
before durations of quiet before it and after it.
pulse_of_waveform
¶
The classical pulse a waveform is, and how far the waveform is from it as a share of its peak; the shape that fits best.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
When the waveform is not within |
twr_reference
¶
A record of a TimeHistory (or TransientSpecification) as a TWR
reference the control service imports as pasted text: one sample a
line, in units (the control channel's), at fs_hz.
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For units not declared, of another quantity than |
transient_from_reference
¶
transient_from_reference(values: Any, fs_hz: float, units: str, channel: str, comment: str = '') -> Any
A TWR reference (samples in units at fs_hz) as a
TransientSpecification at channel, in SI, time from its first
sample: the inverse of twr_reference.
mixed_parts
¶
The Mixed Mode parts a mixed specification asks for: the floor
(random_profile of the floor), a narrowband part for each of the
floor's narrowbands, and a tone part for each tone of tones (a
SineSweepSpecification, or None), with the width left out around
each tone. The run converter reads a run's parts into the same
objects (run_convert._mixed_parts); this is that reading the other
way.
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For a floor |
limit_profile
¶
A Random limit channel's ceiling (limits[] on the wire, a
response density in g²/Hz at each row) from a Specification record
whose target is that ceiling. A ceiling is a protective number: a
seed never fills it without the operator's typed word.
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For a record that is not an acceleration autospectrum. |
specification_from_limit
¶
A Random limit channel's ceiling as a Specification at dof
whose target is the ceiling, in SI: the inverse of limit_profile.
mimo_reference
¶
The MIMO Random reference a Specification with cross terms asks
for, as the setup takes one inline: through reference_convert.build
(the controller's grid, the checks of Hermitian symmetry and positive
semi-definiteness, the one conjugation from the file's convention to
the controller's), in unit squared per hertz: the specification's
SI densities are divided by si_transform(unit) squared here, and
nowhere else.
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ConversionRefused
|
For an object that is not a random specification, has no cross
term, is not of acceleration, is not on evenly spaced lines, whose
matrix |
specification_from_mimo_reference
¶
specification_from_mimo_reference(reference: Mapping[str, Any], channels: Sequence[str], unit: str = 'g') -> Any
An inline MIMO Random reference (unit squared per hertz, the
controller's convention E[X X^H]) as a Specification in SI and the
file's convention: the inverse of mimo_reference, with no limits.