Creation of a regular gridΒΆ

In this example we will demonstrate how to create a regular grid. Note that a regular grid is a particular mesh of \mathcal{D}=[0,T] \in \mathbb{R}.

Here we will assume it represents the time t as it is often the case, but it can represent any physical quantity.

A regular time grid is a regular discretization of the interval [0, T] \in \mathbb{R} into N points, noted (t_0, \dots, t_{N-1}).

The time grid can be defined using (t_{Min}, \Delta t, N) where N is the number of points in the time grid. \Delta t the time step between two consecutive instants and t_0 = t_{Min}. Then, t_k = t_{Min} + k \Delta t and t_{Max} = t_{Min} + (N-1) \Delta t.

Consider X: \Omega \times \mathcal{D} \rightarrow \mathbb{R}^d a multivariate stochastic process of dimension d, where n=1, \mathcal{D}=[0,T] and t\in \mathcal{D} is interpreted as a time stamp. Then the mesh associated to the process X is a (regular) time grid.

from __future__ import print_function
import openturns as ot
import math as m
tMin = 0.
tStep = 0.1
n = 10

# Create the grid
time_grid = ot.RegularGrid(tMin, tStep, n)
# Get the first and the last instants,
# the step and the number of points
start = time_grid.getStart()
step = time_grid.getStep()
grid_size = time_grid.getN()
end = time_grid.getEnd()
print('start=', start, 'step=', step, 'grid_size=', grid_size, 'end=', end)
start= 0.0 step= 0.1 grid_size= 10 end= 1.0
# draw the grid