# HB Discrete Fourier Transform¶

Computes the Discrete Fourier Transform of a HB/TSM computation

## Input Parameters¶

The following keys can be set:

• base – (type = antares.Base ) – The Base that will be DFT computed

• coordinates – (type = tuple/list of variables ) – Coordinates variables that won’t be DFT computed

• variables_to_ignore – (default = [‘time’, ‘iteration’], type = tuple/list of variables ) – Variables that won’t be DFT computed, these are not the coordinates but can be for instance the iteration vector

• hb_computation – (default = in_attr, type = antares.HbComputation, can use in_attr = yes ) – The object that defines the attributes of the current HB/TSM computation

• type – (default = mod/phi, type = str ) – The decomposition of the DFT that you want, mod/phi for modulus/phase decomposition or im/re for imaginery/real part decomposition. If you use the mod/phi decomposition, note that the phase is given in degrees.

• mode – (default = None, type = tuple/list of variables, can use in_attr = yes ) – 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

antares.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

# ------------------
# ------------------
reader['filename'] = os.path.join('..', 'data', 'HARMONIC_BALANCE', 'flow_<zone>.dat')

# -------------------------------
# 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()