Welcome, Guest
Username: Password: Remember me

TOPIC: Example "How-To" interpolate values on mesh with Python

Example "How-To" interpolate values on mesh with Python 9 years 7 months ago #16622

  • Lufia
  • Lufia's Avatar
First we read the data X,Y,IKLE and the variable myVar that we like to interpolate (see www.opentelemac.org/index.php/kunena/oth...lotlib-pytel-scripts)

Matploltib provides a very fast way to interpolate variables on a triangular mesh.

After using the Selafin reader to get X,Y,IKLE and myVar we set up a triangulation of our mesh
import matplotlib.tri as tri
triang = tri.Triangulation(mySlf.X,mySlf.Y,mySlf.ikle)

now we can create an interpolator which needs the triangulation and the variable to interpolate.
interpolator = tri.LinearTriInterpolator(triang, myVar)

Now we can pass a two lists of the x,y coordinates of the points on which we want to interpolate myVar.
xPoints = [1.0,4.0,5.0]
yPoints = [3.4,1.2,5.4]
myVarResult = interpolator.__call__(xPoints,yPoints)

That's all! myVarResult contains the interpolated values.
The administrator has disabled public write access.
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.