Parameter Estimation of RIG Roll Experiments

Setup and descriptions

  • Without ACM model
  • Turn on wind tunnel
  • Only 1DoF for RIG roll movement
  • Use small-amplitude aileron command of CMP as inputs (in degrees) $$U = \delta_{a,cmp}(t)$$
  • Consider RIG roll angle and its derivative as States (in radians) $$X = \begin{pmatrix} \phi_{rig} \\ \dot{\phi}_{rig} \end{pmatrix}$$
  • Observe RIG roll angle and its derivative as Outputs (in degrees) $$Z = \begin{pmatrix} \phi_{rig} \\ \dot{\phi}_{rig} \end{pmatrix}$$
  • Use output error method based on most-likehood(ML) to estimate $$ \theta = \begin{pmatrix} C_{l,\delta_a,cmp} \\ C_{lp,cmp} \end{pmatrix} $$

Startup computation engines


In [1]:
%run matt_startup
%run -i matt_utils

button_qtconsole()

#import other needed modules in all used engines
#with dview.sync_imports():
#   import os


importing numpy on engine(s)
importing scipy on engine(s)
importing matplotlib on engine(s)
importing scipy.integrate on engine(s)
importing scipy.interpolate on engine(s)
importing math on engine(s)
importing time on engine(s)
importing itertools on engine(s)
importing random on engine(s)
:0: FutureWarning: IPython widgets are experimental and may change in the future.

Data preparation

Load raw data


In [2]:
filename = 'FIWT_Exp052_20150616144645.dat.npz'

def loadData():
    # Read and parse raw data
    global exp_data
    exp_data = np.load(filename)

    # Select colums
    global T_cmp, da1_cmp, da2_cmp, da3_cmp , da4_cmp
    T_cmp = exp_data['data33'][:,0]
    da1_cmp = exp_data['data33'][:,3]
    da2_cmp = exp_data['data33'][:,5]
    da3_cmp = exp_data['data33'][:,7]
    da4_cmp = exp_data['data33'][:,9]

    global T_rig, phi_rig
    T_rig = exp_data['data44'][:,0]
    phi_rig = exp_data['data44'][:,2]

loadData()

In [3]:
text_loadData()

In [4]:
V = exp_data['data44'][:,13]
%matplotlib inline
plt.plot(T_rig, V*1.05)
plt.ylim((28,32))


Out[4]:
(28, 32)

Check time sequence and inputs/outputs

Click 'Check data' button to show the raw data.

Click on curves to select time point and push into queue; click 'T/s' text to pop up last point in the queue; and click 'Output' text to print time sequence table.


In [5]:
def checkInputOutputData():

    #check inputs/outputs
    fig, ax = plt.subplots(2,1,True)
    ax[0].plot(T_cmp,da1_cmp,'r', T_cmp,da2_cmp,'g',
               T_cmp,da3_cmp,'b', T_cmp,da4_cmp,'m',
               picker=1)
    ax[1].plot(T_rig,phi_rig, 'b', picker=2)
    ax[0].set_ylabel('$\delta \/ / \/ ^o$')
    ax[1].set_ylabel('$\phi \/ / \/ ^o/s$')
    ax[1].set_xlabel('$T \/ / \/ s$', picker=True)
    ax[0].set_title('Output', picker=True)
    

    fig.canvas.mpl_connect('pick_event', onPickTime)
    fig.show()
    display(fig)

button_CheckData()

Input $\delta_T$ and focused time ranges


In [6]:
# Pick up focused time ranges
time_marks = [
[18.8573202878,137.312699085,"ramp cmp4 u"],
[141.408935166,260.27090166,"ramp cmp4 d"],
[265.592177186,384.456691192,"ramp cmp3 u"],
[391.487466737,509.969548357,"ramp cmp3 d"],
[518.478950349,638.264844453,"ramp cmp2 u"],
[644.71182051,763.983487372,"ramp cmp2 d"],
[770.300044567,889.812031944,"ramp cmp1 u"],
[895.995020394,1014.85848293,"ramp cmp1 d"],
[1022.19234822,1141.45367229,"ramp cmp4 d"],
[1145.14958662,1265.23165475,"ramp cmp4 u"],
[1279.28149733,1397.62176653,"ramp cmp3 u"],
[1411.53843282,1530.01180295,"ramp cmp2 d"],
[1536.98628003,1657.06650374,"ramp cmp2 u"],
[1671.68321255,1792.31335791,"ramp cmp1 d"],
[1798.33449076,1918.9341565,"ramp cmp1 u"],
]

