Kerem Özdemir

Case study · instrument four

unitguard

A converter that names what is missing instead of guessing it.

The problem

A spreadsheet will add a mass to an energy without a word. The cells hold numbers, the plus sign is a plus sign, and the result is a number too. Nothing in the file records that one column was tonnes and the other megawatt hours. The sum is carried into a report where it looks exactly like every figure around it, and the only way to catch it is for somebody to remember what the columns were.

The version of that failure specific to emissions work is the gas species. A tonne is written as a tonne. A tonne of methane and a tonne of carbon dioxide are the same quantity of nothing except mass, and moving between them is not a unit conversion at all: it is a choice about which assessment report and which time horizon to stand on. Converters that do it silently make that choice for you and leave no trace of having made it.

The mirror of it is CO2e treated as a substance. A figure in tonnes of CO2 equivalent is converted back into a mass of one gas, which requires knowing a mixture that the figure was built to forget. The number that comes out looks like a measurement and is a fabrication.

The method

Dimensional analysis, with the gas species carried inside the unit. Every unit in the instrument is a dimension and an exact scale to the SI coherent unit of that dimension. Greenhouse gas units carry a third thing: the species they count. A conversion is allowed when the dimensions match, and for gases only when a route between the two species is defined. Everything else is refused, and the refusal names the input that would make it possible.

Magnitudes are read as exact rationals over big integers rather than as floating point. Typing 0.1 gives one tenth and not the binary double nearest to it, the scale factors are exact ratios, and a conversion followed by its inverse returns the number that was typed.

unit      = (dimension, exact scale to the SI coherent unit)
ghg unit  = (mass, gas species)

same dimension    x(to) = x(from) × scale(from) / scale(to)
                  1 kWh = 3 600 000 J          exactly

between species   tC    →  tCO2    × 44/12     ratio of the molar masses
                  tCO2  →  tC      × 12/44
                  tCO2  →  tCO2e   × 1         by definition of the metric
                  tC    →  tCO2e   × 44/12 then × 1
                  every other pair              refused

Eighteen units are defined: nine of energy, J, kJ, MJ, GJ, TJ, Wh, kWh, MWh and GWh; five of mass, g, kg, t, kt and Mt; and four greenhouse gas units, tC, tCO2, tCO2e and tCH4. The page opens on 1200 tCH4 to tCO2e, which is a refusal, on purpose.

What it does

A quantity, a unit to convert from, a unit to convert to, and four worked examples as chips. The verdict panel either prints Converted, with the result, the sentence written out in full and a note on why the factor is what it is, or it prints Refused, with a headline naming what was missing, a line saying that this conversion has no answer here, and a paragraph explaining what would make it possible.

When a result is a rational that does not terminate in decimal, the printed value carries a leading tilde and a note saying that the stored value is exact and the printed one is not. One of the four example chips lands on exactly that case: five hundred tonnes of carbon to tCO2 is 5500/3, and it prints with the tilde in front of it.

Unitseighteen: nine energy, five mass, four greenhouse gas
Quantitya plain decimal, read as an exact rational
Defined gas routestC to tCO2, tCO2 to tC, tCO2 to tCO2e, tC to tCO2e
Outputa converted value with its factor named, or a refusal with the missing input named

What it refuses to do

Methane to CO2e. This is the refusal the instrument exists for. There is no conversion factor between a tonne of methane and a tonne of CO2e; there is only a global warming potential, and a global warming potential exists only inside a stated IPCC assessment report and a stated time horizon. Over one hundred years AR4 puts methane at 25, AR5 at 28, and AR6 at 27.0 for biogenic and 29.8 for fossil methane. Those are four different answers to the same question and the spread between them is not rounding. The instrument names all of them and picks none.

CO2e back into a single gas. Tonnes of CO2 equivalent are a unit of account and not a substance: the figure records how much warming a bundle of gases is held to cause, not how much of any one gas is present. Without the mix that produced it there is no mass to return, and the instrument says so rather than assume the bundle was pure carbon dioxide. The direction that does work is CO2 to CO2e, where the potential is 1 by definition.

A bare mass into a gas unit. Asking for t to tCO2 asks the instrument to supply the species, and the species is the whole difference between the two quantities. It refuses, and the refusal tells you to state the species on the input side, after which the conversion goes through.

A gas unit into a bare mass. Going the other way is arithmetically trivial, and the instrument still refuses. The species is part of the unit, and dropping it stops the figure from being an emissions figure at all. Keeping a conversion honest sometimes means refusing the easy direction.

Across dimensions. Energy to mass is refused with both dimensions named and with the missing thing named too: an energy density or an emission factor would do it, and neither was supplied. The instrument carries no default emission factor for anything, for any country, in any year.

Anything that is not a magnitude. A quantity that does not parse as a plain decimal is answered with Not a number and an explanation that magnitudes are read as exact rationals. And where two species have no defined route between them at all, the answer is Not defined rather than a chain of assumptions dressed as a factor.

Try it

The instrument runs in the projects page. It opens on a refusal. Change the source unit to tCO2 and the same conversion goes through with its factor named.

Run unitguard on the projects page

github.com/Keremozdemirra/unitguard

A converter that guesses is worse than no converter, because it returns a number, and numbers get believed.

All projects