Metadata-Version: 2.4
Name: smartqhse-hse-calculators
Version: 0.1.0
Summary: Free open-source library of 30+ HSE (Health, Safety, Environment) calculators — TRIR, LTIR, LTIFR, DART, EMR, severity rate, WBGT heat stress, noise exposure, hand-arm vibration, REBA, RULA, NIOSH lifting, fire load, evacuation time, risk matrix. Pure Python 3.11+, zero runtime dependencies, regulation-cited (OSHA, HSE UK, ISO 45001, ILO, NIOSH, ACGIH).
Project-URL: Homepage, https://tools.smartqhse.com
Project-URL: Documentation, https://github.com/SmartQHSE/hse-calculators-py#readme
Project-URL: Repository, https://github.com/SmartQHSE/hse-calculators-py
Project-URL: Issues, https://github.com/SmartQHSE/hse-calculators-py/issues
Project-URL: Changelog, https://github.com/SmartQHSE/hse-calculators-py/releases
Project-URL: Platform, https://www.smartqhse.com
Author-email: SmartQHSE Ltd <support@smartqhse.com>
License: MIT
License-File: LICENSE
Keywords: carbon-footprint,dart-calculator,dart-rate,ehs,ehs-software,emr,ergonomic-risk,ergonomics,evacuation-time,experience-modification-rate,fire-load,frequency-rate,ghg-protocol,hand-arm-vibration,hav-calculator,health-and-safety,heat-stress,heat-stress-calculator,hse,hse-software,incident-rate-calculator,iso-45001,iso-45001-compliance,kpi,ltifr,ltifr-calculator,ltir,ltir-calculator,manhours-calculator,manual-handling,niosh,niosh-lifting-equation,noise-dose,noise-exposure,occupational-safety,osha,osha-300a,osha-compliance,qhse,reba,reba-calculator,riddor,riddor-calculator,risk-assessment,risk-matrix,rula,rula-calculator,safety,safety-management,safety-metrics,severity-rate,trir,trir-calculator,wbgt,whole-body-vibration,workplace-safety,zero-dependencies
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Healthcare Industry
Classifier: Intended Audience :: Manufacturing
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest-cov>=4; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.1; extra == 'dev'
Description-Content-Type: text/markdown

# 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](https://img.shields.io/pypi/v/smartqhse-hse-calculators.svg)](https://pypi.org/project/smartqhse-hse-calculators/)
[![Python versions](https://img.shields.io/pypi/pyversions/smartqhse-hse-calculators.svg)](https://pypi.org/project/smartqhse-hse-calculators/)
[![License](https://img.shields.io/pypi/l/smartqhse-hse-calculators.svg)](./LICENSE)
[![Tests](https://github.com/SmartQHSE/hse-calculators-py/actions/workflows/test.yml/badge.svg)](https://github.com/SmartQHSE/hse-calculators-py/actions/workflows/test.yml)
[![Live demo](https://img.shields.io/badge/demo-tools.smartqhse.com-00C897.svg)](https://tools.smartqhse.com)

The Python port of [`@smartqhse/hse-calculators`](https://github.com/SmartQHSE/hse-calculators) (TypeScript). Same formulas, same authoritative citations, Python-native API with type hints and dataclasses / TypedDicts.

🌐 **Live calculators:** [tools.smartqhse.com](https://tools.smartqhse.com)
🏗️ **Full HSE platform:** [smartqhse.com](https://www.smartqhse.com) — AI-powered permits, risk assessments, incidents, audits, ISO 45001 compliance.

---

## Installation

```bash
pip install smartqhse-hse-calculators
```

Zero runtime dependencies. Python 3.11+.

## Quick start

```python
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`.

```python
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](https://www.smartqhse.com) 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

- **TypeScript version:** [`@smartqhse/hse-calculators`](https://github.com/SmartQHSE/hse-calculators)
- **Live web UI:** [tools.smartqhse.com](https://tools.smartqhse.com)
- **HSE Benchmarks 2026 open dataset:** [smartqhse.com/datasets/hse-benchmarks-2026](https://www.smartqhse.com/datasets/hse-benchmarks-2026)
- **Awesome HSE:** [github.com/SmartQHSE/awesome-hse](https://github.com/SmartQHSE/awesome-hse)
- **HSE knowledge base:** [smartqhse.com/answers](https://www.smartqhse.com/answers)