# Decide DT,U,Z and their processing method
DT=0.2
process_set = {
            'U':[(T_cmp, da1_cmp,0),
                (T_cmp, da2_cmp,0),
                (T_cmp, da3_cmp,0),
                (T_cmp, da4_cmp,0),],
            'Z':[(T_rig, phi_rig,1),],
            'cutoff_freq': 1 #Hz
           }

U_names = ['$\delta_{a1,cmp} \, / \, ^o$',
          '$\delta_{a2,cmp} \, / \, ^o$',
          '$\delta_{a3,cmp} \, / \, ^o$',
          '$\delta_{a4,cmp} \, / \, ^o$']
Y_names = Z_names = ['$\phi_{a,rig} \, / \, ^o$']

display_data_prepare()


$$\delta_T=200.0(ms)$$
Time ranges
IdxStart(s)Spam(s)Description
018.86118.46ramp cmp4 u
1141.41118.86ramp cmp4 d
2265.59118.86ramp cmp3 u
3391.49118.48ramp cmp3 d
4518.48119.79ramp cmp2 u
5644.71119.27ramp cmp2 d
6770.30119.51ramp cmp1 u
7896.00118.86ramp cmp1 d
81022.19119.26ramp cmp4 d
91145.15120.08ramp cmp4 u
101279.28118.34ramp cmp3 u
111411.54118.47ramp cmp2 d
121536.99120.08ramp cmp2 u
131671.68120.63ramp cmp1 d
141798.33120.60ramp cmp1 u
$U$
$\delta_{a1,cmp} \, / \, ^o$
$\delta_{a2,cmp} \, / \, ^o$
$\delta_{a3,cmp} \, / \, ^o$
$\delta_{a4,cmp} \, / \, ^o$
$Z$
$\phi_{a,rig} \, / \, ^o$

Resample and filter data in sections

For each section,

  • Select time range and shift it to start from zero;
  • Resample Time, Inputs, Outputs in unique $\delta_T$;
  • Smooth Input/Observe data if flag bit0 is set;
  • Take derivatives of observe data if flag bit1 is set.

In [7]:
resample(True);

Define dynamic model to be estimated

$$\left\{\begin{matrix}\begin{align} M_{x,rig} &= M_{x,a} + M_{x,f} + M_{x,cg} = 0 \\ M_{x,a} &= \frac{1}{2} \rho V^2S_cb_c C_{la,cmp}\delta_{a,cmp} \\ M_{x,f} &= -F_c \, sign(\dot{\phi}_{rig}) \\ M_{x,cg} &= -m_T g l_{zT} \sin \left ( \phi - \phi_0 \right ) \end{align}\end{matrix}\right.$$

In [19]:
%%px --local
#update common const parameters in all engines

angles = range(-40,41,5)
angles[0] -= 1
angles[-1] += 1
del angles[angles.index(0)]
angles_num = len(angles)

#problem size
Nx = 0
Nu = 4
Ny = 1
Npar = 4*angles_num+1

#reference
S_c = 0.1254   #S_c(m2) 
b_c = 0.7      #b_c(m)
g = 9.81       #g(m/s2)

#static measurement
m_T = 9.585   #m_T(kg)
l_z_T = 0.0416 #l_z_T(m)
V = 30         #V(m/s)

#previous estimations
F_c = 0.06 #F_c(N*m)
Clda_cmp = -0.2966 #Clda_cmp(1/rad)

#for short
qbarSb = 0.5*1.225*V*V*S_c*b_c
_m_T_l_z_T_g = -(m_T*l_z_T)*g


def obs(Z,T,U,params):
    s = T.size
    
    k1 = np.array(params[0:angles_num])
    k2 = np.array(params[angles_num:angles_num*2])
    k3 = np.array(params[angles_num*2:angles_num*3])
    k4 = np.array(params[angles_num*3:angles_num*4])
    phi0 = params[-1]

    Clda1 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k1*angles,assume_sorted=True)
    Clda2 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k2*angles,assume_sorted=True)
    Clda3 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k3*angles,assume_sorted=True)
    Clda4 = scipy.interpolate.interp1d(angles, Clda_cmp*0.00436332313*k4*angles,assume_sorted=True)
    
    moments_a = qbarSb*(Clda1(U[:s,0])+Clda2(U[:s,1])
                       +Clda3(U[:s,2])+Clda4(U[:s,3]))

    phi = phi0+np.arcsin(np.clip(-moments_a/_m_T_l_z_T_g, -1, 1))
    
    return (phi*57.3).reshape((-1,1))

In [20]:
display(HTML('<b>Constant Parameters</b>'))
table = ListTable()
table.append(['Name','Value','unit'])
table.append(['$S_c$',S_c,'$m^2$'])
table.append(['$b_c$',b_c,'$m$'])
table.append(['$g$',g,'$m/s^2$'])
table.append(['$m_T$',m_T,'$kg$'])
table.append(['$l_{zT}$',l_z_T,'$m$'])
table.append(['$V$',V,'$m/s$'])
table.append(['$F_c$',F_c,'$Nm$'])
table.append(['$C_{l \delta a,cmp}$',Clda_cmp,'$rad^{-1}$'])
display(table)


Constant Parameters
NameValueunit
$S_c$0.1254$m^2$
$b_c$0.7$m$
$g$9.81$m/s^2$
$m_T$9.585$kg$
$l_{zT}$0.0416$m$
$V$30$m/s$
$F_c$0.06$Nm$
$C_{l \delta a,cmp}$-0.2966$rad^{-1}$

Initial guess

  • Input default values and ranges for parameters
  • Select sections for trainning
  • Adjust parameters based on simulation results
  • Decide start values of parameters for optimization

In [21]:
#initial guess
param0 = [1]*(4*angles_num)+[0]

param_name = ['k_{}_{}'.format(i/angles_num+1, angles[i%angles_num]) for i in range(4*angles_num)] + ['$phi_0$']
param_unit = ['1']*(4*angles_num) + ['$rad$']

NparID = Npar
opt_idx = range(Npar)
opt_param0 = [param0[i] for i in opt_idx]
par_del = [0.001]*(4*angles_num) + [0.0001]
bounds =  [(0,1.5)]*(4*angles_num) +[(-0.1, 0.1)]
display_default_params()

#select sections for training
section_idx = range(14)
display_data_for_train()

#push parameters to engines
push_opt_param()


