Skip to content

hertzforge.core

core

The data model: what a test holds. Nothing here uses Qt.

The geometry, the data arrays, the shapes, the channel tables and the computations on them. All of it works the same in a script, in a notebook and in the app, because none of it depends on where it is used; the app displays these objects and does not hold its own copy of them. The guide's The objects describes each kind of object (what it stores, where it comes from, what can be done with it) and links back here for the signatures.

Classes:

Name Description
ChannelTable

Per-channel metadata, in one fixed set of typed columns.

DataArray

Base class; use a concrete subclass (TimeHistory, Spectrum, Frf, Psd).

Frf

Frequency response function: response per unit reference.

Psd

Power spectral density. The declared unit is the engineering unit

ShockSpecification

What a shock test was controlled to: an SRS and its limits.

Specification

What a random vibration test was controlled to: a PSD and its

Spectrum

A linear spectrum: amplitude and phase at each frequency line.

Srs

A shock response spectrum: the peak response of an oscillator at

TimeHistory

A measurement against time, as it was acquired.

TransientSpecification

What a transient test was controlled to: a target time history.

Geometry

Nodes, coordinate systems, elements and element groups.

View

The direction a geometry is viewed from in 3-D: where the eye is,

ShapeSet

Mode shapes over a shared set of DOFs.

Classes

ChannelTable

ChannelTable(columns: Mapping[str, Any] | DataFrame, environments: Mapping[str, Environment] | None = None)

Per-channel metadata, in one fixed set of typed columns.

Parameters:

Name Type Description Default
columns mapping or DataFrame

The columns, by name, each with one entry per channel. Names are read through canonical_name, columns outside COLUMNS are dropped, missing ones take their default, and the values are read leniently (see the module description). The controller's columns (CONTROLLER) are there when the source has any of them, and absent otherwise. A channel type left blank is filled in from the unit when the unit names one.

required
environments mapping of str to Environment

The run's control loops by name, each checked as set_environment checks it.

None

Raises:

Type Description
ValueError

If a column in CORE is missing, or the columns differ in length.

Attributes:

Name Type Description
frame DataFrame

The table, one row per channel, columns in SCHEMA order, then the CONTROLLER columns on a table that carries them. Every cell is text except channel, which is an integer. node is text too, blank where no node was recorded.

environments dict of str to Environment

The control loops, in the order they were set. Empty for a table that describes no controller run. While a table has any, its Control column is the union of their control channels and is set through them (set_control), not directly.

Methods:

Name Description
rule_errors

What the table breaks of the rules a row is checked by on both

set_cell

Write one cell, or refuse a value the column cannot hold.

units_for

The units to offer for this channel, given its declared type.

add_channels

Add blank channels at the end of the table, numbered on from

chosen

The rows of the channels choice picks, in table order.

choices

The CHANNEL_CHOICES that pick a channel, in that order:

delete_channels

Remove the given rows in place. At least one row must remain.

add_controller_settings

Convert the table to carry the settings a controller runs each

remove_controller_settings

Drop the controller's columns (CONTROLLER), and nothing else:

orientation

One channel's measured direction on a geometry.

derived_cells

The derived columns' cells for one row, as text.

dof_strings

Each channel's degree of freedom, as '101Z+' strings: the node

rename_dof

Give the channel at coordinate old the coordinate new, in

identities

Each row as the (DOF, quantity) channel of history it names.

roles

Each channel's declared role ('reference', 'response' or

controls

Which channels are control channels, as a boolean per row.

controls_for

The control channels a reference over dofs was held at, as

drives

Which channels the environment drove, as a boolean per row.

rows_of

The rows of the given channel numbers, in the given order.

set_environment

Record a control loop, or replace the one of that name.

remove_environment

Forget a control loop. The Control column keeps what it

set_control

Check or clear Control on one channel for one environment.

transformation

A control loop's transformation as a labeled matrix.

transformed_responses

What a control loop's response transformation made of a

types

Each channel's type (what it measures), '' where undeclared.

sensitivities

Each channel's sensitivity in mV per engineering unit, NaN where

daq_ranges

Each channel's DAQ input range in volts, NaN where unstated.

sensor_ranges

Each sensor's full-scale output in volts, NaN where unstated.

clip_ranges

The level each channel clips at, in volts: the smaller of its

save

Write the table to a file of its own, in the .hforge format.

Attributes
num_channels property
num_channels: int

How many channels the table describes, one per row.

column_names property
column_names: list[str]

The table's column names, in order (title_of gives the headers shown).

has_controller_settings property
has_controller_settings: bool

Whether the table carries the controller's columns (CONTROLLER).

Methods:
rule_errors
rule_errors() -> list[str]

What the table breaks of the rules a row is checked by on both sides of the program, beyond what one cell can say (schema/PROTOCOL.md, "Channel Table"): a sensitivity of 0 on an enabled row that is not a drive, and a negative sensitivity on any enabled row (a channel read inverted says so in its polarity column). A table without the controller's columns has every row on and none a drive. Empty when it breaks none.

Returns:

Type Description
list of str

One sentence per finding, naming the channel.

set_cell
set_cell(name: str, row: int, value: object) -> None

Write one cell, or refuse a value the column cannot hold.

A unit that is not of the channel's declared type is refused; change the type first. Changing the type clears a unit of another kind. A model in the sensor catalog (core.sensor_catalog) fills a blank Make with its maker; a make already written is kept. A triaxial accelerometer's model or serial number is written once: the other acceleration rows at its node, its other legs, get its Make, Model and Serial Number where theirs are blank (and their model is blank or the same). A row of another type at that node, a force gauge, is never filled.

Parameters:

Name Type Description Default
name str

The column to write.

required
row int

Which channel.

required
value object

The value, refused if the column cannot hold it.

required

Returns:

Type Description
None

Raises:

Type Description
KeyError

If there is no column name.

ValueError

If the value cannot be read for that column, repeats a channel number, or disagrees with the channel's type.

units_for
units_for(row: int) -> list[str]

The units to offer for this channel, given its declared type.

Parameters:

Name Type Description Default
row int

Which channel.

required

Returns:

Type Description
list of str

The shortlist for the declared type, or every unit in every shortlist when the type is blank.

add_channels
add_channels(count: int = 1) -> list[int]

Add blank channels at the end of the table, numbered on from the highest channel in it (from 1 in an empty table).

Every other cell takes its column's default, so the node, direction and unit are blank until they are typed in.

Parameters:

Name Type Description Default
count int

How many channels to add.

1

Returns:

Type Description
list of int

The new channels' numbers.

Raises:

Type Description
ValueError

If count is less than 1.

chosen
chosen(choice: str = 'all') -> list[int]

The rows of the channels choice picks, in table order.

Parameters:

Name Type Description Default
choice str

One of CHANNEL_CHOICES: 'control' for the channels with Control checked, whatever their role, or a role.

'all'

Returns:

Type Description
list of int

The rows.

Raises:

Type Description
ValueError

If choice is not one of CHANNEL_CHOICES.

choices
choices() -> list[str]

The CHANNEL_CHOICES that pick a channel, in that order: 'all' always, then 'control' when a channel has Control checked, then each role a channel holds.

delete_channels
delete_channels(indices: Sequence[int]) -> None

Remove the given rows in place. At least one row must remain.

Parameters:

Name Type Description Default
indices sequence of int

Which rows to remove.

required

Returns:

Type Description
None

Raises:

Type Description
IndexError

If an index is out of range.

ValueError

If every row would be removed.

add_controller_settings
add_controller_settings() -> None

Convert the table to carry the settings a controller runs each channel at: the CONTROLLER columns, added after the others.

Nothing the table holds changes, and a table that has them already is left as it is. The new columns start from what the table says: every channel on, none a drive; the control channels are already the Control column's and a reference its role of reference, since a channel's role in the loop is read from those; and each input's full scale in its own unit is its clip level in volts over its sensitivity, where both are stated. The rest start blank: unbound, no IEPE, positive polarity, no control group and no abort limits.

Returns:

Type Description
None
remove_controller_settings
remove_controller_settings() -> None

Drop the controller's columns (CONTROLLER), and nothing else: the table describes the measurement alone again. A table without them is left as it is.

Returns:

Type Description
None
orientation
orientation(row: int, geometry: Any) -> tuple[ndarray | None, str | None, float | None]

One channel's measured direction on a geometry.

The row's DOF (node and direction) is read through the coordinate system its node is measured in (Geometry.dof_direction). The result is that direction as a unit vector in the geometry's global system, the signed global axis nearest it ('X+', 'Z-'), and the angle between the two in degrees. These are the values the derived columns show.

Parameters:

Name Type Description Default
row int

The channel's row.

required
geometry Geometry

The geometry the channel is measured on.

required

Returns:

Type Description
tuple

(vector, axis, angle), each None when the geometry is None or cannot place the channel: the node is not on it, the direction is missing, or the node is measured in a coordinate system that turns with position.

derived_cells
derived_cells(row: int, geometry: Any) -> list[str]

The derived columns' cells for one row, as text.

The three components of the direction to three decimals, the nearest axis, and the angle to a tenth of a degree; all empty when the geometry cannot place the channel.

Parameters:

Name Type Description Default
row int

The channel's row.

required
geometry Geometry

The geometry the channel is measured on.

required

Returns:

Type Description
list of str

One cell per DERIVED_COLUMNS entry.

dof_strings
dof_strings() -> list[str]

Each channel's degree of freedom, as '101Z+' strings: the node and direction cells joined, so a missing one is left out.

rename_dof
rename_dof(old: str, new: str, quantity: str | None = None) -> int

Give the channel at coordinate old the coordinate new, in place, by rewriting its node and direction cells.

This is the same correction as DataArray.rename_dof, made in the table that names the channels. Only the channels at old that match quantity are changed, not every channel at the node.

Parameters:

Name Type Description Default
old str

