codexthermocouple-reference-junction-test.py
thermocouple-reference-junction-test.py
"""Original schematic of a reference-junction sweep; white PNG in cwd."""
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import FancyBboxPatch
def main():
cold = np.array([20., 30.])
signal_mv = .04 * (100 - cold)
np.testing.assert_allclose(signal_mv, [3.2, 2.8])
np.testing.assert_allclose(signal_mv / .04 + cold, 100)
assert np.isclose(.001 * (100 + 1 + 1), .102)
fig, ax = plt.subplots(figsize=(8, 3.6), dpi=100, facecolor='white')
ax.set(xlim=(0, 10), ylim=(0, 4.5))
ax.axis('off')
def box(x, y, w, h, color, text):
p = FancyBboxPatch((x, y), w, h, boxstyle='round,pad=0.06', lw=1.5, edgecolor=color, facecolor='white')
ax.add_patch(p)
ax.text(x+w/2, y+h/2, text, ha='center', va='center', fontsize=11, linespacing=1.5)
box(.2, 1.65, 2.6, 1.65, '#2876ab', 'Stable reference bath\nMeasurement junction\nFixed temperature $T_h$')
box(4.0, 1.65, 3.0, 1.65, '#b06c21', 'Swept chamber\nConnector + converter\nReference temperature $T_c$')
box(8.0, 1.8, 1.8, 1.3, '#53616b', 'Computer\noutside\nchamber')
for y, color in [(2.35, '#b94d43'), (2.65, '#2876ab')]:
ax.plot([2.86, 3.95], [y, y], lw=2, color=color)
ax.text(3.4, 3.13, 'Two alloys', ha='center', fontsize=10)
ax.annotate('', xy=(7.95, 2.45), xytext=(7.06, 2.45), arrowprops=dict(arrowstyle='->', color='#53616b', lw=1.5))
ax.text(7.5, 2.8, 'Data', ha='center', fontsize=10)
ax.text(5.5, .78, r'$V_{\mathrm{meas}}=E(T_h)-E(T_c)$', ha='center', fontsize=13)
ax.text(5.5, .2, r'Compensate: $E(T_h)=V_{\mathrm{meas}}+E(T_c)$', ha='center', fontsize=12)
ax.set_title('Test the reference side while the measurement bath stays fixed', fontsize=13, pad=8)
fig.tight_layout()
fig.savefig(Path.cwd() / (Path(__file__).stem + '.png'), facecolor='white')
plt.close(fig)
if __name__ == '__main__':
main()