示例#1
0
 def plot_data(self, times, figsz=(12, 5)):
     """
     Plot the observations with its values u(x, t) at fixed locations for given time points
     """
     n = len(times)
     nrow = np.floor(np.sqrt(n)).astype('int')
     ncol = np.ceil(np.sqrt(n)).astype('int')
     fig, axes = plt.subplots(nrows=nrow,
                              ncols=ncol,
                              sharex=True,
                              sharey=True,
                              figsize=figsz)
     sub_figs = [None] * len(axes.flat)
     for i in range(n):
         plt.axes(axes.flat[i])
         dl.plot(self.Vh.mesh())
         sub_figs[i] = plt.scatter(self.targets[:, 0],
                                   self.targets[:, 1],
                                   c=self.d.data[np.where(
                                       np.isclose(self.d.times,
                                                  times[i]))[0][0]],
                                   zorder=2)
         #             plt.xlim(0,1); plt.ylim(0,1)
         #             plt.gca().set_aspect('equal', 'box')
         plt.title('Time: {:.1f} s'.format(times[i], ))
     fig = common_colorbar(fig, axes, sub_figs)
     return fig
示例#2
0
 def plot_soln(self, x, times, figsz=(12, 5)):
     """
     Plot solution u(., times)
     """
     n = len(times)
     nrow = np.floor(np.sqrt(n)).astype('int')
     ncol = np.ceil(np.sqrt(n)).astype('int')
     fig, axes = plt.subplots(nrows=nrow,
                              ncols=ncol,
                              sharex=True,
                              sharey=True,
                              figsize=figsz)
     sub_figs = [None] * len(axes.flat)
     for i in range(n):
         plt.axes(axes.flat[i])
         sub_figs[i] = dl.plot(
             vector2Function(x.data[list(x.times).index(times[i])],
                             self.Vh[STATE]))
         plt.title('Time: {:.1f} s'.format(times[i], ))
     fig = common_colorbar(fig, axes, sub_figs)
     return fig
示例#3
0
    
    # obtain MAP as reconstruction of permittivity
    try:
        with open(os.path.join('./result',str(eit.gdim)+'d_EIT_MAP_dim'+str(eit.dim)+'.pckl'),'rb') as f:
            ds=pickle.load(f)[0]
    except:
        ds=eit.get_MAP(lamb_decay=0.1,lamb=1e-3, method='kotre',maxiter=100)
#         ds=eit.get_MAP(lamb_decay=0.2,lamb=1e-2, method='kotre', maxiter=100)
        with open(os.path.join('./result',str(eit.gdim)+'d_EIT_MAP_dim'+str(eit.dim)+'.pckl'),'wb') as f:
            pickle.dump([ds,n_el,bbox,meshsz,el_dist,step,anomaly],f)
     
    # plot MAP results
    if eit.gdim==2:
        fig,axes = plt.subplots(nrows=1,ncols=2,sharex=True,sharey=False,figsize=(12,5))
        sub_figs=[None]*2
        sub_figs[0]=eit.plot(ax=axes.flat[0])
        axes.flat[0].axis('equal')
        axes.flat[0].set_title(r'True Conductivities')
        sub_figs[1]=eit.plot(input=ds,ax=axes.flat[1])
        axes.flat[1].axis('equal')
        axes.flat[1].set_title(r'Reconstructed Conductivities (MAP)')
        from util.common_colorbar import common_colorbar
        fig=common_colorbar(fig,axes,sub_figs)
    #     plt.subplots_adjust(wspace=0.2, hspace=0)
        # save plots
        # fig.tight_layout(h_pad=1)
        plt.savefig(os.path.join('./result',str(eit.gdim)+'d_EIT_MAP_dim'+str(eit.dim)+'.png'),bbox_inches='tight')
        # plt.show()
    else:
        eit.plot()
        eit.plot(input=ds)