Unit Convert
Shippingunit_convertRe-express a quantity in another unit, or simplify/reduce its compound unit to canonical SI form
Signature
Inputs
valueScalar|Signalrequired— The quantity to convert. Its source unit is resolved leniently (custom units auto-register).
Outputs
resultScalar|Signal— Same shape as the input, its value (and ±σ) rescaled and re-expressed in the resolved output unit.
Parameters
| Key | Type | Default | Notes |
|---|---|---|---|
mode | enum | target | one of: target, coherent, base |
target_unit | unit | Unit to express the quantity in (mV, km/h, kg/m^3, Wh, °F …), used only in **Convert to unit** mode. The value AND its uncertainty rescale; temperatures convert affinely. Empty = pass-through. Errors on incompatible dimensions or unknown symbols (resolved strictly, so a typo is a loud error rather than a freshly minted dimension). |
Description
Unit Convert expresses a quantity in a different unit while preserving the physical measurement — the number changes, its meaning does not. It is the semantic partner of set_unit, which changes the meaning while keeping the number.
Three output-unit modes share one conversion engine:
- Convert to unit (
target) — the classic path: re-express in a user-typedtarget_unit(mV,km/h,Wh,°F). - Simplify (coherent SI) (
coherent) — reduce the quantity's dimension to its named coherent SI unit (, , , ). The target is looked up from the source dimension, so the physical quantity is preserved — only its written form is canonicalised. - Reduce to base SI (
base) — decompose the dimension into irreducible base SI units (, ). Numerically identical tocoherent(every base unit has scale 1); only the written symbol differs.
For ordinary units the conversion is the full affine map with , so shifts correctly while is a pure rescale. Per-sample variance converts by only — an offset shifts the value but never affects the spread, so scales purely by the slope.
When the source or target is logarithmic (dB ↔ linear, e.g. dBV, dBm) the map is nonlinear: each value passes through the base scale and each variance propagates first-order by the local slope², which is value-dependent. On this path the σ-correlation lineage is dropped (the node re-enters as a fresh source), mirroring the FFT/IIR drop policy.
Empty target in target mode is an explicit identity pass-through — a freshly dropped node never errors and never silently invents a canonical form. Incompatible dimensions error with both dimensional formulas in the message.
Mathematics
Examples
Volts to millivolts (value and σ rescale)
target mode, target_unit = mV. An input of becomes (). The factor is , offset .
Celsius to Fahrenheit is affine
target_unit = °F. 25\,^{\circ}C \pm 0.5 maps to 77\,^{\circ}F. The value shifts by the offset, but scales by the slope only: , so .
Simplify a compound unit to named SI
coherent mode. A quantity of is dimensionally an energy, so it simplifies to Joules: . Likewise .
Reduce Watts to base SI
base mode on yields kg*m^2/s^3 with the same value. The generated symbol re-parses through the unit engine back to the power dimension, so a downstream node can resolve it.
dBV to Volts (logarithmic)
target_unit = V. . A σ of propagates by the local slope , so at this operating point.
Applications
- Presenting acquired data in engineering units (V→mV, m→km, Pa→bar) with uncertainty carried along automatically.
- Collapsing a chain of arithmetic that leaves a messy compound unit (m·km/h·kg/s) into a clean named result (J) for display or export.
- Reducing named units to irreducible base SI to verify dimensional consistency of a derived quantity.
- Converting logarithmic sensor readings (dBV, dBm) to linear V/W before downstream math that expects linear units.
Neat
One conversion engine serves all three modes: `coherent` and `base` only differ in how the target is *derived* — the coherent mode looks up the dimension's named SI unit, base mode spells the same scale-1 value out in irreducible symbols.
The base-SI symbol is emitted in conventional textbook order (mass·length·time·…), split into numerator and denominator, and is guaranteed to re-parse to the same dimension so it round-trips through the unit parser.
Variance converts by factor² independent of the affine offset — a deliberate consequence of the units subsystem's affine model (ADR-002): a temperature shift moves the mean but not the spread.
Known issues
Logarithmic conversions (dB ↔ linear) are nonlinear, so they drop the σ-correlation lineage and re-enter as a fresh source — downstream correlation with the pre-conversion signal is lost.
In `target` mode an unknown or misspelled target unit is a strict, loud error (it will not auto-register a new dimension); the simplify modes ignore any stale `target_unit`.
Converting across incompatible dimensions (e.g. V→kg, or dBV→W) errors with both dimensional formulas rather than producing a value.