Skip to main content

A package with some fft utility functions

Project description

fft_calculations

This is a small package with some fft utility functions.

functions

fft(wave, max_f=None, output='dBVrms')

The function fft calculates the fast fourier transform of 'wave' using scipy.fft.rfft with default arguments.

The argument 'max-f' determines the maximum frequency for which to return results. With this argument higher frequencies which are not of interest can be chopped of the results.

The argument 'output' determines the unit of the returned magnitudes.

  • 'dBVrms' returns the magnitudes in dBVrms
  • 'dBV' returns the magnitudes in dBV
  • 'V' returns the magnitudes in V (same unit as the unit of wave[1]) This assumes the unit of wave[1] is V, can be substituted for any other unit.

In the future support for windowing functions should be added.

thd(fft,f0,correct_peaks=False,min_level=None)

This function calculates the total harmonic distortion of a signal. The fft for the signal to be analyzed is in the argument 'fft', where fft is a tuple (t,v) in which t is an array of time, and v is an equally sized array of values.

The argument 'f0' is the fundamental frequency for which the harmonics are searched in the suuplied signal.

The argument 'correct_peaks' will decide if frequency bin correction is applied. Frequency bin correction means that after finding the bin for a harmonic, the bin with highest value will take over. This is only for bins directly neighbouring with the original bin, and without any inbetween bins with lower values.

The argument 'min_level' defines the lowest signal level for which harmonics will be included in the THD calculation. Any values lower than 'min_level' will be skipped.

frequency_window(fft,centre,span)

Returns a slice from 'fft'. The argument 'fft' is a tuple (f,y) where f and y are equally sized arrays. The array f contains the centre frequency of the frequency bins of the fft. The array y contains the magnitude (any unit) of the respective frequency bins.

The returned slice is determined by the arguments 'centre' and 'span'. The argument 'centre' determines the centre of the frequency range to return, and 'span' is the entire span of the returned frequency range. The returned frequency range thus will be [centre-span/2:centre+span/2].

The returned slice will be in the same format as the input argument 'fft', namely a tuple (f',y'), where f' is the reduced frequency range, and y' the according magnitudes.

installation

python3 -m pip install fft_calculations

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fft_calculations-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

fft_calculations-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file fft_calculations-0.1.0.tar.gz.

File metadata

  • Download URL: fft_calculations-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for fft_calculations-0.1.0.tar.gz
Algorithm Hash digest
SHA256 684ea9a93dc99197d6be34fe6b09c073736bf910ef3406e00e723161bb48ea73
MD5 c59227b3bd65a7bbd5cf96bd44370d68
BLAKE2b-256 305f8996856eb0ce7f9e9e567a18de1f4abf611a4b51af59189da96339821cd1

See more details on using hashes here.

File details

Details for the file fft_calculations-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fft_calculations-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c645fd6922162f6f152726a1491c5b908c5685224474492ab68868c1f187cc0b
MD5 fc968c8939fa7203e9b000a7ba4225e6
BLAKE2b-256 fd986ddfb99e293f328f3fcbb744bf02b0444c5e1988ce1b296956ad36afcea9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page