Default Parameters for optimization
IdxDescription$x_0$unitopt$\delta_{par}$minmax
0k_1_-4111*0.00101.5
1k_1_-3511*0.00101.5
2k_1_-3011*0.00101.5
3k_1_-2511*0.00101.5
4k_1_-2011*0.00101.5
5k_1_-1511*0.00101.5
6k_1_-1011*0.00101.5
7k_1_-511*0.00101.5
8k_1_511*0.00101.5
9k_1_1011*0.00101.5
10k_1_1511*0.00101.5
11k_1_2011*0.00101.5
12k_1_2511*0.00101.5
13k_1_3011*0.00101.5
14k_1_3511*0.00101.5
15k_1_4111*0.00101.5
16k_2_-4111*0.00101.5
17k_2_-3511*0.00101.5
18k_2_-3011*0.00101.5
19k_2_-2511*0.00101.5
20k_2_-2011*0.00101.5
21k_2_-1511*0.00101.5
22k_2_-1011*0.00101.5
23k_2_-511*0.00101.5
24k_2_511*0.00101.5
25k_2_1011*0.00101.5
26k_2_1511*0.00101.5
27k_2_2011*0.00101.5
28k_2_2511*0.00101.5
29k_2_3011*0.00101.5
30k_2_3511*0.00101.5
31k_2_4111*0.00101.5
32k_3_-4111*0.00101.5
33k_3_-3511*0.00101.5
34k_3_-3011*0.00101.5
35k_3_-2511*0.00101.5
36k_3_-2011*0.00101.5
37k_3_-1511*0.00101.5
38k_3_-1011*0.00101.5
39k_3_-511*0.00101.5
40k_3_511*0.00101.5
41k_3_1011*0.00101.5
42k_3_1511*0.00101.5
43k_3_2011*0.00101.5
44k_3_2511*0.00101.5
45k_3_3011*0.00101.5
46k_3_3511*0.00101.5
47k_3_4111*0.00101.5
48k_4_-4111*0.00101.5
49k_4_-3511*0.00101.5
50k_4_-3011*0.00101.5
51k_4_-2511*0.00101.5
52k_4_-2011*0.00101.5
53k_4_-1511*0.00101.5
54k_4_-1011*0.00101.5
55k_4_-511*0.00101.5
56k_4_511*0.00101.5
57k_4_1011*0.00101.5
58k_4_1511*0.00101.5
59k_4_2011*0.00101.5
60k_4_2511*0.00101.5
61k_4_3011*0.00101.5
62k_4_3511*0.00101.5
63k_4_4111*0.00101.5
64$phi_0$0$rad$*0.0001-0.10.1
Training Data
IdxStart(s)Spam(s)Description
018.86118.46ramp cmp4 u
1141.41118.86ramp cmp4 d
2265.59118.86ramp cmp3 u
3391.49118.48ramp cmp3 d
4518.48119.79ramp cmp2 u
5644.71119.27ramp cmp2 d
6770.30119.51ramp cmp1 u
7896.00118.86ramp cmp1 d
81022.19119.26ramp cmp4 d
91145.15120.08ramp cmp4 u
101279.28118.34ramp cmp3 u
111411.54118.47ramp cmp2 d
121536.99120.08ramp cmp2 u
131671.68120.63ramp cmp1 d

In [22]:
# select 4 section from training data
#idx = random.sample(section_idx, 4)
idx = section_idx[:]

interact_guess();


Optimize using ML


In [23]:
display_preopt_params()

if False:
    InfoMat = None
    method = 'trust-ncg'
    def hessian(opt_params, index):
        global InfoMat
        return InfoMat
    dview['enable_infomat']=True
    options={'gtol':1}
    opt_bounds = None
else:
    method = 'L-BFGS-B'
    hessian = None
    dview['enable_infomat']=False
    options={'ftol':1e-6,'maxfun':400}
    opt_bounds = bounds

cnt = 0
tmp_rslt = None
T0 = time.time()
print('#cnt,     Time,      |R|')

%time res =  sp.optimize.minimize(fun=costfunc, x0=opt_param0, \
        args=(opt_idx,), method=method, jac=True, hess=hessian, \
        bounds=opt_bounds, options=options)