The coordinate as the table has it, '101Z+'.

required
new str

The coordinate to give it: a node number then a direction, normalized as every DOF is. It is refused if either part is missing, although a table row may lack one.

required
quantity str

Which channel at old, by its type, or the quantity its unit names when it has none ('acceleration', 'force' and so on; 'unknown' where neither says). Every channel at the coordinate when omitted.

None

Returns:

Type Description
int

How many channels changed; 0 when new equals old.

Raises:

Type Description
ValueError

If new is not a whole DOF, or no channel matches.

identities
identities(history: Any = None) -> list[Any]

Each row as the (DOF, quantity) channel of history it names.

The row's channel type is the quantity, the same word a time history's ordinate_dim uses. A row with no channel type names the history's channel at its DOF when there is exactly one there. A row that names none of the history's channels is None.

Parameters:

Name Type Description Default
history TimeHistory

The recording the table describes. Without one, each row's own (DOF, type) is returned.

None

Returns:

Type Description
list of (str, str) or None

One entry per row.

roles
roles() -> list[str]

Each channel's declared role ('reference', 'response' or 'monitor'), '' where undeclared.

controls
controls(environment: str | None = None) -> ndarray

Which channels are control channels, as a boolean per row.

Parameters:

Name Type Description Default
environment str

One of environments: that loop's control channels. Left out, the Control column, which is the union of every environment's when the table has any.

None

Returns:

Type Description
ndarray

True where the channel is a control channel, one per row.

Raises:

Type Description
ValueError

If there is no environment of that name.

controls_for
controls_for(dofs: Sequence[Any]) -> ndarray

The control channels a reference over dofs was held at, as a boolean per row.

A reference belongs to the loop that controlled what it is over: a transformed loop's rows ('1', '2', ...), or another loop's control channels. With no environments, or one, that is the Control column (controls). With several, it is the one loop the DOFs name; where none or more than one is named, no channel is flagged, so a reader falls back to the reference's own pairing rather than taking every loop's controls.

Parameters:

Name Type Description Default
dofs sequence

The reference's DOFs, compared as text.

required

Returns:

Type Description
ndarray

True where the channel is a control channel of that loop.

drives
drives(environment: str) -> ndarray

Which channels the environment drove, as a boolean per row.

Parameters:

Name Type Description Default
environment str

One of environments.

required

Returns:

Type Description
ndarray

True where the channel is one of that loop's drives.

Raises:

Type Description
ValueError

If there is no environment of that name.

rows_of
rows_of(numbers: Sequence[int]) -> list[int]

The rows of the given channel numbers, in the given order.

Parameters:

Name Type Description Default
numbers sequence of int

Channel numbers (the channel column).

required

Returns:

Type Description
list of int

Their rows.

Raises:

Type Description
ValueError

If a number is no channel of the table.

set_environment
set_environment(name: str, environment: Environment) -> None

Record a control loop, or replace the one of that name.

Parameters:

Name Type Description Default
name str

The environment's name, as the controller names it.

required
environment Environment

Its channels and matrices. Every channel number must be a channel of the table, listed once; a response transformation must be two-dimensional with one column per control channel, and a reference transformation one per drive.

required

Returns:

Type Description
None

Raises:

Type Description
ValueError

If the name is blank or any of that fails. Nothing is recorded then.

remove_environment
remove_environment(name: str) -> None

Forget a control loop. The Control column keeps what it showed, which a table without environments may then edit.

Parameters:

Name Type Description Default
name str

The environment to forget.

required

Returns:

Type Description
None

Raises:

Type Description
ValueError

If there is no environment of that name.

set_control
set_control(environment: str, row: int, value: object) -> None

Check or clear Control on one channel for one environment.

A channel checked joins the loop's control channels, after the ones it has; cleared, it leaves them. The Control column follows as the union.

Parameters:

Name Type Description Default
environment str

Which loop.

required
row int

Which channel.

required
value object

True or False, in any spelling Control accepts.

required

Returns:

Type Description
None

Raises:

Type Description
ValueError

If there is no such environment, the flag cannot be read, or the environment transforms its control channels: the matrix's columns are those channels, so it is set with them (set_environment), not one at a time.

transformation
transformation(environment: str, form: str = 'response') -> MatrixAt

A control loop's transformation as a labeled matrix.

Parameters:

Name Type Description Default
environment str

Which loop.

required
form str

'response' for the matrix over its control channels, applied to what they measure, or 'reference' for the one over its drives, applied to the drive signals.

'response'

Returns:

Type Description
MatrixAt

The rows numbered from 1, as the controller's records of them are named, and a column per control (or drive) channel headed by its DOF, in the controller's order.

Raises:

Type Description
ValueError

If there is no such environment, or it holds no such transformation.

transformed_responses
transformed_responses(history: Any, environment: str) -> Any

What a control loop's response transformation made of a recording: its rows, as the controller computed them, as a time history of their own.

The controller applies the matrix to every frame of its control channels in their engineering units and controls the rows in their place, so its specification and spectra are over the rows. The rows are computed the same way here, from each control channel's values in its own stated unit, frame by frame when the recording holds one record per frame. A row is in the control channels' unit when they all share one; over a mix of units its values are numbers in no unit, left undeclared rather than labelled with a guess.

Parameters:

Name Type Description Default
history TimeHistory

The recording, with a record of every control channel.

required
environment str

Which loop.

required

Returns:

Type Description
TimeHistory

A record per row and frame, rows numbered from 1 as the controller's own records of them are, each a response, on the recording's clock and with its averaging.

Raises:

Type Description
ValueError

If the loop holds no response transformation, or the recording lacks a control channel or holds a different number of records of two of them.

types
types() -> list[str]

Each channel's type (what it measures), '' where undeclared.

sensitivities
sensitivities() -> ndarray

Each channel's sensitivity in mV per engineering unit, NaN where undeclared.

daq_ranges
daq_ranges() -> ndarray

Each channel's DAQ input range in volts, NaN where unstated.

sensor_ranges
sensor_ranges() -> ndarray

Each sensor's full-scale output in volts, NaN where unstated.

clip_ranges
clip_ranges() -> ndarray

The level each channel clips at, in volts: the smaller of its DAQ range and its sensor range, whichever is stated, NaN where neither is.

save
save(path: str | PathLike) -> None

Write the table to a file of its own, in the .hforge format.

Parameters:

Name Type Description Default
path str or PathLike

Where to write it; .hforge is added when the suffix is not there.

required

Returns:

Type Description
None

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 (Frf).

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 (records, len(abscissa)). Complex where the subclass says so (complex_ordinate), real otherwise.

response_dof list of str

What each record was measured at, as a DOF string ('101X+').

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 ('acceleration', 'force'), or 'unknown' while its units are undeclared.

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 i holds, whether or not its unit is known.

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 records, in the object's order and once

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 i.

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

display_ordinate, a block of records at a time.

save

Write this object to a .hforge file of its own.

Attributes
num_records property
num_records: int

How many records this object holds, all sharing its one abscissa.

units_defined property
units_defined: bool

Whether every record has its units defined. False while any record still holds the file's unconverted numbers.

undefined_records property
undefined_records: list[int]

The indices of the records with no declared dimension, which hold the file's raw numbers until define_units is called.

Methods:
known_dim
known_dim(i: int) -> str

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 ordinate_dim, such as 'acceleration'.

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
record_fields() -> dict[str, Any]

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 DataArray constructor, without the abscissa and ordinate.

rename_dof
rename_dof(old: str, new: str, quantity: str | None = None) -> int

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 old: 'acceleration', 'force' and so on, as channel_quantities names a record's factors. When omitted, every quantity at the coordinate is renamed.

None

Returns:

Type Description
int

How many DOFs changed, counting a response and a reference on one record separately; 0 when new equals old.

Raises:

Type Description
ValueError

If new is not a DOF, no record matches, or the rename would put two channels of one quantity at one coordinate.

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 records.

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 dim to select one.

None
dim str or sequence of str

Limit the selection to records whose ordinate_dim is one of these ('force', 'acceleration', ...).

None
reference str or sequence of str

Remove the records at these reference DOFs: a column of an FRF matrix, where dof is a row.

None
capture int or sequence of int

