Power Spectral Density (1-D signals)

Power Spectral Density.

This processing computes the Power Spectral Density (PSD) of signals using Welch’s average periodogram.

exemple of signal


Dependency on matplotlib.mlab

Input Parameters

The following keys can be set:

  • base – (type = antares.Base ) – a base that contains many zones (independent to each others, typically many probes). Each zone contains one instant object. Each instant contains at least two 1-D arrays that represent a time signal

  • resize_time_factor – (default = 1.0, type = float ) – Factor to re-dimensionalize the time variable (time used will be time_var*resize_time_factor). This is useful when you only have the iteration variables and when the time-step used is constant

  • variables – (type = list(str) ) – The variables that serves as a basis for the PSD

  • time_t0 – (default = None, type = float ) – Time from which the analysis will begin

  • time_tf – (default = None, type = float ) – Time to which the analysis will be done

  • nb_block – (default = 1, type = int or float ) – Number of Welch’s blocks

  • pad – (default = 1, type = int or float ) – This key handles the padding of the signal with zeros.’pad=1’ means that there is no padding.Otherwise, if the length of the signal is Ls, then the length of the padded signal will be Ls*pad

  • overlap – (default = 0.33, type = int or float ) – The percent of the length of the signal to be overlapped


The variable representing time must be the first variable in the Instant. To ensure that, use base slicing if needed (see https://cerfacs.fr/antares/tutorial/api/api3.html for more information).

Main functions

class antares.treatment.TreatmentPsd.TreatmentPsd

Compute the Power Spectral Density.


a base that contains many zones. Each zone contains one instant. Each instant contains two 1-D arrays:

  1. The values for the power spectrum (real valued)

  2. The frequencies corresponding to the elements in the power spectrum (real valued) (variable ‘frequency’)

Return type


Example: impact of options on results

exemple of signal


This example illustrates the Power Spectral Density
treatment of Antares. The signal is analyzed on a time window
corresponding to [0.0294, 0.0318].

WARNING, in this case, the file read contains only two
variables, iteration and convflux_ro, the treatment use
the first one as time variable and the second as psd variable.
In case of multiple variables, the first one must be the time variable
and the second one the psd variable. To do so, use base slicing.
import os
import antares

    input = raw_input
except NameError:
# ------------------
# Reading the files
# ------------------
reader = antares.Reader('column')
reader['filename'] = os.path.join('..', 'data', '1D', 'massflow.dat')
base = reader.read()

# ----
# ----
treatment = antares.Treatment('psd')
treatment['base'] = base
treatment['resize_time_factor'] = 3.0E-7
treatment['time_t0'] = 0.0294
treatment['time_tf'] = 0.0318
treatment['variables'] = ['iteration', 'convflux_ro']
result = treatment.execute()

# -------------------
# Plot the result
# -------------------
plot = antares.Treatment('plot')
plot['base'] = result

# prompt the user
input('press enter to quit')