Frequency Response Function (FRF)
Created on Fri Mar 4 13:04:39 2022
@author: Daniel Kreuter
- class softsensor.linear_methods.tf(window_size=512, fs=1024, hop=256, spectrum_type='spectrum')[source]
linear methods based on FFT and short term FFT Calculate the linear MiMo Transferfunction similar to Matlab tfestimate: https://uk.mathworks.com/help/signal/ref/tfestimate.html#bufqg8e
- Parameters:
- Return type:
None.
Example
Computing the linear transfer function of a linear system with white noise excitation
>>> import softsensor.data_gen as dg >>> import softsensor.linear_methods as lm >>> import matplotlib.pyplot as plt >>> import numpy as np >>> time = np.linspace(0, 100, 1000) >>> params = {'D': 0.05, 'c_nlin': 0} >>> F = dg.white_noise(time) >>> df = dg.get_academic_data(time, Model='Duffing', F=F, params=params) >>> model = lm.tf(NFFT=512, fs=fs, no_overlap=256) >>> model.fit([df], ['F(t)'], ['x']) >>> output = model.prediction(df, ['x']) >>> plt.plot(df.index, df['x'], label='original') >>> plt.plot(df.index, output, label='prediciton')
- fit(df_list, inp_sens, out_sens)[source]
Fit linear TF to list of dfs by taking the mean transfer function
- isfft(Zxx, columns=None, ampl_dist=None, boundary=True)[source]
Computes the inverse Fourier transformation
- Parameters:
Zxx (Array,) – Fourier transformed signal.
columns (list of col names, optional) – Column names of the output df. The default is None.
ampl_dist (None, str, optional) – if STFT is a PSD, you can define the amplitude distribution with a Raleigh or mixed distribution. Options are None, ‘rayleigh’ or ‘mixed’. The default is None.
- Returns:
TS_IFFT – DESCRIPTION.
- Return type:
TYPE
- sfft(ts)[source]
computes the short term fast Fourier transformation (stft) for each input column of the DataFrame
- Parameters:
ts (pd.DataFrame) – pandas data frame.
- Returns:
STFT – The Fourier transformed signal.
- Return type:
array
- tf_mimo(inp_df, out_df)[source]
ToDo: replace with scipy.signal.csd Calculate the linear MiMo Transferfunction similar to Matlab tfestimate: https://uk.mathworks.com/help/signal/ref/tfestimate.html#bufqg8e
- Parameters:
inp_df (pandas DataFrame) – input x(t) (index is time stamp),
out_df (pandas DataFrame) – output y(t) (index is time stamp),
- Returns:
tf (numpy array) –
- transfer function of shape (freq steps,no of out signals,
no of input signal), complex
f (numpy array)
corresponding frequency array