pysnr¶
Submodules¶
pysnr.sfdr module¶
- pysnr.sfdr.sfdr_power_spectral_density(pxx, frequencies, msd=0)¶
SFDR from input signal.
This function computes the SFDR for an input signal from its density-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
pxx (numpy ndarray) – The power spectral density of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
msd (int) – Minimum number of discrete Fourier bins to ignore for the SFDR computation
- Returns
float – The computed SFDR
float – The spurious power magnitude
- pysnr.sfdr.sfdr_power_spectrum(sxx, frequencies, msd=0)¶
SFDR from input signal.
This function computes the SFDR for an input signal from its spectrum-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
sxx (numpy ndarray) – The power spectrum of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
msd (int) – Minimum number of discrete Fourier bins to ignore for the SFDR computation
- Returns
float – The computed SFDR
float – The spurious power magnitude
- pysnr.sfdr.sfdr_signal(signal, fs=1.0, msd=0)¶
SFDR from input signal.
This function computes the SFDR for an input signal. It assumes the fundamental frequency to be the desired signal.
pysnr.sinad module¶
- pysnr.sinad.sinad_power_spectral_density(pxx, frequencies)¶
SINAD from input signal.
This function computes the SINAD for an input signal from its density-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
pxx (numpy ndarray) – The power spectral density of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
- Returns
float – The computed SINAD
float – The total noise and harmonic power magnitude
- pysnr.sinad.sinad_power_spectrum(sxx, frequencies, rbw)¶
SINAD from input signal.
This function computes the SINAD for an input signal from its spectrum-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
sxx (numpy ndarray) – The power spectrum of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
rbw (float) – Resolution Bandwidth computed from the window and the sampling frequency
- Returns
float – The computed SINAD
float – The total noise and harmonic power magnitude
- pysnr.sinad.sinad_signal(signal, fs=1.0)¶
SINAD from input signal.
This function computes the SINAD for an input signal. It assumes the fundamental frequency to be the desired signal. Uses a Kaiser window with beta set to 38 to compute the periodogram.
- Parameters
signal (numpy ndarray) – The true signal
fs (float) – Sampling Frequency. Defaults to 1.0.
- Returns
float – The computed SINAD
float – The total noise and harmonic power magnitude
pysnr.snr module¶
- pysnr.snr.snr_power_spectral_density(pxx, frequencies, n=6, aliased=False)¶
SNR from input signal.
This function computes the SNR for a signal where the noise is not known from its density-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
pxx (numpy ndarray) – The power spectral density of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
n (int) – Number of harmonics to use (including the fundamental frequency)
aliased (bool) – If True, converts the harmonics that are aliased into the Nyquist frequency
- Returns
float – The computed SNR
float – The noise power magnitude
- pysnr.snr.snr_power_spectrum(sxx, frequencies, rbw, n=6, aliased=False)¶
SNR from input signal.
This function computes the SNR for a signal where the noise is not known from its spectrum-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
sxx (numpy ndarray) – The power spectrum of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
rbw (float) – Resolution Bandwidth computed from the window and the sampling frequency
n (int) – Number of harmonics to use (including the fundamental frequency)
aliased (bool) – If True, converts the harmonics that are aliased into the Nyquist frequency
- Returns
float – The computed SNR
float – The noise power magnitude
- pysnr.snr.snr_signal(signal, fs=1.0, n=6, aliased=False)¶
SNR from input signal.
This function computes the SNR for a signal where the noise is not known. It assumes the fundamental frequency to be the desired signal. Uses a Kaiser window with beta set to 38 to compute the periodogram.
- Parameters
- Returns
float – The computed SNR
float – The noise power magnitude
- pysnr.snr.snr_signal_noise(signal, noise)¶
SNR from input signal and known noise.
This function computes the SNR for a signal and a known noise.
- Parameters
signal (numpy ndarray) – The true signal
noise (numpy ndarray) – The noise
- Returns
float – The computed SNR
float – The noise magnitude
pysnr.thd module¶
- pysnr.thd.thd_power_spectral_density(pxx, frequencies, n=6, aliased=False)¶
THD from input signal.
This function computes the THD for an input signal from its density-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
pxx (numpy ndarray) – The power spectral density of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
n (int) – Number of harmonics to use (including the fundamental frequency)
aliased (bool) – If True, converts the harmonics that are aliased into the Nyquist frequency
- Returns
float – The computed THD
float – The harmonic power magnitude
- pysnr.thd.thd_power_spectrum(sxx, frequencies, rbw, n=6, aliased=False)¶
THD from input signal.
This function computes the THD for an input signal from its spectrum-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
sxx (numpy ndarray) – The power spectrum of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
rbw (float) – Resolution Bandwidth computed from the window and the sampling frequency
n (int) – Number of harmonics to use (including the fundamental frequency)
aliased (bool) – If True, converts the harmonics that are aliased into the Nyquist frequency
- Returns
float – The computed THD
float – The harmonic power magnitude
- pysnr.thd.thd_signal(signal, fs=1.0, n=6, aliased=False)¶
THD from input signal.
This function computes the THD for an input signal. It assumes the fundamental frequency to be the desired signal. Uses a Kaiser window with beta set to 38 to compute the periodogram.
- Parameters
- Returns
float – The computed THD
float – The harmonic power magnitude
pysnr.toi module¶
- pysnr.toi.toi_power_spectral_density(pxx, frequencies)¶
TOI from input signal.
This function computes the TOI for an input signal from its density-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
pxx (numpy ndarray) – The power spectral density of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
- Returns
float – The computed TOI
np.ndarray – The powers contained in the two fundamental sinusoids of the signal
np.ndarray – The power contained in the lower and upper intermodulation products of the signal
- pysnr.toi.toi_power_spectrum(sxx, frequencies, rbw)¶
TOI from input signal.
This function computes the TOI for an input signal from its spectrum-periodogram. The function assumes the fundamental frequency to be the desired signal.
- Parameters
sxx (numpy ndarray) – The power spectrum of the signal
frequencies (numpy ndarray) – The frequencies corresponding to the power spectral density
rbw (float) – Resolution Bandwidth computed from the window and the sampling frequency
- Returns
float – The computed TOI
np.ndarray – The powers contained in the two fundamental sinusoids of the signal
np.ndarray – The power contained in the lower and upper intermodulation products of the signal
- pysnr.toi.toi_signal(signal, fs=1.0)¶
TOI from input signal.
This function computes the TOI for an input signal. It assumes the fundamental frequency to be the desired signal. Uses a Kaiser window with beta set to 38 to compute the periodogram.
- Parameters
signal (numpy ndarray) – The true signal
fs (float) – Sampling Frequency. Defaults to 1.0.
- Returns
float – The computed TOI
np.ndarray – The powers contained in the two fundamental sinusoids of the signal
np.ndarray – The power contained in the lower and upper intermodulation products of the signal
pysnr.utils module¶
- pysnr.utils.bandpower(pxx, f)¶
Computes the equivalent noise bandwidth
- Parameters
pxx (numpy ndarray) – The periodogram values in the power spectral density form
f (numpy ndarray) – The frequencies corresponding to the periodogram
- Returns
The computed value
- Return type
- pysnr.utils.enbw(window, Fs=None)¶
Computes the equivalent noise bandwidth
- pysnr.utils.mag2db(data, scaling=10)¶
Converts the magnitude to decibels
- pysnr.utils.periodogram(data, Fs, window, method='welch', scaling='density')¶
Computes the periodogram from signal.
This function computes the periodogram using one of two techniques - Welch method or FFT method By default, it is set to Welch method.
- Parameters
data (numpy ndarray) – The signal whose periodogram is to be computed
Fs (numpy ndarray) – Sampling Freqeuncy of input signal
window (str or tuple or array_like) – Desired window to use. This is passed as an input to scipy’s get_window() function
method (str) – Decides which method to use for computing the periodogram. Can be welch or ‘fft’
scaling (str) – Decides whether to compute the power spectral density or the power spectrum. Can be ‘density’ or ‘spectrum’
- Returns
numpy ndarray – List of frequencies
numpy ndarray – The periodogram