예제 #1
0
                            lorentz_peaks_uy.append(np.nan)
                            gammas_uy.append(np.nan)
                            lorentz_peaks_uy_err.append(np.nan)
                            gammas_uy_err.append(np.nan)
                            pass


                        # Plotting stuff
                        axes = [ax11, ax12]
                        xlabels, ylabel = [r'$\Delta U_x$ (px/frame)', r'$\Delta U_y$ (px/frame)'], r'Probability density'
                        title = r'W=%dpx, $v$=%.1f px/frame (PIVLab, Original, Diff.)' % (iw, mag)
                        for ax, xlabel in zip(axes, xlabels):
                            graph.labelaxes(ax, xlabel, ylabel)
                            graph.setaxes(ax, -0.2, 0.2, 0, 80)
                            ax.legend()
                        graph.suptitle(title, fignum=1)
                        # fig1.tight_layout()

                        # Close hdf5 files
                        pivdata.close()
                        fdata.close()

                        figname = '/noisedist/pivlab_fakedata_comp_W%d_v%spxframe_multiple_passes' % (iw, mag_str_2)
                        graph.save(resultdir + figname)
                        # plt.show()
                        plt.close()
                        break
        #     elif args.mode == 'gradient':
        #         max = fs.get_float_from_str(pivdatum_loc, 'max', '_min')  # max velocity
        #         min = fs.get_float_from_str(pivdatum_loc, 'min', '.h5')  # min velocity
        #
예제 #2
0
                               figsize=(12, 8), color='C2')

        # Velocity Plot
        fig1, ax2 = graph.plot(time_csv, commanded_vel_csv, label='Commanded velocity (software outputs)', fignum=1, subplot=212,
                               figsize=(12, 8))
        fig1, ax2 = graph.plot(time_csv, vel_csv, label='Actual velocity (software outputs)', fignum=1, subplot=212, figsize=(12, 8))
        fig1, ax2 = graph.plot(time_hdf5, v_hdf5, label='Actual velocity (tracking result)', fignum=1, subplot=212, figsize=(12, 8))
        graph.setaxes(ax1, tmin, tmax, -0.2, span * 1.3)
        graph.setaxes(ax2, tmin, tmax, -480, 150)
        graph.legend(ax1, loc=1)
        graph.legend(ax2, loc=4)
        graph.addtext(ax1, 'Actual stroke length(tracking code): %.2f + %.2f mm' % (stroke_length_hdf5, 2*fx), option='bl', fontsize=10)
        graph.addtext(ax1, 'Actual stroke length(software): %.2f mm' % stroke_length_csv, option='bl2', fontsize=10)
        graph.labelaxes(ax1,'Time [s]', 'Position y [mm]')
        graph.labelaxes(ax2, 'Time [s]', 'Velocity [mm/s]')
        graph.suptitle(data_tracking_dir_tail)
        # Draw a line where the two data were aligned
        # graph.axvline(ax1, x=time_csv[vel_csv_right_ind], linestyle='--', color='k')
        # graph.axvline(ax2, x=time_csv[vel_csv_right_ind], linestyle='--', color='k')


        # Scatter plot where the two data (tracking code results and software outputs) were aligned
        # if v_hdf5_left_ind+shift_arg >= time_hdf5.shape[0]:
        #     fig1, ax1 = graph.scatter([time_hdf5[v_hdf5_right_ind + shift_arg - time_hdf5.shape[0]]], [v_hdf5[v_hdf5_right_ind + shift_arg - time_hdf5.shape[0]]], fignum=1, subplot=212,
        #                   marker='x', color='C2', figsize=(12,8))
        # else:
        #     fig1, ax1 = graph.scatter(time_hdf5[v_hdf5_right_ind+shift_arg], v_hdf5[v_hdf5_right_ind+shift_arg], fignum=1, subplot=212,
        #                   marker='x', color='C2', figsize=(12,8))
        # fig1, ax1 = graph.scatter(time_csv[vel_csv_right_ind], vel_csv[vel_csv_right_ind], fignum=1, subplot=212,
        #                   marker='x', color='C1', figsize=(12,8))
예제 #3
0
    print '%d / %d' % (i+1, tdim)
    uz, uy, ux = fyle[vel_keys[i]][zpos, ..., 0], fyle[vel_keys[i]][zpos, ..., 1], fyle[vel_keys[i]][zpos, ..., 2] # unit length / unit time
    uz = uz / fx # px/unit time
    uy = uy / fx # px/unit time
    ux = ux / fx # px/unit time

    fig1, ax11, cc11 = graph.color_plot(x, y, ux, vmin=-vmax, vmax=vmax, cmap=cmap, subplot=131, figsize=(20, 6))
    fig1, ax12, cc12 = graph.color_plot(x, y, uy, vmin=-vmax, vmax=vmax, cmap=cmap, subplot=132, figsize=(20, 6))
    fig1, ax13, cc13 = graph.color_plot(x, y, uz, vmin=-vmax, vmax=vmax, cmap=cmap, subplot=133, figsize=(20, 6))
    axes = [ax11, ax12, ax13]
    ccs = [cc11, cc12, cc13]
    clabels = ['$u_x$ (px/unit time)', '$u_y$ (px/unit time)', '$u_z$ (px/unit time)']
    for ax, cc, clabel in zip(axes, ccs, clabels):
        graph.add_colorbar(cc, ax=ax, label=clabel)
        graph.labelaxes(ax, '$X$ (px)', '$Y$ (px)')
    graph.suptitle(r't= %.1f $ \tau_\eta$ = %.2f (unit time)' % (float(vel_keys[i][1:]) * dt / tau_eta, float(vel_keys[i][1:]) * dt), fignum=1)
    #
    fig2, ax2 = graph.pdf(ux, nbins=int(np.sqrt(ydim * xdim)), fignum=2, label='$u_x$ (px/unit time)')
    fig2, ax2 = graph.pdf(uy, nbins=int(np.sqrt(ydim * xdim)), fignum=2, label='$u_y$ (px/unit time)')
    fig2, ax2 = graph.pdf(uz, nbins=int(np.sqrt(ydim * xdim)), fignum=2, label='$u_z$ (px/unit time)')

    graph.setaxes(ax2, -vmax, vmax, -0.05/100., 0.006)
    graph.labelaxes(ax2, '$u_i$ (px/unit time)', 'Probability density')
    graph.suptitle(r't= %.1f $ \tau_\eta$ = %.2f (unit time)' % (float(vel_keys[i][1:]) * dt / tau_eta, float(vel_keys[i][1:]) * dt), fignum=2)
    ax2.legend()

    filename1 = 'vel_field_t' + vel_keys[i][1:]
    filename2 = 'pdf_vel_field_t' + vel_keys[i][1:]
    graph.save(resultdir + filename1, fignum=1, ext='png')
    graph.save(resultdir + filename2, fignum=2, ext='png')
