Iām searching for a way to interpolate a portion of a 2d array, likely with a power law approach though perhaps more knowledgeable users have other suggestions more suited to the data. In truth, I'm at a loss for how to even implement a power law approach, but my (poor) intuition is that it might do the trick.
I have an array which has a roughly circular region of masked data, similar to the example provided. I would like to interpolate across this area using the surrounding data to get an estimate for the empty region. The complication however is that on one edge (right side here) there is an additional component to the surrounding data which I know has fairly sharp borders, likely fit with a power law. So far I have tried both linear and bicubic interpolation methods however these approaches fail because they over-estimate the contribution from the region of excess on the right.
annulus= np.array([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 16.0, 16.0, 17.0, 18.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 15.0, 15.0, 16.0, 16.0, 17.0, 18.0, 19.0, 19.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 15.0, 15.0, 15.0, 16.0, 17.0, 17.0, 18.0, 19.0, 20.0, 21.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 15.0, 15.0, 16.0, 16.0, 0.0, 0.0, 0.0, 20.0, 21.0, 22.0, 23.0, 0.0, 0.0],
[14.0, 14.0, 15.0, 15.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 22.0, 23.0, 25.0, 26.0, 0.0],
[14.0, 14.0, 15.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 24.0, 26.0, 28.0, 30.0],
[13.0, 14.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 26.0, 28.0, 30.0, 33.0],
[13.0, 14.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 25.0, 28.0, 30.0, 33.0, 0.0],
[13.0, 13.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 24.0, 27.0, 30.0, 33.0, 0.0, 0.0],
[13.0, 13.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 26.0, 28.0, 32.0, 35.0, 0.0, 0.0],
[12.0, 13.0, 14.0, 15.0, 0.0, 0.0, 0.0, 0.0, 24.0, 27.0, 30.0, 34.0, 0.0, 0.0, 0.0],
[0.0, 13.0, 14.0, 15.0, 16.0, 0.0, 0.0, 22.0, 24.0, 27.0, 31.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 15.0, 16.0, 18.0, 19.0, 22.0, 25.0, 28.0, 32.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 14.0, 16.0, 18.0, 20.0, 22.0, 25.0, 29.0, 33.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 14.0, 16.0, 18.0, 20.0, 22.0, 26.0, 29.0, 34.0, 0.0, 0.0, 0.0, 0.0]])
#change 0 to nan
annulus[annulus==0]='nan'
x=np.arange(0,annulus.shape[1])
y=np.arange(0,annulus.shape[0])
#mask
annulus=np.ma.masked_invalid(annulus)
xx,yy=np.meshgrid(x,y)
x1=xx[~annulus.mask]
y1=yy[~annulus.mask]
newarr=annulus[~annulus.mask]
#for method below, "linear" instead of "cubic" applies linear interpolation.
result=interpolate.griddata((x1,y1),newarr.ravel(),
(xx,yy),
method='cubic')
The result is an interpolation which looks like: .
I would like instead to find an approach which leaves lower values in the interpolated central region, taking into account the fact that the data on the right has a sharp decrease in signal strength beyond its border which lies on the edge of the interpolated zone.