fig1, ax11, cc11 = graph.color_plot(xgrid, ygrid, ugrid, fignum=1, subplot=121, figsize=(16, 8)) fig1, ax12, cc12 = graph.color_plot(xgrid, ygrid, vgrid, fignum=1, subplot=122, figsize=(16, 8)) fig2, ax2, cc2 = graph.color_plot(xgrid, ygrid, omega, fignum=2) # print np.nansum(omega), gamma / np.nansum(omega) graph.add_colorbar(cc11, ax=ax11, label=r'$U_x$ (px/frame)') graph.add_colorbar(cc12, ax=ax12, label=r'$U_y$ (px/frame)') graph.add_colorbar(cc2, ax=ax2, label=r'$\omega_z$ (1/frame)') graph.labelaxes(ax11, r'$X$', r'$Y$') graph.labelaxes(ax12, r'$X$', r'$Y$') graph.labelaxes(ax2, r'$X$', r'$Y$') fig1.tight_layout() fig2.tight_layout() fig3, ax31 = graph.pdf(ugrid, nbins=200, fignum=3, subplot=121, figsize=(16, 8)) fig3, ax32 = graph.pdf(vgrid,
nrows_sub, ncolumns_sub = 16, 16 xx_coarse = fa.coarse_grain_2darr(xx, nrows_sub, ncolumns_sub) yy_coarse = fa.coarse_grain_2darr(yy, nrows_sub, ncolumns_sub) ux0_coarse = fa.coarse_grain_2darr(ux0, nrows_sub, ncolumns_sub) uy0_coarse = fa.coarse_grain_2darr(uy0, nrows_sub, ncolumns_sub) uz0_coarse = fa.coarse_grain_2darr(uz0, nrows_sub, ncolumns_sub) #energy_coarse = (ux0_coarse ** 2 + uy0_coarse ** 2 + uz0_coarse ** 2) / 2 energy_coarse = np.sqrt((ux0_coarse**2 + uy0_coarse**2 + uz0_coarse**2)) #graph.color_plot(xx_coarse, yy_coarse, ux0_coarse, cmap='RdBu', vmin=-2, vmax=2, fignum=1) print xx_coarse.shape # # graph.color_plot(xx, yy, ux0, cmap='RdBu', vmin=-2, vmax=2, fignum=1) fig = plt.figure(num=1, figsize=(18, 18)) ax = fig.add_subplot(111) cc = ax.pcolormesh(xx_coarse, yy_coarse, uy0_coarse, cmap='RdBu', vmin=-2, vmax=2) ax.quiver(xx_coarse, yy_coarse, ux0_coarse, uy0_coarse) # ax.invert_yaxis() ax.set_aspect('equal') # set edge color to face color cc.set_edgecolor('face') graph.add_colorbar(cc, ax=ax) plt.show()
kernel3 = np.ones_like(x) kernel3[xmin:xmax, ymin:ymax] = 0.7 xc, yc = 750., 520., sigma = 150. kernel4 = 1 - A * np.exp(- (0.1*(x-xc)**2+(y-yc)**2) / (2. * sigma**2)) e_mod = np.empty_like(e) for i in range(e.shape[2]): print data['x'].shape fig, ax, cc = graph.color_plot(data['y'][..., i], data['x'][..., i], e[..., i] / kernel[i], vmin=0, vmax=1*10**4) ax.invert_yaxis() graph.add_colorbar(cc, option='scientific') graph.title(ax, 'z=%.3f' % data['z'][0, 0, i]) graph.save(dir + '/mod_deltadx_%s_-30/zm%03d' % (str(deltafx).replace('.', 'p'), i), ext='png') plt.close('all') if i < 100: fig, ax, cc = graph.color_plot(data['y'][..., i], data['x'][..., i], e[..., i] / kernel[i] * kernel4, vmin=0, vmax=10 * 10 ** 3) e_mod[..., i] = e[..., i] / kernel[i] * kernel4 else: fig, ax, cc = graph.color_plot(data['y'][..., i], data['x'][..., i], e[..., i] / kernel[i], vmin=0, vmax=10 * 10 ** 3) e_mod[..., i] = e[..., i] / kernel[i] ax.scatter(yc, xc) ax.invert_yaxis()
cmap=cmap, fignum=1, subplot=236) # Plotting stuff axes = [ax11, ax12, ax13, ax14, ax15, ax16] ccs = [cc11, cc12, cc13, cc14, cc15, cc16] cblabels = [ r'$U_x$', r'$U_x$', r'$U_x$', r'$U_y$', r'$U_y$', r'$U_y$' ] xlabel, ylabel = r'$X$ (px)', r'$Y$ (px)' title = r'W=%dpx, $v$=%.1f px/frame (PIVLab, Original, Diff.)' % ( iw, mag) for ax, cc, cblabel in zip(axes, ccs, cblabels): graph.add_colorbar(cc, ax=ax, label=cblabel) graph.labelaxes(ax, xlabel, ylabel) graph.setaxes(ax, 0, xx0.shape[1], 0, xx0.shape[0]) graph.suptitle(title, fignum=1) fig1.tight_layout() pivdata.close() fdata.close() figname = '/pivlab_fakedata_comp_W%d_v%spxframe_multiple_passes' % ( iw, mag_str_2) graph.save(resultdir + figname, ext='png') plt.close() break elif args.mode == 'gradient': max = fs.get_float_from_str(pivdatum_loc, 'max',
uy = filters.gaussian_filter(uy, [0.5, 0.5, 0]) uz = filters.gaussian_filter(uz, [0.5, 0.5, 0]) x, y, z = x / data_spacing, y / data_spacing, z / data_spacing e = (ux**2 + uy**2) / 2. for i in range(x.shape[2]): print i, np.min(z[..., i]), np.max(z[..., i]), np.mean(z[..., i]) fig, ax, cc = graph.color_plot(x[..., i], y[..., i], e[..., i], cmap='plasma', vmin=vmin, vmax=vmax) graph.add_colorbar( cc, label=r'$\bar{E}_{2D}=\frac{1}{2}(\bar{U_x}^2)$', option='scientific') graph.labelaxes(ax, 'X (px)', 'Y (px)') graph.title(ax, '<z>=%.2f px' % np.mean(z[..., i])) fig.tight_layout() filename = '/time_avg_energy_raw_%s/zm%03d' % (args.mode, i) graph.save(args.dir + filename, ext='png', close=True, verbose=True) print x.shape, ux.shape xmin, xmax, ymin, ymax, zmin, zmax = np.min(x), np.max(x), np.min( y), np.max(y), np.min(z), np.max(z) points = zip(np.ravel(x), np.ravel(y),
# for ax in axes: # graph.labelaxes(ax, r'$\Delta t$ (a.u.)', r'$U_x^{true}$ (px/unit time)') # ax.set_facecolor('k') # fig8.tight_layout() fig8, ax81, cc81 = graph.color_plot(grid_deltat, grid_ux, chi_data, cmap=cmap2, aspect=None, fignum=8, subplot=121, vmin=-100, vmax=100) # graph.add_colorbar(cc81, label=r'$\chi / |U_x^{true}|$', aspect=None) graph.add_colorbar(cc81, label=r'$\chi$ (px/unit time)', aspect=None) fig8, ax82, cc82 = graph.color_plot(grid_deltat, grid_ux, gamma_data, cmap='plasma', aspect=None, fignum=8, subplot=122, vmin=0.0, vmax=150, figsize=(20, 10)) # graph.add_colorbar(cc82, label=r'$\gamma / |U_x^{true}|$', aspect=None) graph.add_colorbar(cc82, label=r'$\gamma$ (px/unit time)', aspect=None) axes = [ax81, ax82]
# Coarse-grain data nrows_sub, ncolumns_sub = args.iw, args.iw # number of pixels to average over xx_coarse = fa.coarse_grain_2darr_overwrap(xx, nrows_sub, ncolumns_sub, overwrap=0.5) yy_coarse = fa.coarse_grain_2darr_overwrap(yy, nrows_sub, ncolumns_sub, overwrap=0.5) ux0_coarse = fa.coarse_grain_2darr_overwrap(ux0, nrows_sub, ncolumns_sub, overwrap=0.5) uy0_coarse = fa.coarse_grain_2darr_overwrap(uy0, nrows_sub, ncolumns_sub, overwrap=0.5) fig1, ax11, cc11 = graph.color_plot(xx, yy, ux0, cmap=cmap, vmin=-2, vmax=2, fignum=1, subplot=221) fig1, ax12, cc12 = graph.color_plot(xx_coarse, yy_coarse, ux0_coarse, cmap=cmap, vmin=-2, vmax=2, fignum=1, subplot=222) fig1, ax13, cc13 = graph.color_plot(xx, yy, uy0, cmap=cmap, vmin=-2, vmax=2, fignum=1, subplot=223) fig1, ax14, cc14 = graph.color_plot(xx_coarse, yy_coarse, uy0_coarse, cmap=cmap, vmin=-2, vmax=2, fignum=1, subplot=224, figsize=(18, 14)) axes1 = [ax11, ax12, ax13, ax14] ccs1 = [cc11, cc12, cc13, cc14] titles1 = ['Original $U_x$', 'Coarse-grained $U_x$', 'Original $U_y$', 'Coarse-grained $U_y$'] for ax, cc, title in zip(axes1, ccs1, titles1): graph.add_colorbar(cc, ax=ax, ticklabelsize=10) graph.title(ax, title) # graph.setaxes(ax, 0, 2*np.pi, 0, 2*np.pi) graph.labelaxes(ax, '$X$ (a.u.)', '$Y$ (a.u.)') if cmap == 'RdBu': ax.set_facecolor('k') graph.suptitle('Fake data') filename = 'fake_data_vel_fields_%s' %cmap graph.save(resultdir + filename) plt.close() ################ # PIV-processed data ################ # data architecture