예제 #4
0
        ax_2.set_xlabel(r'Normalized time $ \Delta t / \tau$')
        new_tick_locations = np.array(
            [0, tau / 4., tau / 2., tau / 4. * 3, tau])

        def tick_function(x):
            new_x = x / tau
            return ["%.3f" % z for z in new_x]

        ax_2.set_xlim(ax.get_xlim())
        ax_2.set_xticks(new_tick_locations)
        ax_2.set_xticklabels(tick_function(new_tick_locations))

    iws = [8, 16, 32, 64]
    iw = iws[wind]

    graph.suptitle(r'$W=%d$ px' % iw)
    fig8.tight_layout()

    imgpath8 = dir + '/results/err_dist_heatmap_2/W%dpx' % iw
    # graph.save(imgpath8, 'pdf')
    graph.save(imgpath8, 'png')
    plt.close(fig8)

    # print grid_deltat.shape, grid_ux[:, 0]
    # fig9, ax9 = plt.subplots(nrows=1, ncols=1)
    # for j in range(0, grid_ux.shape[1], 100):
    #     print grid_deltat[:, j], chi_data[:, j]
    #     ax9.scatter(grid_deltat[:, j], chi_data[:, j], label='$U_{x}^{true}=%.f$' % grid_ux[0, j])
    # ax9.legend()
    # plt.show()
        # ax.set_ylim(0, 15)
        # ax.set_yscale("log")

        ax.set_title(title)
        ax.set_xlabel(r'$\Delta U_i(\vec{x}) / U_i(\vec{x})$')
        ax.set_ylabel(r'Probability density')
        # ax.ticklabel_format(style='sci', axis='x', scilimits=(0, 0))

        # ax.legend(loc=1)
        cax, _ = mpl.colorbar.make_axes(ax)
        cbar = mpl.colorbar.ColorbarBase(cax,
                                         cmap=cmap,
                                         norm=normalize,
                                         label=r'$\Delta t (a.u)$')
for i, fig in enumerate([fig1, fig2, fig3, fig4]):
    graph.suptitle(suptitles[i] + ', $W_{in}= 8W$ px', fignum=i + 1)
    imgfilename = '/Volumes/bigraid/takumi/turbulence/JHTD/synthetic_data/hdf5data/tstep1_npt50000_lt20p0_pbcTrue_varyingDt/post_processed/analysisresults_local/' + 'noise_pdf_%d' % (
        i + 1)
    graph.save(imgfilename, fignum=i + 1)
    graph.save(imgfilename, fignum=i + 1, ext='png')

import matplotlib.pyplot as plt

plt.close('all')

# plot fit results
for ind in range(4):
    fit_data = zip(iw_all[ind], deltat_all[ind], gamma_all[ind], chi_all[ind],
                   fit_err_all[ind], r2s[ind])
    for iw in iws:
        fit_data_W = search_tuple(fit_data, 'W%d' % iw)
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
pivlab_outputs = glob.glob(pivdatadir + '/PIV*')
pivlab_output_names = [os.path.split(filename)[1] for filename in pivlab_outputs]
titles2 = ['No. of particles: %s' % filename[-8:-3] for filename in pivlab_output_names]
axes2, ccs2 = [], []
# fig = plt.figure(num=2, figsize=(18, 18))
for i, pivlab_output in enumerate(pivlab_outputs):
예제 #7
0
                                    fignum=1,
                                    subplot=224)
axes1 = [ax11, ax12, ax13, ax14]
ccs1 = [cc11, cc12, cc13, cc14]
titles1 = [
    'Original $U_x$', 'Coarse-grained $U_x$', 'Coarse-grained $U_y$',
    'Coarse-grained $U_z$'
]
for ax, cc, title in zip(axes1, ccs1, titles1):
    graph.add_colorbar(cc, ax=ax)
    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('JHTD')
filename = 'jhtd_vel_fields_%s' % cmap
graph.save(resultdir + filename)
plt.close()

################
# PIV-processed data
################
# data architecture
pivlab_outputs = glob.glob(pivdatadir + '/*')
pivlab_output_names = [
    os.path.split(filename)[1] for filename in pivlab_outputs
]
# ########
# # Fig 2: Ux
# titles2 = ['No. of particles: %s' % filename[-8:-3] for filename in pivlab_output_names]