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
|
#! /usr/bin/env python
from __future__ import print_function
from openturns import *
TESTPREAMBLE()
try:
# Create an intance
myFunc = NumericalMathFunction("x", "x^2")
mySpatialFunc = SpatialFunction(myFunc)
print("mySpatialFunc=", mySpatialFunc)
# Get the input and output description
print("mySpatialFunc input description=",
mySpatialFunc.getInputDescription())
print("mySpatialFunc output description=",
mySpatialFunc.getOutputDescription())
# Get the input and output dimension, based on description
print("mySpatialFunc input dimension=", mySpatialFunc.getInputDimension())
print("mySpatialFunc output dimension=",
mySpatialFunc.getOutputDimension())
# Create a TimeSeries
tg = RegularGrid(0.0, 0.2, 6)
data = NumericalSample(tg.getN(), myFunc.getInputDimension())
for i in range(data.getSize()):
for j in range(data.getDimension()):
data[i, j] = i * data.getDimension() + j
ts = TimeSeries(tg, data)
print("input time series=", ts)
print("output time series=", mySpatialFunc(ts))
# Get the number of calls
print("called ", mySpatialFunc.getCallsNumber(), " times")
except:
import sys
print("t_SpatialFunction_std.py", sys.exc_info()[0], sys.exc_info()[1])
|