I am trying to find the volume given a set of data points (x,y,z) using python. These data points are samples collected from an experiment (so the plotted surface can be quite irregular). I have worked out how to create a 3D plot but not how to calculate the volume using python.
X, Y = np.meshgrid(x, y)
Z = griddata(xpts, ypts, zpts, x, y)
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z,
rstride=5,
cstride=5,
cmap=cm.jet,
linewidth=0,
antialiased=True,
vmin=np.nanmin(Z),
vmax = np.nanmax(Z))
Here's a similar question to find the area under an irregular surface using python, Volume under "plane" defined by data points - python. Could this be adapted to find the volume? Any help is appreciated. Thanks.