Skip to content

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 Specification asks for: its breakpoints in

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 SineSweepSpecification: the

sine_profile

The Sine profile and test a SineSweepSpecification asks for, the

shock_specification_from_target

An SRS target (points in g, at the bands' Q) as a

srs_target

The SRS target a ShockSpecification asks for: its points in g,

classical_pulse

A Classical Shock pulse on the wire as a ClassicalPulse: the

shock_pulse

A ClassicalPulse as the Classical Shock pulse on the wire, the

pulse_waveform

(time, acceleration in SI) of pulse sampled at rate_hz, with

pulse_of_waveform

The classical pulse a waveform is, and how far the waveform is

twr_reference

A record of a TimeHistory (or TransientSpecification) as a TWR

transient_from_reference

A TWR reference (samples in units at fs_hz) as a

mixed_parts

The Mixed Mode parts a mixed specification asks for: the floor

limit_profile

A Random limit channel's ceiling (limits[] on the wire, a

specification_from_limit

A Random limit channel's ceiling as a Specification at dof

mimo_reference

The MIMO Random reference a Specification with cross terms asks

specification_from_mimo_reference

An inline MIMO Random reference (unit squared per hertz, the

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

random_profile(spec: Any, channel: str | None = None, *, floor: bool = False) -> dict[str, Any]

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

breakpoints (rows of freq_hz and psd_g2_hz, with a row's own alarm_db or abort_db where the bands vary), alarm_db and abort_db (one band for the profile, or None where the bands vary or the specification has no such limit), channel (the channel read), limits (which kinds the specification gave) and notes (what the reading did, in words). With floor the specification is a Mixed Mode floor, and its narrowbands are left to mixed_parts.

Raises:

Type Description
ConversionRefused

For an object that is not a random specification, has cross terms or (unless floor) narrowbands, is not of acceleration, or whose channels differ when no channel is named.

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

sine_profile(spec: Any) -> dict[str, Any]

The Sine profile and test a SineSweepSpecification asks for, the inverse of sine_specification_from_profile.

Returns:

Type Description
dict

rows (freq_hz, quantity, value, with a row's own bands where they vary), alarm_db and abort_db (one band, or None), test (a sweep of one pass at its rate on its law, or a dwell), limits (which kinds the tone gave) and notes.

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

srs_target(spec: Any, channel: str | None = None) -> dict[str, Any]

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

target, bands (f_lo_hz, f_hi_hz, and q when the specification states one), alarm_db and abort_db (or None where it has no such limit), channel, limits and notes.

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

classical_pulse(pulse: Mapping[str, Any]) -> Any

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

shock_pulse(pulse: Any) -> dict[str, Any]

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

pulse_waveform(pulse: Any, rate_hz: float, before: float = 0.5) -> tuple[ndarray, ndarray]

(time, acceleration in SI) of pulse sampled at rate_hz, with before durations of quiet before it and after it.

pulse_of_waveform

pulse_of_waveform(time: Any, values: Any) -> tuple[Any, float]

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 PULSE_TOLERANCE of any of the three shapes.

twr_reference

twr_reference(history: Any, record: int = 0, units: str = 'g') -> dict[str, Any]

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

text, fs_hz, units, samples, channel.

Raises:

Type Description
ConversionRefused

For units not declared, of another quantity than units, an abscissa that is not evenly spaced, or a record too long to send as text.

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

mixed_parts(floor: Any, tones: Any = None, channel: str | None = None) -> dict[str, Any]

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

parts, exclusion_hz (or None), floor (the floor's random_profile), tone_limits ({part id: {'alarm_db', 'abort_db'}} for the tones whose specification gives them), notes.

Raises:

Type Description
ConversionRefused

For a floor random_profile refuses, more parts than the module plays, a tone whose amplitude changes along it, or one of several segments.

limit_profile

limit_profile(spec: Any, channel: int, record: int = 0) -> dict[str, Any]

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

specification_from_limit(limit: Mapping[str, Any], dof: str) -> Any

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

mimo_reference(spec: Any, unit: str = 'g', source: str = 'specification') -> dict[str, Any]

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

reference ({kind: 'inline', freqs_hz, n, re, im}, the upper triangle row by row at each line of the band), channels (the specification's channels, in the reference's order), alarm_db and abort_db (one band per channel, or None where it has no such limit), limits, notes.

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 build refuses, or whose bands vary along a channel.

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.