Remove these captures, numbered as capture_indices numbers them (each channel's n-th recording). Time histories only.

None

Returns:

Type Description
None

Raises:

Type Description
ValueError

If the selection matches nothing, would remove every record, or uses reference or capture on a kind that has none.

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
column_keys() -> list[str] | None

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
record_label(i: int) -> str

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
record_pair(i: int) -> tuple[str, str]

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
log_scaled() -> bool

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 records, and its values in display units.

save
save(path: str | PathLike) -> None

Write this object to a .hforge file of its own.

Parameters:

Name Type Description Default
path str or PathLike

Where to write it; .hforge is added when the suffix is not there.

required

Returns:

Type Description
None

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 near

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 ordinate_dim, such as 'acceleration/force'.

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; core.matrix_checks.CONDITION_LIMIT when omitted.

None
progress callable

Told (0, core.progress.BUSY) before the decomposition; the app's progress bar uses it.

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 HalfPowerWarning; the notes are on the reading either way.

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.

Psd

Psd(*args: Any, bandwidth: ArrayLike | None = None, **kwargs: Any)

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 DataArray.

()
**kwargs Any

As for DataArray.

()
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 record, or None when

can_read_tone

Whether a tone can be read off record record

read_tone

Read the tone near frequency off one record of this

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

area over several bands at once, in one pass over the lines.

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
confidence_band(level: float = 0.9, dof: float | ArrayLike | None = None) -> tuple[Psd, Psd]

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 statistical_dof.

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 Specification (a target, not an average: confidence_refusal), or if a count or the level is out of range.

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 statistical_dof.

None

Returns:

Type Description
list of ConfidenceBand

One per record, in record order.

Raises:

Type Description
ValueError

As confidence_band raises: no degrees of freedom known or given, a cross term among the records, a specification, or a count or the level out of range.

is_autospectrum
is_autospectrum(record: int | None = None) -> bool

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
confidence_refusal() -> str | None

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
principal_shapes(quantity: str | None = None) -> tuple[list[str], ndarray, str]

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
tone_refusal(record: int = 0) -> str | None

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
can_read_tone(record: int = 0) -> bool

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 Averaging itself; a project gives the one a computed PSD was made with as Project.averaging_of.

'hann'
parameter float

The Tukey window's alpha or the Kaiser window's beta, when window is a name; an Averaging carries its own.

None
snap bool

Find the tone's own spike near frequency; False reads the lines at frequency exactly, as a tone table states it.

True
warn bool

Warn a tone between lines, an uneven floor or no tone as a ToneWarning; the notes are on the reading either way.

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 (ToneReading.notes_in writes them in others).

Raises:

Type Description
ValueError

For a record tone_refusal refuses: a spectrum on uneven lines (octave bands) or written at breakpoints, which has no line spacing to undo, or a cross spectrum.

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; history's own when omitted. A project gives a computed spectrum's as Project.averaging_of.

None
threshold_db float

The gap, in dB either way, beyond which the two disagree; core.rms_check.GAP_DB when omitted.

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 history holds no such channel, or when the frames do not fit in it.

area
area(record: int = 0, low: float | None = None, high: float | None = None) -> float

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
areas(record: int, lows: ArrayLike, highs: ArrayLike) -> ndarray

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
written(record: int | None = None) -> ndarray

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
extent(record: int | None = None) -> tuple[float, float] | None

(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; octave.PER_OCTAVE when omitted.

None
low float

The frequency range to cover, in hertz. By default, the range the written bins cover (extent).

None
high float

The frequency range to cover, in hertz. By default, the range the written bins cover (extent).

None

Returns:

Type Description
Psd

The same power on proportional bands, with bandwidth set.

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; core.matrix_checks.CONDITION_LIMIT when omitted.

None
progress callable

Told (0, core.progress.BUSY) before the decomposition; the app's progress bar uses it.

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; core.matrix_checks.REALIZABLE_TOLERANCE when omitted.

None
keep_diagonal bool

Whether the repair holds the autospectra where they are.

True
progress callable

Told (done, total) as the repair goes on; what it raises stops it. The app's progress bar uses it.

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 realizability.

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 realizability.

None

Returns:

Type Description
Psd

The repaired copy, of this object's class. realizability on this object says what moved.

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 ordinate_dim, such as 'acceleration**2/frequency'.

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.

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)

Bases: Bounded, Srs

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 ordinate_unit. A single row (which may be one-dimensional) is the requirement at every channel named.

required
response_dof str or sequence of str

The DOF each row is required at.

required
per_octave int

Points to an octave; srs.PER_OCTAVE when omitted.

None
q float

The amplification the requirement is written at; srs.DEFAULT_Q when omitted.

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.

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)

Bases: Bounded, Psd

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
reading_of(frequencies: ArrayLike) -> str

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
written(record: int | None = None) -> ndarray

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 drop_limits is not given: dropping them without being asked would lose what the file said. limit(name) returns one as a PSD of its own.

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.

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 near

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 HalfPowerWarning; the notes are on the reading either way.

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.

Srs

Srs(*args: Any, q: float | None = None, kind: str = 'maximax', **kwargs: Any)

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 DataArray.

()
**kwargs Any

As for DataArray.

()
q float

The amplification factor; srs.DEFAULT_Q when omitted.

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).

Attributes
damping property
damping: float

The damping ratio for the amplification factor, 1/(2Q).

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 i the same channel as another.

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 (core.truncate.truncate), using the

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 (core.filters.filtered): low-pass,

resample

This record at the lower sample rate rate

integrate

One integration: acceleration to velocity, velocity to

differentiate

One differentiation: displacement to velocity, velocity to

rescale

This record with records (all of them when omitted)

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: Srs, or

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 quantity has when nothing

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
sample_rate: float

Samples per second, from the abscissa. Raises a ValueError if the samples are not evenly spaced and in order.

records_per_channel property
records_per_channel: dict[tuple[str, str, str | None], int]

{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
split_into_frames: bool

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
average_counts: tuple[int, int]

(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 averaging by default, or one whole frame per record. Its window is not used.

None
window str

The window, by any name core.averaging.normalize_window takes: 'hann' for a general reading, 'flattop' for a tone's amplitude wherever it falls between lines.

'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
channel_key(i: int) -> tuple[str, str, str | None]

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 window.

{}

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
capture_indices() -> list[int]

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
suggest_truncation() -> Any

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 truncation.

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
suggest_sine_extraction(specification: Any = None) -> Any

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 chosen, so the sine view can show it before anything is extracted.

None

Returns:

Type Description
SineExtraction

The default setting.

suggest_filtering
suggest_filtering() -> Any

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 filtering.

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 core.resample.AliasWarning says so.

True
order int

The anti-alias filter's design order, core.resample.ORDER when omitted.

None

Returns:

Type Description
TimeHistory

The record at rate.

Raises:

Type Description
ValueError

If the record is not evenly sampled, or rate is not a whole division of its sample rate.

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 (...), the default corner is used; None integrates with no high-pass.

...

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

full_scale (the channel's range, in SI), margin, frame, duration and the bands, as core.time_statistics.time_statistics takes them.

{}

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, ChannelTable.clip_ranges, over its Sensitivity), or the ranges in SI, one per channel or one for all.

required
**options Any

records, step_db, margin and rail_samples, as core.overload.overload_check takes them.

{}

Returns:

Type Description
OverloadCheck

Every channel's numbers, in SI as the record is stored, its flags and the judgment.

srs_windows
srs_windows(shocks: Sequence[Any] | None = None) -> list[Any]

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
srs_band(shocks: Sequence[Any] | None = None) -> tuple[float, float]

(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; srs.DEFAULT_Q when omitted.

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 ShockSpecification for a target, see srs_type).

Raises:

Type Description
ValueError

If kind is not one of srs.KINDS.

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; srs_band when omitted.

None
high float

The natural-frequency band, in Hz; srs_band when omitted.

None
per_octave int

Frequency lines per octave; srs.PER_OCTAVE (12) when omitted.

None
q float

The oscillator amplification; srs.DEFAULT_Q when omitted.

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 kind.

compute_psds
compute_psds(averaging: Averaging | None = None) -> Psd

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 averaging, or one frame per record.

None

Returns:

Type Description
Psd

One auto-power spectral density per channel (a Specification for a target, see psd_type).

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 Psd subclass.

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 Srs subclass.

compute_cpsds
compute_cpsds(averaging: Averaging | None = None) -> Psd

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 averaging, or one frame per record.

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
drive_dofs() -> list[str]

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
default_role(quantity: str) -> str

The role a channel measuring quantity has when nothing has said otherwise.

Parameters:

Name Type Description Default
quantity str

What the channel measures, as ordinate_dim names it.

required

Returns:

Type Description
str

'reference', 'response' or 'monitor'.

channel_identities
channel_identities() -> list[tuple[str, str]]

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
channel_roles(stated: bool = True) -> dict[tuple[str, str], str]

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 roles. The provenance fingerprint compares against these, so stating the roles the defaults would give does not mark derived objects out of date.

True

Returns:

Type Description
dict of (str, str) to str

Every channel's role, in first-record order.

reference_channels
reference_channels(references: Sequence[Any] | None = None) -> list[tuple[str, str]]

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
response_channels(references: Sequence[Any] | None = None) -> list[tuple[str, str]]

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 reference_channels takes them.

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 reference_channels). When omitted, the channels whose role is 'reference'.

None
averaging Averaging

How to cut the record into frames. Defaults to the record's own averaging, or one frame per record.

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 method is unknown, there are no reference or no response channels, there are no more averages than references, a channel holds a sample that is not a finite number in the frames read, or H2 is asked of a multi-reference set that is not square.

References

The coupled multi-reference H2 form is Rocklin, Crowley and Vold's; the rest set out the three estimators and their errors.

  1. 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).
  2. 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.
  3. 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.
  4. 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 reference_channels). When omitted, the channels whose role is 'reference'.

None
averaging Averaging

How to cut the record into frames. Defaults to the record's own averaging, or one frame per record.

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.

  1. 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.
  2. 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 compute_multiple_coherence. When omitted, the channels whose role is 'reference'.

None
averaging Averaging

How to cut the record into frames. Defaults to the record's own averaging, or one frame per record.

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 reference_channels does). When omitted, the one channel whose role is 'reference'.

None
averaging Averaging

How to cut the record into frames. Defaults to the record's own averaging, or one frame per record.

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
to_sep005(name: str | None = None) -> list[dict[str, Any]]

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.

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: Specification, since the

srs_type

The class of an SRS of this record: ShockSpecification, for

Methods:
psd_type
psd_type() -> type[Psd]

The class of a PSD of this record: Specification, since the spectrum of a required waveform is itself a requirement.

Returns:

Type Description
type

Specification.

srs_type
srs_type() -> type[Srs]

The class of an SRS of this record: ShockSpecification, for the same reason psd_type gives.

Returns:

Type Description
type

ShockSpecification.

Geometry

Geometry(node_id: Ids, node_xyz: ArrayLike, node_def_cs: ArrayLike | None = None, node_disp_cs: ArrayLike | None = None, node_color: ArrayLike | None = None, cs_id: Ids | None = None, cs_name: Sequence[str] | None = None, cs_type: ArrayLike | None = None, cs_matrix: ArrayLike | None = None, elem_id: Ids | None = None, elem_type: ArrayLike | None = None, elem_color: ArrayLike | None = None, elem_conn: Sequence[ArrayLike] | None = None, elem_group: Ids | None = None, group_id: Ids | None = None, group_name: Sequence[str] | None = None, length_unit: str | None = None, group_properties: Mapping[int, Any] | None = None, from_deck: bool = False, mass_unit: str | None = None)