Parameters for optimization
IdxDescription$x_0$unitopt$\delta_{par}$minmax
0k_1_-411.01*0.00101.5
1k_1_-351.01*0.00101.5
2k_1_-301.01*0.00101.5
3k_1_-251.01*0.00101.5
4k_1_-201.01*0.00101.5
5k_1_-151.01*0.00101.5
6k_1_-101.01*0.00101.5
7k_1_-51.01*0.00101.5
8k_1_51.01*0.00101.5
9k_1_101.01*0.00101.5
10k_1_151.01*0.00101.5
11k_1_201.01*0.00101.5
12k_1_251.01*0.00101.5
13k_1_301.01*0.00101.5
14k_1_351.01*0.00101.5
15k_1_411.01*0.00101.5
16k_2_-411.01*0.00101.5
17k_2_-351.01*0.00101.5
18k_2_-301.01*0.00101.5
19k_2_-251.01*0.00101.5
20k_2_-201.01*0.00101.5
21k_2_-151.01*0.00101.5
22k_2_-101.01*0.00101.5
23k_2_-51.01*0.00101.5
24k_2_51.01*0.00101.5
25k_2_101.01*0.00101.5
26k_2_151.01*0.00101.5
27k_2_201.01*0.00101.5
28k_2_251.01*0.00101.5
29k_2_301.01*0.00101.5
30k_2_351.01*0.00101.5
31k_2_411.01*0.00101.5
32k_3_-411.01*0.00101.5
33k_3_-351.01*0.00101.5
34k_3_-301.01*0.00101.5
35k_3_-251.01*0.00101.5
36k_3_-201.01*0.00101.5
37k_3_-151.01*0.00101.5
38k_3_-101.01*0.00101.5
39k_3_-51.01*0.00101.5
40k_3_51.01*0.00101.5
41k_3_101.01*0.00101.5
42k_3_151.01*0.00101.5
43k_3_201.01*0.00101.5
44k_3_251.01*0.00101.5
45k_3_301.01*0.00101.5
46k_3_351.01*0.00101.5
47k_3_411.01*0.00101.5
48k_4_-411.01*0.00101.5
49k_4_-351.01*0.00101.5
50k_4_-301.01*0.00101.5
51k_4_-251.01*0.00101.5
52k_4_-201.01*0.00101.5
53k_4_-151.01*0.00101.5
54k_4_-101.01*0.00101.5
55k_4_-51.01*0.00101.5
56k_4_51.01*0.00101.5
57k_4_101.01*0.00101.5
58k_4_151.01*0.00101.5
59k_4_201.01*0.00101.5
60k_4_251.01*0.00101.5
61k_4_301.01*0.00101.5
62k_4_351.01*0.00101.5
63k_4_411.01*0.00101.5
64$phi_0$0.0$rad$*0.0001-0.10.1
#cnt,     Time,      |R|
0001,    0.197,       36.6
0002,    0.350,      686.4
0003,    0.495,       17.3
0004,    0.645,        8.6
0005,    0.781,      101.5
0006,    0.940,       14.5
0007,    1.105,        6.9
0008,    1.270,        7.6
0009,    1.435,        6.3
0010,    1.587,       11.6
0011,    1.725,        7.6
0012,    1.880,        6.6
0013,    2.036,        6.3
0014,    2.187,        6.3
0015,    2.330,        6.6
0016,    2.469,        6.2
0017,    2.610,        6.2
0018,    2.764,        6.0
0019,    2.927,        5.4
0020,    3.102,        5.4
0021,    3.267,        4.8
0022,    3.447,        4.4
0023,    3.619,        4.4
0024,    3.792,        4.4
0025,    3.977,        4.4
0026,    4.157,        4.4
0027,    4.324,        4.4
0028,    4.486,        4.4
0029,    4.629,        4.4
0030,    4.773,        4.4
0031,    4.918,        4.4
0032,    5.056,        4.4
0033,    5.192,        4.4
0034,    5.336,        4.4
0035,    5.470,        4.4
0036,    5.611,        4.4
0037,    5.754,        4.4
0038,    5.915,        4.4
0039,    6.067,        4.4
0040,    6.207,        4.4
0041,    6.350,        4.4
0042,    6.493,        4.4
0043,    6.630,      363.2
0044,    6.767,       26.1
0045,    6.907,        5.0
0046,    7.049,        3.5
0047,    7.188,        3.0
0048,    7.320,        3.1
0049,    7.462,        2.9
0050,    7.594,        2.9
0051,    7.737,        2.9
0052,    7.871,        2.9
0053,    8.017,        2.9
0054,    8.177,       46.4
0055,    8.355,       10.1
0056,    8.506,        4.8
0057,    8.674,        3.5
0058,    8.835,        3.0
0059,    8.979,        2.9
0060,    9.127,        2.9
0061,    9.264,        2.9
0062,    9.410,        2.9
0063,    9.553,        2.9
0064,    9.697,        2.9
0065,    9.835,        2.9
0066,    9.970,        2.9
0067,   10.109,        2.9
0068,   10.256,        2.9
0069,   10.404,        2.9
0070,   10.544,        2.9
0071,   10.696,        2.9
0072,   10.838,        2.9
0073,   10.975,        2.9
0074,   11.124,      820.8
0075,   11.265,       45.0
0076,   11.407,        6.2
0077,   11.549,        2.6
0078,   11.692,        2.1
0079,   11.837,        2.1
0080,   11.971,        2.0
0081,   12.126,        2.0
0082,   12.273,        1.9
0083,   12.414,        1.8
0084,   12.562,        1.7
0085,   12.703,        1.6
0086,   12.842,        1.6
0087,   12.987,        1.6
0088,   13.130,        1.6
0089,   13.268,        1.6
0090,   13.409,        1.6
0091,   13.554,        1.6
0092,   13.719,        1.6
0093,   13.884,        1.6
0094,   14.052,        1.6
0095,   14.203,        1.6
0096,   14.348,        1.6
0097,   14.489,        1.6
0098,   14.630,        1.6
0099,   14.770,        1.6
0100,   14.904,        1.6
0101,   15.056,        1.6
0102,   15.209,        1.6
0103,   15.347,        1.6
0104,   15.499,        1.6
0105,   15.644,        1.6
0106,   15.782,      508.0
0107,   15.926,       33.6
0108,   16.066,        5.6
0109,   16.200,        2.1
0110,   16.342,        1.5
0111,   16.476,        1.5
0112,   16.636,        1.4
0113,   16.776,        1.4
0114,   16.932,        1.4
0115,   17.095,        1.4
0116,   17.226,        1.4
0117,   17.370,        1.4
0118,   17.516,        1.4
0119,   17.665,        1.4
0120,   17.808,        1.4
0121,   17.959,        1.4
0122,   18.120,        1.4
0123,   18.268,        1.4
0124,   18.414,        1.4
0125,   18.563,        1.4
0126,   18.709,        1.4
0127,   18.849,        1.4
0128,   18.993,        1.4
0129,   19.142,        1.4
0130,   19.280,        1.4
0131,   19.416,        1.4
0132,   19.565,        1.4
0133,   19.704,        1.4
0134,   19.842,      492.2
0135,   19.990,       27.4
0136,   20.133,        5.8
0137,   20.275,        2.3
0138,   20.427,        1.5
0139,   20.584,        1.4
0140,   20.763,        1.4
0141,   20.931,        1.3
0142,   21.100,        1.3
0143,   21.247,        1.3
0144,   21.386,        1.3
0145,   21.524,        1.3
0146,   21.662,        1.3
0147,   21.805,        1.3
0148,   21.939,        1.3
0149,   22.074,        1.3
0150,   22.212,        1.3
0151,   22.353,        1.3
0152,   22.491,        1.3
0153,   22.636,        1.3
0154,   22.772,        1.3
0155,   22.912,        1.3
0156,   23.050,        1.3
0157,   23.192,        1.3
0158,   23.336,        1.3
0159,   23.485,        1.3
0160,   23.628,        1.3
0161,   23.772,        1.3
0162,   23.916,      281.7
0163,   24.063,       24.0
0164,   24.206,        5.6
0165,   24.344,        2.2
0166,   24.492,        1.4
0167,   24.637,        1.3
0168,   24.779,        1.3
0169,   24.921,        1.3
0170,   25.061,        1.3
0171,   25.210,        1.3
0172,   25.346,        1.3
0173,   25.489,        1.3
0174,   25.640,        1.3
0175,   25.779,        1.3
0176,   25.916,        1.3
0177,   26.050,        1.3
0178,   26.182,        1.3
0179,   26.326,        1.3
0180,   26.472,        1.3
0181,   26.617,        1.3
0182,   26.762,        1.3
0183,   26.896,        1.3
0184,   27.034,        1.3
0185,   27.184,        1.3
0186,   27.321,        1.3
0187,   27.464,        1.3
0188,   27.606,        1.3
0189,   27.744,        1.3
0190,   27.878,        1.3
0191,   28.019,        1.3
0192,   28.157,      482.8
0193,   28.297,       29.6
0194,   28.442,        6.2
0195,   28.583,        2.4
0196,   28.722,        1.5
0197,   28.859,        1.2
0198,   28.994,        1.2
0199,   29.132,        1.2
0200,   29.274,        1.2
0201,   29.413,        1.2
0202,   29.556,        1.2
0203,   29.707,        1.2
0204,   29.853,        1.2
0205,   29.989,        1.1
0206,   30.142,        1.1
0207,   30.287,        1.0
0208,   30.419,        1.0
0209,   30.561,        0.9
0210,   30.695,        0.9
0211,   30.840,        0.8
0212,   30.983,        0.8
0213,   31.119,        0.8
0214,   31.256,        0.8
0215,   31.407,        0.8
0216,   31.550,        0.8
0217,   31.690,        0.8
0218,   31.844,        0.8
0219,   31.990,        0.8
0220,   32.132,        0.8
0221,   32.287,        0.8
0222,   32.444,        0.8
0223,   32.593,        0.8
0224,   32.746,        0.8
0225,   32.880,        0.8
0226,   33.018,        0.8
0227,   33.166,        0.8
0228,   33.307,        0.8
0229,   33.453,        0.8
0230,   33.589,        0.8
0231,   33.734,        0.8
0232,   33.870,        0.8
0233,   34.009,      745.3
0234,   34.149,       34.8
0235,   34.289,        8.5
0236,   34.439,        3.0
0237,   34.582,        1.5
0238,   34.725,        1.0
0239,   34.876,        0.9
0240,   35.024,        0.8
0241,   35.201,        0.8
0242,   35.356,        0.8
0243,   35.499,        0.8
0244,   35.650,        0.8
0245,   35.815,        0.8
0246,   35.992,        0.8
0247,   36.192,        0.8
0248,   36.393,        0.8
0249,   36.568,        0.8
0250,   36.731,        0.8
0251,   36.891,        0.8
0252,   37.080,        0.8
CPU times: user 10.1 s, sys: 712 ms, total: 10.9 s
Wall time: 37.1 s

