File: plot_parametric_spectral_density.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 (40 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download
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
"""
Create a parametric spectral density function
=============================================
"""

# %%
# This example illustrates how the User can create a density spectral
# function from parametric models.
#
# The library implements the *Cauchy spectral model* as a parametric model for the spectral density function
# :math:`S`.
#
# The library defines this model thanks to the object :class:`~openturns.CauchyModel`.

# %%
import openturns as ot


# %%
# 1. Define a spectral density function from correlation matrix
amplitude = [1.0, 2.0, 3.0]
scale = [4.0, 5.0, 6.0]
spatialCorrelation = ot.CorrelationMatrix(3)
spatialCorrelation[0, 1] = 0.8
spatialCorrelation[0, 2] = 0.6
spatialCorrelation[1, 2] = 0.1
spectralModel_Corr = ot.CauchyModel(amplitude, scale, spatialCorrelation)
spectralModel_Corr

# %%
# 2. Define a spectral density function from a covariance matrix
spatialCovariance = ot.CovarianceMatrix(3)
spatialCovariance[0, 0] = 4.0
spatialCovariance[1, 1] = 5.0
spatialCovariance[2, 2] = 6.0
spatialCovariance[0, 1] = 1.2
spatialCovariance[0, 2] = 0.9
spatialCovariance[1, 2] = -0.2
spectralModel_Cov = ot.CauchyModel(scale, spatialCovariance)
spectralModel_Cov