Estimate a matrix of numbers based on known angle values?

There is probably a name for the algorithm I want, but I'm not sure how to find this. I have many 96-well plates like this:

    1  2  3  4  5  6  7  8  9 10 11 12
   ------------------------------------
A | X  O  O  O  O  O  O  O  O  O  O  X |
B | O  O  O  O  O  O  O  O  O  O  O  O |
C | O  O  O  O  O  O  O  O  O  O  O  O |
D | O  O  O  O  O  O  O  O  O  O  O  O |
E | O  O  O  O  O  O  O  O  O  O  O  O |
F | O  O  O  O  O  O  O  O  O  O  O  O |
G | O  O  O  O  O  O  O  O  O  O  O  O |
H | X  O  O  O  O  O  O  O  O  O  O  X |
   ------------------------------------

I measured the light level in each corner using a light indicator and would like to use these four values ​​(indicated by Xs) to evaluate the levels everywhere else. I think I want some weighted average based on how close each corner is.

Levels tend to change diagonally, if that matters. For example, the upper right will be the highest, the lower left lower, and the other two somewhere somewhere between them (but perhaps nowhere near the middle).

My hosts are usually R and python, but any language is fine, since I just need to write matrices as CSV files.

+4
3

, :

import numpy as np
import matplotlib.pyplot as plt

c1 = 0  # Corner values
c2 = 1
c3 = 1
c4 = 4

a=np.linspace(c1, c2, 8)
b=np.linspace(c3, c4, 8)
c = np.array([np.linspace(i,j,12) for i,j in zip(a,b)])

print np.shape(c)

plt.figure()
plt.imshow(c)
plt.show()

enter image description here

+1

R, ( ) :

library(raster)

##  Four corner values defined as a matrix, raster:
m <- matrix(c(12,4,3,9), 2, 2)
r <- raster(m)

##  Construct a new raster, with dimentions matching
##    the grid you're interpolating to:
r_i <- raster(nrows=200, ncols=200, ext=extent(r))

##  Resample your four corners, the default is using
##    bilinear interpolation:
r_i <- resample(r, r_i)

##  Plot our results:
par(mfrow=c(1,2))
plot(r, zlim=c(-10,25))
plot(r_i, zlim=c(-10,25))

enter image description here

, , , , , , . (, ..).

+3

2D-. , .

python ( , R ):

import numpy as np
import numpy as np
import scipy.interpolate
import matplotlib.pyplot as plt

y, x = np.mgrid[:12, :12]

xcorners = x[0,0], x[0, -1], x[-1, 0], x[-1, -1]
ycorners = y[0,0], y[0, -1], y[-1, 0], y[-1, -1]
zcorners = [1, 2, 3, 4]

xy = np.column_stack([xcorners, ycorners])
xyi = np.column_stack([x.ravel(), y.ravel()])
zi = scipy.interpolate.griddata(xy, zcorners, xyi)
zi = zi.reshape(x.shape)

fig, ax = plt.subplots()
grid = ax.pcolormesh(x, y, zi)
ax.scatter(xcorners, ycorners, c=zcorners, s=200)
fig.colorbar(grid)
ax.margins(0.05)

plt.show()

enter image description here

+2

All Articles