Signals, HIC and the 3 ms clip¶
Module: crashmetrics.signals, crashmetrics.acceleration,
crashmetrics.pedestrian (HIC).
1. Filter: cfc_filter¶
from crashmetrics.signals import cfc_filter
a_filtered = cfc_filter(t, a_raw, cfc=1000) # 60, 180, 600 or 1000
- Implements the SAE J211-1 Appendix C filter: a 2-pole Butterworth low-pass run forward and backward, so it adds no phase shift.
- Needs uniformly sampled data and a sample rate above 2 × 2.0775 × CFC (about 4.2 kHz for CFC 1000); otherwise it raises an error.
- Each end is padded by odd reflection (
pad_ms, 10 ms by default) to reduce start-up transients.
The tests check the gain against the J211 corridor for CFC 60, 180, 600 and 1000.
2. Resultant: resultant¶
from crashmetrics.signals import resultant
a_res = resultant(ax_f, ay_f, az_f) # two or three filtered components
Filter first
Always filter the components, then form the resultant. A filtered
resultant can dip below zero and will be rejected by calculate_hic.
3. Resample irregular output: resample_uniform¶
from crashmetrics.signals import resample_uniform
t_u, a_u = resample_uniform(t, a, sample_rate=20_000.0) # Hz
Linear interpolation onto a uniform grid. Use a rate high enough for the CFC you apply next.
4. HIC: calculate_hic¶
from crashmetrics.pedestrian import calculate_hic
hic = calculate_hic(t, a_res, window_ms=15.0) # HIC15; 36.0 for HIC36
hic.value, hic.start_time, hic.end_time
- Acceleration is the resultant in g, time in s.
- The signal is linearly interpolated between samples and integrated
exactly. The default
method="grid"searches the interval end points on a 0.1 ms grid (resolution_ms) plus the samples, which is a lower bound usually within 0.05 %;method="exact"finds the maximum over continuous end points. See HIC accuracy and performance. - If the record is shorter than the window, a warning is issued and the whole record is used.
5. Peak and 3 ms clip¶
from crashmetrics.acceleration import clip_3ms, peak
peak(t, a_res) # PeakResult(value, time)
clip_3ms(t, a_res) # cumulative 3 ms, g
clip_3ms(t, a_res, mode="continuous")
clip_3ms(t, a_res, duration_ms=5) # any duration
The 3 ms clip is the highest level the signal reaches or exceeds for 3 ms:
mode="cumulative"(default): 3 ms in total, possibly over several separate intervals. Exact for the linearly interpolated signal.mode="continuous": 3 ms in one interval; never higher than the cumulative value.
Euro NCAP's "A3ms" is the cumulative definition.
6. Exceedance curves and force–duration limits¶
A force–duration (exceedance) curve gives, for each force level, how long the signal stays at or above it. Regulations such as UN R94 limit the neck and femur forces this way.
from crashmetrics.acceleration import exceedance_check, exceedance_duration, exceedance_level
exceedance_duration(t, fz, level=2000.0) # ms at or above 2 kN
exceedance_level(t, fz, duration_ms=35.0) # level held for 35 ms
limit = ((0.0, 3300.0), (35.0, 2900.0), (60.0, 1100.0)) # (ms, N)
check = exceedance_check(t, fz, limit, direction="positive")
check.utilisation, check.passed, check.critical_duration_ms
direction chooses which part of the signal is assessed: "positive",
"negative" (e.g. compression stored as negative force) or
"absolute". utilisation above 1 means the limit is exceeded.
Complete example¶
"""Example 1: from raw headform accelerations to HIC15, peak and 3 ms clip.
A synthetic headform impact in the LS-DYNA mm-ms-kg unit system
(accelerations in mm/ms^2, time in ms), with a little measurement noise.
Steps: convert units, CFC 1000 filter each axis, form the resultant,
then compute HIC15, the peak and the 3 ms clip.
"""
import numpy as np
from crashmetrics.acceleration import clip_3ms, peak
from crashmetrics.pedestrian import calculate_hic, hic_colour
from crashmetrics.signals import (
cfc_filter,
resample_uniform,
resultant,
to_g,
to_seconds,
)
# --- 1. Input data (replace with your own channels) -------------------------
time_ms = np.arange(0.0, 30.0, 0.01) # 100 kHz sampling
pulse = np.where(time_ms < 12.0, np.sin(np.pi * time_ms / 12.0) ** 2, 0.0)
rng = np.random.default_rng(1)
ax = -1.15 * pulse + 0.01 * rng.standard_normal(time_ms.size) # mm/ms^2
az = 0.55 * pulse + 0.01 * rng.standard_normal(time_ms.size)
ay = 0.01 * rng.standard_normal(time_ms.size)
# --- 2. Units: seconds and g -------------------------------------------------
t = to_seconds(time_ms, "ms")
components_g = [to_g(a, "mm/ms^2") for a in (ax, ay, az)]
# --- 3. Filter each axis with CFC 1000, then the resultant --------------------
filtered = [cfc_filter(t, a, cfc=1000) for a in components_g]
a_res = resultant(*filtered)
# --- 4. Head criteria ---------------------------------------------------------
hic = calculate_hic(t, a_res, window_ms=15.0)
a_peak = peak(t, a_res)
print(f"HIC15 : {hic.value:.0f} ({hic.start_time * 1000:.2f} to "
f"{hic.end_time * 1000:.2f} ms) -> Euro NCAP colour {hic_colour(hic.value)}")
print(f"Peak : {a_peak.value:.1f} g at {a_peak.time * 1000:.2f} ms")
print(f"3 ms clip : {clip_3ms(t, a_res):.1f} g (cumulative)")
print(f"3 ms clip : {clip_3ms(t, a_res, mode='continuous'):.1f} g (continuous)")
# --- 5. Non-uniform output? Resample before filtering -------------------------
t_irregular = np.unique(np.concatenate([t[::7], t[3::11]]))
a_irregular = np.interp(t_irregular, t, components_g[0])
t_uniform, a_uniform = resample_uniform(t_irregular, a_irregular, sample_rate=20_000.0)
print(f"Resampled : {t_irregular.size} irregular samples -> "
f"{t_uniform.size} samples at 20 kHz")
Output: