コード例 #1
0
# Get a time series or a sample of time series
# myTimeSeries = gp.getRealization()
mySample = gp.getSample(1000)

mySegmentNumber = 10
myOverlapSize = 0.3

# Build a spectral model factory
myFactory = ot.WelchFactory(ot.Hanning(), mySegmentNumber, myOverlapSize)

# Estimation on a TimeSeries or on a ProcessSample
# myEstimatedModel_TS = myFactory.build(myTimeSeries)
myEstimatedModel_PS = myFactory.buildAsUserDefinedSpectralModel(mySample)

# Change the filtering window
myFactory.setFilteringWindows(ot.Hamming())

# Get the FFT algorithm
myFFT = myFactory.getFFTAlgorithm()

# Get the frequencyGrid
frequencyGrid = myEstimatedModel_PS.getFrequencyGrid()

# With the model, we want to compare values
# We compare values computed with theoritical values
plotSample = ot.Sample(frequencyGrid.getN(), 3)

# Loop of comparison ==> data are saved in plotSample
for k in range(frequencyGrid.getN()):
    freq = frequencyGrid.getStart() + k * frequencyGrid.getStep()
    plotSample[k, 0] = freq
コード例 #2
0
import openturns as ot
from matplotlib import pyplot as plt
from openturns.viewer import View

filteringWindow = ot.Hamming()
numPoints = 512
data = ot.Sample(numPoints, 2)
for i in range(numPoints):
    x = -0.1 + (1.2 * i) / (numPoints - 1.0)
    data[i, 0] = x
    data[i, 1] = filteringWindow(x)
graph = ot.Graph(str(filteringWindow), '$tau$', 'W', True)
graph.add(ot.Curve(data))
graph.setColors(['red'])
fig = plt.figure(figsize=(10, 4))
filtering_axis = fig.add_subplot(111)
View(graph, figure=fig, axes=[filtering_axis], add_legend=False)