Exemplo n.º 1
0
    'vmin': 0,
    'vmax': 1,
    'cbar_kwargs': avker_cbar_kwargs,
    'fig_kwargs': small_fig_kwargs,
    'map_kwargs': small_map_kwargs
}
fig2a, ax, c = true.plot_state('dofs',
                               clusters_plot,
                               title=title,
                               **avker_kwargs)
ax.text(0.025,
        0.05,
        'DOFS = %d' % round(np.trace(true.a)),
        fontsize=config.LABEL_FONTSIZE * config.SCALE,
        transform=ax.transAxes)
fp.save_fig(fig2a, plots, 'fig2a_true_averaging_kernel')

# Initial estimate averaging kernel
title = 'Initial estimate averaging\nkernel sensitivities'
avker_cbar_kwargs = {'title': r'$\partial\hat{x}_i/\partial x_i$'}
avker_kwargs['cbar_kwargs'] = avker_cbar_kwargs
fig2b, ax, c = est0.plot_state('dofs',
                               clusters_plot,
                               title=title,
                               **avker_kwargs)
ax.text(0.025,
        0.05,
        'DOFS = %d' % round(np.trace(est0.a)),
        fontsize=config.LABEL_FONTSIZE * config.SCALE,
        transform=ax.transAxes)
fp.save_fig(fig2b, plots, 'fig2b_est0_averaging_kernel')
                  fontsize=(config.TICK_FONTSIZE - 2) * config.SCALE,
                  loc='center')
table.scale(1, 3)

for cell in table._cells:
    table._cells[cell].set_alpha(0.1)

ax[1].add_table(table)
plt.subplots_adjust(hspace=0.4)

# print(cols)

ax[0] = fp.add_title(ax[0],
                     title='DOFS per Cluster Accumulation in Multiscale Grids')

fp.save_fig(fig, plots, 'rd_scheme')

# Second update
est2_ms = est1_ms.update_jacobian_rd(true.k,
                                     true.xa_abs,
                                     true.sa_vec,
                                     clusters_plot,
                                     n_cells=[60],
                                     dofs_e=est0.dofs)
print(est2_ms.dofs.sum())

# Save outputs
np.savetxt(join(inputs, 'state_vector_rd.csv'),
           est2_ms.state_vector,
           delimiter=',')
np.savetxt(join(inputs, 'k_rd.csv'), est2_ms.k, delimiter=',')
    'y': 1,
    'pad':
    (1.5 * config.TITLE_PAD + 1 * config.SUBTITLE_FONTSIZE * config.SCALE)
}

## Original dimension
fig1a, ax = est0.plot_multiscale_grid(clusters_plot,
                                      colors='0.5',
                                      zorder=3,
                                      linewidths=0.5,
                                      fig_kwargs=small_fig_kwargs,
                                      map_kwargs=small_map_kwargs)
ax = flow_chart_settings(ax)
ax = fp.add_title(ax, 'Native resolution', **title_kwargs)
ax = fp.add_subtitle(ax, r'dimension $n$, rank $> k$')
fp.save_fig(fig1a, loc=plots, name='fig1a_dimn_rankn')

## Reduced rank
true.evec_sum = true.evecs[:, :3].sum(axis=1)
fig1b, ax, c = true.plot_state('evec_sum',
                               clusters_plot,
                               title='',
                               cbar=False,
                               cmap='RdBu_r',
                               vmin=-0.1,
                               vmax=0.1,
                               default_value=0,
                               fig_kwargs=small_fig_kwargs,
                               map_kwargs=small_map_kwargs)
ax = flow_chart_settings(ax)
ax = fp.add_subtitle(ax,
Exemplo n.º 4
0
ax[0].plot(nstate_record, dpc_record, color=fp.color(0))
for i in range(len(state_thresholds) - 1):
    ax[0].axvspan(state_thresholds[i],
                  state_thresholds[i + 1],
                  color=fp.color(2 * i),
                  alpha=0.2,
                  zorder=-100)
ax[0].set_ylim(0.3, 0.5)

ax1 = ax[0].twinx()
ax1.plot(nstate_record, dofs_record, color=fp.color(0), ls=':')

ax[0].set_xlim(0, est0.nstate)

fp.save_fig(fig, plots, 'rd_scheme_test')

# Save outputs
np.savetxt(join(inputs, 'state_vector_rd.csv'),
           est2_ms.state_vector,
           delimiter=',')
np.savetxt(join(inputs, 'k_rd.csv'), est2_ms.k, delimiter=',')
np.savetxt(join(inputs, 'sa_vec_rd.csv'), est2_ms.sa_vec, delimiter=',')
np.savetxt(join(inputs, 'xa_rd.csv'), est2_ms.xa, delimiter=',')
np.savetxt(join(inputs, 'xa_abs_rd.csv'), est2_ms.xa_abs, delimiter=',')
np.savetxt(join(inputs, 'xhat_long_rd.csv'), est2_ms.xhat_long, delimiter=',')
np.savetxt(join(inputs, 'dofs_long_rd.csv'), est2_ms.dofs_long, delimiter=',')
np.savetxt(join(inputs, 'shat_err_long_rd.csv'),
           est2_ms.shat_err_long,
           delimiter=',')