Show and test results


In [24]:
display_opt_params()

# show result
idx = [0,1, 8,9,
       2,3,10,
       4,5,11,12,
       6,7,13,14,]
display_data_for_test();

update_guess();


Parameters from optimization
IdxDescription$x$
0k_1_-411.14629833042
1k_1_-351.16285127459
2k_1_-301.17710541985
3k_1_-251.1848702943
4k_1_-201.20462684676
5k_1_-151.26263485422
6k_1_-101.2516653674
7k_1_-50.980486789023
8k_1_50.921488273382
9k_1_101.18096915384
10k_1_151.18680742601
11k_1_200.976157836667
12k_1_250.981902151188
13k_1_300.981624526926
14k_1_351.03185651775
15k_1_411.00522359098
16k_2_-410.902541621017
17k_2_-350.884894492126
18k_2_-300.85779634002
19k_2_-250.850118219298
20k_2_-200.857266999961
21k_2_-150.954364989351
22k_2_-100.985177949469
23k_2_-50.920009656205
24k_2_50.882755514768
25k_2_100.8702506961
26k_2_150.904451603012
27k_2_200.822128063143
28k_2_250.807405493692
29k_2_300.833238377866
30k_2_350.867097942574
31k_2_410.901428442592
32k_3_-410.783253295092
33k_3_-350.80961579614
34k_3_-300.808739907178
35k_3_-250.796131138216
36k_3_-200.801968396797
37k_3_-150.823087064097
38k_3_-100.971335363651
39k_3_-51.04014757757
40k_3_50.766494037217
41k_3_100.784015882181
42k_3_150.814137346191
43k_3_200.833601120864
44k_3_250.803644778053
45k_3_300.801404908323
46k_3_350.781241093956
47k_3_410.751036228465
48k_4_-410.67726168876
49k_4_-350.709191222946
50k_4_-300.730766942093
51k_4_-250.757722730251
52k_4_-200.77644120936
53k_4_-150.842963957098
54k_4_-100.832071019129
55k_4_-50.890877419764
56k_4_50.712761573116
57k_4_100.75747752219
58k_4_150.693799985731
59k_4_200.615338433167
60k_4_250.624007620236
61k_4_300.642944325071
62k_4_350.67409581342
63k_4_410.69184419717
64$phi_0$0.0102403971686
Test Data
IdxStart(s)Spam(s)Description
018.86118.46ramp cmp4 u
1141.41118.86ramp cmp4 d
81022.19119.26ramp cmp4 d
91145.15120.08ramp cmp4 u
2265.59118.86ramp cmp3 u
3391.49118.48ramp cmp3 d
101279.28118.34ramp cmp3 u
4518.48119.79ramp cmp2 u
5644.71119.27ramp cmp2 d
111411.54118.47ramp cmp2 d
121536.99120.08ramp cmp2 u
6770.30119.51ramp cmp1 u
7896.00118.86ramp cmp1 d
131671.68120.63ramp cmp1 d
141798.33120.60ramp cmp1 u

