Skip to content

SmartQHSE/hse-calculators-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smartqhse-hse-calculators (Python)

30+ health, safety & environment (HSE) calculators — TRIR, LTIR, LTIFR, DART, EMR, severity rate, heat stress (WBGT), noise exposure, hand-arm vibration, ergonomics (REBA, RULA, NIOSH), fire load, evacuation time, manhours, risk matrix, incident cost, and more. Pure Python 3.11+, zero runtime dependencies, MIT licensed.

PyPI version Python versions License Tests Live demo

The Python port of @smartqhse/hse-calculators (TypeScript). Same formulas, same authoritative citations, Python-native API with type hints and dataclasses / TypedDicts.

🌐 Live calculators: tools.smartqhse.com 🏗️ Full HSE platform: smartqhse.com — AI-powered permits, risk assessments, incidents, audits, ISO 45001 compliance.


Installation

pip install smartqhse-hse-calculators

Zero runtime dependencies. Python 3.11+.

Quick start

from smartqhse_hse_calculators import (
    calculate_trir,
    calculate_ltifr,
    calculate_wbgt,
    calculate_risk_matrix,
)

# TRIR — OSHA Total Recordable Incident Rate
trir = calculate_trir(recordable_incidents=3, hours_worked=500_000)
print(trir.rate)   # 1.2
print(trir.base)   # 200_000

# LTIFR — ISO/ILO Lost Time Injury Frequency Rate
ltifr = calculate_ltifr(lost_time_injuries=3, hours_worked=500_000)
print(ltifr.rate)  # 6.0

# WBGT heat stress (ACGIH TLV / ISO 7243)
heat = calculate_wbgt(temp_c=38, humidity=60, globe_temp_c=42, indoor=False)
print(heat["risk_level"])            # 'high' or 'extreme'
print(heat["acgih_work_rest_ratio"]) # '25/75' or 'Stop work'

# 5×5 Risk matrix (oil & gas standard)
risk = calculate_risk_matrix(likelihood=4, severity=5, matrix="5x5")
print(risk["band"])     # 'extreme'
print(risk["action"])   # 'Intolerable — stop work, escalate to leadership'

Available calculators

Incident rate formulas

Function Measures Base Regulation
calculate_trir Total Recordable Incident Rate (OSHA) 200,000 29 CFR 1904.7
calculate_ltir Lost Time Incident Rate (OSHA) 200,000 29 CFR 1904.7(b)(3)
calculate_ltifr Lost Time Injury Frequency Rate (ISO/ILO) 1,000,000 ILO / ISO 45001:2018
calculate_dart Days Away, Restricted, Transferred 200,000 29 CFR 1904.7(a)
calculate_severity_rate Days lost per exposure base 200k / 1M OSHA / ILO
calculate_frequency_rate International accident frequency 1,000,000 HSE UK / IOGP
calculate_emr Workers comp Experience Modification Rate NCCI
calculate_incident_cost OSHA $afety Pays direct + indirect OSHA
calculate_heinrich_ratio Near-miss pyramid ratios Heinrich / Bird
calculate_safe_days Days since last recordable
calculate_working_days_lost ISO 45001 Clause 9.1 days-lost KPI ISO 45001

Occupational exposure

Function Measures Regulation
calculate_noise_dose Daily noise dose + 8-hr TWA OSHA 29 CFR 1910.95
calculate_noise_exposure Multi-segment TWA OSHA / ACGIH
calculate_hav Hand-Arm Vibration A(8) HSE UK L140 / ISO 5349
calculate_wbv Whole-Body Vibration A(8) ISO 2631-1 / EU 2002/44/EC
calculate_coshh_risk_score COSHH control banding HSE UK COSHH Essentials

Environmental

Function Measures Regulation
calculate_wbgt Wet Bulb Globe Temperature ACGIH TLV / ISO 7243
calculate_heat_index NWS heat index ("feels like") NWS / OSHA
calculate_lux_level Workplace illuminance CIBSE / EN 12464-1
calculate_ventilation Ventilation rate (ACH) ASHRAE 62.1
calculate_carbon_footprint Scope 1+2+3 CO₂e GHG Protocol / ISO 14064-1

