Functional Weave
Code in TypeScript

fleet.emissions@1.0.1

README.md

4,562 bytes · view raw

# fleet.emissions

Greenhouse gas emissions, in grams of CO2 equivalent, for fuel a fleet burned
or distance it drove, using the UK government's conversion factors for company
reporting (published by DESNZ, the Department for Energy Security and Net
Zero). `fleetEmissions("fuel-diesel", "100", "litres", 2025)` is 257,082 g.

## Which factor

Fuel is the better measure when you have it (fuel cards, bunkered fuel): it
already reflects how the vehicles were driven. Distance by vehicle class is the
fallback. The factors are the **Scope 1** figures, direct tailpipe emissions
in kg CO2e (CO2, CH4 and N2O together):

- fuels, per litre: `fuel-diesel` and `fuel-petrol` (UK forecourt fuel with
  its average biofuel blend), `fuel-diesel-mineral` and `fuel-petrol-mineral`
  (100% mineral), `fuel-lpg`;
- cars by size, per km or mile: `car-{small|medium|large|average}-{diesel|petrol|hybrid|phev|cng|lpg|unknown}`
  where DESNZ publishes one (there is no small CNG or LPG car);
- `motorbike-{small|medium|large|average}`;
- vans: `van-{class-1|class-2|class-3|average}-{diesel|petrol}`, and
  `van-average-{cng|lpg|unknown|phev}` and `van-class-3-phev` (the van PHEV
  factors appear from 2024);
- HGVs (all diesel): `hgv-{rigid-3.5-7.5t|rigid-7.5-17t|rigid-over-17t|all-rigids|artic-3.5-33t|artic-over-33t|all-artics|all-hgvs}-laden-{0|50|100|average}`.

Battery electric vehicles are deliberately absent: their Scope 1 factor is
zero, and their emissions belong to the electricity used (Scope 2, DESNZ's "UK
electricity for EVs" table), which this package does not carry. A plug-in
hybrid's factor likewise covers only the fuel it burns.

Per-mile factors are DESNZ's own, not the per-km factor times 1.609344, so a
report matches the published spreadsheet exactly.

## Which year

`factorYear` picks the DESNZ set: 2023, 2024, 2025 or 2026. DESNZ publishes
each set in June for reporting periods in that year; use the set for the year
you are reporting, and keep it for restatements. The sets are publications,
not rules that expire, so the table has no effective columns and ships whole.

In the 2026 set DESNZ split HGVs into refrigerated and non-refrigerated and
renamed the averages; the `hgv-*` codes read the non-refrigerated rows for
2026 (earlier years' "HGV (all diesel)" table is the non-refrigerated fleet,
refrigerated HGVs having had their own table), so the codes mean the same
vehicle in every year.

## Exactness

Each factor is stored as an integer in units of 0.00001 kg (10 mg): DESNZ
publishes five decimal places. The 2023 flat file holds the unrounded values
behind them (2.5120638845637586 for diesel); they are rounded half up to the
five places shown in the published tables (2.51206). The quantity is decimal
text, so quantity times factor is exact, and the only rounding is the final
one, half up to a whole gram. Quantities are limited to 15 significant digits
and 9 decimal places, and a result above 2^53 - 1 grams is an error, so all
three languages agree.

## Relationship to energy.*

This package is self-contained. If an `energy.carbon-emissions` capability
with the same DESNZ tables appears in the registry, a later version of this
one should read its data instead of carrying a second copy.

## Sources

- DESNZ, "Greenhouse gas reporting: conversion factors 2023", flat file
  (ghg-conversion-factors-2023-flat-file-update.xlsx):
  https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2023
- DESNZ, "Greenhouse gas reporting: conversion factors 2024", flat file v1.1
  (ghg-conversion-factors-2024-FlatFormat_v1_1.xlsx):
  https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2024
- DESNZ, "Greenhouse gas reporting: conversion factors 2025", flat file
  (ghg-conversion-factors-2025-flat-format.xlsx):
  https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2025
- DESNZ, "Greenhouse gas reporting: conversion factors 2026", flat file,
  revised July 2026 (ghg-conversion-factors-2026-flat-format-revised.xlsx):
  https://www.gov.uk/government/publications/greenhouse-gas-reporting-conversion-factors-2026

Every row of `data/ghg-factors.json` names the spreadsheet path it came from
(Level 1 / Level 2 / Level 3 / column), always the "kg CO2e" row of Scope 1.

## Notices

Contains public sector information licensed under the Open Government
Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

1.0.1 adds its attribution notices (NOTICE). The code and the tests are unchanged.