Get the minimal surface solution of a 3D contour

You can use FEniCS: from fenics import ( UnitSquareMesh, FunctionSpace, Expression, interpolate, assemble, sqrt, inner, grad, dx, TrialFunction, TestFunction, Function, solve, DirichletBC, DomainBoundary, MPI, XDMFFile, ) # Create mesh and define function space mesh = UnitSquareMesh(100, 100) V = FunctionSpace(mesh, “Lagrange”, 2) # initial guess (its boundary values specify the Dirichlet boundary conditions) # (larger … Read more

How to perform cubic spline interpolation in python?

Short answer: from scipy import interpolate def f(x): x_points = [ 0, 1, 2, 3, 4, 5] y_points = [12,14,22,39,58,77] tck = interpolate.splrep(x_points, y_points) return interpolate.splev(x, tck) print(f(1.25)) Long answer: scipy separates the steps involved in spline interpolation into two operations, most likely for computational efficiency. The coefficients describing the spline curve are computed, using … Read more

Rotation Interpolation

I know this is 2 years old, but I’ve recently been looking around for the same problem and I don’t see an elegant solution without ifs posted in here, so here it goes: shortest_angle=((((end – start) % 360) + 540) % 360) – 180; return shortest_angle * amount; that’s it ps: of course, % is … Read more

`ValueError: A value in x_new is above the interpolation range.` – what other reasons than not ascending values?

If you are running Scipy v. 0.17.0 or newer, then you can pass fill_value=”extrapolate” to spi.interp1d, and it will extrapolate to accomadate these values of your’s that lie outside the interpolation range. So define your interpolation function like so: intfunc = spi.interp1d(coarsex, coarsey,axis=0, fill_value=”extrapolate”) Be forewarned, however! Depending on what your data looks like and … Read more

How do I make angular.js reevaluate / recompile inner html?

You have to $compile your inner html like .directive(‘autotranslate’, function($interpolate, $compile) { return function(scope, element, attr) { var html = element.html(); debugger; html = html.replace(/\[\[(\w+)\]\]/g, function(_, text) { return ‘<span translate=”‘ + text + ‘”></span>’; }); element.html(html); $compile(element.contents())(scope); //<—- recompilation } })

interpolate 3D volume with numpy and or scipy

In scipy 0.14 or later, there is a new function scipy.interpolate.RegularGridInterpolator which closely resembles interp3. The MATLAB command Vi = interp3(x,y,z,V,xi,yi,zi) would translate to something like: from numpy import array from scipy.interpolate import RegularGridInterpolator as rgi my_interpolating_function = rgi((x,y,z), V) Vi = my_interpolating_function(array([xi,yi,zi]).T) Here is a full example demonstrating both; it will help you understand … Read more