Skip to main content
Glama
dfieser

io.github.dfieser/thermocouple-its90

thermocouple-its90

用于 Python 的 NIST ITS-90 热电偶转换:电压转温度和温度转电压,支持全部八种字母代号类型(B、E、J、K、N、R、S、T),并带有冷端补偿和塞贝克系数。测试套件在每次运行时都会验证 NIST 参考表中全部 12,026 个列表点的数据。

Tests PyPI Python License: MIT DOI

纯标准库实现,无任何依赖,完整类型标注。本引擎的浏览器版本以免费在线热电偶计算器的形式运行,每次发布时都会从本仓库同步代码。

安装

pip install thermocouple-its90

Related MCP server: mcp-units

将热电偶毫伏转换为温度

from thermocouple_its90 import TypeK

TypeK.emf(300.0)          # 12.209  (mV at 300 C, 0 C reference: the table value)
TypeK.temperature(12.209) # 300.0   (C, ice-bath reference)
TypeK.seebeck(300.0)      # 0.0416  (mV per C)
TypeK.range               # (-270.0, 1372.0)

冷端补偿

热电偶测量的是其两个结点之间的温差,而参考表假定冷端处于 0 C。如果您的仪表接线端子处于室温,直接查表就会出错:

from thermocouple_its90 import TypeK

# Meter reads 4.096 mV, terminals at 25 C:
TypeK.temperature(4.096)                  # 100.0 C  <- naive lookup, wrong
TypeK.temperature(4.096, reference=25.0)  # 124.3 C  <- the actual answer

全部八种类型的工作方式相同:

from thermocouple_its90 import get, letters

letters()                       # ['B', 'E', 'J', 'K', 'N', 'R', 'S', 'T']
get("s").emf(1400.0)            # 14.373 mV
get("t").temperature(-4.648)    # -149.98 C (cryogenic ranges included)

精度:经过验证,而非口头宣称

  • 正向参考函数可复现 NIST 参考表中全部 12,026 个逐度数据点,误差在其 0.001 mV 的打印舍入范围内。完整对比在每次推送时都会在 CI 中运行(tests/test_full_tables.py)。

  • 反演以已发布的 ITS-90 逆多项式为初值,并在精确正向函数上通过牛顿迭代进行精化。往返转换的误差可达微度量级,远优于逆多项式 0.02 至 0.06 C 的误差带。

  • K、E 和 T 型可在其完整低温范围内(低至 -270 C)进行反演,而已发布的逆多项式在该范围以下即失效。

  • B 型按其物理特性处理:其电动势在室温附近是非单调的,因此当输入低于 0.291 mV(约 250 C)时会拒绝反演并给出解释,而不是返回两个可能答案之一。

面向 AI 智能体的 MCP 服务器

语言模型经常记错热电偶多项式。本包附带一个 Model Context Protocol 服务器,使智能体可以调用经过验证的实现:

pip install "thermocouple-its90[mcp]"
claude mcp add thermocouple -- thermocouple-its90-mcp

工具:thermocouple_to_temperature、thermocouple_to_emf、thermocouple_types。

数据来源与许可

系数是从 NIST ITS-90 热电偶数据库(SRD 60,https://its90.nist.gov/)中通过机器解析获得,绝非手工录入。该数据库复现了 NIST Monograph 175(Burns、Scroger、Strouse、Croarkin 和 Guthrie,1993 年),这是美国政府的出版物,不受版权保护。规范数据集位于 data/its90.json 中;_data.py 由它生成,如果两者出现偏差,CI 将失败。代码采用 MIT 许可。

相关资源

引用

如果本库在已发表的工作中有用,请通过概念 DOI https://doi.org/10.5281/zenodo.22036393 引用它,该 DOI 始终解析到最新版本(参见 CITATION.cff)。还请引用底层参考文献:Burns, G. W., Scroger, M. G., Strouse, G. F., Croarkin, M. C., & Guthrie, W. F. (1993). Temperature-electromotive force reference functions and tables for the letter-designated thermocouple types based on the ITS-90 (NIST Monograph 175). NIST.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    MCP server for converting cooking measurements (volume, weight, temperature) between common units like ml, cup, g, oz, and Celsius/Fahrenheit.
    3
    1
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    An MCP server for controlling lab instruments (oscilloscopes, signal generators, etc.) via standardized interfaces like USBTMC, RS-232, and LAN.
    100
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    This MCP server enables AI clients to calculate the boiling temperature of water at a given absolute pressure using the IAPWS-IF97 standard, separating natural-language reasoning from authoritative scientific computation.
    1
    MIT