hertzforge.core.data¶
data
¶
Data arrays: time histories, spectra, FRFs, PSDs.
Every kind has the same structure: one abscissa shared by all records (time or frequency, in SI), an ordinate matrix of shape (records, samples), a response DOF string per record ('101X+'), an optional reference DOF per record (FRFs, cross spectra), and unit information per record.
Units are kept per record, because one measurement set often mixes quantities: a test's time data may hold accelerations, forces, voltages, strains and temperatures together. Each record has:
ordinate_unit[i]: the unit its values were declared in, or None when the source did not say.reference_unit[i]holds an FRF's denominator unit, or a cross spectrum's second unit.ordinate_dim[i]: the dimension tag used for display ('acceleration', 'acceleration/force', ..., or 'unknown').dimension_hint[i]: the kind of quantity the source said this was, kept only for records whose units are undefined.
A record whose unit is unknown keeps the file's raw numbers unchanged.
define_units() converts it to SI once and records the unit, so a wrong
choice can be corrected later by redefining the units instead of
importing again.
What a quantity is and what scale its numbers are on are separate facts,
and a file can give one without the other. A UNV with no dataset 164
still says a channel is an acceleration, but gives no way to tell g from
m/s**2. Such a record is imported undefined (raw values, dimension
'unknown', nothing converted), and dimension_hint keeps the claim.
Nothing is ever scaled by a hint. It limits the units offered when units
are defined by hand, labels a plot axis, and is written back out to a
format that can name a quantity without giving its unit.
Function type codes follow UFF dataset 58 (also used by sdynpy): 1 time response, 4 FRF, 6 coherence, 9 PSD, 12 spectrum, 24 shock response spectrum, 26 multiple coherence. A specification is a PSD with limits, and a shock specification is an SRS with limits; each is saved to a file as its own type.
Classes:
| Name | Description |
|---|---|
DataArray |
Base class; use a concrete subclass (TimeHistory, Spectrum, Frf, Psd). |
TimeHistory |
A measurement against time, as it was acquired. |
Spectrum |
A linear spectrum: amplitude and phase at each frequency line. |
Frf |
Frequency response function: response per unit reference. |
Coherence |
Ordinary coherence: one response against one reference. |
MultipleCoherence |
How much of a response all the references together account for. |
Psd |
Power spectral density. The declared unit is the engineering unit |
Srs |
A shock response spectrum: the peak response of an oscillator at |
Bounded |
Limit curves stored with an ordinate, in the same units. |
Specification |
What a random vibration test was controlled to: a PSD and its |
ShockSpecification |
What a shock test was controlled to: an SRS and its limits. |
TransientSpecification |
What a transient test was controlled to: a target time history. |
TimeComparison |
Two sets of time responses put on one clock, station by station, |
Functions:
| Name | Description |
|---|---|
dof_string |
(101, 3) -> '101Z+': a node and a UFF direction code as a DOF string. |
direction_code |
'Z+' -> 3: a direction string as its UFF code; the inverse of the |
parse_dof |
'101RX+' -> (101, 'RX+'); the inverse of |
same_axis |
Whether two DOFs are one node and one axis, whatever their signs: |
has_phase |
Whether complex values have an imaginary part that was measured, |
channel_quantities |
The (response, reference) quantities a record's dimension names. |
autospectrum |
Whether one record of a spectrum is an autospectrum: a channel |
ordinary_coherence |
The ordinary coherence of one pair of channels at every line, |
frequency_axis |
Read or set how frequency axes are drawn in every plot, 3-D view |
paired_channels |
The channels two densities share, as (signal row, floor row, DOF, |
class_for_function_type |
The data class for a UFF dataset 58 function type code. |
Classes¶
DataArray
¶
DataArray(abscissa: ArrayLike, ordinate: ArrayLike, response_dof: str | Sequence[str], reference_dof: str | Sequence[str] | None = None, ordinate_dim: str | Sequence[str] | None = None, comment: str | Sequence[str] | None = None, ordinate_unit: str | Sequence[str | None] | None = None, reference_unit: str | Sequence[str | None] | None = None, dimension_hint: str | Sequence[str | None] | None = None, block: str | Sequence[str] | None = None)
Base class; use a concrete subclass (TimeHistory, Spectrum, Frf, Psd).
One object holds many records, such as 36 accelerometer channels or
the 2 592 FRFs of a 36-by-72 matrix, all sharing one abscissa.
Everything that varies between records is a list with one entry per
record, so record i is ordinate[i] measured at response_dof[i].
Values are stored in SI once their units are known. A record whose
units were never declared keeps the file's raw numbers and has
ordinate_dim == 'unknown'; what the file said it was, without giving
its unit, is kept in dimension_hint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
abscissa
|
array - like
|
The x axis, in seconds or hertz. |
required |
ordinate
|
array - like
|
The values, shape (records, len(abscissa)); a single record may be one-dimensional. |
required |
response_dof
|
str or sequence of str
|
One DOF string per record, or one string for every record. |
required |
reference_dof
|
str or sequence of str
|
One per record. Required by the kinds that need a reference
( |
None
|
ordinate_dim
|
str or sequence of str
|
The dimension of each record; 'unknown' when omitted. |
None
|
comment
|
str or sequence of str
|
Free text per record. |
None
|
ordinate_unit
|
str or sequence of str
|
The unit each record was declared in. Filled with the SI unit where the dimension is known and no unit is given. |
None
|
reference_unit
|
str or sequence of str
|
The unit each record was declared in. Filled with the SI unit where the dimension is known and no unit is given. |
None
|
dimension_hint
|
str or sequence of str
|
The quantity the source named for each record, kept only where the dimension is unknown. |
None
|
block
|
str or sequence of str
|
A label per record for repeats of the same measurement. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the ordinate's shape does not match the abscissa, a list has the wrong length, a DOF cannot be read, or a needed reference is missing. |
Attributes:
| Name | Type | Description |
|---|---|---|
abscissa |
ndarray
|
The x axis, shared by every record: seconds for a time history, hertz for anything in the frequency domain. It is stored as it arrived, and uneven spacing and out-of-order samples are both allowed, since both occur in real data. Anything that needs an even step (anything with an FFT in it) checks for one when it runs and raises a ValueError saying what is wrong. |
ordinate |
ndarray
|
Shape |
response_dof |
list of str
|
What each record was measured at, as a DOF string ( |
reference_dof |
list of str or None
|
What each record was measured against, for the kinds that have one: the shaker on an FRF, the other channel of a cross spectrum. None where the kind has no reference. |
block |
list of str or None
|
Which repeat of the same measurement each record is: an average, a run, a shock. A short label, not a time. |
ordinate_dim |
list of str
|
The quantity each record measures ( |
ordinate_unit |
list of str or None
|
The unit each record was declared in, such as 'g'. The values are stored in SI whatever the declared unit; a record made with a known dimension and no unit is given the SI unit. None means undeclared. |
reference_unit |
list of str or None
|
The same for the reference of a ratio, so an FRF record has both halves of (m/s²)/N. |
dimension_hint |
list of str or None
|
What the file said a record measures, without giving its unit. Nothing is ever scaled by a hint: it limits the units offered, labels an axis, and is written back out on export. |
comment |
list of str
|
Free text per record, as the source file had it. |
Methods:
| Name | Description |
|---|---|
known_dim |
What quantity record |
units_for |
The (ordinate unit, reference unit) a unit system gives for a |
record_fields |
Each record's description (DOFs, quantity, units, hint, comment |
rename_dof |
Give a channel's coordinate a new name, in place. |
kept |
A copy holding only |
delete_records |
Remove records in place, by index, by DOF, or by capture. |
define_units |
Declare what the ordinate values are in, converting them to SI. |
undefine_units |
Withdraw a units declaration, restoring the file's raw values. |
column_keys |
What tells one record from another besides its response DOF. |
record_label |
A short label for one record, for a legend or an axis. |
record_pair |
The (response, reference) DOFs of record |
log_scaled |
Whether this object's magnitude is drawn on a log axis. |
display_abscissa |
The abscissa converted into a unit system's own units. |
display_ordinate |
The ordinate in display units; records with undefined units are |
display_blocks |
|
save |
Write this object to a |
Attributes¶
num_records
property
¶
How many records this object holds, all sharing its one abscissa.
units_defined
property
¶
Whether every record has its units defined. False while any record still holds the file's unconverted numbers.
undefined_records
property
¶
The indices of the records with no declared dimension, which
hold the file's raw numbers until define_units is called.
Methods:¶
known_dim
¶
What quantity record i holds, whether or not its unit is known.
The dimension when the units are defined, otherwise the dimension hint, otherwise 'unknown'. Do not scale values by this: a hinted record's values are raw, and its scale is what is not known.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
Which record. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The quantity the record holds, falling back to its dimension hint when the unit is undeclared. |
units_for
classmethod
¶
units_for(dimension: str, system: UnitSystem = SI) -> tuple[str, str | None]
The (ordinate unit, reference unit) a unit system gives for a known dimension.
With SI, the default, this is the pair a record is labeled with
when it is made with a known dimension and no unit. With another
system it is the pair a record is labeled with when its values
are written in that system, as the .mat writer does in the
display units. The base class returns no reference unit; Frf
and Psd split the dimension into its two halves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension
|
str
|
An |
required |
system
|
UnitSystem
|
The unit system; SI when omitted. |
SI
|
Returns:
| Type | Description |
|---|---|
tuple of (str, str or None)
|
The ordinate unit and the reference unit, None where the record has no reference. |
record_fields
¶
Each record's description (DOFs, quantity, units, hint, comment and block) as the keyword arguments for making a derived object with the same records. Every list is a copy.
A filter, a truncation and an octave banding keep their source's
records and change only the values. Override comment where the
derived object should say how it was made.
Returns:
| Type | Description |
|---|---|
dict
|
Keyword arguments for a |
rename_dof
¶
Give a channel's coordinate a new name, in place.
A channel is a coordinate and a quantity: a drive point has a
load cell and an accelerometer at one DOF. With quantity given,
only that channel is renamed, so a force labeled at the wrong
node can be moved without moving the accelerometer at the same
node. The channel is renamed wherever it appears, as a response
and as a reference, since a CPSD's accelerometer is on both sides
of its cross terms and is one sensor. A rename that would give
two records the same coordinate and quantity (two accelerometers
at one point) is refused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
str
|
The coordinate as it is, '101Z+'. |
required |
new
|
str
|
The coordinate to give it; normalized the way every DOF is ('101Z' is '101Z+'), and refused when it is not one. |
required |
quantity
|
str
|
Which channel at |
None
|
Returns:
| Type | Description |
|---|---|
int
|
How many DOFs changed, counting a response and a reference
on one record separately; 0 when |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
kept
¶
kept(records: Sequence[int] | None) -> DataArray
A copy holding only records, in the object's order and once
each, with everything each record has (delete_records on the
copy); the object itself when records is None. The records
picked in the tree are what an action reads.
Only the rows kept are copied: the ordinate is sliced, and the object itself is not changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
sequence of int or None
|
Which records to keep, by zero-based index. |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
The copy, of the object's own type, or the object itself for None. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an empty |
IndexError
|
For a record the object does not have. |
delete_records
¶
delete_records(indices: Sequence[int] | None = None, *, dof: str | Sequence[str] | None = None, dim: str | Sequence[str] | None = None, reference: str | Sequence[str] | None = None, capture: int | Sequence[int] | None = None) -> None
Remove records in place, by index, by DOF, or by capture.
Everything a record has is removed with it: its row of the ordinate, its DOFs, units, comment, hint and block, and on a specification its limit curves. Removing every record is refused, since an empty data array cannot be shown. Numbered block labels are renumbered without gaps afterward; named ones are kept.
dof, dim, reference and capture select records by what
they are ("channel 101Z+", "the third run"). Together they select
the records that match all of them, and that selection is added
to any indices given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
sequence of int
|
Which records to remove, by position. |
None
|
dof
|
str or sequence of str
|
Remove the records at these response DOFs. A drive point has
two records at one DOF, a force and an acceleration, and the
DOF alone selects both; add |
None
|
dim
|
str or sequence of str
|
Limit the selection to records whose |
None
|
reference
|
str or sequence of str
|
Remove the records at these reference DOFs: a column of an
FRF matrix, where |
None
|
capture
|
int or sequence of int
|
Remove these captures, numbered as |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the selection matches nothing, would remove every record,
or uses |
IndexError
|
If an index is out of range. |
define_units
¶
define_units(units: str | Sequence[str | None], reference_units: str | Sequence[str | None] | None = None) -> DataArray
Declare what the ordinate values are in, converting them to SI.
units is one unit applied to every record, a sequence with one
entry per record, or a {record index: unit} mapping to set only
some. An entry of None leaves that record as it is. A record that
already has units is converted from its original values, so it is
never scaled twice. The record's dimension is set from the unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
units
|
str, sequence of str, or dict
|
The unit each record's values are in. |
required |
reference_units
|
str, sequence of str, or dict
|
The reference unit, in the same forms: an FRF's denominator (required for an FRF), or a cross spectrum's second channel. Kinds with no reference ignore it. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Self, converted to SI in place. |
Raises:
| Type | Description |
|---|---|
UnitError
|
If a unit cannot be read or names no tracked dimension. |
undefine_units
¶
undefine_units(records: Sequence[int] | None = None) -> DataArray
Withdraw a units declaration, restoring the file's raw values.
The inverse of define_units. The records return to dimension
'unknown' with no unit. There is no unit string that means "not
known", so withdrawing a declaration has its own call. Records
that have no units are left as they are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
sequence of int
|
Which records to revert. All of them when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Self, with the file's raw values restored. |
column_keys
¶
What tells one record from another besides its response DOF.
The reference DOFs when the records are a matrix of measurements, the block labels when they are the same measurement repeated, and None when the response DOF alone identifies a record. An object with column keys is shown as a grid.
record_label
¶
A short label for one record, for a legend or an axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
Which record. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The record's DOF, plus whatever tells it from its neighbors. |
record_pair
¶
The (response, reference) DOFs of record i.
A record with no reference is an autospectrum, a channel against itself, so its reference is its own response DOF (the diagonal, which is what a specification bounds).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
The record. |
required |
Returns:
| Type | Description |
|---|---|
tuple of str
|
Response DOF, reference DOF. |
log_scaled
¶
Whether this object's magnitude is drawn on a log axis.
Logarithmic for frequency-domain data unless the class sets
log_ordinate (a coherence is a ratio from 0 to 1 and is drawn
linear).
Returns:
| Type | Description |
|---|---|
bool
|
True for a log ordinate axis. |
display_abscissa
¶
display_abscissa(unit_system: UnitSystem) -> ndarray
The abscissa converted into a unit system's own units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_system
|
UnitSystem
|
The units to present in. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The abscissa in display units. |
display_ordinate
¶
display_ordinate(unit_system: UnitSystem, records: Iterable[int] | None = None) -> ndarray
The ordinate in display units; records with undefined units are returned unchanged.
Only the records in records are converted, in that order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_system
|
UnitSystem
|
The units to present the values in. |
required |
records
|
iterable of int
|
Which records to convert. All of them when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The values in display units, one row per record asked for. Records with undefined units are unchanged. |
display_blocks
¶
display_blocks(unit_system: UnitSystem, records: Iterable[int] | None = None, block_bytes: int | None = None) -> Iterator[tuple[int, int, ndarray]]
display_ordinate, a block of records at a time.
Yields (start, stop, values): positions within records and the
converted rows for them, each block at most block_bytes
(DISPLAY_BLOCK_BYTES by default). A caller that reduces each
record before drawing it, such as the 3-D view, then never holds
a converted copy of the whole object. A record larger than the
limit is one block on its own; a row is never split.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_system
|
UnitSystem
|
The units to present the values in. |
required |
records
|
iterable of int
|
Which records to convert. All of them when omitted. |
None
|
block_bytes
|
int
|
The most a block may hold, in bytes. |
None
|
Yields:
| Type | Description |
|---|---|
tuple of (int, int, numpy.ndarray)
|
The block's positions among |
save
¶
Write this object to a .hforge file of its own.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
Where to write it; |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
TimeHistory
¶
TimeHistory(abscissa: ArrayLike, ordinate: ArrayLike, response_dof: str | Sequence[str], reference_dof: str | Sequence[str] | None = None, ordinate_dim: str | Sequence[str] | None = None, comment: str | Sequence[str] | None = None, ordinate_unit: str | Sequence[str | None] | None = None, reference_unit: str | Sequence[str | None] | None = None, dimension_hint: str | Sequence[str | None] | None = None, block: str | Sequence[str] | None = None)
Bases: DataArray
A measurement against time, as it was acquired.
Everything else in a random or shock test is computed from a time
history, and the methods that compute it are here: spectra, PSDs, the
full CPSD matrix, FRFs, multiple coherence and shock response
spectra. Settings that say how to process the record are stored on
it, not passed to each call: averaging (the frames a spectrum is
averaged over), shocks (the events an SRS is computed from),
truncation, filtering, sine_extraction and roles. A PSD and
the coherence computed beside it therefore describe the same frames.
Methods:
| Name | Description |
|---|---|
compute_spectra |
The averaged spectrum of every channel. |
amplitude_spectrum |
Every channel's amplitude spectrum: each line scaled so a sine |
channel_key |
What makes record |
suggest_averaging |
Averaging parameters worked out from the record itself. |
default_averaging |
The averaging a view of this record opens with. |
capture_indices |
Which capture each record is: 0 for a channel's first record, |
suggest_truncation |
A truncation that spans the whole record. |
truncate |
This record cut to a span ( |
suggest_sine_extraction |
The sine extraction setting a record starts from: automatic |
suggest_filtering |
A starting low-pass filter at a tenth of the sample rate, |
filter |
This record filtered ( |
resample |
This record at the lower sample rate |
integrate |
One integration: acceleration to velocity, velocity to |
differentiate |
One differentiation: displacement to velocity, velocity to |
rescale |
This record with |
time_statistics |
Read one channel's statistics in the time domain: the |
overload_check |
Read each channel against its range: the samples on the |
srs_windows |
The windows an SRS of this record would be computed over. |
srs_band |
(low, high) in Hz: the band the SRS windows can support. |
compute_srs |
A shock response spectrum for every channel of every shock. |
compute_srs_polarities |
The positive, negative and maximax spectra together, from one |
compute_psds |
One-sided auto-power spectral density per channel, averaged |
psd_type |
The class of a PSD computed from this history. |
srs_type |
The class of an SRS computed from this history: |
compute_cpsds |
The full cross-spectral density matrix, averaged across the |
drive_dofs |
The DOFs this history appears to have been driven at: those |
default_role |
The role a channel measuring |
channel_identities |
Every channel as (DOF, quantity), in order of first record. |
channel_roles |
Every channel's role, {(DOF, quantity): role}. |
reference_channels |
The channels an FRF or a coherence takes as references, as |
response_channels |
The channels an FRF or a coherence explains, as (DOF, quantity) |
compute_frfs |
The frequency response functions, one per response and reference |
compute_multiple_coherence |
How much of each response the references together account for. |
read_partial_coherence |
Which reference explains each response, and whether the |
read_transmissibility |
The ASD-ratio transmissibility of one response over one |
to_sep005 |
This record as SEP 005 timeseries, the sdypy interchange format |
Attributes:
| Name | Type | Description |
|---|---|---|
sample_rate |
float
|
Samples per second, from the abscissa. Raises a ValueError if |
records_per_channel |
dict[tuple[str, str, str | None], int]
|
{channel key: number of records with that key}. |
split_into_frames |
bool
|
Whether the records are already the averages. |
average_counts |
tuple[int, int]
|
(fewest, most) frames any one channel will be averaged over. |
Attributes¶
sample_rate
property
¶
Samples per second, from the abscissa. Raises a ValueError if the samples are not evenly spaced and in order.
records_per_channel
property
¶
{channel key: number of records with that key}.
Usually one. A capture that a controller saved frame by frame has one record per average.
split_into_frames
property
¶
Whether the records are already the averages.
A controller that saves its spectral captures writes each frame as its own record. True when the averaging takes each record whole as one frame and some channel has more than one record. Then the frame length and count are fixed by the file, and only the window is left to choose.
average_counts
property
¶
(fewest, most) frames any one channel will be averaged over.
The two are equal for anything a controller wrote, since it saves every channel the same number of times. They differ only for a history put together by hand from unequal captures, and the table then shows both instead of a number true of only some channels.
Methods:¶
compute_spectra
¶
compute_spectra() -> Spectrum
The averaged spectrum of every channel.
Each of a channel's records (one per average) is transformed with
a one-sided FFT, a rectangular window and no amplitude scaling
(numpy's rfft with norm='backward', so a sine of amplitude A on a
bin reads A*N/2), and the transforms are averaged as a complex
mean. This is the same convention as sdynpy's
TimeHistoryArray.fft. Phase is kept, so content whose phase is
random from frame to frame, such as the response to burst random
excitation, averages toward zero. For lines scaled so a sine
reads its amplitude under a chosen window, with the frames'
magnitudes averaged, see amplitude_spectrum.
Returns:
| Type | Description |
|---|---|
Spectrum
|
One record per channel, with the channel's quantity and units. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the time samples are not evenly spaced and in order. |
amplitude_spectrum
¶
amplitude_spectrum(averaging: Averaging | None = None, *, window: str = 'hann', parameter: float | None = None) -> AmplitudeSpectrum
Every channel's amplitude spectrum: each line scaled so a sine
of amplitude A on it reads A, in peak units, under window, the
frames' magnitudes averaged.
Beside compute_spectra, which is left as it is: that one is
unscaled, rectangular and a complex mean. Here the window's
amplitude correction, N/Σw (×2.000 for Hann), is applied and
stated on the result, and a tone keeps its amplitude in the
average whatever its phase in each frame.
core.amplitude_spectrum.amplitude_spectrum does the reading
and says how; hertzforge.drawing.plot.plot_amplitude_spectrum
draws it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
averaging
|
Averaging
|
How to cut the record into frames: the record's own
|
None
|
window
|
str
|
The window, by any name |
'hann'
|
parameter
|
float
|
The Tukey window's alpha or the Kaiser window's beta. |
None
|
Returns:
| Type | Description |
|---|---|
AmplitudeSpectrum
|
One row per channel, in SI peak units as the record is stored, with the window, its coherent gain and correction, the line spacing and the frames averaged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the samples are not evenly spaced, or the frames do not fit in the record. |
channel_key
¶
What makes record i the same channel as another.
The DOF and what is measured there, never the DOF alone: a drive point has a force record and an acceleration record at the same DOF, and those two are not averages of each other. Spectra, PSDs and the channel counts all group records by this key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
Which record. |
required |
Returns:
| Type | Description |
|---|---|
tuple of (str, str, str or None)
|
The response DOF, the dimension and the dimension hint. Records with the same key are the same channel. |
suggest_averaging
¶
suggest_averaging(**kwargs: Any) -> Averaging
Averaging parameters worked out from the record itself.
A run holds more than the test (the shaker coming up, a
reduced-level check, whatever was still recording afterward), and
this finds the steady stretch to average and as many frames as fit
in it. See hertzforge.core.detect.
A record that already has an averaging, from an import or set by hand, keeps its frame length, window, overlap and detrend; only the start and the number of frames are worked out. A record with none gets the detector's own settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Overrides for individual parameters, such as |
{}
|
Returns:
| Type | Description |
|---|---|
Averaging
|
The suggested averaging. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the detector cannot frame the record. |
default_averaging
¶
default_averaging() -> Averaging
The averaging a view of this record opens with.
The record's own averaging when its start was set (by an import,
a drag or a typed value). Otherwise the result of
suggest_averaging, unless that has fewer frames than the
record's own averaging asks for, in which case the record's own is
used. A record with no averaging that the detector cannot frame
gets each record as one frame.
Returns:
| Type | Description |
|---|---|
Averaging
|
The averaging to show. |
capture_indices
¶
Which capture each record is: 0 for a channel's first record, 1 for its second, and so on.
A channel is a channel_key group. The numbering is the order in
which the PSD and CPSD computations combine the records, so the
capture the averaging view shows is one of those averaged.
Returns:
| Type | Description |
|---|---|
list of int
|
One capture number per record. |
suggest_truncation
¶
A truncation that spans the whole record.
This is the starting position of the truncate view's handles,
not a default that truncate uses: keeping everything changes
nothing, so Truncate Data is refused until a span is set.
Returns:
| Type | Description |
|---|---|
Truncation
|
From the first sample's time to the last's. |
truncate
¶
truncate(truncation: Any = None) -> TimeHistory
This record cut to a span (core.truncate.truncate), using the
history's own truncation unless one is passed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncation
|
Truncation
|
The start and stop, in seconds on the record's own clock.
Defaults to the record's own |
None
|
Returns:
| Type | Description |
|---|---|
TimeHistory
|
The samples inside the span, every channel, with their original times. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no truncation is passed or set. |
suggest_sine_extraction
¶
The sine extraction setting a record starts from: automatic smoothing, chosen from the recording and the specification when the levels are read, with the clock refinement on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specification
|
SineSweepSpecification
|
The sweep the levels would be read against. When given, the
smoothing the automatic setting would choose is worked out
now and stored in the setting as |
None
|
Returns:
| Type | Description |
|---|---|
SineExtraction
|
The default setting. |
suggest_filtering
¶
A starting low-pass filter at a tenth of the sample rate, order 4.
A low-pass, because removing noise above the content is the most
common case; the filter view also offers high-pass and band-pass.
The corner is a choice, not a detection, since nothing in the
record says where its content stops being signal. At a tenth of
the sample rate the integrate and differentiate round trip was
measured at about 2 % RMS error (core.filters), and the corner
is below the mounted-resonance range of a shock accelerometer.
Check it in the filter view before using it.
Returns:
| Type | Description |
|---|---|
Filtering
|
The suggested filter. |
filter
¶
filter(filtering: Any = None) -> TimeHistory
This record filtered (core.filters.filtered): low-pass,
high-pass or band-pass, as the filtering describes, using the
history's own filtering unless one is passed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filtering
|
Filtering
|
The pass-band edges and order. Defaults to the record's
own |
None
|
Returns:
| Type | Description |
|---|---|
TimeHistory
|
Every channel filtered, with zero phase shift. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no filtering is passed or set. |
resample
¶
resample(rate: float, *, anti_alias: bool = True, order: int | None = None) -> TimeHistory
This record at the lower sample rate rate
(core.resample.resample): every channel through a zero-phase
low-pass at the new rate over 2.56, then every q-th sample kept.
core.resample.read_resample reads what the resampling does on
a channel's spectrum, and hertzforge.drawing.plot.plot_resample
draws it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
float
|
The new sample rate, in Hz, a whole division of this record's. |
required |
anti_alias
|
bool
|
Filter before decimating. Without the filter, anything the
record holds above the new Nyquist frequency folds into the
new band, and an |
True
|
order
|
int
|
The anti-alias filter's design order,
|
None
|
Returns:
| Type | Description |
|---|---|
TimeHistory
|
The record at |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the record is not evenly sampled, or |
integrate
¶
integrate(drift_corner: Any = ...) -> TimeHistory
One integration: acceleration to velocity, velocity to
displacement (core.filters.integrate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drift_corner
|
float or None
|
High-pass corner in Hz applied after integrating, so a sensor
bias does not become a ramp. Omitted ( |
...
|
Returns:
| Type | Description |
|---|---|
TimeHistory
|
Acceleration becomes velocity, velocity becomes displacement. Other quantities are left out. |
differentiate
¶
differentiate() -> TimeHistory
One differentiation: displacement to velocity, velocity to
acceleration (core.filters.differentiate).
Returns:
| Type | Description |
|---|---|
TimeHistory
|
The differentiated channels. |
rescale
¶
rescale(factor: float, records: Any = None) -> TimeHistory
This record with records (all of them when omitted)
multiplied by factor, the rest unchanged
(core.rescale.rescaled): the correction for a channel
recorded with the wrong sensitivity, whose factor
core.rescale.sensitivity_factor gives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factor
|
float
|
Finite and not zero; negative flips the sign. |
required |
records
|
sequence of int
|
Which records, counting from zero. |
None
|
Returns:
| Type | Description |
|---|---|
TimeHistory
|
The rescaled record, with this one's clock, channels and settings. |
time_statistics
¶
time_statistics(record: int = 0, **options: Any) -> TimeStatistics
Read one channel's statistics in the time domain: the moments, the crest factor and its peak, the excursions at the peak, the samples on the rail and those not finite, the tails beyond 3, 4 and 5 sigma against the Gaussian's, the crossing rate counted and from the spectrum, the expected largest peak and the kurtosis frame by frame, each judged against its band.
core.time_statistics.record_statistics does the reading, over
the span the kurtosis bars read, and says how;
hertzforge.drawing.plot.plot_time_statistics draws it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
Which channel. |
0
|
**options
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
TimeStatistics
|
Every number, in SI as the record is stored, the bands and the flags. |
overload_check
¶
overload_check(ranges: ChannelTable | ArrayLike | float, **options: Any) -> OverloadCheck
Read each channel against its range: the samples on the rail (a count, a share and a rate), the crest factor, the headroom of the range over the largest peak in dB, and that peak scaled to the next level, each channel judged for the rail, the next level and samples beyond the range.
core.overload.overload_check does the reading, over the span
the kurtosis bars read, and says how;
hertzforge.drawing.plot.plot_overload draws it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ranges
|
(ChannelTable, array_like or float)
|
The channel table describing this record (the level each
channel clips at, |
required |
**options
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
OverloadCheck
|
Every channel's numbers, in SI as the record is stored, its flags and the judgment. |
srs_windows
¶
The windows an SRS of this record would be computed over.
The record's shocks; if it has none, its averaging frames; if it
has neither, the whole record as one window. Every window is
clipped to the record. compute_srs and the shock panel both use
this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shocks
|
sequence of Shock
|
Override windows; the record's own when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
list of Shock
|
The settled windows, clipped to the record. |
srs_band
¶
(low, high) in Hz: the band the SRS windows can support.
The low end is the frequency whose period is the shortest window
(at least 1 Hz), since every curve uses one frequency grid and
the shortest window has to hold a cycle of the lowest frequency.
The high end is a fifth of the sample rate; above it the
ramp-invariant filter would be asked about frequencies the record
cannot resolve. compute_srs uses this band when none is given,
and the shock panel shows it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shocks
|
sequence of Shock
|
Override windows; the record's own when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
tuple of float
|
(low, high) in Hz. |
compute_srs
¶
compute_srs(shocks: Sequence[int] | None = None, low: float | None = None, high: float | None = None, per_octave: int | None = None, q: float | None = None, kind: str = 'maximax') -> Srs
A shock response spectrum for every channel of every shock.
The windows are stored on the history, as the averaging is: pass
shocks to override them. Otherwise the record's shocks are
used, or its averaging frames when it has no shocks, or the whole
record as one window when it has neither (srs_windows). A
specification has neither, and is one window.
There is one curve per channel per event, never an average across
events, because a shock test is judged on the worst shock and the
mean of four shocks describes none of them. The event a curve came
from is in its block label ('shock 2').
The band defaults to srs_band: from the lowest frequency the
shortest window holds a cycle of, up to a fifth of the sample
rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shocks
|
sequence of Shock
|
The windows to use in place of the record's own. |
None
|
low
|
float
|
The natural-frequency band, in Hz. |
None
|
high
|
float
|
The natural-frequency band, in Hz. |
None
|
per_octave
|
int
|
Frequency lines per octave. |
None
|
q
|
float
|
The oscillator amplification; |
None
|
kind
|
str
|
Which peak to keep: 'maximax' (largest magnitude of either sign), 'positive' or 'negative' (reported as a positive magnitude). |
'maximax'
|
Returns:
| Type | Description |
|---|---|
Srs
|
One curve per channel per shock (a |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
compute_srs_polarities
¶
compute_srs_polarities(shocks: Sequence[Any] | None = None, low: float | None = None, high: float | None = None, per_octave: int | None = None, q: float | None = None) -> dict[str, Srs]
The positive, negative and maximax spectra together, from one pass of the filter.
The windows, the band and the curves are those of compute_srs,
which is this call keeping one of the three. Each oscillator's
highest and lowest response come out of the same pass
(srs.peaks), so the three spectra cost what one does, and they
are worth reading together: a shock whose response is nearly all
in one direction shows it as a gap between the positive and the
negative spectrum that the maximax alone hides. The negative
spectrum is reported as a positive magnitude, so the two are
drawn on one log axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shocks
|
sequence of Shock
|
The windows to use in place of the record's own. |
None
|
low
|
float
|
The natural-frequency band, in Hz; |
None
|
high
|
float
|
The natural-frequency band, in Hz; |
None
|
per_octave
|
int
|
Frequency lines per octave; |
None
|
q
|
float
|
The oscillator amplification; |
None
|
Returns:
| Type | Description |
|---|---|
dict of str to Srs
|
'positive', 'negative' and 'maximax', in that order, each one
curve per channel per shock and each carrying its own |
compute_psds
¶
One-sided auto-power spectral density per channel, averaged across the frames.
Welch's method: each frame is windowed and transformed, and Gxx = 2|X|²/(fs·S) with S the sum of the window's squares (N for a rectangular window). DC and Nyquist have no mirror image to fold in and are |X|²/(fs·S), as scipy's welch computes them, so the spectrum sums to the record's mean square. The frames' powers are averaged. Power does not depend on phase, so the random phase of burst random excitation does not affect the result. Values are in (SI unit)²/Hz with dimensions such as 'acceleration**2/frequency'; a channel with undefined units stays undefined, with its hint squared the same way.
Each channel's statistical degrees of freedom, discounted for
overlap (Averaging.statistical_dof), are stored on the result
as Psd.statistical_dof, so the PSD can say what its average
is worth (Psd.confidence_band) without the history beside it,
and how the window ties neighboring lines together
(Averaging.line_correlation) as Psd.line_correlation, so a
sum of adjacent lines can say what it is worth too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
averaging
|
Averaging
|
How to cut the record into frames. Defaults to the record's
own |
None
|
Returns:
| Type | Description |
|---|---|
Psd
|
One auto-power spectral density per channel (a
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the samples are not evenly spaced, or the frames do not fit in the record. |
psd_type
¶
psd_type() -> type[Psd]
The class of a PSD computed from this history.
Psd for an ordinary record. A target's PSD is still a target:
the PSD of a waveform the test article was required to see is the
spectrum it was required to see, so TransientSpecification
overrides this to return Specification. Otherwise a requirement
and a measurement would be two objects of the same class, told
apart only by name.
Returns:
| Type | Description |
|---|---|
type
|
A |
srs_type
¶
srs_type() -> type[Srs]
The class of an SRS computed from this history: Srs, or
ShockSpecification for a target (see psd_type).
Returns:
| Type | Description |
|---|---|
type
|
An |
compute_cpsds
¶
The full cross-spectral density matrix, averaged across the frames: every channel against every channel.
Gxy = 2·conj(X)·Y/(fs·S), not doubled at DC and Nyquist, which
equals compute_psds on the diagonal, where conj(X)·X is |X|².
The cross terms describe how two channels move together, which a
PSD does not.
The records are laid out as an imported matrix is: one record per
(response, reference) pair, row by row, so an n-channel history
gives n² records shown as a grid. A cross term's dimension is the
product of the two, a*b/frequency, and a diagonal term's is
a**2/frequency. Each record's statistical degrees of freedom,
the lesser of its two channels' as compute_psds counts them,
are stored as Psd.statistical_dof.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
averaging
|
Averaging
|
How to cut the record into frames. Defaults to the record's
own |
None
|
Returns:
| Type | Description |
|---|---|
Psd
|
The full cross-spectral matrix, complex, with reference DOFs. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the samples are not evenly spaced, or the frames do not fit in the record. |
drive_dofs
¶
The DOFs this history appears to have been driven at: those
with a force or voltage record (EXCITATION_DIMS).
This is a guess from the quantities alone and only a default. What makes a channel a drive is that the controller had a feedback device on it, which the channel table records and a time history does not.
Returns:
| Type | Description |
|---|---|
list of str
|
The DOFs, each once, in record order. |
default_role
classmethod
¶
The role a channel measuring quantity has when nothing
has said otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
str
|
What the channel measures, as |
required |
Returns:
| Type | Description |
|---|---|
str
|
'reference', 'response' or 'monitor'. |
channel_identities
¶
Every channel as (DOF, quantity), in order of first record.
roles names channels by this pair.
Returns:
| Type | Description |
|---|---|
list of (str, str)
|
One entry per channel. |
channel_roles
¶
Every channel's role, {(DOF, quantity): role}.
The role roles gives, or for a channel it does not name, the
default for the quantity (default_role): a force is a
reference, a motion a response, anything else a monitor. FRFs,
multiple coherence and the grid's Role column all read this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stated
|
bool
|
False gives the defaults alone, ignoring |
True
|
Returns:
| Type | Description |
|---|---|
dict of (str, str) to str
|
Every channel's role, in first-record order. |
reference_channels
¶
The channels an FRF or a coherence takes as references, as (DOF, quantity) pairs.
When references is omitted, the channels whose role is
'reference' (channel_roles). A call may name them instead, as
(DOF, quantity) pairs or by DOF alone. A DOF alone picks the
excitation channel (force or voltage) at that point, the force at
a drive point and not the accelerometer beside it, which is what
a controller computes against; if the point has no excitation
channel, its first channel is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
references
|
sequence of str or (str, str)
|
References to use in place of the roles. |
None
|
Returns:
| Type | Description |
|---|---|
list of (str, str)
|
The reference channels, each once; a name that matches no channel is left out, and the caller says so. |
response_channels
¶
The channels an FRF or a coherence explains, as (DOF, quantity) pairs: every channel that is neither a reference nor a monitor.
With references named by the call, a channel whose role is
'reference' but that the call left out is a response, so a script
asking for one drive of two gets the other as a response. A
monitor is left out either way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
references
|
sequence of str or (str, str)
|
As |
None
|
Returns:
| Type | Description |
|---|---|
list of (str, str)
|
The response channels, in order of first record. |
compute_frfs
¶
compute_frfs(references: Sequence[str] | None = None, averaging: Averaging | None = None, method: str = 'Hv') -> Frf
The frequency response functions, one per response and reference pair.
The three estimators differ in one assumption, where the noise is, and agree wherever there is little noise. They differ most where a measurement is worst, so the estimator is a choice.
H1 assumes the noise is on the response. It is biased low at resonance, where the response is large and the force small, and it is what a controller computes and a modal fit expects.
Gfx = Gff H, so H = Gff^-1 Gfx
With one reference that is Gfx / Gff. With several it is the
MIMO estimate, and the matrix inverse is required: two shakers
driving one test article are correlated, and dividing each
response by each drive separately would credit both with the
same motion. A pseudoinverse is used instead of a solve, because
two shakers can be very nearly the same drive and Gff is then
close to singular; the pseudoinverse gives the least-squares
answer.
H2 assumes the noise is on the reference, and is biased high at
anti-resonance for the same reason. With one reference it is
Gxx / Gxf, one response at a time. With several references it
needs as many equations as unknowns, which holds only when the
system is square (as many responses as references). It is then
the coupled form Gxx * Gfx^-1 (Rocklin, Crowley and Vold,
1985), computed the same way as sdynpy computes it. Because every
response enters one matrix inverse, a channel's H2 depends on
which other channels are in the set (measured at about 0.2 % on
test signals with 5 % noise, more with more noise); H1 and Hv
rows do not. A multi-reference set that is not square is refused;
Hv answers the same question per response for any shape.
Hv, the default, assumes noise on both. It is the total least squares fit: the null direction of
[[Gff, Gfx], [Gxf, Gxx]]
taken as the eigenvector of its smallest eigenvalue, per response and per line. It falls between H1 and H2 (strictly between wherever the coherence is less than one) and needs no claim about which instrument is better. It is the default because a test can rarely make that claim: an accelerometer on a structure and a force cell in the load path both have errors, in different places. A total least squares fit weighs a unit of error on the force against a unit of error on the acceleration, which are not the same thing; that is part of the standard formulation, and it is why Hv is a middle estimate and not a better one.
The FRFs use the same frames compute_psds averages and the same
references compute_multiple_coherence uses, so the coherence
beside an FRF is that FRF's coherence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
references
|
sequence of str or (str, str)
|
The reference channels, by DOF or as (DOF, quantity) pairs
(see |
None
|
averaging
|
Averaging
|
How to cut the record into frames. Defaults to the record's
own |
None
|
method
|
str
|
The estimator: 'Hv', 'H1' or 'H2'. |
'Hv'
|
Returns:
| Type | Description |
|---|---|
Frf
|
One record per response and reference pair, every reference for one response before the next response. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
References
The coupled multi-reference H2 form is Rocklin, Crowley and Vold's; the rest set out the three estimators and their errors.
- Rocklin, G. T., Crowley, J., & Vold, H. (1985). "A comparison of H1, H2 and Hv frequency response functions." Proceedings of the International Modal Analysis Conference (IMAC).
- Ewins, D. J. (2000). Modal Testing: Theory, Practice and Application, 2nd ed. Research Studies Press. Which estimator biases which way, and why the bias is worst exactly where the measurement matters.
- Bendat, J. S., & Piersol, A. G. (2010). Random Data: Analysis and Measurement Procedures, 4th ed. Wiley. The single- and multiple-input frequency response estimates and their errors.
- Van Huffel, S., & Vandewalle, J. (1991). The Total Least Squares Problem: Computational Aspects and Analysis. SIAM. The fit Hv performs, and what it means to weigh error in one measured quantity against error in another.
compute_multiple_coherence
¶
compute_multiple_coherence(references: Sequence[str] | None = None, averaging: Averaging | None = None) -> MultipleCoherence
How much of each response the references together account for.
Ordinary coherence measures what one reference explains; multiple coherence measures what the whole set of references explains at once. In a MIMO test this is the useful measure: two shakers driving one test article are correlated with each other, so a response can have poor coherence with either one alone and still be fully accounted for by the pair.
For a response x and references r,
gamma^2 = (Grx^H Grr^-1 Grx) / Gxx
the power of the best linear prediction of x from all the references at once, divided by the measured power. With one reference it reduces to the ordinary coherence. Values are limited to 0 to 1.
The coherence uses the same frames compute_psds averages, so it
covers the stretch of record the averaging view has set, and the
same references and framing as compute_frfs, so the coherence
beside an FRF is that FRF's coherence. A pseudoinverse is used
instead of a solve, because two shakers can be very nearly the
same drive and the reference matrix is then close to singular.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
references
|
sequence of str or (str, str)
|
The reference channels, by DOF or as (DOF, quantity) pairs
(see |
None
|
averaging
|
Averaging
|
How to cut the record into frames. Defaults to the record's
own |
None
|
Returns:
| Type | Description |
|---|---|
MultipleCoherence
|
One curve per response channel. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no reference or no response channels, or no more averages than references. |
References
The multiple coherence function is standard; these are where it and the bias of an estimate of it are set out.
- Bendat, J. S., & Piersol, A. G. (2010). Random Data: Analysis and Measurement Procedures, 4th ed. Wiley. Multiple-input systems: the multiple coherence function, read as the fraction of a response's power the whole set of references accounts for.
- Carter, G. C., Knapp, C. H., & Nuttall, A. H. (1973). "Estimation of the magnitude-squared coherence function via overlapped fast Fourier transform processing." IEEE Transactions on Audio and Electroacoustics, 21(4), 337-344. doi:10.1109/TAU.1973.1162496 The bias of a coherence estimate against the number of averages, which is why a coherence from too few frames reads high.
read_partial_coherence
¶
read_partial_coherence(references: Sequence[str] | None = None, averaging: Averaging | None = None) -> PartialCoherence
Which reference explains each response, and whether the
references were independent: the partial, reference and virtual
coherence (core.partial_coherence).
Read from the frames compute_multiple_coherence and
compute_frfs use, against the same references, so the
multiple coherence in the reading is that method's, and the
partial coherences are of the FRFs computed beside it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
references
|
sequence of str or (str, str)
|
The reference channels, as for |
None
|
averaging
|
Averaging
|
How to cut the record into frames. Defaults to the record's
own |
None
|
Returns:
| Type | Description |
|---|---|
PartialCoherence
|
Every response against every reference, at every line. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no reference or no response channels, no more averages than references, or a channel holds a sample that is not a finite number in the frames read. |
read_transmissibility
¶
read_transmissibility(response: Any, reference: Any = None, averaging: Averaging | None = None) -> TransmissibilityReading
The ASD-ratio transmissibility of one response over one reference, beside H1, with H1's coherence and random error.
The ratio is the root of the response's autospectrum over the
reference's; H1 is their cross-spectrum over the reference's
autospectrum. The two are tied by the coherence: the ratio is
|H1| over the root of the coherence at every line, so it never
reads under H1, and the gap between them says the coherence is
under one without saying why. Noise on the response lifts the
ratio and leaves H1; noise on the reference pulls H1 down by the
coherence and the ratio by its root, so there the ratio is the
nearer of the two. The error of |H1| follows from the coherence
and the averages (core.transmissibility sets out both). The
three spectra come
from the frames compute_psds averages and compute_frfs
estimates from, so this H1 is compute_frfs(method='H1')'s for
the pair and this coherence the ordinary one
compute_multiple_coherence gives against the one reference.
The error is read at the averages the frames are worth, the
equivalent count discounted for overlap that the PSD's
confidence band uses (Averaging.statistical_dof, half its
equivalent degrees of freedom), not the frames cut; the reading
carries both.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
str or (str, str)
|
The response channel, by DOF or as a (DOF, quantity) pair. |
required |
reference
|
str or (str, str)
|
The input channel, the same way (a DOF alone picks the
excitation channel there, as |
None
|
averaging
|
Averaging
|
How to cut the record into frames. Defaults to the record's
own |
None
|
Returns:
| Type | Description |
|---|---|
TransmissibilityReading
|
H1, the ASD ratio and the coherence at every line, in SI as the record is stored, with the frames and the averages. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is not exactly one reference, the response is not a response channel of this history, a DOF given alone holds more than one quantity, there are fewer than two averages, or either channel holds a sample that is not a finite number in the frames read. |
to_sep005
¶
This record as SEP 005 timeseries, the sdypy interchange format
(io.sep005 reads them back).
timeseries = history.to_sep005('run 4')
Returns the standard's list form: usually one dict, and one per
unit and quantity where the channels mix. The sdypy validator
requires a series' unit_str to be a single string, so
accelerometers and a force gauge cannot be one valid series; the
standard's list of series is for that case. A split series has
its unit in its name, so the series can be told apart.
Values are written as they are held: SI where units are defined,
with unit_str naming the SI unit, and the file's raw numbers
where they are not, with unit_str empty (the standard allows
an empty unit). fs gives the sample rate when the samples are
evenly spaced; otherwise the time vector is written, which
the standard also accepts. quantity is set where the standard
has a letter for what a series measures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A name for the series. Defaults to the first non-empty comment, or 'time history', since a SEP 005 series must be named. |
None
|
Returns:
| Type | Description |
|---|---|
list of dict
|
One SEP 005 timeseries mapping per unit and quantity, each holding every channel of that unit. |
Spectrum
¶
Spectrum(abscissa: ArrayLike, ordinate: ArrayLike, response_dof: str | Sequence[str], reference_dof: str | Sequence[str] | None = None, ordinate_dim: str | Sequence[str] | None = None, comment: str | Sequence[str] | None = None, ordinate_unit: str | Sequence[str | None] | None = None, reference_unit: str | Sequence[str | None] | None = None, dimension_hint: str | Sequence[str | None] | None = None, block: str | Sequence[str] | None = None)
Bases: DataArray
A linear spectrum: amplitude and phase at each frequency line.
It is the complex average of a record's frames, not a power average,
so content whose phase is random from frame to frame averages toward
zero. That makes it suited to a deterministic signal and not to burst
random. A Psd is the power average and does not have that property.
Methods:
| Name | Description |
|---|---|
half_power |
Read Q from the half-power width of the peak nearest |
Methods:¶
half_power
¶
half_power(near: float, record: int = 0, *, within: tuple[float, float] | None = None, warn: bool = True) -> HalfPower
Read Q from the half-power width of the peak nearest near
on one record's magnitude.
core.half_power.read_half_power does the reading and says how;
hertzforge.drawing.plot.plot_half_power draws it on the record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
near
|
float
|
A frequency on the peak to read, in Hz. |
required |
record
|
int
|
Which record. |
0
|
within
|
tuple of float
|
A (low, high) band in Hz whose tallest line is the peak. |
None
|
warn
|
bool
|
Warn a missing crossing or too few lines across the peak as
a |
True
|
Returns:
| Type | Description |
|---|---|
HalfPower
|
The peak's frequency and height (in SI, as the record is stored), its half-power crossings, Q and damping ratio. |
Frf
¶
Frf(abscissa: ArrayLike, ordinate: ArrayLike, response_dof: str | Sequence[str], reference_dof: str | Sequence[str] | None = None, ordinate_dim: str | Sequence[str] | None = None, comment: str | Sequence[str] | None = None, ordinate_unit: str | Sequence[str | None] | None = None, reference_unit: str | Sequence[str | None] | None = None, dimension_hint: str | Sequence[str | None] | None = None, block: str | Sequence[str] | None = None)
Bases: DataArray
Frequency response function: response per unit reference.
Every record has a reference DOF. Units are declared as a response
unit and a reference unit (define_units('g', 'lbf')), and the
dimension is their ratio, such as 'acceleration/force'.
Methods:
| Name | Description |
|---|---|
units_for |
The (response unit, reference unit) a unit system gives for an |
conditioning |
The singular values and condition number of this FRF matrix at |
half_power |
Read Q from the half-power width of the peak nearest |
Methods:¶
units_for
classmethod
¶
units_for(dimension: str, system: UnitSystem = SI) -> tuple[str, str]
The (response unit, reference unit) a unit system gives for an
FRF dimension: 'acceleration/force' in SI is ('m/s**2', 'N').
See DataArray.units_for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension
|
str
|
An |
required |
system
|
UnitSystem
|
The unit system; SI when omitted. |
SI
|
Returns:
| Type | Description |
|---|---|
tuple of (str, str)
|
The response unit and the reference unit. |
conditioning
¶
conditioning(records: Sequence[int] | None = None, *, limit: float | None = None, progress: Callable[[int, int], None] | None = None) -> Conditioning
The singular values and condition number of this FRF matrix at
every line, and the lines where it is ill-conditioned
(core.matrix_checks.read_conditioning).
The records make the matrix of responses by references; two
references or more, every response against every reference, one
unit. Where the condition number is over limit, the drives
reach the responses in nearly the same proportions and an
inverse of this matrix, which a controller makes to drive them,
amplifies the error in it by up to that much.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
sequence of int
|
The records that make the matrix; all of them when omitted. |
None
|
limit
|
float
|
The condition number lines are flagged over;
|
None
|
progress
|
callable
|
Told |
None
|
Returns:
| Type | Description |
|---|---|
Conditioning
|
The singular values at every line, with the condition number, the effective rank and the flagged bands. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an empty selection, one reference, records in different units, or an incomplete matrix. |
half_power
¶
half_power(near: float, record: int = 0, *, within: tuple[float, float] | None = None, warn: bool = True) -> HalfPower
Read Q from the half-power width of the peak nearest near
on one record's magnitude.
core.half_power.read_half_power does the reading and says how;
hertzforge.drawing.plot.plot_half_power draws it on the record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
near
|
float
|
A frequency on the peak to read, in Hz. |
required |
record
|
int
|
Which record. |
0
|
within
|
tuple of float
|
A (low, high) band in Hz whose tallest line is the peak. |
None
|
warn
|
bool
|
Warn a missing crossing or too few lines across the peak as
a |
True
|
Returns:
| Type | Description |
|---|---|
HalfPower
|
The peak's frequency and height (in SI, as the record is stored), its half-power crossings, Q and damping ratio. |
Coherence
¶
Bases: _CoherenceBase
Ordinary coherence: one response against one reference.
UFF dataset 58 function type 6, and multiple coherence has a code of
its own (see MultipleCoherence). The two are separate classes, not
one class with an optional reference: ordinary coherence is a matrix
of pairs and has a reference DOF on every record, while multiple
coherence is one curve per response.
MultipleCoherence
¶
Bases: _CoherenceBase
How much of a response all the references together account for.
One curve per response channel, with no reference DOF, since it is computed over the whole set of references. A Rattlesnake modal survey reports this, and so does its random environment against its control channels. UFF dataset 58 function type 26.
Psd
¶
Bases: _Bands, DataArray
Power spectral density. The declared unit is the engineering unit whose square per hertz the values are in (declare 'g' for g²/Hz).
The class allows complex values because a cross spectrum is complex:
the phase between two channels is most of what a CPSD is for. An
autospectrum is a magnitude squared and real, so an object with no
imaginary content (has_phase) stores a real array, half the size.
interpolation says how values are read between the lines: 'bin'
(constant across each line's bin, drawn as steps) or 'log_log' (a
power law between breakpoints). area, the plots and octave banding
all follow it. scale_db is the decibels added to this spectrum when
it is compared against a specification, and nowhere else; None means
it is detected from the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
As for |
()
|
**kwargs
|
Any
|
As for |
()
|
bandwidth
|
array - like
|
The width of each line's band, for lines that are not evenly spaced (octave bands). Omitted for a narrowband spectrum. |
None
|
Methods:
| Name | Description |
|---|---|
confidence_band |
The chi-square confidence band on this averaged spectrum: two |
confidence_reading |
The chi-square band on each record, as the reading states it: |
is_autospectrum |
Whether a record is an autospectrum, a channel against itself: |
confidence_refusal |
Why this spectrum has no chi-square band, or None when it has |
principal_shapes |
The dominant shape of the cross-spectral matrix at each line, as |
tone_refusal |
Why a tone cannot be read off record |
can_read_tone |
Whether a tone can be read off record |
read_tone |
Read the tone near |
rms_check |
Check one record of this autospectrum against the time history |
area |
The area under one record, over a band or over all of it. |
areas |
|
written |
Which lines hold a value: the finite ones, in one record, or in |
extent |
(low, high), in hertz, of the range this spectrum is written |
as_specification |
This PSD as a specification: the same values, records, units and |
to_octave |
This spectrum integrated onto proportional (octave) bands. |
coherence |
The ordinary coherence of every cross term this CPSD holds: |
conditioning |
The singular values and condition number of this cross-spectral |
realizability |
Whether this cross-spectral matrix is Hermitian and positive |
made_realizable |
A copy with the cross-spectral matrix repaired to the nearest |
units_for |
The (unit, reference unit) a unit system gives for a PSD |
Methods:¶
confidence_band
¶
The chi-square confidence band on this averaged spectrum: two PSDs, the band's lower and upper edges, in this spectrum's units.
Each record's edges are its values times the factors
core.averaging.chi_square_factors gives at its degrees of
freedom, so the band follows the spectrum line for line, and on
log axes it is the spectrum moved down and up by a fixed number
of decibels. The true spectrum lies inside it at the stated
confidence, line by line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
float
|
The confidence, a fraction: 0.90 by default, 0.95 for the stricter band. |
0.9
|
dof
|
float or array - like
|
The statistical degrees of freedom, one number for every
record or one per record. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
tuple of (Psd, Psd)
|
The lower edge and the upper edge, each with this spectrum's records, units and lines. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the spectrum carries no degrees of freedom and none are
given, if it holds cross terms (whose error is not
chi-square), if it is a |
confidence_reading
¶
confidence_reading(level: float = 0.9, dof: float | ArrayLike | None = None) -> list[ConfidenceBand]
The chi-square band on each record, as the reading states it:
one core.averaging.ConfidenceBand per record, holding the
confidence, the degrees of freedom it was worked out at, the two
factors and their decibels (ConfidenceBand.describe puts them
in words), and the edges in this spectrum's units.
The same band confidence_band returns as two PSDs, from the
same counts by the same rule, so a number read here is the edge
drawn on the plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
float
|
The confidence, a fraction: 0.90 by default, 0.95 for the stricter band. |
0.9
|
dof
|
float or array - like
|
The statistical degrees of freedom, one number for every
record or one per record. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
list of ConfidenceBand
|
One per record, in record order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
As |
is_autospectrum
¶
Whether a record is an autospectrum, a channel against itself:
one DOF and one quantity on both sides. Only such a record has a
chi-square band (confidence_band), a tone to read
(tone_refusal) or a chance of reading outside a band
(core.chance).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
Which record; every record must be one when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
|
confidence_refusal
¶
Why this spectrum has no chi-square band, or None when it has
one: confidence_band and confidence_reading raise this as
their ValueError, and the application offers the band only where
it is None.
Two things are refused, whatever count is given. A cross term,
whose magnitude has a different error law, so a band drawn on it
as if chi-square would be a claim nobody computed. And a
Specification, which is a target and not an average, even the
spectrum of a transient specification, which is averaged from a
waveform and carries the count of that averaging: the band says
where the true spectrum of a measurement lies, and a requirement
has no true spectrum other than itself. A missing count is not
refused here, since it can be given (confidence_band's dof).
Returns:
| Type | Description |
|---|---|
str or None
|
The reason, in words, or None. |
principal_shapes
¶
The dominant shape of the cross-spectral matrix at each line, as (dofs, shapes (channels x lines), quantity).
The channels of one quantity form a square Hermitian matrix at
each line. The eigenvector of its largest eigenvalue, scaled by
the square root of that eigenvalue, is the principal operating
deflection shape: each channel's phase relative to the others,
with no reference to choose. quantity picks the channels (the
most common quantity when omitted). A set with no cross records
is refused, since an autospectrum set has no phase (its display
is the envelope), and so is a matrix with missing terms.
Two matrices have no principal shape and are refused too. When every cross term is zero the channels share no phase, and the largest eigenvector is the loudest channel alone (or, with every level equal, whichever channel the eigensolver returns). When the largest eigenvalue is repeated at a line, any mix of its eigenvectors is as dominant as any other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
str
|
Which quantity, for a mixed object. |
None
|
Returns:
| Type | Description |
|---|---|
tuple of (list of str, numpy.ndarray, str)
|
The DOF labels, the dominant shape at each line, and the quantity they are in. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there are no cross records, no record names a quantity, fewer than two channels have the quantity, the matrix is incomplete, every cross term is zero, or the largest eigenvalue is repeated at a line. |
tone_refusal
¶
Why a tone cannot be read off record record, or None when
it can: read_tone raises this as its ValueError, and the
application offers the reading only where it is None.
A tone is read off an autospectrum (a record whose response and reference are one channel, with no phase) on evenly spaced lines; an octave-band spectrum, one written at breakpoints and a cross spectrum are refused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
Which record. |
0
|
Returns:
| Type | Description |
|---|---|
str or None
|
The reason, in words, or None. |
can_read_tone
¶
Whether a tone can be read off record record
(tone_refusal says why not).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
Which record. |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
|
read_tone
¶
read_tone(frequency: float, record: int = 0, *, window: Any = 'hann', parameter: float | None = None, snap: bool = True, warn: bool = True) -> ToneReading
Read the tone near frequency off one record of this
autospectrum, as an amplitude beside the spike it stands at.
The lines the tone leaks into, less the floor beside them, times
the line spacing, are its mean square whatever the spacing and
window; core.tone_readout.read_tone does the reading and says
how, and hertzforge.drawing.plot.plot_tone_readout draws it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequency
|
float
|
A frequency at or near the tone, in Hz. |
required |
record
|
int
|
Which record. |
0
|
window
|
str or Averaging
|
The window this spectrum was averaged with, or the
|
'hann'
|
parameter
|
float
|
The Tukey window's alpha or the Kaiser window's beta, when
|
None
|
snap
|
bool
|
Find the tone's own spike near |
True
|
warn
|
bool
|
Warn a tone between lines, an uneven floor or no tone as a
|
True
|
Returns:
| Type | Description |
|---|---|
ToneReading
|
The tone's amplitude in the square root of this spectrum's
units (SI, as the spectrum is stored), the spike, the floor
and the notes, whose densities are in SI too
( |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a record |
rms_check
¶
rms_check(history: TimeHistory, record: int = 0, *, averaging: Averaging | None = None, threshold_db: float | None = None) -> RmsCheck
Check one record of this autospectrum against the time history it came from: the rms from the area under it beside the record's own rms, and the gap between them in dB.
The area under a density is the mean square of its record, so a
correctly scaled spectrum gives back the record's rms;
core.rms_check.check_record does the check and says how, and
hertzforge.drawing.plot.plot_rms_check draws it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
TimeHistory
|
The record this spectrum was computed from; the channel with this record's DOF and quantity is the one read, every capture of it pooled. |
required |
record
|
int
|
Which record of this spectrum. |
0
|
averaging
|
Averaging
|
How the spectrum was averaged, which sets the span the
record's rms is read over and the frames' own mean square;
|
None
|
threshold_db
|
float
|
The gap, in dB either way, beyond which the two disagree;
|
None
|
Returns:
| Type | Description |
|---|---|
RmsCheck
|
Both rms in the record's unit (SI, as stored), the gap, the frames' own rms when the averaging is known, and the verdict. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a banded spectrum, one written at breakpoints or a cross
spectrum, when |
area
¶
The area under one record, over a band or over all of it.
The record is integrated the way it is drawn, as set by
interpolation: the sum of value times bin width for 'bin', the
exact power-law area for 'log_log'. The area is in the ordinate's
units times hertz, so for a PSD its square root is the RMS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
Which record. |
0
|
low
|
float
|
The band to integrate over. |
None
|
high
|
float
|
The band to integrate over. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
The area under the curve (the mean square, whose root is the RMS); NaN when no line is written. |
areas
¶
area over several bands at once, in one pass over the lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
Which record. |
required |
lows
|
array - like
|
The bands' edges, paired. |
required |
highs
|
array - like
|
The bands' edges, paired. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
One area per band; 0 for a band outside the written lines (for a breakpoint curve with fewer than two usable points, NaN). |
written
¶
Which lines hold a value: the finite ones, in one record, or in
any record when none is named. (Specification.written also
requires a positive value.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
The record; every record when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
A boolean per line. |
extent
¶
(low, high), in hertz, of the range this spectrum is written over.
For a density per bin, the outer edges of the written bins, since
a line covers its whole bin. For a curve between breakpoints, the
outer ends of its compliance.coverage. Octave banding and
comparisons use this range, because a controller's target is
stored on every FFT line to Nyquist but is only written over part
of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
The record; the union over every record when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
tuple of float, or None
|
None when nothing is written above zero hertz. |
as_specification
¶
as_specification() -> Specification
This PSD as a specification: the same values, records, units and bands, as the requirement a measurement is judged against, with no limits.
Some formats have no way to mark a PSD as a requirement (ESCDF's
data types do not), so a target written by another program
arrives as a PSD, and the user marks it with this. A banded PSD is
read per bin, as a banded specification is; otherwise its
frequencies decide whether it is read as a controller's lines or
as breakpoints (Specification.reading_of). Any scale_db is
dropped, since a requirement is not scaled for comparison.
Returns:
| Type | Description |
|---|---|
Specification
|
A copy; this PSD is unchanged. |
to_octave
¶
to_octave(per_octave: int | None = None, low: float | None = None, high: float | None = None) -> Psd
This spectrum integrated onto proportional (octave) bands.
Each band takes the mean-square content that falls in it, divided by its own width, so the area under the spectrum, and so the RMS, is unchanged. Reading the narrowband curve at each band center would lose everything between the centers.
The band grid is fixed (see hertzforge.core.octave): the
frequency range only chooses which bands of that grid are
returned, so two runs banded the same way are on the same bands
whatever their ranges. Bands are whole, so a band the data only
partly covers holds that content averaged over its whole width.
Cross terms stay complex, so a CPSD can be banded as well as a
PSD. scale_db is kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_octave
|
int
|
Bands per octave; |
None
|
low
|
float
|
The frequency range to cover, in hertz. By default, the
range the written bins cover ( |
None
|
high
|
float
|
The frequency range to cover, in hertz. By default, the
range the written bins cover ( |
None
|
Returns:
| Type | Description |
|---|---|
Psd
|
The same power on proportional bands, with |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the spectrum has fewer than two lines above zero hertz. |
coherence
¶
coherence() -> Coherence
The ordinary coherence of every cross term this CPSD holds: |S_pq|² / (S_pp S_qq), from the cross spectrum and the two autospectra.
For an octave-banded CPSD the result is the banded quantity (each band's averaged cross spectrum against its averaged autospectra), and it keeps the bands, so it is drawn flat across each band as the CPSD is. That is not the average of a narrowband coherence over the band, which would weight a band's lines equally whatever their power. Values are limited to 0 to 1. A cross term without both of its autospectra is left out.
Returns:
| Type | Description |
|---|---|
Coherence
|
One record per cross term, response against reference. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the object has no reference DOFs, or no cross term has both its autospectra. |
conditioning
¶
conditioning(records: Sequence[int] | None = None, *, limit: float | None = None, progress: Callable[[int, int], None] | None = None) -> Conditioning
The singular values and condition number of this cross-spectral
matrix at every line (core.matrix_checks.read_conditioning).
Read of the drives' CSD, Gff, it says where the drives are
nearly copies of one another, so that an FRF estimated from them
inverts a matrix that is nearly singular.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
sequence of int
|
The records that make the matrix; all of them when omitted. The channels must be of one quantity. |
None
|
limit
|
float
|
The condition number lines are flagged over;
|
None
|
progress
|
callable
|
Told |
None
|
Returns:
| Type | Description |
|---|---|
Conditioning
|
The singular values at every line, with the condition number, the effective rank and the flagged bands. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an empty selection, no cross terms, channels of different quantities, or an incomplete matrix. |
realizability
¶
realizability(records: Sequence[int] | None = None, *, tolerance: float | None = None, keep_diagonal: bool = True, progress: Callable[[int, int], None] | None = None) -> Realizability
Whether this cross-spectral matrix is Hermitian and positive
semi-definite at every line, so that some set of signals has it,
and the nearest matrix that is
(core.matrix_checks.read_realizability).
A specification that is not cannot be played: no drive gives the control channels those coherences and phases together.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
sequence of int
|
The records that make the matrix; all of them when omitted. |
None
|
tolerance
|
float
|
How far below zero the smallest eigenvalue of the coherence
matrix may lie, as a fraction of the largest;
|
None
|
keep_diagonal
|
bool
|
Whether the repair holds the autospectra where they are. |
True
|
progress
|
callable
|
Told |
None
|
Returns:
| Type | Description |
|---|---|
Realizability
|
The eigenvalues at every line, the verdict, the failing bands, and the repaired matrix. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an empty selection, no cross terms, records some declared in units and some not, one channel, or an incomplete matrix. |
made_realizable
¶
made_realizable(records: Sequence[int] | None = None, *, tolerance: float | None = None, keep_diagonal: bool = True, progress: Callable[[int, int], None] | None = None) -> Psd
A copy with the cross-spectral matrix repaired to the nearest
realizable one at every line that is not
(core.matrix_checks.made_realizable); the lines that are, and
every record's place and units, are unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
sequence of int
|
The records that make the matrix; all of them when omitted. |
None
|
tolerance
|
float
|
As for |
None
|
keep_diagonal
|
bool
|
Hold the autospectra where they are and move only the cross terms. Without it a specification's limits follow each autospectrum that moved. |
True
|
progress
|
callable
|
As for |
None
|
Returns:
| Type | Description |
|---|---|
Psd
|
The repaired copy, of this object's class. |
units_for
classmethod
¶
units_for(dimension: str, system: UnitSystem = SI) -> tuple[str, str | None]
The (unit, reference unit) a unit system gives for a PSD
dimension: 'acceleration2/frequency' in SI is ('m/s2', None),
and a cross term's 'acceleration*force/frequency' is ('m/s**2',
'N'). See DataArray.units_for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension
|
str
|
An |
required |
system
|
UnitSystem
|
The unit system; SI when omitted. |
SI
|
Returns:
| Type | Description |
|---|---|
tuple of (str, str or None)
|
The engineering unit and, for a cross term with two quantities, the second unit. |
Srs
¶
Bases: DataArray
A shock response spectrum: the peak response of an oscillator at each natural frequency.
It is not a spectrum of the shock. Every point is the largest response that a single-degree-of-freedom oscillator of that natural frequency reached while its base was driven by the measured transient: one number from the whole response of one filter. Two shocks with the same SRS can look very different, and an SRS cannot be turned back into a time history, because the phase that produced each peak is not kept.
The abscissa is the oscillator's natural frequency, not a frequency
in the shock, and is drawn on a log axis (log_abscissa): an SRS is
specified at octave-spaced natural frequencies, and on a linear axis
the lowest five octaves would be squeezed against the left edge. The
ordinate is in the quantity the base was measured in, so an
acceleration transient gives an acceleration SRS.
q and kind change what the curve means, so they are stored on
the object: an SRS at Q = 10 and the same shock at Q = 50 are
different curves, and a maximax SRS is not a positive one. See
hertzforge.core.srs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
As for |
()
|
**kwargs
|
Any
|
As for |
()
|
q
|
float
|
The amplification factor; |
None
|
kind
|
str
|
Which peak each point is: 'maximax', 'positive' or 'negative'. |
'maximax'
|
Attributes:
| Name | Type | Description |
|---|---|---|
damping |
float
|
The damping ratio for the amplification factor, 1/(2Q). |
Bounded
¶
Bounded(*args: Any, warning_lower: ArrayLike | None = None, warning_upper: ArrayLike | None = None, abort_lower: ArrayLike | None = None, abort_upper: ArrayLike | None = None, **kwargs: Any)
Limit curves stored with an ordinate, in the same units.
A test is controlled to a target and the tolerance around it: how far the response may go before the controller warns, and how far before it stops. A random vibration specification and a shock specification both have the same four curves, so they are defined once here and mixed into both classes.
The limits are arrays stored with the ordinate, not four more data
objects, so they share the abscissa, the DOFs, the dimensions and
the units, and every unit conversion of the ordinate is applied to
them too. limit() returns one as an object of the underlying kind,
to plot or export.
Limits are per control channel, so a record that is not a control channel has none: its rows are NaN, which plots as a gap and not as a line at zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
As for the underlying class ( |
()
|
**kwargs
|
Any
|
As for the underlying class ( |
()
|
warning_lower
|
array - like
|
The limit curves, each the shape of the ordinate. |
None
|
warning_upper
|
array - like
|
The limit curves, each the shape of the ordinate. |
None
|
abort_lower
|
array - like
|
The limit curves, each the shape of the ordinate. |
None
|
abort_upper
|
array - like
|
The limit curves, each the shape of the ordinate. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a limit's shape differs from the ordinate's. |
Attributes:
| Name | Type | Description |
|---|---|---|
limits |
dict of str to numpy.ndarray
|
The limits given, by name ( |
Methods:
| Name | Description |
|---|---|
limit_area |
The area under one limit curve, integrated the same way as the |
limit_areas |
|
limit |
One limit as an object of the underlying kind ( |
display_limit |
A limit in display units; records with undefined units are |
Attributes¶
Methods:¶
limit_area
¶
limit_area(name: str, record: int = 0, low: float | None = None, high: float | None = None) -> float
The area under one limit curve, integrated the same way as the
specification (its interpolation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
One of |
required |
record
|
int
|
Which record. |
0
|
low
|
float
|
The band to integrate over. |
None
|
high
|
float
|
The band to integrate over. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
The area beneath the limit; NaN when it was never written. |
limit_areas
¶
limit_area over several bands at once; see areas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
One of |
required |
record
|
int
|
Which record. |
required |
lows
|
array - like
|
The bands' edges, paired. |
required |
highs
|
array - like
|
The bands' edges, paired. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
One area per band; all NaN when the limit was never written. |
limit
¶
limit(name: str) -> DataArray | None
One limit as an object of the underlying kind (PLAIN), or None
if that limit is not stored.
The object has the specification's records and units, and its
interpolation where it has one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
One of |
required |
Returns:
| Type | Description |
|---|---|
DataArray or None
|
The limit curve. |
display_limit
¶
display_limit(name: str, unit_system: UnitSystem) -> ndarray | None
A limit in display units; records with undefined units are returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
One of |
required |
unit_system
|
UnitSystem
|
The units to convert to. |
required |
Returns:
| Type | Description |
|---|---|
ndarray or None
|
The limit's values, or None if that limit is not stored. |
Specification
¶
Specification(*args: Any, warning_lower: ArrayLike | None = None, warning_upper: ArrayLike | None = None, abort_lower: ArrayLike | None = None, abort_upper: ArrayLike | None = None, **kwargs: Any)
What a random vibration test was controlled to: a PSD and its limits.
A specification is a PSD in every respect (the same abscissa,
quantity and unit conversions) with the four limit curves of
Bounded, and it inherits from both. By default its points are read
as breakpoints of a power law (interpolation 'log_log'); one
computed from a record, or a target on a controller's lines, is read
per bin.
Methods:
| Name | Description |
|---|---|
reading_of |
How a specification written at these frequencies is read. |
written |
Which lines the requirement is written on: finite and positive, |
as_psd |
This specification as a plain PSD; the inverse of |
to_octave |
This specification integrated onto proportional bands, with its |
Methods:¶
reading_of
staticmethod
¶
How a specification written at these frequencies is read.
'bin', a density per line, for LINES_AT_LEAST or more lines on
an even grid (a controller's target on its FFT lines), and
'log_log', breakpoints of a power law, otherwise. Octave-band and
narrowband specifications are drawn as steps; only a breakpoint
curve is drawn as the power law between its points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
array_like
|
The specification's frequency lines, ascending. |
required |
Returns:
| Type | Description |
|---|---|
str
|
'bin' or 'log_log'. |
written
¶
Which lines the requirement is written on: finite and positive, in one record, or in any record when none is named. A controller writes zero on the lines it did not control, and those lines are not a requirement of zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
int
|
The record; every record when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
A boolean per line. |
as_psd
¶
as_psd(drop_limits: bool = False) -> Psd
This specification as a plain PSD; the inverse of
Psd.as_specification, for a PSD marked as a requirement by
mistake or a target to be driven as a CPSD. Its interpolation
is kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drop_limits
|
bool
|
Leave out the warning and abort limits, which a PSD cannot hold. Without it a specification with limits is refused. |
False
|
Returns:
| Type | Description |
|---|---|
Psd
|
A copy; this specification is unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If it has limits and |
to_octave
¶
to_octave(per_octave: int | None = None, low: float | None = None, high: float | None = None) -> Specification
This specification integrated onto proportional bands, with its warning and abort limits.
The same area rule as Psd.to_octave, applied the way the object
is read. A specification on lines is a density, and each line is
a bin. One written at breakpoints is a power law between them,
and each band takes the exact area under that law
(compliance.log_log_area) over the part of the band the
specification covers, divided by the band's width. The limits go
through the same rule, so a band's warning line has the same
relation to its target as at the breakpoints, and a point that is
not written is a gap in both. Cross terms of a breakpoint
specification are not power laws (the phase is not, and a zero is
a value), so they are read onto a fine log grid as
compliance.record_at reads them and integrated there.
The result is a density per band (interpolation 'bin', with the
bands' widths), which a banded measurement is compared against
band by band. scale_db and any band constraints are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_octave
|
int
|
Bands per octave. |
None
|
low
|
float
|
The band to cover. |
None
|
high
|
float
|
The band to cover. |
None
|
Returns:
| Type | Description |
|---|---|
Specification
|
The same power and the same limits on proportional bands. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the specification is not written over a range of frequencies above zero. |
ShockSpecification
¶
ShockSpecification(*args: Any, warning_lower: ArrayLike | None = None, warning_upper: ArrayLike | None = None, abort_lower: ArrayLike | None = None, abort_upper: ArrayLike | None = None, **kwargs: Any)
What a shock test was controlled to: an SRS and its limits.
It is to Srs what Specification is to Psd. A shock target is
written as a required SRS with a tolerance on each side, usually
+6 dB and -3 dB (a factor of 2 up and 0.707 down), and the limits are
those curves.
A target is written at one Q and read at that Q: a target at Q = 10 says nothing about what the same shock does to a Q = 50 oscillator, so the Q is stored with the target as it is with a measurement.
Methods:
| Name | Description |
|---|---|
from_breakpoints |
A requirement written as breakpoints, read onto the points of |
Methods:¶
from_breakpoints
classmethod
¶
from_breakpoints(frequencies: ArrayLike, levels: ArrayLike, response_dof: str | Sequence[str], *, per_octave: int | None = None, q: float | None = None, kind: str = 'maximax', ordinate_dim: str = 'acceleration', ordinate_unit: str | None = None, warning: tuple[float, float] | None = None, abort: tuple[float, float] | None = None) -> ShockSpecification
A requirement written as breakpoints, read onto the points of its spacing, with its bands as limits.
spec = ShockSpecification.from_breakpoints(
[10.0, 100.0, 2000.0], [10.0, 100.0, 100.0], '101Z+',
ordinate_unit='g', warning=(-1.5, 3.0), abort=(-3.0, 6.0))
A shock requirement is usually written as a few breakpoints
joined by straight lines on log axes (a rising slope in dB per
octave, a knee and a plateau), with its Q, its spacing and its
type stated beside it. The points are the spacing's, from the
first breakpoint up, per_octave to an octave, the last one at
or below the last breakpoint, so every point lies on the curve
the breakpoints draw (compliance.log_interpolate). That
spacing is the one a tolerance is counted at, so a measured
spectrum computed at the same per_octave from the same lowest
frequency lands on the requirement's points. Its last point can
fall past the last breakpoint, where nothing is required, and is
not judged.
Each band, given as dB below and above the requirement, becomes
a pair of limit curves: warning the warning limits and abort
the abort limits. A tolerance written as an inner and an outer
band is the two of them, inner as the warning, outer as abort.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
array - like
|
The breakpoints' frequencies in Hz, increasing. |
required |
levels
|
array - like
|
The level at each breakpoint, one row per channel, in
|
required |
response_dof
|
str or sequence of str
|
The DOF each row is required at. |
required |
per_octave
|
int
|
Points to an octave; |
None
|
q
|
float
|
The amplification the requirement is written at;
|
None
|
kind
|
str
|
The spectrum's type: 'maximax', 'positive' or 'negative'. |
'maximax'
|
ordinate_dim
|
str
|
The quantity the levels are of. |
'acceleration'
|
ordinate_unit
|
str
|
The unit the levels are written in; SI when omitted. |
None
|
warning
|
(float, float)
|
A band in dB below and above the requirement, kept as that pair of limits. |
None
|
abort
|
(float, float)
|
A band in dB below and above the requirement, kept as that pair of limits. |
None
|
Returns:
| Type | Description |
|---|---|
ShockSpecification
|
The requirement on its points, with the limits given. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For fewer than two breakpoints, frequencies that are not positive and increasing, levels that are not positive, a number of level rows other than one or one per DOF, a spacing that is not a whole number of points to the octave, or a band whose lower edge is not below its upper. |
TransientSpecification
¶
TransientSpecification(abscissa: ArrayLike, ordinate: ArrayLike, response_dof: str | Sequence[str], reference_dof: str | Sequence[str] | None = None, ordinate_dim: str | Sequence[str] | None = None, comment: str | Sequence[str] | None = None, ordinate_unit: str | Sequence[str | None] | None = None, reference_unit: str | Sequence[str | None] | None = None, dimension_hint: str | Sequence[str | None] | None = None, block: str | Sequence[str] | None = None)
Bases: TimeHistory
What a transient test was controlled to: a target time history.
This is different from a ShockSpecification, although the two are
often called by each other's names. A shock specification is an SRS,
a required response spectrum, and a controller meets it with any
transient whose SRS falls inside the limits. A transient
specification is a waveform, this acceleration sample by sample, and
the controller inverts the structure's transfer function to
reproduce it.
It is a time history that is a target, and it is compared against another time history (what the test article did), not against limits. It has no limits, since there is no settled convention for a tolerance on a waveform as there is for one on a spectrum.
Its computed spectra are targets too. Its PSD is a Specification
and its SRS a ShockSpecification, both without limits, because the
spectrum of a waveform the test article was required to see is the
spectrum it was required to see. As plain objects they could not be
told from the response's own spectra except by name, and the
comparison would have to be set up by hand instead of by type.
Methods:
| Name | Description |
|---|---|
psd_type |
The class of a PSD of this record: |
srs_type |
The class of an SRS of this record: |
TimeComparison
¶
TimeComparison(abscissa: ArrayLike, ordinate: ArrayLike, response_dof: str | Sequence[str], *, pairs: Sequence[Sequence[Any]], sources: Sequence[str], start: float, stop: float, **kwargs: Any)
Bases: DataArray
Two sets of time responses put on one clock, station by station,
to be scored against each other (core.time_compare).
The records come in pairs: record 2k is pair k's first trace (the
test, by convention) and record 2k + 1 its second (the model), both
on the shared clock core.time_compare.compare chose. pairs says
where each came from, as [first name, record, second name, record];
sources names the time histories compared; start and stop are
the scoring window, in seconds, inside the clock.
It is not a TimeHistory, on purpose. A time history's records at
one DOF and quantity are repeats of one channel, and its spectra
average them; here the two records at a DOF are two different
signals, and averaging a test with its model would give a number
that means nothing. The comparison is read by its scores.
Methods:
| Name | Description |
|---|---|
rename_source |
Follow a source that was renamed, in |
Functions:¶
dof_string
¶
(101, 3) -> '101Z+': a node and a UFF direction code as a DOF string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
int or str
|
The node id. |
required |
direction_code
|
int
|
The UFF direction code (1 to 6 for X+ to RZ+, negative for the minus directions, 0 for none). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The DOF string; just the node when the code is 0 or unknown. |
direction_code
¶
'Z+' -> 3: a direction string as its UFF code; the inverse of the
table dof_string reads.
An unsigned direction means the positive one, which is how DOFs are usually written by hand. Case and surrounding spaces are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
str
|
The direction, such as 'Z+', 'z' or 'RX-'. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The direction code. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the direction is not one of the twelve. |
parse_dof
¶
'101RX+' -> (101, 'RX+'); the inverse of dof_string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The DOF string. |
required |
Returns:
| Type | Description |
|---|---|
tuple of (int or None, str)
|
The node number and the rest of the string. The node is None
when the string does not start with a digit, so a caller can
report the problem instead of failing. A channel's name
( |
same_axis
¶
Whether two DOFs are one node and one axis, whatever their signs: '206X-' and '206X+' are, as are '206X' and '206X-'; '206X+' and '206RX+' are not.
A drive point is often measured with the accelerometer mounted opposite the force, so its response and reference differ only in sign. A DOF that does not parse matches only itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
str
|
The DOF strings. |
required |
b
|
str
|
The DOF strings. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when the nodes are the same and the direction codes are the same in magnitude. |
has_phase
¶
Whether complex values have an imaginary part that was measured, not only round-off from computing them.
The imaginary part counts when its largest magnitude is more than
REAL_FLOOR times the largest real magnitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
array - like
|
The values. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
False for real values or an imaginary part below the floor. |
channel_quantities
¶
The (response, reference) quantities a record's dimension names.
A record's dimension combines its two channels' quantities: an FRF's 'acceleration/force' gives ('acceleration', 'force'), a CPSD cross term's 'acceleration*force/frequency' the same, and a diagonal's 'acceleration**2/frequency' gives ('acceleration', 'acceleration'). A single quantity is paired with itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
str
|
The record's dimension. |
required |
Returns:
| Type | Description |
|---|---|
tuple of (str, str)
|
The response quantity and the reference quantity. |
autospectrum
¶
Whether one record of a spectrum is an autospectrum: a channel against itself, one DOF and one quantity on both sides.
A drive point's force against its acceleration names one DOF twice
and is still a cross term, so the quantities are read too, from the
record's dimension (channel_quantities). What is not an
autospectrum is judged by its coherence and phase, never by its
level: its real part is not the power of either channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
The spectrum. |
required |
record
|
int
|
Which record. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for an autospectrum. |
ordinary_coherence
¶
The ordinary coherence of one pair of channels at every line, |Gpq|² / (Gpp Gqq), from their cross spectrum and their two autospectra.
One statement of the ratio for everything that reads it
(Cpsd.coherence, core.transmissibility), so the coherence beside
a CPSD and the one a transmissibility reading is judged by cannot
differ in how they treat an edge. A ratio of powers cannot exceed
one, so a value a few parts in 1e12 over is the arithmetic and is
held at one, and nothing reads under zero. Where either autospectrum
is not above zero, or any of the three is not a finite number, the
coherence is undefined and is not a number: a line no one drove, a
channel that recorded nothing and a sample that is not a number are
not a coherence of zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gpp
|
array - like
|
The two autospectra, one value per line (the real part is read). |
required |
gqq
|
array - like
|
The two autospectra, one value per line (the real part is read). |
required |
gpq
|
array - like
|
The cross spectrum between them, the same shape. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The coherence, 0 to 1, or not a number where it is undefined. |
frequency_axis
¶
Read or set how frequency axes are drawn in every plot, 3-D view and report figure: 'log', 'linear', or 'default' (each kind of data by its own convention: an SRS on a log axis, the rest linear).
The setting belongs to the session, not to a project, and is not saved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
('log', 'linear', 'default')
|
The choice to make. When omitted, the current one is returned. True and False stand for 'log' and 'linear', None for 'default'. |
'log'
|
Returns:
| Type | Description |
|---|---|
str
|
The setting after the call. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
paired_channels
¶
The channels two densities share, as (signal row, floor row, DOF, quantity).
Channels are matched by (DOF, quantity), never by index or by DOF alone, since a drive point has an accelerometer and a load cell at one DOF. Channels only one side has are left out. Both densities must be on the same frequency lines; neither a ratio nor an overlay means anything across different bins, so that is refused instead of interpolated. The signal-to-noise ratio and the overlay of the two densities both pair channels here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal
|
Psd
|
The two densities, such as a run and its noise floor. |
required |
floor
|
Psd
|
The two densities, such as a run and its noise floor. |
required |
Returns:
| Type | Description |
|---|---|
list of (int, int, str, str)
|
One entry per shared channel. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the frequency lines differ or no channel is shared. |
class_for_function_type
¶
class_for_function_type(code: int) -> type[DataArray]
The data class for a UFF dataset 58 function type code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
int
|
The function type: 1, 4, 6, 9, 12, 24 or 26. |
required |
Returns:
| Type | Description |
|---|---|
type
|
The |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the code is not one of those. |