I hope someone can point me in the right direction... I am quite new to Python and coding in general.
As part of a project I have sampled the temperature at various points on the surface of a solar panel, noting the x and y positions of each point as I went in millimeters. So I have a meshgrid of the surface of the panel created from x and y arrays which have mm granularity.
I also have a vector of the sampled data, with the measurements at their respective coordinates, otherwise populated by zeros.
I would like to smoothly interpolate the data between the points I know and create a nice heatmap. However, after a few hours on here reading answers and checking scipy documentation I just can't get my head round how to plot it.
I understand that RectBivariateSpline is what I should be using as my data is on a regular grid.
Here is what I have so far:
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import RectBivariateSpline
x = np.arange(0,481,1)
y = np.arange(0,544,1)
xmin, xmax = 0, 480
ymin, ymax = 0, 543
xi, yi = np.meshgrid(x,y)
Z = np.zeros_like(xi)
#Temperature samples
#row1
Z[520, 40] = 37.8 #B1
Z[520, 80] = 38 #C1
Z[520, 120] = 40 #D1
Z[520, 200] = 41 #G1
Z[520, 240] = 42.6 #H1
Z[520, 280] = 41 #I1
Z[520, 360] = 40 #L1
Z[520, 400] = 38 #M1
Z[520, 440] = 37.8 #N1
#row2
Z[475, 120] = 37.9 #D2
Z[475, 360] = 37.9 #L2
#row3
Z[430, 40] =33.4 #B3
Z[430, 440] = 33.4 #N3
#row4
Z[385, 120] = 34 #D4
Z[385, 240] = 41.4 #H4
Z[385, 360] = 34 #L4
#row6
Z[295, 40] = 35.6 #B6
Z[295, 120] = 36 #D6
Z[295, 240] = 43.2 #H6
Z[295, 360] = 36 #L6
Z[295, 440] = 35.6 #N6
#row7
Z[250, 40] = 33.7 #B7
Z[250, 80] = 31.3 #C7
Z[250, 120] = 35.2 #D7
Z[250, 200] = 39.1 #G7
Z[250, 240] = 40.5 #H7
Z[250, 280] = 39.1 #I7
Z[250, 360] = 35.2 #L7
Z[250, 400] = 31.3 #M7
Z[250, 440] = 33.7 #N7
#row8
Z[205, 40] = 33.9 #B8
Z[205, 80] = 32.4 #C8
Z[205, 120] = 33.4 #D8
Z[205, 200] = 39.8 #G8
Z[205, 240] = 42.4 #H8
Z[205, 280] = 39.8 #I8
Z[205, 360] = 33.4 #L8
Z[205, 400] = 32.4 #M8
Z[205, 440] = 33.9 #N8
#row10
Z[115, 40] = 33.1 #B10
Z[115, 120] = 30.4 #D10
Z[115, 200] = 33.9 #G10
Z[115, 280] = 33.9 #I10
Z[115, 360] = 30.4 #L10
Z[115, 440] = 33.1 #N10
#row12
Z[25, 40] = 28.6 #B12
Z[25, 120] = 27.7 #D12
Z[25, 360] = 27.7 #L12
Z[25, 440] = 28.6 #N12
interp_spline = RectBivariateSpline(yi, xi, Z)
Z2 = interp_spline(y, x)
plt.scatter(xi,yi,c=Z2)
plt.axis([xmin,xmax,ymin,ymax])
plt.colorbar()
plt.show
Any help would be much appreciated!
Regards Phil