In [25]:
res_params = res['x']
params = param0[:]
for i,j in enumerate(opt_idx):
    params[j] = res_params[i]

k1 = np.array(params[0:angles_num])
k2 = np.array(params[angles_num:angles_num*2])
k3 = np.array(params[angles_num*2:angles_num*3])
k4 = np.array(params[angles_num*3:angles_num*4])

Clda_cmp1 = Clda_cmp*0.00436332313*k1*angles
Clda_cmp2 = Clda_cmp*0.00436332313*k2*angles
Clda_cmp3 = Clda_cmp*0.00436332313*k3*angles
Clda_cmp4 = Clda_cmp*0.00436332313*k4*angles

print('angeles = ')
print(angles)
print('Clda_cmpx = ')
print(np.vstack((Clda_cmp1,Clda_cmp2,Clda_cmp3,Clda_cmp4)))

%matplotlib inline
plt.figure(figsize=(12,8),dpi=300)
plt.plot(angles,  Clda_cmp1, 'r')
plt.plot(angles,  Clda_cmp2, 'g')
plt.plot(angles,  Clda_cmp3, 'b')
plt.plot(angles,  Clda_cmp4, 'm')
plt.xlabel('$\delta_{a,cmp}$')
plt.ylabel('$C_{l \delta a,cmp}$')
plt.show()


