ak9im/p2/visualise.py
leo c3f9185077
p2: calculate impulse func estimate
* add visualisation code
* add pic
2023-02-26 21:20:40 +01:00

56 lines
1.1 KiB
Python

import seaborn as sb
import pandas as pd
import scipy
import matplotlib.pyplot as plt
data_uy=pd.read_csv('data/m.csv')
# head(data_uy)
correlation_result=scipy.stats.pearsonr(data_uy['u'], data_uy['y'])
print(correlation_result)
p = sb.lmplot(
data=data_uy,
x='u',
y='y',
fit_reg=True,
height=8,
)
p.set(title='Correlation UY')
p.savefig('res/uy-correlation-analysis.png')
plt.clf()
lp = sb.lineplot(data=data_uy['u'])
lp.set(
title='Signal u',
xlabel='samples',
ylabel='u',
)
fig = lp.get_figure()
fig.subplots_adjust(top=.97)
fig.savefig('res/signal_u.png')
plt.clf()
lp = sb.lineplot(data=data_uy['y'])
lp.set(
title='Signal y',
xlabel='samples',
ylabel='y',
)
fig = lp.get_figure()
fig.subplots_adjust(top=.97)
fig.savefig('res/signal_y.png')
plt.clf()
imf=pd.read_csv('data/impulse_func.csv')
lp = sb.lineplot(data=imf, legend=False, linewidth=2.5)
lp.set(
title='Impulse Function Estimate',
xlabel='time (s)',
ylabel='y',
)
fig = lp.get_figure()
fig.subplots_adjust(top=.97)
fig.savefig('res/impulse_func_estimate.png')
plt.clf()