1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
"""
Polynomial chaos graphs
=======================
"""
# %%
# In this example we are going to create some graphs useful after the launch of a polynomial chaos algorithm.
# More precisely, we draw some members of the 1-d polynomial family.
# %%
import openturns as ot
import openturns.viewer as otv
def drawFamily(factory, degreeMax=5):
# Create a fine title
titleJacobi = factory.__class__.__name__.replace("Factory", "") + " polynomials"
# Create an empty graph which will be fulfilled
# with curves
graphJacobi = ot.Graph(titleJacobi, "z", "polynomial values", True, "upper right")
# Fix the number of points for the graph
pointNumber = 101
# Bounds of the graph
xMinJacobi = -1.0
xMaxJacobi = 1.0
# Get the curves
for i in range(degreeMax):
graphJacobi_temp = factory.build(i).draw(xMinJacobi, xMaxJacobi, pointNumber)
graphJacobi_temp_draw = graphJacobi_temp.getDrawable(0)
graphJacobi_temp_draw.setLegend("degree " + str(i))
graphJacobi.add(graphJacobi_temp_draw)
return graphJacobi
# %%
# Draw the 5-th first members of the Jacobi family.
# %%
# Instantiate a polynomial from the Jacobi family using the default Jacobi.ANALYSIS parameter set.
alpha = 0.5
beta = 1.5
jacobiFamily = ot.JacobiFactory(alpha, beta)
graph = drawFamily(jacobiFamily)
view = otv.View(graph)
# %%
laguerreFamily = ot.LaguerreFactory(2.75, 1)
graph = drawFamily(laguerreFamily)
view = otv.View(graph)
# %%
graph = drawFamily(ot.HermiteFactory())
view = otv.View(graph)
# %%
view.ShowAll()
|