angeles = 
[-41, -35, -30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30, 35, 41]
Clda_cmpx = 
[[ 0.06082331  0.05267211  0.04570094  0.03833534  0.03117964  0.0245108
   0.01619857  0.00634454 -0.00596277 -0.01528365 -0.02303881 -0.02526612
  -0.0317685  -0.03811142 -0.04673862 -0.05333779]
 [ 0.04788942  0.04008188  0.03330381  0.02750476  0.02218884  0.01852654
   0.0127498   0.00595321 -0.00571214 -0.01126245 -0.0175576  -0.02127933
  -0.02612283 -0.03235035 -0.03927577 -0.04783036]
 [ 0.04155991  0.03667208  0.0313992   0.02575806  0.02075753  0.01597812
   0.01257065  0.0067306  -0.00495984 -0.01014643 -0.01580438 -0.02157629
  -0.02600116 -0.03111442 -0.03538683 -0.03985045]
 [ 0.03593593  0.03212328  0.02837192  0.02451539  0.02009681  0.01636397
   0.01076834  0.0057647  -0.00461214 -0.00980298 -0.01346834 -0.01592695
  -0.02018917 -0.02496222 -0.03053361 -0.03670969]]

In [ ]:


In [ ]:
toggle_inputs()
button_qtconsole()