HB Discrete Fourier Transform

Computes the Discrete Fourier Transform of a HB/TSM computation

Parameters

  • base: Base

    The Base that will be DFT computed.

  • coordinates: list(str), default= antares.Base.coordinate_names

    The variable names that define the set of coordinates. The coordinates will not be computed by the DFT treatment.

  • variables_to_ignore: list(str), default= [‘time’, ‘iteration’]

    Variables that won’t be DFT computed, these are not the coordinates but can be for instance the iteration vector.

  • hb_computation: :class:`.HbComputation or in_attr, default= ‘in_attr’

    The object that defines the attributes of the current HB/TSM computation.

  • type: str, default= ‘mod/phi’

    The DFT type of the output data: ‘mod/phi’ for modulus/phase decomposition or ‘im/re’ for imaginery/real part decomposition. The phase is expressed in degrees.

  • mode: list(int) or in_attr, default= None

    If you want to extract only some harmonics, you can put here the harmonic (i.e. 1 for example) or a list of harmonics ([1, 2, 4] for example). If empty, this return all the harmonics including the mean part.

Initialization

To initialize a DFT object:

>>> treatment = Treatment('hbdft')

Main functions

class antares.hb.TreatmentHbdft.TreatmentHbdft
execute()

Execute the treatment.

Returns:

the base containing the results

Return type:

Base

Example

"""
This example illustrates the Discrete Fourier Transform
treatment on a single frequency (TSM) computation.
As the HB/TSM methods are spectral ones, this DFT is exact
"""
import os
if not os.path.isdir('OUTPUT'):
    os.makedirs('OUTPUT')

from antares import HbComputation, Reader, Treatment, Writer

# ------------------
# Reading the files
# ------------------
reader = Reader('bin_tp')
reader['filename'] = os.path.join('..', 'data', 'HARMONIC_BALANCE', 'flow_<zone>.dat')
reader['n_hbt'] = 1
ini_base = reader.read()

# -------------------------------
# Create an HbComputation object
# -------------------------------
hb_comp = HbComputation()
hb_comp['frequencies'] = [6.2344674e-04]
ini_base.attrs['hb_computation'] = hb_comp

# ----
# DFT
# ----
treatment = Treatment('hbdft')
treatment['base'] = ini_base
treatment['type'] = 'mod/phi'
treatment['mode'] = (0, 1)
result = treatment.execute()

# -------------------
# Writing the result
# -------------------
writer = Writer('bin_tp')
writer['filename'] = os.path.join('OUTPUT', 'ex_hbdft.plt')
writer['base'] = result
writer.dump()