Ergonomics

Function Measures Source
calculate_niosh_lift Recommended Weight Limit + Lifting Index NIOSH 94-110
calculate_reba Rapid Entire Body Assessment (1-15) Hignett & McAtamney 2000
calculate_rula Rapid Upper Limb Assessment (1-7) McAtamney & Corlett 1993
calculate_manual_handling HSE UK MAC risk banding HSE UK MAC tool

Fire safety

Function Measures Source
calculate_fire_load Fire load density (MJ/m²) NFPA 557 / BS 9999
calculate_evacuation_time RSET (Required Safe Egress Time) NFPA 101 / BS 9999
calculate_fire_extinguisher_size Min rating + count NFPA 10 / BS 5306

Workload & risk

Function Measures
calculate_manhours Total exposure hours with overtime
calculate_fte Full-time equivalent workers
calculate_risk_matrix 5×5 or 4×4 matrix scoring
calculate_risk_reduction Pre/post residual reduction
calculate_safety_score Composite 0-100 HSE KPI (A-F grade)
calculate_stress_risk HSE UK Management Standards

Type safety

Every function has type hints. Result types are @dataclass(frozen=True) or TypedDict. Works with mypy --strict.

from smartqhse_hse_calculators.incident_rates import RateResult

result: RateResult = calculate_trir(recordable_incidents=3, hours_worked=500_000)
# result.rate  → float
# result.base  → int
# result.formula → str

Regulation citations

Every formula is rooted in a published regulation or peer-reviewed ergonomic standard. No proprietary calculations, no "SmartQHSE recommends" values.

United States

  • 29 CFR 1904.7 — OSHA recordability (TRIR, LTIR, DART)
  • 29 CFR 1910.95 — OSHA occupational noise
  • NIOSH Publication 94-110 — Revised lifting equation
  • NFPA 10, 101, 557 — Fire codes
  • ASHRAE 62.1 — Ventilation
  • NCCI — Workers comp EMR

United Kingdom

  • HSE L140 — Hand-arm vibration
  • HSE MAC tool — Manual handling
  • BS 5306, BS 9999 — Fire safety
  • HSE Stress Management Standards

International

  • ISO 45001:2018 — OH&S management systems
  • ISO 14064-1 — GHG quantification
  • ISO 2631-1 — Whole-body vibration
  • ISO 7243 — WBGT heat stress
  • ILO — Frequency rate standards

Europe

  • EU Directive 2003/10/EC — Noise
  • EU Directive 2002/44/EC — Vibration
  • EN 12464-1 — Workplace lighting

Professional bodies

  • ACGIH TLVs® — Threshold Limit Values
  • GHG Protocol — Scope 1/2/3 accounting
  • IOGP — Oil & gas safety benchmarks
  • NIOSH — National Institute for Occupational Safety and Health

Who uses this library

  • Data scientists doing safety analytics in pandas / Jupyter
  • Safety researchers running statistical analyses on HSE datasets
  • Academic institutions teaching occupational health and safety
  • Government agencies analysing workplace safety trends
  • EHS software vendors embedding standardised calculations
  • Consultants producing client reports with auditable formulas
  • Industrial hygienists quantifying exposure

Full platform

SmartQHSE is the AI-powered HSE / QHSE management platform built on top of these calculators — permits, AI-generated risk assessments, incident management, contractor prequalification, ISO 45001 compliance dashboards.


License

MIT © SmartQHSE Ltd

Related

About

Python port of @smartqhse/hse-calculators — 30+ HSE calculators (TRIR, LTIR, LTIFR, DART, EMR, WBGT, REBA, RULA, NIOSH, risk matrix, fire load). Pure Python 3.11+, zero dependencies, MIT, regulation-cited (OSHA, HSE UK, ISO 45001, ILO, NIOSH, ACGIH, NFPA).

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages