crashmetrics.bncap¶
bncap
¶
Bharat NCAP adult occupant protection scoring (AIS-197).
Follows AIS-197 (Bharat NCAP): Annexure IV (assessment criteria), Annexure VI (safety assist qualifiers), Annexure VII (modifiers) and Annexure VIII (scoring), with the star thresholds of Table 2A.
Tests: ODB frontal at 64 km/h (Hybrid III 50th driver and passenger,
16 points), MDB side at 50 km/h (ES-2, 16 points) and the pole side test
at 29 km/h (pass/fail, pole_test_passed).
Scoring
Each criterion scores 0-4 points on a linear sliding scale between the
higher (4 points) and lower (0 points) performance limit
(sliding_points). Neck shear and tension and femur compression
are scored from their exceedance curves against force-duration limits
(curve_points): the lowest point on the curve gives the score.
A body region takes its lowest-scoring criterion, then point modifiers
are subtracted (not below zero). Region scores are rounded to 3
decimals.
Frontal: the regions of driver and passenger are grouped into head & neck, chest, knee/femur/pelvis and leg & foot; each group takes the worst region or limb of the two occupants (16 points). Side: head, chest, abdomen and pelvis, 4 points each (16 points).
Capping (Annexure IV 3.2 and 4.2): a biomechanical value above the lower performance (capping) limit of a critical region (frontal head, neck, chest; side head, chest, abdomen, pelvis) removes all points of that test and caps the rating at 0 stars; a critical region scoring zero after modifiers caps it at 1 star.
Protocol edition
Every function here implements the 2023 edition of Bharat NCAP
(AIS-197, published September 2023), which rates cars from 1 October
2023 and is valid for four years, until 30 September 2027 (PROTOCOL,
VALID_FROM, VALID_UNTIL). The scoring functions take
edition=2023 and their results carry a protocol text, so a
stored result says which rules produced it. Bharat NCAP 2.0 (AIS-197
Revision 1, ratings from October 2027: 100 points in five pillars) is
not implemented yet; asking for edition=2027 raises an error rather
than scoring by the old rules. edition_for_date gives the edition for a
rating date.
Units: forces in N, moments in N m, deflections and displacements in mm, accelerations in g, VC in m/s, time in s.
EDITION
module-attribute
¶
Bharat NCAP edition implemented here: AIS-197 of September 2023.
VALID_FROM
module-attribute
¶
First day of Bharat NCAP ratings under AIS-197 (2023).
VALID_UNTIL
module-attribute
¶
Last day of the 2023 edition: four years (AIS-197 Section 1.0). Bharat NCAP 2.0 (AIS-197 Revision 1) applies from October 2027.
PROTOCOL
module-attribute
¶
Text stored in every result, naming the rules that produced it.
SUPPORTED_EDITIONS
module-attribute
¶
Editions this package can score.
NECK_SHEAR_CURVES
module-attribute
¶
NECK_SHEAR_CURVES: tuple[Curve, Curve] = (
(
(0.0, 1900.0),
(25.0, 1200.0),
(35.0, 1200.0),
(45.0, 1100.0),
),
(
(0.0, 3100.0),
(25.0, 1500.0),
(35.0, 1500.0),
(45.0, 1100.0),
),
)
Neck shear (higher, lower performance) curves, (duration ms, force N), Annexure IV 3.2.2. The lower curve is also the capping limit.
NECK_TENSION_CURVES
module-attribute
¶
NECK_TENSION_CURVES: tuple[Curve, Curve] = (
((0.0, 2700.0), (35.0, 2300.0), (60.0, 1100.0)),
((0.0, 3300.0), (35.0, 2900.0), (60.0, 1100.0)),
)
Neck tension (higher, lower performance) curves, Annexure IV 3.2.2.
FEMUR_CURVES
module-attribute
¶
Femur compression (higher, lower performance) curves, Annexure IV 3.2.4: 3.8 kN; 9.07 kN at 0 ms to 7.56 kN at 10 ms and longer.
FRONTAL_LIMITS
module-attribute
¶
FRONTAL_LIMITS: dict[str, tuple[float, float]] = {
"hic15": (500.0, 700.0),
"head_a3ms": (72.0, 88.0),
"neck_extension": (42.0, 57.0),
"chest_compression": (22.0, 42.0),
"viscous_criterion": (0.5, 1.0),
"knee_displacement": (6.0, 15.0),
"tibia_index": (0.4, 1.3),
"tibia_force": (2000.0, 8000.0),
"pedal_rearward": (100.0, 200.0),
}
Frontal (higher, lower) performance limits, Annexure IV 3.2.
SIDE_LIMITS
module-attribute
¶
SIDE_LIMITS: dict[str, tuple[float, float]] = {
"hic15": (500.0, 700.0),
"head_a3ms": (72.0, 88.0),
"rib_deflection": (22.0, 42.0),
"rib_vc": (0.32, 1.0),
"abdominal_force": (1000.0, 2500.0),
"pubic_force": (3000.0, 6000.0),
}
Side (ES-2) (higher, lower) performance limits, Annexure IV 4.2.
AOP_STAR_THRESHOLDS
module-attribute
¶
AOP_STAR_THRESHOLDS: tuple[tuple[int, float], ...] = (
(5, 27.0),
(4, 22.0),
(3, 16.0),
(2, 10.0),
(1, 4.0),
)
Minimum frontal + side score per star rating (AIS-197 Table 2A).
COP_STAR_THRESHOLDS
module-attribute
¶
COP_STAR_THRESHOLDS: tuple[tuple[int, float], ...] = (
(5, 41.0),
(4, 35.0),
(3, 27.0),
(2, 18.0),
(1, 9.0),
)
Child occupant protection (49 points) thresholds (Table 2B).
COP_STAR_THRESHOLDS_TWO_SEATER
module-attribute
¶
COP_STAR_THRESHOLDS_TWO_SEATER: tuple[
tuple[int, float], ...
] = ((5, 20.0), (4, 17.0), (3, 13.0), (2, 9.0), (1, 5.0))
Child occupant protection thresholds for two-seaters (22 points), Annexure VIII 4.3.
CurveScore
dataclass
¶
Score of an exceedance curve between two force-duration curves.
exceeds_lower
instance-attribute
¶
True if the curve goes above the lower performance (capping) curve.
FrontalOccupant
dataclass
¶
FrontalOccupant(
neck_shear: Series,
neck_tension: Series,
neck_extension: float,
chest_compression: float,
viscous_criterion: float,
femur: tuple[Series, Series],
knee_displacement: tuple[float, float],
tibia_index: tuple[float, float],
tibia_force: tuple[float, float],
hic15: float | None = None,
head_a3ms: float | None = None,
hard_contact: bool = True,
pedal_rearward: float | None = None,
modifiers: Mapping[str, float] = dict(),
)
Hybrid III 50th results in the ODB test (driver or passenger).
Leg values are given per side as (left, right); for the tibia
give the worse of upper and lower. Modifiers are points to subtract
per region: "head", "neck", "chest", "knee_left",
"knee_right", "lower_leg_left", "lower_leg_right",
"foot" (see the *_modifier helpers for the sliding ones).
neck_shear
instance-attribute
¶
neck_shear: Series
Upper neck Fx history, N (both directions assessed).
neck_extension
instance-attribute
¶
Extension moment at the occipital condyle, N m (magnitude).
femur
instance-attribute
¶
Femur Fz histories (left, right), compression negative.
tibia_force
instance-attribute
¶
Peak tibia compression, N (positive).
hard_contact
class-attribute
instance-attribute
¶
If False (peak head acceleration <= 80 g and no other evidence), the head scores 4 points.
pedal_rearward
class-attribute
instance-attribute
¶
Worst pedal rearward displacement, mm (driver only).
SideOccupant
dataclass
¶
SideOccupant(
hic15: float,
head_a3ms: float,
rib_deflection: float,
rib_vc: float,
abdominal_force: float,
pubic_force: float,
modifiers: Mapping[str, float] = dict(),
)
ES-2 results in the MDB side test.
modifiers
class-attribute
instance-attribute
¶
Points to subtract per region ("head", "chest",
"abdomen", "pelvis"), e.g. {"chest": backplate_modifier(fy)
+ t12_modifier(fy, mx)}.
RegionResult
dataclass
¶
RegionResult(
points: float,
raw_points: float,
governing: str,
criteria: dict[str, float],
capped: bool,
values: dict[str, float] = dict(),
)
points
instance-attribute
¶
Points after modifiers, rounded to 3 decimals (not below zero).
capped
instance-attribute
¶
A criterion of a critical region is above its capping limit.
values
class-attribute
instance-attribute
¶
Criterion values (HIC15, mm, N ...). For force-duration criteria (neck shear and tension, femur) the level of the exceedance curve where the score is lowest, N.
TestResult
dataclass
¶
TestResult(
points: float,
groups: dict[str, float],
regions: dict[str, dict[str, RegionResult]],
capped: bool,
critical_zero: bool,
test_modifiers: float,
protocol: str = PROTOCOL,
)
regions
instance-attribute
¶
regions: dict[str, dict[str, RegionResult]]
Region results per occupant.
critical_zero
instance-attribute
¶
A critical region scores zero after modifiers (at most 1 star).
AopRating
dataclass
¶
AopRating(
stars: int,
points: float,
frontal: float,
side: float,
reasons: tuple[str, ...],
protocol: str = PROTOCOL,
)
check_edition
¶
Return PROTOCOL for a supported edition; raise for any other.
2027 (Bharat NCAP 2.0) is refused with an explanation, so old
rules are never applied to a new-edition rating by mistake.
edition_for_date
¶
Bharat NCAP edition that applies to a rating on date.
2023 for 1 October 2023 to 30 September 2027. Earlier dates (before
the programme started) and later dates (Bharat NCAP 2.0, not
implemented yet) raise ValueError.
sliding_points
¶
Linear sliding scale: max_points at or below the HPL, 0 at or
above the LPL.
colour
¶
Colour of a 4-point region score (Annexure VIII): green 4.000, yellow 2.670-3.999, orange 1.330-2.669, brown 0.001-1.329, red 0.
curve_points
¶
curve_points(
time: ArrayLike,
signal: ArrayLike,
curves: tuple[Curve, Curve],
direction: Literal[
"positive", "negative", "absolute"
] = "positive",
mode: Literal[
"cumulative", "continuous"
] = "cumulative",
max_points: float = MAX_POINTS,
) -> CurveScore
Score an exceedance curve against higher and lower force-duration curves (Annexure IV 3.2.2 and 3.2.4).
For each level L of the exceedance curve, with duration D(L) at or
above it, the points are interpolated between the higher curve H(D)
(max_points) and the lower curve W(D) (0). The score is the lowest
point on the curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curves
|
tuple[Curve, Curve]
|
(higher, lower) curves as (duration ms, value) points, linear between points and constant after the last. |
required |
direction
|
Literal['positive', 'negative', 'absolute']
|
Part of the signal assessed (e.g. |
'positive'
|
mode
|
Literal['cumulative', 'continuous']
|
AIS-197 assesses the curves as cumulative exceedance. |
'cumulative'
|
steering_column_modifier
¶
steering_column_modifier(
rearward: float = 0.0,
upward: float = 0.0,
lateral: float = 0.0,
) -> float
Steering column displacement penalty, 0-1 point (Annexure VII 2.1.5): none up to 90 % of the EEVC limits (100 mm rearward, 80 mm upward, 100 mm lateral), 1 point beyond 110 %; worst of the three. Applied to the driver's head.
a_pillar_modifier
¶
A-pillar rearward displacement penalty on the chest, 0-2 points: 0 up to 100 mm, 2 above 200 mm (Annexure VII 2.1.6.1).
pedal_upward_modifier
¶
Upward pedal displacement penalty on the lower leg, 0-1 point: none up to 90 % of 80 mm, 1 point beyond 110 % (Annexure VII 2.1.8).
pedal_blocking_modifier
¶
Blocked pedal penalty on the foot and ankle, 0-1 point between 50 and 175 mm rearward displacement (Annexure VII 2.1.9.2).
backplate_modifier
¶
Side backplate load penalty on the chest, 0-2 points between Fy
1.0 and 4.0 kN (fy in N, Annexure VII 3.2).
t12_modifier
¶
Side T12 load penalty on the chest, 0-2 points, worst of Fy 1.5-2.0
kN and Mx 150-200 N m (Annexure VII 3.3 text; its limits table gives
1.0 kN as the Fy higher limit). fy in N, mx in N m;
magnitudes are used.
frontal_modifiers
¶
frontal_modifiers(
*,
driver: bool = True,
steering_column: tuple[float, float, float]
| None = None,
a_pillar: float | None = None,
pedal_upward: tuple[float, float] = (0.0, 0.0),
blocked_pedal_rearward: float | None = None,
unstable_airbag_contact: bool = False,
hazardous_airbag_deployment: bool = False,
incorrect_airbag_deployment: str
| Sequence[str]
| None = None,
steering_wheel_contact: bool = False,
compartment_integrity_lost: bool = False,
shoulder_belt_load: float | None = None,
knee_variable_contact: tuple[bool, bool] = (
False,
False,
),
knee_concentrated_load: tuple[bool, bool] = (
False,
False,
),
knee_variable_contact_areas: tuple[
tuple[bool, bool], tuple[bool, bool]
]
| None = None,
footwell_rupture: bool = False,
edition: int = EDITION,
) -> dict[str, float]
Frontal (ODB) modifiers by name, as points per region for
FrontalOccupant (AIS-197 2023, Annexure VII Section 2).
Each argument is one modifier, so none is applied to the wrong region or forgotten:
============================= ======================= ============
Argument Region Penalty
============================= ======================= ============
steering_column head 0-1, sliding
unstable_airbag_contact head 1
hazardous_airbag_deployment head 1
incorrect_airbag_deployment each region given 1 each
a_pillar chest 0-2, sliding
steering_wheel_contact chest 1
compartment_integrity_lost chest 1
shoulder_belt_load chest 2 above 6 kN
knee_variable_contact knee (per leg) 1
knee_concentrated_load knee (per leg) 1
knee_variable_contact_areas knee (per leg) 0.5 per area
pedal_upward lower leg (per leg) 0-1, sliding
blocked_pedal_rearward foot 0-1, sliding
footwell_rupture foot 1
============================= ======================= ============
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
driver
|
bool
|
False for the passenger: the steering, pedal and footwell modifiers are driver-only and raise an error if given. |
True
|
steering_column
|
tuple[float, float, float] | None
|
Rearward, upward and lateral steering column displacement, mm. |
None
|
a_pillar
|
float | None
|
A-pillar rearward displacement, mm. |
None
|
pedal_upward
|
tuple[float, float]
|
Upward pedal displacement acting on the (left, right) lower leg, mm. |
(0.0, 0.0)
|
blocked_pedal_rearward
|
float | None
|
Rearward displacement of a blocked pedal, mm. |
None
|
incorrect_airbag_deployment
|
str | Sequence[str] | None
|
Region or regions the airbag was meant to protect, 1 point each
(Annexure VII 2.1.4): |
None
|
shoulder_belt_load
|
float | None
|
Peak shoulder belt force, N. |
None
|
knee_variable_contact
|
tuple[bool, bool]
|
(left, right) flags, 1 point each. |
(False, False)
|
knee_concentrated_load
|
tuple[bool, bool]
|
(left, right) flags, 1 point each. |
(False, False)
|
knee_variable_contact_areas
|
tuple[tuple[bool, bool], tuple[bool, bool]] | None
|
Driver only, when the concentrated loading modifier is applied to
neither knee (Annexure VII 2.1.7.2): each knee zone is split into
the column area (75 mm either side of the steering column
centreline) and the rest of the facia, 0.5 point each. Give
|
None
|
edition
|
int
|
Bharat NCAP edition (2023). |
EDITION
|
Returns:
| Type | Description |
|---|---|
dict
|
Points to subtract per region; regions without a penalty are
left out. Pass it as |
side_modifiers
¶
side_modifiers(
*,
backplate_fy: float | None = None,
t12_fy: float | None = None,
t12_mx: float | None = None,
incorrect_airbag_deployment: str
| Sequence[str]
| None = None,
edition: int = EDITION,
) -> dict[str, float]
Side (MDB) modifiers by name, as points per region for
SideOccupant (AIS-197 2023, Annexure VII Section 3).
backplate_fy: backplate load penalty (backplate_modifier, 0-2) on the chest.t12_fy,t12_mx: T12 load penalty (t12_modifier, 0-2) on the chest, added to the backplate penalty.incorrect_airbag_deployment: region or regions the airbag was meant to protect, 1 point each (3.1), for example"head"for a curtain airbag,("head", "chest")for a seat airbag protecting both. A knee airbag deploying incorrectly in the side test is penalised in the frontal test instead (frontal_modifiers).
Forces in N, moment in N m; peak magnitudes. A hazardous airbag
deployment seen in the pole test (-1 point, 4.2) is carried over with
score_side(..., other_test_modifiers=1).
score_frontal
¶
score_frontal(
driver: FrontalOccupant,
passenger: FrontalOccupant,
door_openings: int = 0,
fuel_leakage: bool = False,
other_test_modifiers: float = 0.0,
edition: int = EDITION,
) -> TestResult
ODB frontal test score, 16 points (AIS-197 2023, Annexures IV and VIII).
Groups: head & neck (head, neck), chest, knee/femur/pelvis (both
knees) and leg & foot (both lower legs and the driver's foot), each
the worst region or limb of driver and passenger. Test modifiers:
1 point per door opening, 1 point for fuel leakage (or the EV / hybrid
post-crash penalty) and other_test_modifiers points.
score_side
¶
score_side(
occupant: SideOccupant,
door_openings: int = 0,
fuel_leakage: bool = False,
other_test_modifiers: float = 0.0,
edition: int = EDITION,
) -> TestResult
MDB side test score, 16 points: head, chest (worst rib), abdomen
and pelvis, 4 points each (AIS-197 2023, Annexures IV 4.2 and VIII). All four are
critical regions. other_test_modifiers covers e.g. a hazardous
airbag deployment carried over from the pole test (1 point).
pole_test_passed
¶
pole_test_passed(
hic15: float,
head_peak: float,
head_contact: bool,
rib_deflection: float,
rib_vc: float,
abdominal_force: float,
pubic_force: float,
edition: int = EDITION,
) -> bool
Side pole test, 29 km/h (AIS-197 2023, Annexure IV 5.2, Annexure VII 4.1): HIC15 < 700, peak resultant head acceleration < 80 g, no direct head contact with the pole, and thorax, abdomen and pelvis below the side lower performance limits (modifiers not applied).
aop_rating
¶
aop_rating(
frontal: TestResult,
side: TestResult,
max_stars_allowed: int = 5,
edition: int = EDITION,
) -> AopRating
Adult occupant protection star rating (AIS-197 2023, Table 2A and Annexure VII Section 5).
- Stars from the frontal + side points: 27 / 22 / 16 / 10 / 4 for 5 / 4 / 3 / 2 / 1 stars.
- A capping limit exceeded in either test: 0 stars.
- A critical region at zero points (red): at most 1 star.
- Front and side scores differing by more than 35 % (taken here as 35 % of the 16-point test maximum): one star less, unless both scores exceed 8.2 points and the total exceeds 22.
max_stars_allowed: the highest rating whose safety assist qualifiers (Annexure VI: ESC, side head protection with a side pole test, pedestrian protection, seat belt reminders) are met; seepole_test_passed.
cop_stars
¶
Child occupant protection stars from its points (49, or 22 for two-seaters), AIS-197 Table 2B and Annexure VIII 4.3.