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]:
['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 [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]:
[{'error_y': {'array': array([  2.04505794e-03,   3.26536043e-05,   1.43685692e-03,
            2.79668003e-03,   3.62464449e-03,   4.68294431e-03,
            5.43251093e-03,   6.16984865e-03,   7.37428799e-03]),
   'type': 'percent',
   'visible': True},
  'type': 'scatter',
  'x': array([ 1.        ,  1.16326531,  1.32653061,  1.48979592,  1.65306122,
          1.81632653,  1.97959184,  2.14285714,  2.30612245,  2.46938776,
          2.63265306,  2.79591837,  2.95918367,  3.12244898,  3.28571429,
          3.44897959,  3.6122449 ,  3.7755102 ,  3.93877551,  4.10204082,
          4.26530612,  4.42857143,  4.59183673,  4.75510204,  4.91836735,
          5.08163265,  5.24489796,  5.40816327,  5.57142857,  5.73469388,
          5.89795918,  6.06122449,  6.2244898 ,  6.3877551 ,  6.55102041,
          6.71428571,  6.87755102,  7.04081633,  7.20408163,  7.36734694,
          7.53061224,  7.69387755,  7.85714286,  8.02040816,  8.18367347,
          8.34693878,  8.51020408,  8.67346939,  8.83673469,  9.        ]),
  'y': array([ 1.26947002,  1.40318625,  1.36927636,  1.36597271,  1.39362404,
          1.41248926,  1.44711521,  1.47673271,  1.50791116])}]

In [63]:
np.linspace(1,9,9)


Out[63]:
array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.])

In [ ]: