Open aurelieladier opened 5 years ago
There is no example for the P1LagrangeInterpolation
class:
http://openturns.github.io/openturns/master/user_manual/_generated/openturns.P1LagrangeInterpolation.html
Below is an example.
import openturns as ot
import math
# Create a fine mesh with 50 vertices
xmin = 0.0
xmax = 2 * math.pi
nVertices = 50
delta = (xmax - xmin) / (nVertices - 1)
mesh = ot.RegularGrid(xmin, delta, nVertices)
# Create a gross mesh with 11 vertices
nVertices = 10
delta = (xmax - xmin) / (nVertices - 1)
outputMesh = ot.RegularGrid(xmin, delta, nVertices)
# Create a sample with dimension 2 and size corresponding to the fine mesh
sample = ot.Sample([[math.sin(x), math.cos(x)] for x in mesh.getValues()])
# Create the interpolator ...
dimension = sample.getDimension() # 2
interpolation = ot.P1LagrangeInterpolation(mesh, outputMesh, dimension)
# ... and interpolate:
interpolatedSample = interpolation(sample)
# Create the fine and gross fields
field = ot.Field(mesh, sample)
interpolatedField = ot.Field(outputMesh, interpolatedSample)
# Draw
graph = ot.Graph("P1 Lagrange interpolation", "t", "Value", True, "bottomleft")
for marginalIndex in range(dimension):
curve = field.drawMarginal(marginalIndex)
curve.setLegends(["Field(%d)" % (marginalIndex)])
graph.add(curve)
curve = interpolatedField.drawMarginal(marginalIndex)
curve.setLegends(["Interp.(%d)" % (marginalIndex)])
graph.add(curve)
graph.setColors(["dodgerblue3", "darkorange1", "forestgreen", "firebrick3"])
A notebook is available here:
example-P1LagrangeInterpolation.ipynb.txt
A plot would be highly appreciated in the help page (from the pyplots directory).
No theory exists in the documentation for the methods: PiecewiseLinearEvaluation PiecewiseHermiteEvaluation P1LagrangeInterpolation