ValueFunction

class ValueFunction(*args)

Spatial function.

Available constructors:

ValueFunction(meshDimension=1)

ValueFunction(g, meshDimension=1)

Parameters:

g : NumericalMathFunction

Function g: \Rset^d \mapsto \Rset^q.

meshDimension : int, n \geq 0

Dimension of the vertices of the mesh \cM. This data is required for tests on the compatibility of dimension when a composite process is created using the spatial function.

Notes

A spatial function f_{spat}: \cD \times \Rset^d \mapsto \cD \times \Rset^q, with \cD \in \Rset^n, is a particular field function that lets invariant the mesh of a field and defined by a function g : \Rset^d  \mapsto \Rset^q such that:

f_{spat}(\vect{t}, \vect{x})=(\vect{t}, g(\vect{x}))

Let’s note that the input dimension of f_{spat} still designs the dimension of \vect{x}: d. Its output dimension is equal to q.

Examples

>>> import openturns as ot

Create a function g : \Rset^d \mapsto \Rset^q such as:

g: \left|\begin{array}{rcl}
            \Rset & \rightarrow & \Rset \\
            x & \mapsto & x^2
        \end{array}\right.

>>> g = ot.SymbolicFunction(['x'], ['x^2'])

Convert g into a spatial function with n the dimension of the mesh of the field on which g will be applied:

>>> n = 1
>>> myValueFunction = ot.ValueFunction(g, n)
>>> # Create a TimeSeries
>>> tg = ot.RegularGrid(0.0, 0.2, 6)
>>> data = ot.NumericalSample(tg.getN(), g.getInputDimension())
>>> for i in range(data.getSize()):
...     for j in range(data.getDimension()):
...         data[i, j] = i * data.getDimension() + j
>>> ts = ot.TimeSeries(tg, data)
>>> print(ts)
    [ t   v0  ]
0 : [ 0   0   ]
1 : [ 0.2 1   ]
2 : [ 0.4 2   ]
3 : [ 0.6 3   ]
4 : [ 0.8 4   ]
5 : [ 1   5   ]
>>> print(myValueFunction(ts))
    [ t    y0   ]
0 : [  0    0   ]
1 : [  0.2  1   ]
2 : [  0.4  4   ]
3 : [  0.6  9   ]
4 : [  0.8 16   ]
5 : [  1   25   ]

Methods

__call__(*args)
getCallsNumber() Get the number of calls of a FieldFunction.
getClassName() Accessor to the object’s name.
getEvaluation() Get the evaluation function of g.
getId() Accessor to the object’s id.
getInputDescription() Get the description of the inputs.
getInputDimension() Get the dimension of the input.
getMarginal(*args) Get the marginal(s) at given indice(s).
getName() Accessor to the object’s name.
getOutputDescription() Get the description of the outputs.
getOutputDimension() Get the dimension of the output.
getOutputMesh(inputMesh) Get the mesh associated to the output process.
getShadowedId() Accessor to the object’s shadowed id.
getSpatialDimension() Get the dimension of the mesh.
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
setInputDescription(inputDescription) Set the description of the inputs.
setName(name) Accessor to the object’s name.
setOutputDescription(outputDescription) Set the description of the outputs.
setShadowedId(id) Accessor to the object’s shadowed id.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)
getCallsNumber()

Get the number of calls of a FieldFunction.

Returns:

callsNumber : int

Counts the number of times the FieldFunction has been called since its creation.

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getEvaluation()

Get the evaluation function of g.

Returns:

g : NumericalMathEvaluationImplementation

Evaluation function of g: \Rset^d \mapsto \Rset^q.

Examples

>>> import openturns as ot
>>> g = ot.NumericalMathFunction('x', 'x^2')
>>> n = 1
>>> myValueFunction = ot.ValueFunction(g, n)
>>> print(myValueFunction.getEvaluation())
[x]->[x^2]
getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getInputDescription()

Get the description of the inputs.

Returns:

inputDescription : Description

Describes the inputs of the function.

getInputDimension()

Get the dimension of the input.

Returns:

d : int

Input dimension d of the function.

getMarginal(*args)

Get the marginal(s) at given indice(s).

Parameters:

i : int or list of ints, 0 \leq i < d

Indice(s) of the marginal(s) needed. d is the dimension of the FieldFunction.

Returns:

fieldFunction : FieldFunction

FieldFunction restricted to the concerned marginal(s) at the indice(s) i of the field function f_{dyn}.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getOutputDescription()

Get the description of the outputs.

Returns:

outputDescription : Description

Describes the outputs of the function.

getOutputDimension()

Get the dimension of the output.

Returns:

q : int

Output dimension q of the function.

getOutputMesh(inputMesh)

Get the mesh associated to the output process.

Returns:

outputMesh : Mesh

The mesh of the output process.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getSpatialDimension()

Get the dimension of the mesh.

Returns:

spatialDimension : int, n \geq 0

Dimension of the mesh \cM.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

setInputDescription(inputDescription)

Set the description of the inputs.

Parameters:

inputDescription : sequence of str

Describes the inputs of the function.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setOutputDescription(outputDescription)

Set the description of the outputs.

Parameters:

outputDescription : sequence of str

Describes the outputs of the function.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.