Nodes, coordinate systems, elements and element groups.

The parameters are array-likes with the names of the attributes below; elem_conn holds one integer array of node ids per element. Coordinates are in the global cartesian frame, in meters once length_unit is declared. Without coordinate systems the geometry gets one, the global cartesian system with id 1. An element whose descriptor does not match its node count is corrected (reconcile_type), and an element group holding more than one element family is split (split_groups_by_family). Raises ValueError when the result is not consistent (validate).

The arrays below hold the data; nodes, coordinate_systems, elements and groups are views of them, which is how the project tree lists a geometry and usually the easiest way for a script to use one. A view is not a copy, so writing through a row writes into the geometry.

There are no separate tracelines. A line drawn through nodes is an element group of two-node line elements with no properties: add_beams creates one, and drawn_lines returns them for the file formats that store tracelines separately. The same element group becomes part of the structure once it is given a section.

Attributes: node_id: Every node's id. Unique, because elements and placement refer to nodes by id. node_xyz: (nodes, 3) coordinates, in meters once length_unit is declared and the file's numbers before that. node_def_cs: The coordinate system each node is placed in. node_disp_cs: The coordinate system each node is measured in, which is the system a shape's values at that node are in. node_color: Palette index per node. cs_id: Coordinate system ids. Unique, for the same reason as node ids. cs_name: A name per system, often empty. cs_type: 0 cartesian, 1 cylindrical, 2 spherical (CS_TYPES). cs_matrix: (systems, 4, 3): three direction rows, then the origin, so cs_matrix[i, 3] is the origin of system i. elem_id: Element ids. They are only labels; nothing refers to them. elem_type: UFF dataset 2412 descriptor code per element (ELEMENT_TYPES names them and says how each is drawn). elem_color: Palette index per element. elem_conn: One array of node ids per element. elem_group: The id of the element group each element belongs to. group_id: The declared element groups. Unique, since elements refer to them by id. group_name: A name per element group, such as 'wing' or 'arm front left'. This is where a mesh records that a region is a different part from its neighbor, and fem.Model.from_geometry reads a member's section from it. group_properties: {element group id: fem.GroupProperties}, the material and thickness or section of each element group that has them. length_unit: The unit of the coordinates, or None while it has not been declared, in which case they are the file's own numbers and nothing has been scaled. mass_properties: The reference point, mass and inertia for the rigid-body shapes (core.rigid.MassProperties), or None. view: The direction the geometry opens in 3-D (View), or None for DEFAULT_VIEW. solids: The solid shapes of the parts before they are meshed (core.solids). mates: Where element groups' surfaces are joined, by rigid links or springs made when a model is built (core.mates).

Methods:

Name Description
validate

Check that the geometry is consistent, and raise ValueError

node_index

Positions of the given node ids in the node arrays.

contains_nodes

Boolean array: which of node_ids this geometry defines.

missing_dofs

The DOF strings whose node this geometry does not define.

suggest_mass_properties

Mass properties with the centroid of the nodes as the reference

define_units

Declare the length unit of the coordinates, converting them to SI.

undefine_units

Remove the length unit and restore the original coordinates; returns self.

dof_direction

A DOF's direction in global coordinates, from the coordinate

add_node

Add a node at xyz and return its id.

add_nodes

Add nodes at xyz, numbered from one more than the highest id.

add_coordinate_system

Add a coordinate system and return its id.

place_coordinate_system

Rotate a coordinate system, move it, or both, as the 3-D

set_coordinate_system_type

Make a coordinate system cartesian (0), cylindrical (1) or

node_local_xyz

Each node's coordinates in the coordinate system it is placed

set_node_local_xyz

Place the node at row at xyz, given in the coordinate

set_node_placement

Place nodes in another coordinate system, keeping their

add_beams

Add a chain of two-node line elements through the given nodes,

mixed_groups

{element group id: families} for every element group that

split_groups_by_family

Split every element group that holds more than one element family.

attach_drawn_lines

Add drawn lines read from a format that stores them separately

is_drawn_line

Whether an element group is a drawn line.

drawn_lines

The drawn lines, in the form used by file formats that store

group_of

The name of the element group an element belongs to, or '' when

elements_in

The ids of the elements in an element group, given by id or name.

nodes_in

The ids of the nodes used by the elements of these element

add_group

Declare an element group and return its id.

add_element

Add an element and return its row index.

add_elements

Add many elements at once, numbered from one more than the

renumber_node

Give a node a new id, and update the elements that use it.

rename_group

Give an element group a name.

move_elements

Put elements in another element group, as dragging them onto it in the tree does.

renumber_group

Give an element group a new id, and update its elements.

renumber_coordinate_system

Give a coordinate system a new id, and update the nodes that use it.

delete_nodes

Remove nodes, and the elements that use them.

coincident_nodes

{node: the node it coincides with} for every node within

duplicate_elements

{element id: the element it duplicates} for every solid

merge_duplicate_elements

Remove duplicate solid elements (duplicate_elements).

node_spacing

The mesh's finest spacing: the shortest nonzero distance between

coincident_spots

The places where a merge would make one node.

merge_folds

Why this merge would be refused, or None.

merge_collapses

The ids of the line elements this merge would remove.

merge_coincident_nodes

Merge nodes that are at one point into one node.

align_reach

The default reach of Align Meshes: half the mesh size of the

align_moves

The moves Align Meshes would make, each [node, onto]: a node

align_folds

Why these moves would be refused, or None.

align_meshes

Move the nodes of the coarser piece onto the nodes of the finer

delete_coordinate_systems

Remove coordinate systems, and give the nodes that used them to

delete_groups

Remove element groups with their elements, their properties, and

merge_refusal

Why these element groups cannot be merged, or None when they can.

merge_groups

