I have a series of x,y,z data in a csv file. I tried to make a grid data for contour plotting of them in a grid. My code looks like below:
source_data1= open('XYZ_data.csv').readlines()
firstline= source_data1.pop(0)
xCoord=[]
yCoord=[]
zCoord=[]
for line in source_data1:
if len(line) > 1:
X,Y,Z= line.split(',')
xCoord.append(float(X))
yCoord.append(float(Y))
zCoord.append(float(Z))
x = np.linspace(minXData, maxXData, 50)
y = np.linspace(minYData, maxYData, 50)
Z= griddata((xCoord, yCoord), zCoord, (x[None,:], y[:,None]), method='linear')
Now, with the new structured grid (i.e. 50x50), I would like to have the interpolated z components in another csv file in a format like below
x,y,z
12.2344,5.3435,12.4
...
Can someone help me please?