File: t_Function_draw.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (54 lines) | stat: -rwxr-xr-x 1,426 bytes parent folder | download | duplicates (2)
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
#! /usr/bin/env python

import openturns as ot

ot.TESTPREAMBLE()


# Simplified interfaces
# First, try 1D drawing
f = ot.SymbolicFunction("x", "sin(2*pi_*x)*exp(-x^2/2)")
print("f=", f)
graph = f.draw(-1.2, 1.2, 32)
print("graph=", graph)

# Second, try 2D drawing
f = ot.SymbolicFunction(["x", "y"], ["2.0+x-2*y+x*y-x^2-3*y^2+x*y^2"])
print("f=", f)
graph = f.draw(ot.Point(2, -10.0), ot.Point(2, 10.0), ot.Indices(2, 21))
print("graph=", graph)

# Full interfaces
f = ot.SymbolicFunction(
    ["x0", "x1", "x2"],
    [
        "x0 * sin(x1 + 2.4 * x2) - 2.0 * x1 * cos(3.2 * x0 - x2)",
        "x1 * cos(x2 + 2.4 * x1) + 2.0 * x0 * cos(3.2 * x1 - x0)",
    ],
)
centralPoint = ot.Point([1.0, -0.5, 1.5])
# First output as a function of first input around central point
graph1D = f.draw(0, 0, centralPoint, -5.0, 5.0, 32)
print("graph1D=", graph1D)
# Second output as a function of second and third inputs around central
# point
graph2D = f.draw(
    1, 2, 1, centralPoint, ot.Point(2, -5.0), ot.Point(2, 5.0), ot.Indices(2, 21)
)
print("graph2D=", graph2D)
# Cross cuts
crossCuts = f.getMarginal(0).drawCrossCuts(
    centralPoint, ot.Point(3, -5.0), ot.Point(3, 5.0), ot.Indices(3, 10)
)
print("crossCuts=", crossCuts)
crossCuts = f.getMarginal(1).drawCrossCuts(
    centralPoint,
    ot.Point(3, -5.0),
    ot.Point(3, 5.0),
    ot.Indices(3, 3),
    True,
    False,
    -5.0,
    3.0,
)
print("crossCuts=", crossCuts)