Functional Weave
Code in Rust

energy.carbon-emissions@1.0.0

README.md

3,242 bytes · view raw

# energy.carbon-emissions

Emissions in CO2 equivalent (CO2e) from an amount of fuel or electricity:

```
kgCO2e = quantity x conversion factor
```

using the UK government's greenhouse gas conversion factors for company
reporting (published each June by DESNZ, previously BEIS), for the 2023,
2024, 2025 and 2026 sets. They are the factors Streamlined Energy and Carbon
Reporting (SECR) and most UK carbon footprints use.

## Fuels

| fuel | unit | factor used | scope |
|---|---|---|---|
| `electricity` | kWh | UK electricity, "Electricity generated" | 2 |
| `electricity-td` | kWh | UK electricity transmission and distribution losses | 3 |
| `natural-gas` | kWh | Natural gas, kWh (Gross CV) | 1 |
| `lpg` | litres | LPG, litres | 1 |
| `burning-oil` | litres | Burning oil (kerosene, heating oil), litres | 1 |
| `gas-oil` | litres | Gas oil (red diesel), litres | 1 |
| `fuel-oil` | litres | Fuel oil, litres | 1 |
| `diesel` | litres | Diesel (average biofuel blend), litres | 1 |
| `petrol` | litres | Petrol (average biofuel blend), litres | 1 |

Gas bills are in kWh on gross calorific value (see `energy.gas-kwh`), which
is why the gas factor is the Gross CV one. A full electricity footprint is
`electricity` plus `electricity-td` for the same kWh.

## Units and rounding

- Quantities are integers in **thousandths** of the fuel's unit (watt-hours,
  millilitres), so fractional litres and kWh are exact.
- Factors are integers in **hundred-thousandths of a kg** per unit: the five
  decimal places DESNZ publishes (0.20705 kg/kWh is `20705`). The 2023 flat
  file carries more digits than the published tables show (0.2070742...);
  those were rounded half-up to the five places the condensed set displays.
- The result is **grams of CO2e**, rounded once, half-up (kgCO2e to three
  decimals). The product is split so it stays exact for any quantity whose
  answer fits an exact integer.

## Why the year is an argument, and there are no effective dates

A factor set is chosen by reporting year, not by the date the fuel was burned:
a company reporting its 2025 financial year uses the 2025 set (or states which
it used). Older sets stay valid for restating older years, so they are never
"no longer in force" and the table deliberately has no `effective` columns:
a `history=current` build keeps every year. A year that is not in the table
is an error rather than falling back to another year's factors.

## Sources

Department for Energy Security and Net Zero, "Greenhouse gas reporting:
conversion factors", flat-format workbooks, rows "Fuels", "UK electricity"
and "Transmission and distribution", column "kg CO2e":

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