Principal Fourier Transformation (PFT)
An implementation A complete overhaul of https://github.com/eloquentarduino/principal-fft for pytorch.
Extracts the principal Fourier Transform Components. That is, for a set of signal data, PFT will extract the top N components for the whole dataset.
TL;DR: Principal Component Analysis (PCA) for Fourier Space.
Installation
With pip...
pip install pft
Usage
# Lets say you've a dataset of transient signal data
# For now, lets construct our own dataset with a single signal.
# The signal will be a composite of many sine functions
num_steps = 100 # Number of temporal steps
num_coefs = 100 # Number of sine functions that make up our composite signal
coefs = torch.rand(num_coefs) * torch.linspace(0, 1, num_steps)
freqs = torch.rand(num_coefs) * 2 * torch.pi
# Don't forgot the leading dimension!
# pft expects the data to have the shape (num_of_data_samples, num_of_time_steps)
signal = torch.zeros((1, num_steps))
for i, coef in enumerate(coefs):
signal += coef * torch.sin(freqs[i] * t)
# Now lets extract 10 prinicipal Fourier coefficients
import pft
num_pfc = 10 # Number of principal Fourier coefficients
pfa = pft.PFT( # pfa = Principal Fourier Analysis
num_pfc,
use_torch=True, # Change to False to use numpy backend. Default is True.
norm="ortho", # Forward and Inverse Foureir Transform normalisation. Defaults to "ortho".
)
pfa.fit(signal) # Calculates the prinicipal Fourier coefficients indexes.
pfc = pfa.transform(signal) # Gets the principal Fourier coefficients for this set of signals.
# The indexes of the prinicipal Fourier coefficients are stored internally.
# To get from the principal Fourier coefficients back to the transient signal
# do the following:
reconstructed_signal = pfa.ifit(pfc)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pft-0.4.2.tar.gz
(15.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pft-0.4.2-py3-none-any.whl
(15.1 kB
view details)
File details
Details for the file pft-0.4.2.tar.gz.
File metadata
- Download URL: pft-0.4.2.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.1.12 CPython/3.9.10 Linux/5.15.63-gentoo-dist
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e652139e35097955a6cfb803bfec86e0ed556eceb3a788e88afab7ebf38ccca3
|
|
| MD5 |
0aea93f4c012d2c280224b2755324b69
|
|
| BLAKE2b-256 |
c49983c291f5962c54d01f3ae5cc70185c536423efffd8e34dbda6b8b637ef49
|
File details
Details for the file pft-0.4.2-py3-none-any.whl.
File metadata
- Download URL: pft-0.4.2-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.1.12 CPython/3.9.10 Linux/5.15.63-gentoo-dist
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c31d99ab0a9c877af647a9123880b40e6e8972dcbbfa8d9b37c0172b1e5711ee
|
|
| MD5 |
be15b09cbef5b0dee291cc2b0271fcda
|
|
| BLAKE2b-256 |
b0c5f8f097f380c8a0490b61d85559b89cb76afebfba12b1a7d507cb5f059669
|