Merge several element groups into the first one (Merge Element

delete_elements

Remove elements by id. Ids that are not present are ignored.

save

Write the geometry to a file of its own.

load

Read a geometry written by save.

Attributes:

Name Type Description
opening_view View

The view the geometry opens in 3-D: its own view, or

num_nodes int

How many nodes the geometry defines.

nodes EntityView

Every node: ids, xyz, colors, placement_systems and

coordinate_systems EntityView

Every coordinate system: ids, names, types and matrices

elements EntityView

Every element: ids, types, colors, groups and nodes

groups EntityView

Every element group: ids and names (an EntityView).

extent tuple[ndarray, ndarray]

(min_xyz, max_xyz) of the nodes, in meters once units are defined.

units_defined bool

Whether the length unit of the coordinates has been declared.

Attributes
opening_view property
opening_view: View

The view the geometry opens in 3-D: its own view, or DEFAULT_VIEW (from +X+Y+Z, Z up) when it has none.

num_nodes property
num_nodes: int

How many nodes the geometry defines.

nodes property
nodes: EntityView

Every node: ids, xyz, colors, placement_systems and displacement_systems (an EntityView).

coordinate_systems property
coordinate_systems: EntityView

Every coordinate system: ids, names, types and matrices (an EntityView).

elements property
elements: EntityView

Every element: ids, types, colors, groups and nodes (an EntityView).

groups property
groups: EntityView

Every element group: ids and names (an EntityView).

An element group does not store its elements. Which elements are in one is read from elem_group (elements_in), so moving an element to another element group is an edit to the element.

extent property
extent: tuple[ndarray, ndarray]

(min_xyz, max_xyz) of the nodes, in meters once units are defined.

units_defined property
units_defined: bool

Whether the length unit of the coordinates has been declared. False until define_units is called.

Methods:
validate
validate() -> None

Check that the geometry is consistent, and raise ValueError naming the first problem found.

Node, coordinate system and element group ids must be unique, every element's nodes must exist, every element must name an element group the geometry has, every element type must be in ELEMENT_TYPES, and each element group must hold one element family.

node_index
node_index(node_ids: Ids) -> ndarray

Positions of the given node ids in the node arrays.

Every id must be one the geometry has (contains_nodes asks without raising).

Parameters:

Name Type Description Default
node_ids int or sequence of int

The identifiers, one or many.

required

Returns:

Type Description
ndarray

Each identifier's row in the node arrays.

Raises:

Type Description
KeyError

Naming the ids the geometry does not have.

contains_nodes
contains_nodes(node_ids: Ids) -> ndarray

Boolean array: which of node_ids this geometry defines.

Parameters:

Name Type Description Default
node_ids int or sequence of int

The identifiers, one or many.

required

Returns:

Type Description
ndarray

A boolean per identifier: whether the geometry has it.

missing_dofs
missing_dofs(dofs: Sequence[str]) -> list[str]

The DOF strings whose node this geometry does not define.

Parameters:

Name Type Description Default
dofs sequence of str

The degrees of freedom to check, such as '101Z+'.

required

Returns:

Type Description
list of str

The DOFs whose node the geometry does not have, including any DOF that names no node. A data object with such DOFs is not compatible with this geometry.

suggest_mass_properties
suggest_mass_properties() -> MassProperties

Mass properties with the centroid of the nodes as the reference point and no mass, which give unit rigid-body shapes about the middle of the model.

The rigid-body panel opens with these values, and generate_rigid_body_modes uses them when nothing has been set. They are the settings the virtual point transformation needs most often. Raises ValueError when the geometry has no nodes.

Returns:

Type Description
MassProperties

The centroid, unscaled.

define_units
define_units(length_unit: str, mass_unit: str | None = None) -> Geometry

Declare the length unit of the coordinates, converting them to SI.

The node coordinates, the coordinate system origins and the solids' lengths are converted. Declaring again reinterprets the original values instead of scaling twice, so a wrong unit can be corrected.

A geometry read from a finite element deck (from_deck) also holds the deck's property values, in the consistent system its length unit, a mass unit and seconds make: a thickness is a length, a modulus a force per area, a density a mass per volume, a point mass a mass, a spring a force per length (or, about an axis, a force times a length). Those are converted with the coordinates (deck_to_si). The mass unit is mass_unit, or the one a deck in that length is written with when it is omitted (DECK_MASS_UNITS: tonnes with millimeters, lbf·s²/in with inches). A material whose converted modulus or density is not a structural material's is warned about, since that is what a wrong mass unit looks like.

Parameters:

Name Type Description Default
length_unit str

The unit the coordinates are in, such as 'm' or 'in'.

required
mass_unit str

The mass unit of a deck's properties, such as 'tonne'.

None

Returns:

Type Description
Geometry

Self, converted to SI in place.

undefine_units
undefine_units() -> Geometry

Remove the length unit and restore the original coordinates; returns self.

dof_direction
dof_direction(dof: str) -> ndarray | None

A DOF's direction in global coordinates, from the coordinate system its node is measured in.

'101X+' at a node whose node_disp_cs is rotated is not global X. The report's table of control channels uses this to show which global axis each channel is nearest and how far it is from it. A rotational DOF points along its axis, as the DOF arrows draw it. A node whose system is not in the geometry is taken to be in the global system.

Parameters:

Name Type Description Default
dof str

The DOF, such as '101X+' or '1313RZ-'.

required

Returns:

Type Description
ndarray or None

A unit vector, or None when the DOF names no node this geometry has, has no axis (a node number alone), or is at a node measured in a cylindrical or spherical system, whose local axes depend on the node's position and are not computed here.

add_node
add_node(xyz: ArrayLike, node_id: int | None = None, color: int = 1, def_cs: int | None = None, disp_cs: int | None = None) -> int

Add a node at xyz and return its id.

Raises ValueError if a node with node_id already exists.

Parameters:

Name Type Description Default
xyz array_like

The node's coordinates in the global cartesian frame, in meters once units are defined. They are stored as given.

required
node_id int

Its identifier. One more than the highest node id when omitted.

None
color int

Its display color index.

1
def_cs int

The coordinate system the node is placed in, which a writer uses to give its position. xyz is not converted from it. The first coordinate system when omitted.

None
disp_cs int

The coordinate system displacements at the node are measured in. The first coordinate system when omitted.

None

Returns:

Type Description
int

The node's identifier.

add_nodes
add_nodes(xyz: ArrayLike) -> ndarray

Add nodes at xyz, numbered from one more than the highest id.

This is add_node for many nodes at once, with the defaults of add_node. Each array is copied once instead of once per node, so adding the thousands of nodes of a meshed plane is fast.

Parameters:

Name Type Description Default
xyz array_like

(n, 3) coordinates in the global cartesian frame, in meters once units are defined.

required

Returns:

Type Description
ndarray

The new nodes' identifiers, in order.

add_coordinate_system
add_coordinate_system(origin: ArrayLike = (0.0, 0.0, 0.0), rotation: ArrayLike | None = None, cs_id: int | None = None, name: str = '', cs_type: int = 0) -> int

Add a coordinate system and return its id.

Raises ValueError if a system with cs_id already exists.

Parameters:

Name Type Description Default
origin array_like

The system's origin, in meters once units are defined.

(0, 0, 0)
rotation array_like

A 3x3 matrix whose rows are the system's axes. Identity when omitted.

None
cs_id int

Its identifier. One more than the highest id when omitted.

None
name str

What to call it.

''
cs_type int

0 cartesian, 1 cylindrical, 2 spherical.

0

Returns:

Type Description
int

The coordinate system's identifier.

place_coordinate_system
place_coordinate_system(cs_id: int, *, origin: ArrayLike | None = None, angles: ArrayLike | None = None, rotation: ArrayLike | None = None) -> None

Rotate a coordinate system, move it, or both, as the 3-D view's rings and arrows do. The nodes placed in it move with it, keeping their coordinates in it.

Raises KeyError for an unknown cs_id, and ValueError when both angles and rotation are given.

Parameters:

Name Type Description Default
cs_id int

Which coordinate system.

required
origin array_like

The new origin, in the geometry's stored length unit (meters once its units are declared). Unchanged when omitted.

None
angles array_like

The rotation as angles in degrees about the fixed global X, then Y, then Z axes (rotate.frame_from_angles), the same angles the view's angle box and the box panel use. (0, 0, 0) removes any rotation. Unchanged when omitted.

None
rotation array_like

The rotation as a 3x3 matrix whose rows are the system's axes, instead of angles.

None

Returns:

Type Description
None
set_coordinate_system_type
set_coordinate_system_type(cs_id: int, cs_type: int) -> None

Make a coordinate system cartesian (0), cylindrical (1) or spherical (2). The nodes placed in it keep their coordinates, which now mean (r, theta, z) or (r, theta, phi), so they move.

Raises KeyError for an unknown cs_id, and ValueError for a type that is none of the three.

Parameters:

Name Type Description Default
cs_id int

Which coordinate system.

required
cs_type int

0 cartesian, 1 cylindrical, 2 spherical.

required

Returns:

Type Description
None
node_local_xyz
node_local_xyz(rows: Ids | None = None) -> ndarray

Each node's coordinates in the coordinate system it is placed in, as the node table shows them: (x, y, z) in a cartesian system, (r, theta, z) in a cylindrical one and (r, theta, phi) in a spherical one, angles in degrees.

Parameters:

Name Type Description Default
rows sequence of int

Which nodes, by row; all of them when omitted.

None

Returns:

Type Description
ndarray

(nodes, 3).

set_node_local_xyz
set_node_local_xyz(row: int, xyz: ArrayLike) -> None

Place the node at row at xyz, given in the coordinate system it is placed in (node_local_xyz).

Parameters:

Name Type Description Default
row int

The node's row.

required
xyz array_like

Its three coordinates in its placement system.

required

Returns:

Type Description
None
set_node_placement
set_node_placement(rows: Ids, cs_id: int) -> None

Place nodes in another coordinate system, keeping their coordinates: the same numbers, now in cs_id, so the nodes move to where those numbers put them.

Raises ValueError for a system the geometry does not have.

Parameters:

Name Type Description Default
rows int or sequence of int

The nodes, by row.

required
cs_id int

The coordinate system to place them in.

required

Returns:

Type Description
None
add_beams
add_beams(node_ids: Ids, group: int | None = None, color: int = 1, elem_type: int = 21) -> int

Add a chain of two-node line elements through the given nodes, in order, and return the element group's id.

This is how a drawn line (a traceline in some file formats) is stored, and it becomes a run of beams once the element group is given a section. Raises ValueError for fewer than two nodes, an unknown node, or an elem_type that is not a two-node line.

Parameters:

Name Type Description Default
node_ids sequence of int

The nodes the line runs through, in order; two at least.

required
group int

The element group the segments are added to. A new, unnamed element group when omitted; a drawn line is its own element group, named for the line.

None
color int

The display color index of every segment.

1
elem_type int

The two-node line code (ELEMENT_TYPES): a beam, unless the source says rod, pipe or rigid bar.

21

Returns:

Type Description
int

The element group the segments are in.

mixed_groups
mixed_groups() -> dict[int, list[str]]

{element group id: families} for every element group that holds more than one element family.

It is empty for any geometry that passes validate.

Returns:

Type Description
dict of int to list of str
split_groups_by_family
split_groups_by_family() -> dict[int, list[int]]

Split every element group that holds more than one element family.

The group keeps its first family, and each other family is moved into a new element group named with the old name and the family, such as 'wing quads', with the old group's properties. A file without element groups (UNV dataset 2412, the sdynpy layout) puts every element in one group, so this is applied when such a file is read.

Returns:

Type Description
dict of int to list of int

{old element group: [the new element groups made from it]}, empty when no group was mixed.

attach_drawn_lines
attach_drawn_lines(lines: Sequence[tuple[str, int, Sequence[Ids]]]) -> list[int]

Add drawn lines read from a format that stores them separately from elements, each as its own element group of two-node line elements with no properties.

This is the reading side of drawn_lines.

Parameters:

Name Type Description Default
lines sequence of (name, color, chains)

One entry per line: its name, its color index, and its runs, each a sequence of node ids in drawing order (a UNV line that lifts the pen has several).

required

Returns:

Type Description
list of int

The element groups made, one per line.

is_drawn_line
is_drawn_line(group: int) -> bool

Whether an element group is a drawn line.

It is when every element in it is a two-node line element and the element group has no properties. The app and every file writer use this one test. An empty element group is not a drawn line.

Parameters:

Name Type Description Default
group int

The element group's identifier.

required

Returns:

Type Description
bool
drawn_lines
drawn_lines() -> list[dict[str, Any]]

The drawn lines, in the form used by file formats that store tracelines separately from elements.

One dict {'group', 'name', 'color', 'chains'} per drawn-line element group (is_drawn_line), in element group order. The chains are the group's segments taken in element order, each a list of node ids, with a new chain wherever a segment does not start where the last one ended. An element group read from one polyline gives that polyline back, and one read from a UNV line that lifts the pen gives its runs back under the one element group. The color is that of the group's first element.

Returns:

Type Description
list of dict
group_of
group_of(elem_id: int) -> str

The name of the element group an element belongs to, or '' when that group is not declared.

Parameters:

Name Type Description Default
elem_id int

Which element.

required

Returns:

Type Description
str

The name of the element group it belongs to.

elements_in
elements_in(group: int | str) -> list[int]

The ids of the elements in an element group, given by id or name.

A name that no element group has gives an empty list; with two groups of one name, the first is used.

Parameters:

Name Type Description Default
group int or str

An element group, by identifier or by name.

required

Returns:

Type Description
list of int

The identifiers of the elements it holds.

nodes_in
nodes_in(groups: Ids) -> list[int]

The ids of the nodes used by the elements of these element groups, in ascending order. These are the nodes a merge limited to those groups may change.

Parameters:

Name Type Description Default
groups sequence of int

Element groups, by identifier.

required

Returns:

Type Description
list of int

The node identifiers.

Raises:

Type Description
ValueError

When a group is not in the geometry.

add_group
add_group(name: str = '', group_id: int | None = None, family: str = '') -> int

Declare an element group and return its id.

An empty element group is allowed: exodus files contain empty ones, and an element group has to exist before an element can be put in it. Raises ValueError if group_id is already used.

Parameters:

Name Type Description Default
name str

What to call the element group.

''
group_id int

Its identifier. One more than the highest id when omitted.

None
family str

The element family it is for, such as 'quads' (FAMILIES), kept in group_family: where an empty element group is listed.

''

Returns:

Type Description
int

The element group's identifier.

add_element
add_element(node_ids: Ids, elem_type: int | None = None, color: int = 1, group: int | None = None) -> int

Add an element and return its row index.

The element id is one more than the highest element id. Without elem_type, the type is chosen from the node count: 2 nodes a beam (21), 3 a triangle (41), 4 a quadrilateral (44); any other count needs elem_type. Raises ValueError for an unknown node or type, or for a group that holds a different element family.

Parameters:

Name Type Description Default
node_ids int or sequence of int

The nodes the element connects, in order.

required
elem_type int

The element type code. Inferred from the node count when omitted.

None
color int

Its display color index.

1
group int

The element group it belongs to, which is declared if it does not exist yet. When omitted, the first element group that holds this element's family (or is empty), otherwise a new one. An element group holds one family, so a beam added to a mesh of plates goes in an element group of its own.

None

Returns:

Type Description
int

The element's row index in the element arrays (not its id).

add_elements
add_elements(connectivity: Sequence[Ids], elem_types: Ids, groups: Ids) -> None

Add many elements at once, numbered from one more than the highest element id, with color 1.

The nodes and types are checked once for all of them, and an element group may hold only one element family, as in add_element. If any check fails, ValueError is raised and nothing is added.

Parameters:

Name Type Description Default
connectivity sequence of sequence of int

Each element's nodes, in order.

required
elem_types sequence of int

Each element's type code.

required
groups sequence of int

The element group each belongs to; an element group that does not exist yet is declared, with no name.

required

Returns:

Type Description
None
renumber_node
renumber_node(row: int, node_id: int) -> None

Give a node a new id, and update the elements that use it.

Elements refer to nodes by id, so the connectivity is updated too; otherwise every element at the node would lose it. Raises ValueError if another node already has the id.

Parameters:

Name Type Description Default
row int

Which node, by row.

required
node_id int

Its new identifier.

required

Returns:

Type Description
None
rename_group
rename_group(group_id: int, name: str) -> None

Give an element group a name.

Parameters:

Name Type Description Default
group_id int

The element group's id.

required
name str

Its new name; empty for none.

required

Returns:

Type Description
None

Raises:

Type Description
ValueError

When the geometry has no element group with that id.

move_elements
move_elements(elem_ids: Ids, group_id: int) -> int

Put elements in another element group, as dragging them onto it in the tree does.

An element group holds one element family, so elements of another family than the group holds, or than an empty group was made for (group_family), are refused, as are elements of two families at once. The groups they leave stay, empty if they held nothing else.

Parameters:

Name Type Description Default
elem_ids sequence of int

The elements, by id.

required
group_id int

The element group they go in.

required

Returns:

Type Description
int

How many elements moved: those not in the group already.

Raises:

Type Description
ValueError

When the group or an element is not in the geometry, or the families differ.

renumber_group
renumber_group(row: int, group_id: int) -> None

Give an element group a new id, and update its elements.

An element refers to its element group by id, so the elements are updated too; otherwise they would refer to an element group that no longer exists. Raises ValueError if another element group already has the id.

Parameters:

Name Type Description Default
row int

Which element group, by row.

required
group_id int

Its new identifier.

required

Returns:

Type Description
None
renumber_coordinate_system
renumber_coordinate_system(row: int, cs_id: int) -> None

Give a coordinate system a new id, and update the nodes that use it.

Both the placement and the displacement systems of the nodes are updated. Raises ValueError if another system already has the id.

Parameters:

Name Type Description Default
row int

Which system, by row.

required
cs_id int

Its new identifier.

required

Returns:

Type Description
None
delete_nodes
delete_nodes(node_ids: Ids) -> dict[str, int]

Remove nodes, and the elements that use them.

An element that uses a deleted node is deleted too. Ids that are not present are ignored.

Parameters:

Name Type Description Default
node_ids int or sequence of int

The identifiers, one or many.

required

Returns:

Type Description
dict of str to int

'nodes' and 'elements', the number of each removed.

coincident_nodes
coincident_nodes(tolerance: float, nodes: Ids | None = None) -> dict[int, int]

{node: the node it coincides with} for every node within tolerance of another.

Each node is mapped to the lowest id in its group, which is the node a merge keeps. Groups are chained: if a is within tolerance of b and b of c, all three are one point.

Parameters:

Name Type Description Default
tolerance float

How close two nodes must be to be one point, in the stored length unit: meters once units are defined.

required
nodes sequence of int

Only these nodes are considered, by id; a node outside them is not merged and nothing is merged into it, however close. Every node when omitted.

None

Returns:

Type Description
dict of int to int

Only the nodes that would be removed, each mapped to the node it becomes.

duplicate_elements
duplicate_elements(groups: Ids | None = None) -> dict[int, int]

{element id: the element it duplicates} for every solid element of the same type and on the same nodes as an earlier element, such as two bricks filling one cell.

The earlier element (in element order) is the one that stays. Only solids are checked: two beams on one line can be two members, and a plate on another plate's nodes is how a doubler or a layer is modeled, but two solids are never meant to fill one cell. Two element groups that overlap and share their nodes in the overlap (the bars of an X cross-section) put two elements in every cell there, which doubles the stiffness and mass of the region.

Parameters:

Name Type Description Default
groups sequence of int

Only the elements of these element groups, by id; every element when omitted.

None

Returns:

Type Description
dict of int to int

Each element that fills a cell another element already fills, mapped to that element.

merge_duplicate_elements
merge_duplicate_elements(groups: Ids | None = None) -> int

Remove duplicate solid elements (duplicate_elements).

The later element of each pair is removed, and the earlier one stays in its element group.

Parameters:

Name Type Description Default
groups sequence of int

Only the elements of these element groups, by id; every element when omitted.

None

Returns:

Type Description
int

How many elements were removed.

node_spacing
node_spacing(groups: Ids | None = None) -> float | None

The mesh's finest spacing: the shortest nonzero distance between two nodes of one element, such as a brick's shortest edge or half an edge of a quad8.

Merge Coincident Nodes sets its default tolerance to a quarter of this value. Nodes of parts meshed separately are usually much closer than that where the parts meet, and no two nodes of one element are.

Parameters:

Name Type Description Default
groups sequence of int

Only these element groups' elements, by id; every element when omitted.

None

Returns:

Type Description
float or None

The spacing, in the stored length unit; None when no element has two nodes at different positions.

coincident_spots
coincident_spots(tolerance: float, groups: Ids | None = None, exclude: Ids | None = None) -> list[list[int]]

The places where a merge would make one node.

Each place is a list of the node ids that coincide there, in ascending order, so the first is the node that stays. Merge Coincident Nodes marks these places in the view before anything is merged, so some of them can be left out.

Parameters:

Name Type Description Default
tolerance float

How close two nodes must be to be one, in the stored length unit: meters once units are defined.

required
groups sequence of int

Only the nodes used by these element groups' elements, by id; every node when omitted.

None
exclude sequence of int

Nodes left out, by id: they are not merged and nothing is merged into them.

None

Returns:

Type Description
list of list of int

One list per place, sorted by the node each keeps.

merge_folds
merge_folds(tolerance: float, groups: Ids | None = None, exclude: Ids | None = None) -> str | None

Why this merge would be refused, or None.

Returns the message merge_coincident_nodes raises when the tolerance would fold an element onto itself, so a panel can show it before the merge is applied.

Parameters:

Name Type Description Default
tolerance float

As merge_coincident_nodes.

required
groups sequence of int

As merge_coincident_nodes.

None
exclude sequence of int

As merge_coincident_nodes.

None

Returns:

Type Description
str or None
merge_collapses
merge_collapses(tolerance: float, groups: Ids | None = None, exclude: Ids | None = None) -> list[int]

The ids of the line elements this merge would remove.

These are the line elements (a rigid link, a spring, a beam) whose nodes would all become one node, so they no longer join anything. Merging a joint built with rigid links removes the links.

Parameters:

Name Type Description Default
tolerance float

As merge_coincident_nodes.

required
groups sequence of int

As merge_coincident_nodes.

None
exclude sequence of int

As merge_coincident_nodes.

None

Returns:

Type Description
list of int
merge_coincident_nodes
merge_coincident_nodes(tolerance: float, groups: Ids | None = None, exclude: Ids | None = None) -> dict[str, int]

Merge nodes that are at one point into one node.

Nodes within tolerance of each other (coincident_nodes) become the one with the lowest id: every element that uses one of them is changed to use that node, and the others are removed. Plates are only connected where they share nodes, so this is what connects a model built from separate planes at its edges.

The merge is refused with ValueError, naming the element, when the tolerance would fold an element onto itself (two of its own nodes within the tolerance), since that means the tolerance is larger than the mesh. A line element whose nodes would all become one, such as a rigid link across the gap the merge closes, is removed instead (merge_collapses). Solid elements the merge leaves on exactly the same nodes fill one cell twice, and the duplicates are removed (merge_duplicate_elements).

With groups, only those element groups are merged: the nodes their elements use are the candidates, so two groups picked together are joined to each other and to nothing else, and only their duplicate elements are removed. A merge over the whole geometry joins every part to every part it touches, which is usually more than intended; the app offers the merge on element groups only.

Parameters:

Name Type Description Default
tolerance float

How close two nodes must be to be one, in the stored length unit: meters once units are defined.

required
groups sequence of int

The element groups whose nodes are merged, by id. Every node of the geometry when omitted.

None
exclude sequence of int

Nodes left out of the merge, by id: they are not merged and nothing is merged into them. In the app, these are the places that were unpicked (coincident_spots).

None

Returns:

Type Description
dict of str to int

'merged', the number of nodes removed; 'into', the number of nodes they became; 'duplicates', the number of elements removed for filling a cell another already filled; and 'links', the number of line elements removed because their nodes became one.

align_reach
align_reach(groups: Ids | None = None) -> float | None

The default reach of Align Meshes: half the mesh size of the coarsest piece.

A piece is a set of elements connected by shared nodes. With this reach no node moves more than half an element of its own mesh. Parts with a gap between them need a larger reach, by the size of the gap.

Parameters:

Name Type Description Default
groups sequence of int

The element groups, by id; every element when omitted.

None

Returns:

Type Description
float or None

In the stored length unit; None when no element has a nonzero size.

align_moves
align_moves(reach: float, groups: Ids | None = None, exclude: Ids | None = None) -> list[list[int]]

The moves Align Meshes would make, each [node, onto]: a node of a coarser piece and the node of a finer piece it would move onto, so the two are at one point and can be merged with Merge Coincident Nodes.

A piece is a set of elements connected by shared nodes. Two pieces meshed at different sizes cannot be matched node for node, since their node counts differ, but each node of the coarser piece can be moved onto the nearest node of the finer one. No node moves more than reach. The rules:

  • Only nodes on the outside of the pieces move or are moved onto.
  • A node moves once, and onto a node no other node moves onto.
  • A node already at another node's position is a place to merge, not a move.
  • The nearest pairs are taken first. As a result, a washer's lower face moves onto the frame under it, and its upper face, whose nearest frame nodes are already taken, stays.
  • Of two pieces with the same mesh size, the later piece moves.
  • A move that would turn an element inside out is left out.

Parameters:

Name Type Description Default
reach float

How far a node may move, in the stored length unit.

required
groups sequence of int

The element groups whose pieces are aligned, by id; every element when omitted.

None
exclude sequence of int

Nodes left out, by id: they are not moved and nothing is moved onto them. In the app, these are the moves that were unpicked.

None

Returns:

Type Description
list of [int, int]

Sorted by the node moved.

align_folds
align_folds(moves: Sequence[Sequence[int]]) -> str | None

Why these moves would be refused, or None.

Returns the message align_meshes raises when a move would turn an element inside out (a solid's corner volume or a plate's normal changing sign), so a panel can show it before the moves are applied.

Parameters:

Name Type Description Default
moves sequence of [int, int]

As align_moves gives them.

required

Returns:

Type Description
str or None
align_meshes
align_meshes(reach: float, groups: Ids | None = None, exclude: Ids | None = None) -> dict[str, float]

Move the nodes of the coarser piece onto the nodes of the finer piece where they meet (align_moves), so Merge Coincident Nodes can join them.

This is for parts meshed separately at sizes that do not match: it makes their nodes coincide at their mating faces or where they overlap. Nothing is merged and no node is removed. A move that would turn an element inside out is left out by align_moves; the call raises ValueError, naming the element, only when the nodes left out with exclude make one of the other moves do so (align_folds).

Parameters:

Name Type Description Default
reach float

How far a node may move, in the stored length unit: meters once units are defined.

required
groups sequence of int

The element groups whose pieces are aligned, by id; every element of the geometry when omitted.

None
exclude sequence of int

Nodes left out, by id: neither moved nor moved onto.

None

Returns:

Type Description
dict

'moved', how many nodes moved; 'farthest', the longest move, in the stored length unit.

delete_coordinate_systems
delete_coordinate_systems(cs_ids: Ids) -> dict[str, int]

Remove coordinate systems, and give the nodes that used them to the first remaining system. A node placed in a removed system keeps its coordinates, now in the remaining one, so it moves.

Ids that are not present are ignored. Removing every coordinate system is refused with ValueError, since every node needs one.

Parameters:

Name Type Description Default
cs_ids int or sequence of int

The identifiers, one or many.

required

Returns:

Type Description
dict of str to int

'coordinate_systems', the number removed, and 'nodes_reassigned', the number of node placement and displacement references moved to the remaining system.

delete_groups
delete_groups(group_ids: Ids, keep: Ids = ()) -> dict[str, int]

Remove element groups with their elements, their properties, and the nodes no element outside them uses.

A node that an element of another element group also uses stays, so a neighboring part is not cut along the nodes the two share. Ids that are not present are ignored. To combine element groups instead, use merge_groups.

Parameters:

Name Type Description Default
group_ids int or sequence of int

The identifiers, one or many.

required
keep sequence of int

Nodes that stay whatever uses them (delete_elements).

()

Returns:

Type Description
dict of str to int

'groups', 'elements' and 'nodes', the number of each removed.

merge_refusal
merge_refusal(group_ids: Ids) -> str | None

Why these element groups cannot be merged, or None when they can.

There must be at least two, all in the geometry, holding the same element types and with the same properties. A merged element group has one material and one thickness or section, so merging groups that differ would change the model without saying so.

Parameters:

Name Type Description Default
group_ids sequence of int

The element groups, by identifier.

required

Returns:

Type Description
str or None
merge_groups
merge_groups(group_ids: Ids) -> dict[str, int]

Merge several element groups into the first one (Merge Element Groups).

The elements of the others are moved into the first group, and the others are removed with their properties. Raises ValueError with the reason from merge_refusal when the groups cannot be merged.

Parameters:

Name Type Description Default
group_ids sequence of int

The element groups; the first keeps its id, name and properties.

required

Returns:

Type Description
dict of str to int

'into', the id of the element group kept; 'groups', how many were merged into it; 'elements', how many elements moved.

delete_elements
delete_elements(elem_ids: Ids, nodes: bool = False, keep: Ids = ()) -> dict[str, int]

Remove elements by id. Ids that are not present are ignored.

With nodes, the nodes used only by these elements are removed too, which is what deleting an element group (delete_groups) and deleting elements in the app do. A node another element uses stays, and so does a node in keep: the project keeps the nodes its data is measured or solved at (Project.delete_elements), so redrawing a test geometry's panels leaves its measurement points. nodes is off by default because the merge removes the links it collapses and then remaps their nodes.

Parameters:

Name Type Description Default
elem_ids int or sequence of int

The identifiers, one or many.

required
nodes bool

Also remove the nodes only these elements used.

False
keep sequence of int

Nodes never removed that way.

()

Returns:

Type Description
dict of str to int

'elements', the number removed, and with nodes, 'nodes', the number of nodes removed.

save
save(path: str | PathLike) -> None

Write the geometry to a file of its own.

Parameters:

Name Type Description Default
path str or PathLike

Where to write it.

required

Returns:

Type Description
None
load classmethod
load(path: str | PathLike) -> Geometry

Read a geometry written by save.

Raises TypeError when the file holds something other than a geometry.

View

View(eye: ArrayLike = (1.0, 1.0, 1.0), up: ArrayLike = (0.0, 0.0, 1.0))

The direction a geometry is viewed from in 3-D: where the eye is, seen from the model's center, and which way is up on screen.

A view is only a direction. Every view is fitted to what it shows, so there is no distance or zoom to store. Set on a geometry, it is the view the app opens the geometry and everything drawn on it in, the view Reset View returns to, and the view of the report's scenes and exported figures. A model built with Y up then opens upright without its nodes being rotated. Raises ValueError for a zero or non-finite direction, or an up along the line of sight.

Parameters:

Name Type Description Default
eye sequence of 3 floats

The direction from the model toward the eye, in the global frame; any length.

(1, 1, 1)
up sequence of 3 floats

Which way is up on screen. Only its part across the line of sight counts, so it need not be exactly perpendicular to eye.

(0, 0, 1)

Examples:

A model built with Y up, seen from the front, above and to the right:

>>> geometry.view = View(eye=(1, 1, -1), up=(0, 1, 0))

Methods:

Name Description
basis

(right, up) on screen, as unit vectors in the global frame.

Methods:
basis
basis() -> tuple[tuple[float, ...], tuple[float, ...]]

(right, up) on screen, as unit vectors in the global frame.

Right is the line of sight crossed with up, and up is up made perpendicular to the line of sight.

ShapeSet

ShapeSet(frequency: ArrayLike, damping: ArrayLike, coordinate: Sequence[str], shape_matrix: ArrayLike, modal_mass: ArrayLike | None = None, comment: str | Sequence[str] | None = None, mass_unit: str | None = None, description: Sequence[str] | None = None, unscaled: bool = False, modal_damping: ArrayLike | None = None, reference_only: Sequence[str] | None = None)

Mode shapes over a shared set of DOFs.

shape_matrix is (modes, dofs). coordinate lists the DOF strings that the columns correspond to ('101X+'). The modes are always stored in ascending frequency, so rigid-body modes come first.

A fitted set is also the record of the fit: reopening one in the app (Edit Fit) restores the fitting session that produced it, which is why the descriptions and the scaling flag are stored with the numbers.

Attributes: frequency: Hz per mode. A rigid-body mode is exactly 0.0, because the FRF synthesis tests for exactly 0.0 to handle its 0/0; a very small frequency is not treated the same way. damping: Fraction of critical per mode, so 2% is 0.02. coordinate: The DOF string of each column of shape_matrix. shape_matrix: (modes, dofs). Complex for complex modes; the overlay and the MAC handle either. modal_mass: Per mode. 1.0 for every mode of a mass-normalized set, which is what an eigensolution here produces. For complex shapes it is modal A, the first-order scaling, and synthesize_frf uses it that way. It is complex when an imported file had it complex; the values are kept as read and never converted to real. modal_damping: Complex modal damping per mode where a file had one (I-DEAS ADFs do), or None. It is different from damping, the viscous fraction of critical: it is the complex-mode estimate as the identification software reported it. mass_unit: The mass unit the shapes were normalized against, or None when it has not been declared. description: Free text per mode describing the shape, for example 'first torsion'. comment: One line per mode; a single string given to the constructor is used for every mode. unscaled: True when the fit had no drive point to set the mass-normalized scale. Shapes and MACs are not affected, but the modal masses are only a convention, and comparisons do not report a scale factor from them. reference_only: The DOFs a fit measured only as references, in the order of coordinate. Their values come from the references' participation: a residue is the product of a response's value and a reference's, so without a drive point to measure the split, the two parts of a shape are each on a scale of their own. The values are kept, since the synthesis and Edit Fit need them, and cross_mac leaves these DOFs out of an unscaled set.

Methods:

Name Description
set_description

Write free text against one mode, as the mode table's

auto_mac

The MAC of every mode against every other mode; the diagonal is 1.

covers

Whether the shape set has a coefficient at this DOF.

synthesize_frf

FRFs from the modal model, one row per DOF pair.

modal_frf

Each real mode's own frequency response, one row per mode:

delete_modes

Remove the given modes in place.

kept

A copy holding only modes, in the set's order and once each;

define_units

Declare the mass unit the shapes were normalized against.

undefine_units

Remove the mass unit and restore the original coefficients; returns self.

display_shapes

The coefficients in the display system's 1/sqrt(mass).

unit_label

The unit label of the coefficients, such as '1/√kg'.

mode_label

A short label for one mode, such as 'Mode 3 — 12.4 Hz, 2% damping'.

save

Write the shape set to a file of its own.

Attributes:

Name Type Description
num_shapes int

How many mode shapes the set holds.

num_dofs int

How many degrees of freedom each shape covers.

is_complex bool

Whether these are complex modes.

units_defined bool

Whether a mass unit has been declared. Without one, a modal

Attributes
num_shapes property
num_shapes: int

How many mode shapes the set holds.

num_dofs property
num_dofs: int

How many degrees of freedom each shape covers.

is_complex property
is_complex: bool

Whether these are complex modes.

Real normal modes move every DOF in or out of phase; complex modes do not, which is the result of non-proportional damping. A set is complex when its shape matrix has a complex dtype.

units_defined property
units_defined: bool

Whether a mass unit has been declared. Without one, a modal mass is a number with no unit.

Methods:
set_description
set_description(mode: int, text: str) -> None

Write free text against one mode, as the mode table's Description column takes it.

Parameters:

Name Type Description Default
mode int

The mode, from 0.

required
text str

The description; stripped, and blank clears it.

required

Returns:

Type Description
None
auto_mac
auto_mac() -> ndarray

The MAC of every mode against every other mode; the diagonal is 1.

covers
covers(dof: str) -> bool

Whether the shape set has a coefficient at this DOF.

The sign is ignored, so '101Z-' is covered when '101Z+' is.

Parameters:

Name Type Description Default
dof str

A degree of freedom, such as '101Z+'.

required

Returns:

Type Description
bool

Whether the shapes include it.

synthesize_frf
synthesize_frf(frequencies: ArrayLike, response_dof: Sequence[str], reference_dof: Sequence[str], modes: Sequence[int] | None = None, power: int = 0) -> ndarray

FRFs from the modal model, one row per DOF pair.

For real shapes, the second-order residue form

H_jk(f) = sum_r (iw)^power phi_jr phi_kr
                / (m_r (w_r^2 - w^2 + 2i z_r w_r w))

with w = 2pif. It is exact for mass-normalized shapes, and modal_mass holds any other scaling. For complex shapes, the first-order form, with a pole and its conjugate:

H_jk(f) = sum_r (iw)^power [ psi_jr psi_kr / (A_r (iw - l_r))
              + conj(psi_jr psi_kr / A_r) / (iw - conj(l_r)) ]

with the pole l_r = -z_r w_r + i w_r sqrt(1 - z_r^2) and modal_mass used as modal A, the scaling of a complex mode (1.0 when a set has none). The two forms give the same FRF for a real mode whose modal A is 2i w_d m_r, where w_d is the damped natural frequency.

The form is selected by the shapes alone: complex shapes use the first-order form and real shapes the second-order form. The second-order form cannot represent a complex mode, because it gives the conjugate pole the residue -R where the structure has conj(R), whatever modal_mass is set to. Modal A is conjugated in the second term, which only matters when modal A is complex.

power selects the response quantity: 0 displacement per force, 1 velocity, 2 acceleration. It is applied inside the sum because a real rigid-body mode's denominator is exactly -w^2: at w = 0 its accelerance reduces to the finite residue, while multiplying afterward would give 0/0. Its displacement and velocity at w = 0 are unbounded and are returned as nan.

Both forms are checked to rounding error against the direct inverse of the dynamic stiffness (proportionally damped for real shapes, non-proportionally damped for complex ones) and against the output of sdynpy's synthesis saved as test data (tests/test_frf_synthesis_exact.py, tests/test_modal_frf_oracle.py).

modes limits the sum to some modes; a synthesis from a subset of modes plotted beside the measurement shows which modes the measurement contains. Raises ValueError for a DOF the shapes do not cover, which covers can check in advance.

Parameters:

Name Type Description Default
frequencies array_like

The lines to synthesize at, in Hz.

required
response_dof sequence of str

The response degrees of freedom.

required
reference_dof sequence of str

The drive degrees of freedom.

required
modes sequence of int

Which modes to include. All of them when omitted.

None
power int

0 receptance, 1 mobility, 2 accelerance.

0

Returns:

Type Description
ndarray

The synthesized FRFs, one row per response and drive pair.

References
  1. Ewins, D. J. (2000). Modal Testing: Theory, Practice and Application, 2nd ed. Research Studies Press. The residue form for real modes, and why non-proportional damping makes the modes complex.
  2. Maia, N. M. M., & Silva, J. M. M. (1997). Theoretical and Experimental Modal Analysis. Research Studies Press. The first-order (state-space) form, its conjugate pole pairs, and modal A as the scaling that goes with them.
modal_frf
modal_frf(frequencies: ArrayLike, modes: Sequence[int] | None = None, power: int = 0) -> ndarray

Each real mode's own frequency response, one row per mode:

H_r(f) = (iw)^power / (m_r (w_r^2 - w^2 + 2i z_r w_r w))

with w = 2pif. It is the modal coordinate's response to a unit modal force, and the term synthesize_frf sums over the modes, so a physical FRF is phi_jr phi_kr H_r summed over r. power goes inside, as there: a rigid mode's accelerance at 0 Hz is 1/m_r, and its displacement and velocity there are nan.

Parameters:

Name Type Description Default
frequencies array_like

The lines, in Hz.

required
modes sequence of int

Which modes, by index from zero, in increasing order; all of them when omitted.

None
power int

0 displacement, 1 velocity, 2 acceleration per modal force.

0

Returns:

Type Description
ndarray

(modes, lines), complex.

Raises:

Type Description
ValueError

If the set is complex: a complex mode has no second-order modal coordinate.

delete_modes
delete_modes(indices: Sequence[int]) -> None

Remove the given modes in place.

Raises IndexError for an index out of range, and ValueError if every mode would be removed (delete the object instead).

Parameters:

Name Type Description Default
indices sequence of int

Which modes to remove, by zero-based index.

required

Returns:

Type Description
None
kept
kept(modes: Sequence[int] | None) -> ShapeSet

A copy holding only modes, in the set's order and once each; the set itself when modes is None. The modes picked in the tree are what an action reads.

Parameters:

Name Type Description Default
modes sequence of int or None

Which modes to keep, by zero-based index.

required

Returns:

Type Description
ShapeSet

The copy, or the set itself for None.

Raises:

Type Description
ValueError

For a mode the set does not have, or an empty modes (picked_modes).

define_units
define_units(mass_unit: str) -> ShapeSet

Declare the mass unit the shapes were normalized against.

The coefficients are converted to SI, 1/sqrt(kg). Declaring again reinterprets the original values instead of scaling twice, so a wrong unit can be corrected.

Parameters:

Name Type Description Default
mass_unit str

The mass unit of the mass matrix the shapes were normalized against, such as 'kg'.

required

Returns:

Type Description
ShapeSet

Self, converted to SI in place.

undefine_units
undefine_units() -> ShapeSet

Remove the mass unit and restore the original coefficients; returns self.

display_shapes
display_shapes(unit_system: UnitSystem) -> ndarray

The coefficients in the display system's 1/sqrt(mass).

A set without a declared mass unit is returned unchanged.

Parameters:

Name Type Description Default
unit_system UnitSystem

The units to present in.

required

Returns:

Type Description
ndarray

The shape matrix in display units.

unit_label
unit_label(unit_system: UnitSystem | None = None) -> str

The unit label of the coefficients, such as '1/√kg'.

Parameters:

Name Type Description Default
unit_system UnitSystem

The units to label in. The declared mass unit when omitted.

None

Returns:

Type Description
str

The label, or '' when no mass unit has been declared.

mode_label
mode_label(i: int) -> str

A short label for one mode, such as 'Mode 3 — 12.4 Hz, 2% damping'.

Parameters:

Name Type Description Default
i int

Which mode, by zero-based index.

required

Returns:

Type Description
str

A short label: its frequency, and its damping when known.

save
save(path: str | PathLike) -> None

Write the shape set to a file of its own.

Parameters:

Name Type Description Default
path str or PathLike

Where to write it.

required

Returns:

Type Description
None