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.
The function returns a tuple (xf,yf,fft_max_f,fft_f_res) in which:
- xf is an array of frequency bins [0..max_f] is max_f is not None, else [0..fft_max_f]
- yf is an equally sized array of magnitudes with th eunit determined by the argument 'output'
- fft_max_f is the maximum frequency if the fft (equal to the Nyquist frequency)
- fft_f_res is the frequency resolution in the resulting fft. This is the distance between frequency bins.
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.
The function returns a tuple (thd,bins) where
- thd is a float giving the total harmonic distortion (in %)
- bins is an array of indices into the frequency bins for the harmonics (regardless if they have been taken into account for the thd calculation or not)
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
requirements
- numpy
- scipy
Metadata
Release files for fft-calculations 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fft_calculations-0.2.3.tar.gz | 4.7 kB | Without provenance | Details for fft_calculations-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fft_calculations-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for fft_calculations-0.2.3-py3-none-any.whl |
Total release size: 10.3 kB
Release files / fft_calculations-0.2.3.tar.gz
| Download URL | fft_calculations-0.2.3.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f2a05b0ab52964020546fec43eae3acccbc5e7d97581fe1c3b2131b4b586c33
|
|
BLAKE2b-256 checksum How to use checksums |
5bdd617c3dd4ba040f2b79ec6319547dd71605b24410ef577ece2627212536d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Release files / fft_calculations-0.2.3-py3-none-any.whl
| Download URL | fft_calculations-0.2.3-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ded61d97adc19ff813c2269ca90a2ee76e3e9fe1693be6b11c5cf133d4e8e750
|
|
BLAKE2b-256 checksum How to use checksums |
db9d3a30a058ccfb2ce6835acd7e9239077dec90d2253f3458ecc1ea05ae5938
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Security for fft-calculations 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.