diff --git a/kalman/graphics/figure2.py b/kalman/graphics/figure2.py index 90e55d5..5021274 100644 --- a/kalman/graphics/figure2.py +++ b/kalman/graphics/figure2.py @@ -52,42 +52,31 @@ def plot_parameters(dat, input_file, deparameterize=False, ref=None): inputfile = yaml.full_load(file) - #true_values = { - # 3: 3400, - # 4: 4200, - # 5: 11000, - # 6: 7800, - # 2: 100 - # } true_values = { 3: 4800, - 4: 7020, + 4: 7200, 5: 11520, 6: 11520, 2: 75 } + true_values_C = { + 3: 0.0004, + 4: 0.0004, + 5: 0.0003, + 6: 0.0003, + } - true_values_c = { - 3: 0.0008, - 4: 0.00034, - 5: 0.00034, - 6: 0.00034, - 2: 100 - } - - true_values_rp = { - 3: 10, - 4: 60, - 5: 220, - 6: 160, - 2: 100 - } + meas_flag = False + RC_mod = True + line_split = 1.5 current_val = [] + current_val_C = [] + ids_type = [] labels = [] ids = [] @@ -97,14 +86,23 @@ def plot_parameters(dat, input_file, deparameterize=False, ref=None): for bnd_set in inputfile['boundary_conditions']: if bnd_c['id'] == bnd_set['id']: ids.append(bnd_c['id']) + ids_type.append('windkessel') current_val.append(bnd_set['parameters']['R_d']) labels.append('$R_' + str(bnd_c['id'])) + if RC_mod: + current_val_C.append(bnd_set['parameters']['C']) + labels.append('$C_' + str(bnd_c['id'])) + elif 'dirichlet' in bnd_c['type']: current_val.append(inputfile['boundary_conditions'][0]['parameters']['U']) ids.append(bnd_c['id']) + ids_type.append('dirichlet') labels.append('$U') + + + dim = dat['theta'].shape[-1] fig1, axes = plt.subplots(1,1,figsize=(8,6)) @@ -116,9 +114,12 @@ def plot_parameters(dat, input_file, deparameterize=False, ref=None): col = cycle(['C0', 'C1', 'C2', 'C3','C4']) ls = cycle(['-', '-', '--', '--', ':', ':', '-.', '-.']) - #legends = cycle(['$R_3$','$R_4$','$R_5$','$R_6$','$U$']) legends = cycle(labels) - + + if meas_flag: + t_und = t[0::30] + t_und = np.append( t_und , [t[-1]]) + meas_mark = t_und*0 col_ = next(col) ls_ = next(ls) @@ -127,23 +128,51 @@ def plot_parameters(dat, input_file, deparameterize=False, ref=None): if dim == 1: theta = theta.reshape((-1, 1)) P = P.reshape((-1, 1, 1)) + - for i in range(dim): - - true_level = np.log(true_values[ids[i]]/current_val[i])/np.log(2) - rec_value = np.round(2**theta[-1, i]*current_val[i],2) + idx = 0 + idc = 0 + + for i in range(len(ids)): cur_key = ids[i] - axes.plot(t, theta[:, i] + 1.5*i, '-', color=col_,label= legends_ + '= ' + str(rec_value) + '/' + str(true_values[cur_key]) + '$') - axes.fill_between(t, theta[:, i] + 1.5*i - np.sqrt(P[:, i, i]), - theta[:, i] + 1.5*i + np.sqrt(P[:, i, i]), alpha=0.3, - color=col_) - + true_level = np.log(true_values[ids[i]]/current_val[i])/np.log(2) + rec_value = np.round(2**theta[-1, idx]*current_val[i],2) - axes.plot(t,1.5*i + t*0 + true_level , color=col_,ls='--') - col_ = next(col) + #curve = theta[:,i] + line_split*i + #dash_curve = line_split*i + t*0 + true_level + + curve = theta[:,idx] + line_split*idx - true_level + dash_curve = line_split*idx + t*0 + + axes.plot(t, curve , '-', color=col_,label= legends_ + '= ' + str(rec_value) + '/' + str(true_values[cur_key]) + '$') + axes.fill_between(t, curve - np.sqrt(P[:, idx, idx]), curve + np.sqrt(P[:, idx, idx]), alpha=0.3, color=col_) legends_=next(legends) + axes.plot(t, dash_curve , color=col_,ls='--') + + + if RC_mod: + + if i1.6) + (t<2.4)*(1.6+Th