@metrologybench/core
v0.6.1
Published
Open-source metrology calculations with every equation, coefficient and source shown. Powers metrologybench.com, its embeddable calculators and the metrology-toolbox-mcp server.
Maintainers
Readme
@metrologybench/core
Open-source metrology calculations with every equation, coefficient and source shown. This library powers metrologybench.com, its embeddable calculators and its MCP server, so every surface gives the same answer.
Results are calculated values, not certified results. Accredited laboratories must validate any software they use for calibration results themselves (ISO/IEC 17025, clause 7.11). The test vectors in vectors/ are provided to help with that.
What's in v0.1.0
| Module | Functions | Source |
|---|---|---|
| RTD | rtdResistance, rtdTemperature, rtdSensitivity | Callendar–Van Dusen equation, Pt385 coefficients (IEC 60751 / ASTM E1137) |
| Thermocouple | tcEmf, tcTemperature, tcRange (types B, E, J, K, N, R, S, T); cold-junction compensation tcTemperatureCjc, tcEmfCjc | NIST ITS-90 Thermocouple Database, SRD 60 (Monograph 175); same functions as IEC 60584-1:2013 |
| Rounding | roundDecimals, roundSigFigs, formatValue | Decimal-string rounding, half up or half to even |
| Conformity | conformity, specificRisk, guardBandForSpecificRisk, acceptanceLimits, globalRisk, managedGuardBand, globalRiskStatement | Decision rules and guard bands (ILAC G8:09/2019, ASME B89.7.3.1); specific and global risk with normal distributions (JCGM 106:2012, ANSI/NCSL Z540.3 Handbook) |
Rules every function follows
- Full precision inside, rounding only for display. Use the rounding module to present a result; never round in the middle of a calculation.
- Refuse, don't extrapolate. Inputs outside an equation's defined range throw
OutOfRangeErrorwith the valid range in the message. - Every thermocouple inverse reports its NIST error band alongside the temperature.
- Cold-junction compensation adds EMFs, never temperatures: E_total = E_measured + E(t_ref), then invert.
Example
import { rtdResistance, tcTemperature, roundDecimals } from '@metrologybench/core';
roundDecimals(rtdResistance(100), 4); // "138.5055" (Pt100 at 100 °C)
tcTemperature('K', 4.096); // { value: ≈100.0, inverseError: [-0.05, 0.04] }
tcTemperatureCjc('J', 4.095, 23); // reference junction at 23 °C: value ≈ 100.0 °CTest vectors
vectors/v0.1.0.json holds every reference case: inputs, expected value, tolerance, source and why the case matters. npm test checks the library against all of them, plus full-range round-trip sweeps.
License
Code: Apache 2.0. Written content on metrologybench.com: CC BY 4.0. "Metrology Bench" is a name, not part of the license.
