In [57]:
# Get the package for importing matalab data
import scipy.io
# Define the TUBS Colorscale for 10 Colors
# TUBS Rot, Gelb, Orange, Hellgrün, Grün, Dunkelgrün, Hellblau, Blau, Dunkelblau
TUBScolorscale=['rgba(190,30,60,0.9)',
'rgba(255,200,42,0.9)',
'rgba(225,109,0,0.9)',
'rgba(172,193,58,0.9)',
'rgba(109,131,0,0.9)',
'rgba(0,83,74,0.9)',
'rgba(102,180,211,0.9)',
'rgba(0,112,155,0.9)',
'rgba(0,63,87,0.9)',
'rgba(138,48,127,0.9)']
In [58]:
# Data is stored like Order, Sample, 0 = Real System 1= Model System
Data = scipy.io.loadmat(r'C:\Users\juliu\Documents\Thesis\Matlab\KTL_5000\KTL50000.mat')
Data = Data['TFData']
OP =Data['OperatingPoint']
FT =Data['Fan_Temperature']
VT =Data['Valve_Temperature']
FP =Data['Fan_Pressure']
VP =Data['Valve_Pressure']
In [59]:
# Import Plotly
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
from plotly.graph_objs import *
import plotly
plotly.offline.init_notebook_mode()
In [60]:
TUBScolorscale
Out[60]:
In [62]:
# Make a trace
x = []
y1 = []
y2 = []
y3 = []
y4 = []
for op in range(0,OP[0][0][0].shape[0]):
#print(OP[op])
#print(FT[0][0][1][op])
x.append(OP[0][0][0][op])
y1.append(FT[0][0][1][op] + FT[0][0][2][op])
y2.append(VT[0][0][1][op] + VT[0][0][2][op])
y3.append(FP[0][0][1][op] + FP[0][0][2][op])
y4.append(VP[0][0][1][op] + VP[0][0][2][op])
trace1 = Scatter(x=x,
y=y1,
mode = 'lines+markers',
name = 'Fan to Temperature',
line = dict(
color = TUBScolorscale[5],
width = 1
#dash = 'dash'
)
)
trace2 = Scatter(x=x,
y=y2,
mode = 'lines+markers',
name = 'Valve to Temperature',
line = dict(
color = TUBScolorscale[6],
width = 1
#dash = 'dash'
)
)
trace3 = Scatter(x=x,
y=y3,
mode = 'lines+markers',
name = 'Fan to Pressure',
line = dict(
color = TUBScolorscale[2],
width = 1
#dash = 'dash'
))
trace4 = Scatter(x=x,
y=y4,
mode = 'lines+markers',
name = 'Valve to Pressure',
line = dict(
color = TUBScolorscale[4],
width = 1
#dash = 'dash'
))
layout = dict(autosize = False,
width = 755, # approx 20 cm
height = 400, # approx 11 cm
font=dict(family='Nexus'), # TUBS Font
# Change here for title etc
yaxis = dict(
zeroline = False,
title = 'Approximated System Time Constants [s]',
#range = [1.2,1.35],
autotick = True,
ticks='outside',
#tick0 = 1.2,
#dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Operating points in [K]',
range = [271,313],
autotick = False,
ticks='outside',
tick0 = 273,
dtick = 2,
showgrid = True
),
legend=dict(
#orientation = "h",
traceorder='normal',
font=dict(
family='Nexus',
size=12,
color='#000'
),
bgcolor='#E2E2E2',
bordercolor='#FFFFFF',
borderwidth=2
)
)
data1 = [trace1,trace2,trace3,trace4]
data2 = [trace3,trace4]
fig = dict(data=data1, layout=layout)
iplot(fig)
#fig2 = dict(data=data1,layout=layout)
#iplot(fig2)
In [4]:
# Make traces
plot_Data = [];
# Loop over the System Order and make a plotly data Set
for Order in range(0,AccuracyData.shape[0]):
new_data = Scatter(
x = SensitivityData[Order,:,0],
y = SensitivityData[Order,:,1],
name = 'Order '+str(Order+1),
mode = 'markers',
marker = dict(
size =10*SensitivityData[Order,:,0]/SensitivityData[Order,:,1])
)
plot_Data.append(new_data)
In [6]:
layout = dict(title = 'Maximum Sensitivity for FOTD Identified Systems with AMIGO Controller',
autosize = False,
width = 1000,
height = 1000,
yaxis = dict(
zeroline = False,
title = 'Maximum Sensitivity of the Identified System',
range = [1.2,1.35],
autotick = False,
ticks='outside',
tick0 = 1.2,
dtick = 0.05,
showgrid = True ),
xaxis = dict(
zeroline = False,
title = 'Maximum Sensitivity of the Real System',
range = [1.2,1.7],
autotick = False,
ticks='outside',
tick0 = 1.2,
dtick = 0.1,
showgrid = True
)
)
fig = dict(data=plot_Data, layout=layout)
iplot(fig, filename='Maximum Sensitivity for FOTD Identified Systems with AMIGO Controller')
In [6]:
# Make the Accuracy Plot
# Make traces
plot_Data = [];
# Loop over the System Order and make a plotly data Set
for Order in range(0,AccuracyData.shape[0]):
new_data = Histogram(
x = SensitivityData[Order,:,0]/SensitivityData[Order,:,1],
name = 'Order '+str(Order),
histnorm = 'probability')
plot_Data.append(new_data)
In [7]:
layout = Layout(
autosize = False,
width = 1000,
height = 1000,
title='Robustness for FOTD Identified Systems',
xaxis=dict(
title='Ratio of the Maximum Sensitivities'
),
yaxis=dict(
title='Probability'
)
)
fig = Figure(data=plot_Data, layout=layout)
iplot(fig, filename='styled histogram')
In [78]:
import numpy as np
# Make traces
data = []
# Loop over the System Order and make a plotly data Set
data = [
Scatter(
x = np.linspace(1,9,9),
y = SensitivityData[:,:,0].mean(axis = 1),
name = 'Maximum Sensitivity'
),
Scatter(
x = np.linspace(1,9,9),
y = SensitivityData[:,:,0].mean(axis = 1)+SensitivityData[:,:,0].var(axis = 1),
fill = 'tonexty',
fillcolor='rgba(80,0,0,0.2)',
line=Line(color='transparent'),
showlegend=False
),
Scatter(
x = np.linspace(1,9,9),
y = SensitivityData[:,:,0].mean(axis = 1)-SensitivityData[:,:,0].var(axis = 1),
fill = 'tonexty',
fillcolor='rgba(80,0,0,0.2)',
line=Line(color='transparent'),
showlegend=False
)
]
layout = Layout(
autosize = False,
width = 1000,
height = 1000,
title='Maximum Sensitivity Development',
xaxis=dict(
title='System Order'
),
yaxis=dict(
title='Maximum Sensitivity'
)
)
fig = Figure(data=data, layout=layout)
iplot(fig, filename='styled histogram')
In [60]:
data
Out[60]:
In [63]:
np.linspace(1,9,9)
Out[63]:
In [ ]: