Skip to content

hertzforge.io.rattlesnake_sine

rattlesnake_sine

Read Rattlesnake sine specification files (.npz), one tone per file.

The controller's sine environment saves each specification the way its own save_specification writes it: frequency (the breakpoints), amplitude (channels by breakpoints, the specification table's column transposed), and sweep_type and sweep_rate for each segment; and, from the controller versions that have them, phase in degrees, warning and abort as (lower/upper, left/right, channels, breakpoints), start_time and name. Files from older versions lack some of the optional arrays, and read as well.

The file names no channels and has no units. The channels are named in the controller's own order, '1', '2' and so on, which is also how a run through a response transformation records them, unless response_dof names them; the amplitudes are read as written unless ordinate_unit gives their unit. Nine files are nine specifications of one tone each; Project.merge joins them into one.

Functions:

Name Description
sniff

True for an .npz with the four arrays every sine specification

load

Read one tone as the controller wrote it.

Classes

Functions:

sniff

sniff(path: str | PathLike) -> bool

True for an .npz with the four arrays every sine specification has, and without the random specification's f and cpsd, since the two formats come from the same controller and are otherwise unrelated.

load

load(path: str | PathLike, response_dof: Sequence[str] | None = None, ordinate_dim: str = 'acceleration', ordinate_unit: str | None = None) -> SineSweepSpecification

Read one tone as the controller wrote it.

The phase is converted from degrees to radians. The warning and abort bands must be the same on the left and right sides of each breakpoint, since a tone here has one value per breakpoint; a file where they differ is refused. The tone is named by the file's name, or by the file name without it.

Parameters:

Name Type Description Default
path str or PathLike

The .npz file.

required
response_dof sequence of str

The control channels the amplitude columns belong to, in the file's order. Defaults to '1', '2', ..., the controller's channel order, which is how a run through a response transformation names them.

None
ordinate_dim str

What the amplitudes measure.

'acceleration'
ordinate_unit str

The amplitudes' unit. None keeps the file's values as they are, to be read beside data in the same unit.

None

Returns:

Type Description
SineSweepSpecification

A specification of one tone.

Raises:

Type Description
ValueError

For a file with no breakpoints, a response_dof whose length is not the number of amplitude columns, a band of the wrong shape, or a band that differs between the sides of a breakpoint.