crashmetrics.signals¶
signals
¶
Signal processing for crash time histories.
Functions:
cfc_filter: SAE J211 channel frequency class (CFC) filter.resultant: Resultant magnitude of axis components.to_g: Convert acceleration from common unit systems to g.to_seconds: Convert time to seconds.resample_uniform: Linearly interpolate a signal onto a uniform time grid.
Typical head-impact workflow: convert units, filter each axis component with CFC 1000, compute the resultant, then calculate HIC. Filter the components, not the resultant.
STANDARD_GRAVITY
module-attribute
¶
Standard acceleration of gravity in m/s^2.
cfc_filter
¶
cfc_filter(
time: ArrayLike,
signal: ArrayLike,
cfc: float,
pad_ms: float = 10.0,
) -> NDArray[float64]
Apply an SAE J211 channel frequency class (CFC) filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ArrayLike
|
Uniformly sampled 1D time array in seconds. |
required |
signal
|
ArrayLike
|
1D signal, in any unit, sampled at |
required |
cfc
|
float
|
Channel frequency class, for example 60, 180, 600 or 1000. Head acceleration for HIC normally uses CFC 1000. |
required |
pad_ms
|
float
|
Length of padding added at each end before filtering, in milliseconds, to reduce start-up transients. Set to 0 to disable. Limited to the length of the signal. |
10.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Filtered signal, same length and unit as |
Notes
Implements the digital filter of SAE J211-1 Appendix C: a 2-pole Butterworth low-pass filter applied forward and then backward, giving a phaseless 4-pole response.
With sample interval T::
wd = 2 * pi * CFC * 2.0775
wa = tan(wd * T / 2)
a0 = wa**2 / (1 + sqrt(2) * wa + wa**2)
a1 = 2 * a0
a2 = a0
b1 = -2 * (wa**2 - 1) / (1 + sqrt(2) * wa + wa**2)
b2 = (-1 + sqrt(2) * wa - wa**2) / (1 + sqrt(2) * wa + wa**2)
y[i] = a0*x[i] + a1*x[i-1] + a2*x[i-2] + b1*y[i-1] + b2*y[i-2]
The padding reflects the signal about each end point (an odd reflection), which keeps the end value and slope continuous. The padding method is a numerical choice of this package; check that it matches the procedure required by your assessment protocol.
resultant
¶
Return the resultant magnitude of two or three components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*components
|
ArrayLike
|
1D arrays of equal length in the same unit, for example the x, y and z acceleration of a headform. |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
to_g
¶
Convert acceleration to g (standard gravity, 9.80665 m/s^2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acceleration
|
ArrayLike
|
Array of acceleration values. |
required |
unit
|
str
|
Unit of Common LS-DYNA unit systems: mm-ms-kg gives |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Acceleration in g. |
to_seconds
¶
Convert time to seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ArrayLike
|
Array of time values. |
required |
unit
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Time in seconds. |
resample_uniform
¶
resample_uniform(
time: ArrayLike, signal: ArrayLike, sample_rate: float
) -> tuple[NDArray[float64], NDArray[float64]]
Linearly interpolate a signal onto a uniform time grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ArrayLike
|
Strictly increasing 1D time array in seconds. |
required |
signal
|
ArrayLike
|
1D signal sampled at |
required |
sample_rate
|
float
|
Target sample rate in Hz. |
required |
Returns:
| Type | Description |
|---|---|
tuple of numpy.ndarray
|
|
Notes
Linear interpolation does not remove content above the new Nyquist frequency. Resample to a rate well above the CFC you will apply, not below the original rate.