"""Illustrative equal-area thermal indicator curves; Python 3.14 / Matplotlib 3.10. Run from _media; output is thermodilution-equal-area-curves.png in cwd. Curves are A*t*exp(-t/tau)/tau**2, with analytic integral A=1 K s. They illustrate a conservation calculation, not patient data. """ from pathlib import Path import math import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt A = 1.0 # K s, exact integral from zero to infinity seconds = [i / 100 for i in range(1601)] fig, ax = plt.subplots(figsize=(7.2, 3.8), dpi=100, facecolor='white') for tau, color in ((1.0, '#1766a5'), (2.0, '#c15b18')): deficit = [A * t * math.exp(-t / tau) / tau**2 for t in seconds] ax.plot(seconds, deficit, color=color, linewidth=2.3, label=rf'$\tau={tau:g}$ s; peak ${A/(math.e*tau):.3f}$ K') ax.set(xlim=(0, 16), ylim=(0, .42), xlabel='Time after indicator arrival (s)', ylabel='Temperature deficit (K)', title='Equal thermal area, different peak temperatures') ax.text(.98, .95, 'Both full integrals: 1 K s\nSynthetic curves; no patient data', transform=ax.transAxes, ha='right', va='top', fontsize=10) ax.legend(loc='center right', frameon=False, fontsize=10) ax.spines[['top', 'right']].set_visible(False) ax.grid(axis='y', color='#dddddd', linewidth=.6) fig.tight_layout() fig.savefig(Path('thermodilution-equal-area-curves.png'), facecolor='white', dpi=100) plt.close(fig)