Surface Curvature Matlab equivalent in Python
I was trying to calculate the curvature of a surface given by array of points (x,y,z). Initially I was trying to fit a polynomial equation z=a + bx + cx^2 + dy + exy + fy^2) and then calculate the gaussian curvature $ K = \frac{F_{xx}\cdot F_{yy}-{F_{xy}}^2}{(1+{F_x}^2+{F_y}^2)^2} $ However the problem is fitting if the surface is complex. I found this Matlab code to numerically calculate curvature. I wonder how to do the same in Python. function [K,H,Pmax,Pmin] = surfature(X,Y,Z), % SURFATURE - COMPUTE GAUSSIAN AND MEAN CURVATURES OF A SURFACE % [K,H] = SURFATURE(X,Y,Z), WHERE X,Y,Z ARE 2D