In [64]:
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt

def pt_convert(t_pg, t_ht, p_ht=11.48636):
    p_atm_ht = 14.7
    p_atm_pg = 14.7
    t_pg = 5 / 9 * (t_pg + 459.67)
    t_ht = 5 / 9 * (t_ht + 459.67)
    p_ht = p_ht + p_atm_ht
    p_pg = p_ht * t_pg / t_ht
    p_pg = p_pg - p_atm_pg
    return p_pg

t_pg = np.linspace(60, 80, (80 - 60) / 0.1 + 1)
t_ht = np.linspace(40, 80, (80 - 40) / 0.1 + 1)

p_pg = []
for tp in t_pg:
    for th in t_ht:
        p_pg.append(pt_convert(tp, th))

p_pg = np.array(p_pg)
p_pg = p_pg.reshape(len(t_pg), len(t_ht))

plt.pcolor(t_ht, t_pg, p_pg, cmap='coolwarm', vmin=10, vmax=15)
plt.xlabel('Halftime ball temperature at measurement ($^\circ$F)')
plt.ylabel('Pre-game ball temperature at measurement ($^\circ$F)')
cbar = plt.colorbar()
cbar.set_label('Pre-game ball pressure (psig)', rotation=270, labelpad=20)
plt.title('Temperature heatmap showing legal/illegal pre-game pressure\n(for average halftime pressure reading of 11.5 psig)', y=1.05)
plt.show()