Skip to content

hertzforge.core.shock_check

shock_check

Check a shock record before its spectrum is computed from it.

A shock on a shaker starts and ends with the table at rest, so the acceleration it records, integrated once, is a velocity that leaves zero, swings, and comes back to zero. A record whose velocity does not come back carries something the table did not do. The usual causes are a zero shift, the offset a piezoelectric accelerometer can be left with after a severe shock, and a DC offset anywhere in the signal chain. Both are small beside the peak of the acceleration and easy to miss on its plot, and both integrate to a ramp. An SRS computed from such a record is wrong at its low end, because an oscillator far below the shock's content responds to the step and to nothing else, and draws a shelf the shock never had.

So the record is integrated raw here, by the trapezoid rule with nothing removed: no mean, no drift high-pass. That is the opposite of what filters.integrate does by default, and on purpose. Its 2 Hz drift high-pass is the right default for turning a good record into a displacement estimate, and the wrong one for this check, because the drift it removes is the fault the check looks for: a record with a zero shift, integrated with the default, ends at zero velocity as if nothing were wrong. The integration is still filters.integrate, called with drift_corner=None, so there is one trapezoid rule in the package and this is a second, explicit path through it rather than a second rule.

Each window is integrated on its own, from its first sample, so every event begins from rest whatever the record did before it, and only the samples the windows cover are integrated. A window holding a sample that is not a finite number is refused rather than read, since its velocity from that sample on is not a number either.

The reading, per channel and per window, is the velocity change (the span from the lowest velocity to the highest, which for a one-signed pulse with compensation on either side is the main pulse's change), and where the velocity and displacement end as a share of their largest excursion. A record whose velocity ends further from rest than the tolerance share is flagged, and the words say which of two things it did: held at a net velocity change, as a drop machine's pulse does, or still changing when the record stops, as a zero shift or an offset does.

References

The check itself is integration and the arithmetic above; this sets out why a shock record is checked by its velocity before its spectrum is read. The spectrum is core.srs's, which cites its filter.

  1. Department of Defense (2019). MIL-STD-810H, Environmental Engineering Considerations and Laboratory Tests. Method 516.8, paragraphs 4.4 and 4.5: a shock record integrated to velocity to show a zero shift, clipping, a cable fault or a slew-rate limit, the false low-frequency content a zero shift puts in the spectrum, and an invalid record discarded; paragraph 2.3.1.1 and Annex A: the spectrum computed by the ramp-invariant algorithm.

Classes:

Name Description
ShockCheck

One channel's velocity check over one window.

Functions:

Name Description
velocity_span

The span from the lowest velocity to the highest, in the

check_shock

The velocity check of every acceleration channel over every

summarize

The checks of a record in a few lines, worst first.

Classes

ShockCheck dataclass

ShockCheck(dof: str, record: int, window: int, start: float, sample_rate: float, velocity: ndarray, displacement: ndarray, tolerance: float = RETURN_SHARE)

One channel's velocity check over one window.

The arrays are the raw velocity and displacement, in SI (m/s and m), sampled with the window and starting from rest at its first sample; start is that sample's time on the record's clock, in seconds. The numbers are read from them. flagged says the velocity did not come back within tolerance of rest, and drifting says it was still changing when the window closed.

Methods:

Name Description
describe

The verdict in words, as the view and the shock panel state

Attributes:

Name Type Description
time ndarray

Each sample's time on the record's clock, in seconds.

velocity_change float

The span from the lowest velocity to the highest, in m/s

peak_velocity float

The largest velocity either way, in m/s.

end_velocity float

The velocity at the window's last sample, in m/s, signed.

peak_displacement float

The largest displacement either way, in m.

end_displacement float

The displacement at the window's last sample, in m, signed.

end_velocity_share float

How far from rest the velocity ends, as a share of its peak.

end_displacement_share float

How far from where it started the displacement ends, as a

flagged bool

Whether the velocity ends further from rest than tolerance

drifting bool

Whether the velocity is still changing when the window closes.

Attributes
time property
time: ndarray

Each sample's time on the record's clock, in seconds.

velocity_change property
velocity_change: float

The span from the lowest velocity to the highest, in m/s (velocity_span).

peak_velocity property
peak_velocity: float

The largest velocity either way, in m/s.

end_velocity property
end_velocity: float

The velocity at the window's last sample, in m/s, signed.

peak_displacement property
peak_displacement: float

The largest displacement either way, in m.

end_displacement property
end_displacement: float

The displacement at the window's last sample, in m, signed.

end_velocity_share property
end_velocity_share: float

How far from rest the velocity ends, as a share of its peak.

Zero for a record that ends at rest, one for a pulse that ends at its full velocity change, more than one for a velocity that turned and kept going. Zero when the window never moved.

end_displacement_share property
end_displacement_share: float

How far from where it started the displacement ends, as a share of its peak; zero when the window never moved.

flagged property
flagged: bool

Whether the velocity ends further from rest than tolerance of its peak.

drifting property
drifting: bool

Whether the velocity is still changing when the window closes.

The change across the window's last TAIL is carried across the whole window, which is the velocity the acceleration the record ends on would build on its own, and compared with the peak by the same tolerance. A zero shift or an offset leaves the record ending on an acceleration that is not zero, and this is what says so; a pulse that ends at a held velocity change ends on none.

Methods:
describe
describe() -> str

The verdict in words, as the view and the shock panel state it.

Functions:

velocity_span

velocity_span(velocity: Any) -> float

The span from the lowest velocity to the highest, in the velocity's unit: a shock's velocity change.

For one pulse with nothing either side it is the area under the pulse, 2AT/π for a half-sine of peak A and duration T. For a one-signed pulse with compensation pulses before and after it, the velocity runs down through the first, up through the pulse and back through the second, and the span is still the main pulse's change, where the record's net change is zero by design. The shock check and the stroke readout both read it here.

check_shock

check_shock(history: TimeHistory, *, shocks: Sequence[Any] | None = None, tolerance: float = RETURN_SHARE) -> list[ShockCheck]

The velocity check of every acceleration channel over every window.

The windows are the ones the SRS would be computed over (TimeHistory.srs_windows): the record's shocks, or its averaging frames, or the whole record as one window. Pass shocks to check other windows. Each acceleration channel is integrated raw, once to velocity and once more to displacement, and read from each window's start (the module docstring says why raw, and why from the window's start). Channels of any other quantity are left out.

Parameters:

Name Type Description Default
history TimeHistory

The shock record.

required
shocks sequence of Shock

The windows to check in place of the record's own.

None
tolerance float

How far from rest the velocity may end, as a share of its peak, before the check is flagged.

`RETURN_SHARE`

Returns:

Type Description
list of ShockCheck

One per acceleration channel per window, channel by channel in the record's order and window by window within each.

Raises:

Type Description
ValueError

If the record holds no acceleration channel, tolerance is not a positive share, or a window holds a sample that is not a finite number.

summarize

summarize(checks: Sequence[ShockCheck], most: int = 3) -> str

The checks of a record in a few lines, worst first.

One line when every check returns to rest. Otherwise how many did not, and the verdict of up to most of them, the furthest from rest first, each named by its channel and, when the record has more than one window, its shock.