I have issues interpolating my data into a grid using scipy interpolate griddata. My data is in 2D and has the form: X array, Y array and some intensity in Z. As these data are not spaced evenly, I want to reinterpolate them into a grid, in order to save images to work with later.
It works perpectly if I have one Z data block. My problem arises when I have discontinous Z data (like "islands" of data separated by zones were there is no data). In this case, interpolation also occurs in the gap between my data blocks.
Some illustration of the problem:
Is there any way to interpolate my data properly?
Some part of the (very simple) code:
import numpy as np
from scipy import interpolate
X=data['X']
Y=data['Y']
Z=data['Z']
Xa,Ya=np.linspace(min_x, max_x, dim_x),np.linspace(min_y, max_y, dim_y) #dimensions of my grid, depends on the dataset I have
XX,YY=np.meshgrid(Xa,Ya) #creation of the grid
Zb = interpolate.griddata((X,Y), Z, (XX,YY), method='linear')
I have tried 'nearest' or 'cubic' but I does not work either...
EDIT: I added a text file with some example X, Y an Z I tried to interpolate, along with the new "Zb" interpolated data to show the problem. The same data was plotted in the image above. The data is available here: Gdrive


griddataon each side of the image withfill_value=0and then recombine? - user228395