Skip to content

[FEATURE] add pytta.descriptors with crest factor, kurtosis and spectral shape - #73

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-descriptors
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-descriptors

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Oct 31, 2026 •

Copy link
Copy Markdown

Adds the module pytta.descriptors with descriptors of a whole signal, one value per channel:

  1. crest_factor(signalObj, dB=False): peak magnitude over rms.
  2. kurtosis(signalObj): Pearson kurtosis of the samples, used to rate how impulsive a noise or vibration is (3 for Gaussian noise).
  3. spectral_centroid, spectral_spread, spectral_flatness and spectral_rolloff(signalObj, fraction=0.85): power-weighted mean frequency, its standard deviation, the geometric over arithmetic mean of the power spectrum, and the frequency below which a fraction of the power lies.

The tests in tests/test_descriptors.py use signals with exact values: a crest factor of sqrt(2) (3.01 dB) for a sine and 1 for a square wave, a kurtosis of 1.5 for a sine and 3 for Gaussian noise, a centroid of 1000 Hz with zero spread and flatness for a 1 kHz sine, and for white noise a flatness of exp(-gamma) = 0.5615 (the power of each bin is exponentially distributed), a rolloff of 0.85 fs/2 and a centroid of fs/4.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The existing tests behave as on development: the 7 failures there (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

…ral shape

Crest factor (ratio or dB), Pearson kurtosis of the samples, and the
centroid, spread, flatness and rolloff of the power spectrum, one value
per channel.

Tests use signals with exact values: crest factor of a sine and a square
wave, kurtosis of a sine and of Gaussian noise, the spectral shape of a
sine, and the flatness, rolloff and centroid of white noise.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant