Exemplo n.º 1
0
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()
    graph.add_colorbar(cc, option='scientific')
    graph.title(ax, 'z=%.3f' % data['z'][0, 0, i])
Exemplo n.º 2
0
            veff_list_for_vring, vr_err_list2 = fa.sort_two_arrays_using_order_of_first_array(
                veff_list, vr_err_list)

            # Circulation vs veff
            fig1, ax1 = graph.errorbar(veff_list_for_gammar,
                                       gammar_list1,
                                       yerr=gammar_err_list,
                                       fignum=1,
                                       label=label,
                                       fmt=fmt)
            graph.labelaxes(
                ax1, '|$\overline{v^2_p} / \overline{v_p} \alpha $| [mm/s]',
                '$\Gamma [mm^2/s]$ ')
            ax1.legend()
            graph.setaxes(ax1, 0, 300, 0, 15000)
            graph.save(base_dir + 'gamma_vs_Veff')

            # Stroke length
            fig2, ax2 = graph.plot(veff_list_for_actual_span,
                                   actual_span_ratio_list1,
                                   fignum=2,
                                   marker=fmt,
                                   label=label)
            graph.labelaxes(ax2,
                            '|$\overline{v^2_p} / \overline{v_p}$| [mm/s]',
                            '$L/ L_c[mm^2/s]$ ')
            ax2.legend()
            graph.setaxes(ax2, 0, 300, 0, 1.5)
            graph.axhline(ax2, 1)
            graph.save(base_dir + 'strokelength')
Exemplo n.º 3
0
                    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',
                                        '_min')  # max velocity
            min = fs.get_float_from_str(pivdatum_loc, 'min',
                                        '.h5')  # min velocity

            max_str = 'max' + fs.convert_float_to_decimalstr(max)
            min_str = 'min' + fs.convert_float_to_decimalstr(min)
            max_str_2 = 'max' + fs.convert_float_to_decimalstr(
                max, zpad=4)  # for naming scheme
            min_str_2 = 'min' + fs.convert_float_to_decimalstr(
                min, zpad=4)  # for naming scheme
            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),
                     np.ravel(z))  # px after piv processing
        # values = np.ravel(ux)*scale*frame_rate #mm/s

        print 'make grid'

        # xx, yy, zz= np.mgrid[2:126:100j, 2:90:100j, -40:40:100j]
        xx, yy, zz = np.mgrid[xmin:xmax:200j, ymin:ymax:200j, zmin:zmax:200j]
Exemplo n.º 5
0
    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')

    plt.close('all')
fyle.close()

# # make movies
# movie.make_movie(resultdir + 'vel_field_t', resultdir + 'movie_vel_field', ext='png', framerate=10, option='glob')
# movie.make_movie(resultdir + 'pdf_vel_field_t', resultdir + 'movie_pdf_vel_field', ext='png', framerate=10, option='glob')
Exemplo n.º 6
0
            ax = fig8.add_axes([0, 0, 1, 1])
            left, width = .25, .5
            bottom, height = .25, .5
            right = left + width
            top = bottom + height
            ax.text(0.5 * (left + right),
                    0.5 * (bottom + top),
                    'No vortex ring was detected!',
                    horizontalalignment='center',
                    verticalalignment='center',
                    fontsize=20,
                    color='red',
                    transform=ax.transAxes)
            savedir = resultsdir + '/time_evolution/'
            filename = 'No_vortex_ring_detected'
            graph.save(savedir + filename, ext='png', close=True)
            continue

        # Plot circulation, ring velocity, and diameter
        #fig8, ax8 = graph.scatter(trForGammar, gammar, fignum=2, subplot=131,figsize=(20, 5))
        fig8, ax8 = graph.errorbar(trForGammar,
                                   gammar,
                                   yerr=gammar_err,
                                   fignum=2,
                                   subplot=131,
                                   figsize=(20, 5))
        graph.labelaxes(ax8, 'Time ($s$)', 'Circulation ($mm^2/s$)')
        if gammar_avg * 1.3 > np.max(gammar):
            graph.setaxes(ax8, 0, time[-1], 0, gammar_avg * 1.3)
        else:
            graph.setaxes(ax8, 0, time[-1], 0, np.max(gammar))
                ax.set_xlim(-vmax, vmax)
            else:
                ax.set_facecolor('k')
        title = r'$W = {0:d}$ px, FWHM={1:.1f} px, $D=$3px, $N={2:d}$, $Re_\lambda$=420, $t={3:05.3f}$, 1 frame={4:.3f}'.format(iw, fwhm, npt, t * dt_sim * param['tstep'] * dt_spacing, dt_sim * param['tstep'] * dt_spacing)
        graph.suptitle(title, fignum=1)
        graph.suptitle(title, fignum=2)
        fig1.tight_layout()
        fig2.tight_layout()

        imgfilename1 = 'comp_pivlab_and_jhtd_field_at_center_of_illum_plane/' \
                       'comp_pivlab_and_jhtd_field_at_center_of_illum_planeim_{0:04d}'.format(t)
        imgfilename2 = 'comp_pivlab_and_jhtd_field_avg_over_illum_volume_in_z_direction/' \
                       'comp_pivlab_and_jhtd_field_avg_over_illum_volume_in_z_directionim_{0:04d}'.format(t)

        # Save
        graph.save(os.path.join(resultdir, imgfilename1), fignum=1, ext='png')
        graph.save(os.path.join(resultdir, imgfilename2), fignum=2, ext='png')
        plt.close('all')

    piv_data.close()


graph.show()

jhtd_data.close()

print 'Done'


# with h5py.File(args.jhtddatapath) as jhtd_data:
#     # jhtd_data[vel_key] has a structure (z, y, x, ui)
Exemplo n.º 8
0
                               subplot=221,
                               figsize=(12, 8))
        fig3, ax2 = graph.plot(time,
                               y_pos,
                               fignum=3,
                               subplot=222,
                               figsize=(12, 8))
        fig3, ax3 = graph.plot(time, u, fignum=3, subplot=223, figsize=(12, 8))
        fig3, ax4 = graph.plot(time, v, fignum=3, subplot=224, figsize=(12, 8))
        plt.suptitle(title)
        graph.labelaxes(ax1, 'Time [s]', 'X [mm]', fontsize=8)
        graph.labelaxes(ax2, 'Time [s]', 'Y [mm]', fontsize=8)
        graph.labelaxes(ax3, 'Time [s]', 'u [mm/s]', fontsize=8)
        graph.labelaxes(ax4, 'Time [s]', 'v [mm/s]', fontsize=8)
        plotfilename = os.path.join(fn_noext, 'plots/position_time')
        graph.save(plotfilename, verbose=True)

        # Piston tracking: average over multiple cycles
        print 'file name:' + fn_noext
        if not args.end == 0:
            x_pos = x_pos[args.start:-args.end]
            y_pos = y_pos[args.start:-args.end]
            u = u[args.start:-args.end]
            v = v[args.start:-args.end]
            print 'Number of frames in cine: %d' % len(time)
            time = time[args.start:-args.end]
        else:
            x_pos = x_pos[args.start:]
            y_pos = y_pos[args.start:]
            u = u[args.start:]
            v = v[args.start:]
Exemplo n.º 9
0
                      fontsize=10)
        graph.addtext(ax1,
                      'Actual stroke length(software): %.2f mm' %
                      stroke_length_csv,
                      option='bl2',
                      fontsize=10,
                      alpha=0.5)
        graph.labelaxes(ax1, 'Time [s]', 'Position y [mm]')
        graph.labelaxes(ax2, 'Time [s]', 'Velocity [mm/s]')
        graph.suptitle(data_tracking_dir_tail)
        graph.setaxes(ax1, 0.15, 0.8, -0.5, 13)
        graph.setaxes(ax2, 0.15, 0.8, -550, 200)
        # 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))

        plot_filename = '/comparison/' + data_tracking_dir_tail
        graph.save(data_tracking_basedir + plot_filename, verbose=True)
        plt.close('all')
        graph.show()
Exemplo n.º 10
0
                                     xx,
                                     yy,
                                     n_bins,
                                     option=option)
    else:
        _, DLL = compute_struc_func(ux0,
                                    ux0_noise,
                                    xx,
                                    yy,
                                    n_bins,
                                    option=option)
    rr_scaled = rr / eta
    Dxx_scaled = DLL / ((epsilon * rr)**(2. / 3))
    fig, ax = graph.plot(rr_scaled, Dxx_scaled, label=labels[i], alpha=0.9)
    fig, ax = graph.scatter(rr_scaled, Dxx_scaled, alpha=0.9)

    data['rr_scaled_' + option] = rr_scaled
    data['Dxx_scaled_' + option] = Dxx_scaled
    data['rr_' + option] = rr
    data['Dxx_' + option] = DLL

graph.tosemilogx(ax)
ax.legend(loc=2)
graph.labelaxes(ax, '$r/\eta$', r'$D_{xx}/(\epsilon r)^{2/3}$')
#graph.setaxes(ax, 1, 5000, -0.2, 4)
graph.axhband(ax, 2 * 0.85, 2 * 1.15, 1, 5000)
graph.save(savedir + 'jhtd_struc_func_scaled_white_noise_budget_test')
# graph.show()

datafile = 'jhtd_struc_func_scaled_white_noise_budget_test_data'
rw.write_hdf5_dict(savedir + datafile, data)
Exemplo n.º 11
0
import h5py
import numpy as np
import matplotlib.pyplot as plt
import library.display.graph as graph

griddata_path = '/Volumes/bigraid/takumi/turbulence/3dprintedbox/multilayerPIV_Dp57mm_Do12p8mm/2018_11_04/PIV_W8_step2_data/sample/3dinterpolated_data_200x200x200_center_linear.h5'
resultdir = '/Volumes/bigraid/takumi/turbulence/3dprintedbox/multilayerPIV_Dp57mm_Do12p8mm/2018_11_04/PIV_W8_step2_data/sample/results_linear/'
with h5py.File(griddata_path, 'r') as data:
    uxdata = np.asarray(data['ux'])
    uydata = np.asarray(data['uy'])
    energy = (uxdata**2 + uydata**2) / 2. * 10**-6  # m^2/s^2
    xx, yy, zz = np.asarray(data['x']), np.asarray(data['y']), np.asarray(
        data['z'])
    for i in range(uxdata.shape[2]):
        fig, ax, cc = graph.color_plot(xx[..., 0],
                                       yy[..., 0],
                                       energy[..., i, 0],
                                       cmap='plasma',
                                       vmin=0,
                                       vmax=0.06)
        graph.add_colorbar(cc, ax=ax)
        fig.tight_layout()
        graph.save(resultdir + 'im%04d' % i, ext='png')
        # graph.save(resultdir + 'pdf/im%04d' % i, ext='pdf')
        plt.close('all')
        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)
        iw_list, deltat_list, gamma_list, chi_list, fit_err_test, r2_list = zip(
            *fit_data_W)
        if iw > 16:
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):
    print pivlab_output
    data = rw.read_hdf5(pivlab_output)
Exemplo n.º 14
0
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]
# axes2, ccs2 = [], []
# # fig = plt.figure(num=2, figsize=(18, 18))
Exemplo n.º 15
0
                        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
        #
        #         max_str = 'max' + fs.convert_float_to_decimalstr(max)
        #         min_str = 'min' + fs.convert_float_to_decimalstr(min)
        #         max_str_2 = 'max' + fs.convert_float_to_decimalstr(max, zpad=4) # for naming scheme
        #         min_str_2 = 'min' + fs.convert_float_to_decimalstr(min, zpad=4) # for naming scheme
        #
        #         # Plotting settings Part 2
        #         vmin, vmax = min, max * 1.2
        #
Exemplo n.º 16
0
for iw in range(fitdata_arr.shape[3]):
    fig9, ax9 = plt.subplots(nrows=1, ncols=1)
    for j in range(0, ux_points.shape[0], 10):
        ind = np.abs(fitdata_arr[j, :, 0, iw]) < 300
        ax9.plot(deltat_points[j, ind],
                 fitdata_arr[j, ind, 0, iw],
                 label='$U_{x}^{true} [%.f, %.f)$' %
                 (ux_points[j, 0] - 5, ux_points[j, 0] + 5),
                 color=cmap3(normalize(ux_points[j, 0])),
                 linewidth=6)
    ax9.set_xlim(0, 0.2)
    ax9.set_ylim(-100, 100)
    ax9.legend(loc=2)
    graph.labelaxes(ax9, '$ \Delta t$ (a.u.)', '$\chi$ (px/unit time)')

    graph.save(dir + '/results/err_dist_nouz/_w%dpx' % iw, ext='png')
    plt.close()
import sys
sys.exit()
#
# setting up fitparams for manipulation

# plotting preparation
grid_deltat, grid_ux = np.mgrid[0.0:0.2:200j, -300:300:1001j]
ind = ~np.isnan(np.ravel(fitdata_arr[..., 0, 0]))
points = np.array(zip(np.ravel(deltat_points)[ind], np.ravel(ux_points)[ind]))

fitparams = np.zeros(
    (fitdata_arr.shape[0], fitdata_arr.shape[1], fitdata_arr.shape[2]))
wind = 0  # index for interrogation window size
print fitdata_arr.shape
Exemplo n.º 17
0
                       nbins=200,
                       fignum=3,
                       subplot=121,
                       figsize=(16, 8))
fig3, ax32 = graph.pdf(vgrid,
                       nbins=200,
                       fignum=3,
                       subplot=122,
                       figsize=(16, 8))
graph.labelaxes(ax31, r'$U_x$ (px/frame)', 'Probability density')
graph.labelaxes(ax32, r'$U_y$ (px/frame)', 'Probability density')
fig3.tight_layout()

filename = 'lamb_oseen_vortex_ux_uy'
filepath = os.path.join(savedir + filename)
graph.save(filepath, fignum=1)

filename = 'lamb_oseen_vortex_omegaz'
filepath = os.path.join(savedir + filename)
graph.save(filepath, fignum=2)

filename = 'lamb_oseen_vortex_ux_uy_pdf'
filepath = os.path.join(savedir + filename)
graph.save(filepath, fignum=3)

# Output velocity/vorticity field in hdf5
data = {}
data['x'] = xgrid  # px
data['y'] = ygrid  # px
data['ux'] = ugrid  # px/frame
data['uy'] = vgrid  # px/frame
Exemplo n.º 18
0
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
nn = 20
for i in range(ndata):
    ax.scatter(coord_data[0][::nn, ::nn, i * 17:(i + 1) * 17],
               coord_data[1][::nn, ::nn, i * 17:(i + 1) * 17],
               coord_data[2][::nn, ::nn, i * 17:(i + 1) * 17],
               alpha=0.3)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
ax.view_init(azim=270, elev=00)
fig.tight_layout()
# graph.save(args.dir + '/laser_pos2', ext='png')

plt.show()
#

resultdir = '/Volumes/bigraid/takumi/turbulence/3dprintedbox/multilayerPIV_Dp57mm_Do12p8mm/2018_11_04/PIV_W8_step2_data/sample/raw_results/'
zzz = np.arange(51)

for i in range(len(zzz)):
    xx, yy = coord_data[0][:, :, i], coord_data[1][:, :, i]
    ux = vel_data[0][:, :, i, 0]
    plt.figure()
    plt.pcolormesh(xx, yy, ux, cmap='RdBu', vmin=-0.8, vmax=0.8)
    plt.colorbar()
    graph.save(resultdir + 'z%d' % i, ext='png')
    plt.close()

# print 750*scale
Exemplo n.º 19
0
        # 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))

        outputdir = '/Volumes/labshared3-1/takumi/Similar_flows/pistontuning/encoder_outputs'
        plot_filename = '/comparison/' + data_tracking_dir_tail
        graph.save(outputdir + plot_filename, verbose=True)
        plt.close('all')
        #graph.show()



        # Read encover outputs
        #20180405_4000fps_span10p0mm_v400mms_f1Hz_setting2
        encoder_output_path = '/Volumes/labshared3-1/takumi/Similar_flows/' \
                              'pistontuning/encoder_outputs/2018_05_10/test_span5p0mm_v400p0mms_freq1Hz__position_data.txt'
        span = fs.get_float_from_str(encoder_output_path, 'span', 'mm')
        vp_commanded = fs.get_float_from_str(encoder_output_path, '_v', 'mms')
        freq = fs.get_float_from_str(encoder_output_path, 'freq', 'Hz')

        data = np.loadtxt(encoder_output_path)
        time_enc, pos_enc =  data[0], data[1]
Exemplo n.º 20
0
basedir = "/Volumes/labshared3-1/takumi/2018_05_13_mid/freq1Hz/PIV_AnalysisResults/PIV_sv_vp_left_macro55mm_fps2000_D25p6mm_piston13p1mm_freq1Hz_v100mms_fx0p1259mmpx_setting1/time_evolution/"

marker = ['v', '^', 's', 'o']  # makers corresponding to domains
fillstyle = ['full', 'none']  # Positive core: fill, Negative core: no fill
colors = graph.get_first_n_colors_from_color_cycle(4)

for domain_num in range(1, 5):
    filename = "time_evolution_data_domain{0}_before_collision.json".format(
        domain_num)
    filepath = basedir + filename
    data = rw.read_json(filepath)

    cx_max, cy_max = data["cxmaxlist"], data["cymaxlist"]
    cx_min, cy_min = data["cxminlist"], data["cyminlist"]
    core_positions = [[cx_max, cy_max], [cx_min, cy_min]]
    fig, ax = graph.set_fig(fignum=3, subplot=111, figsize=(16, 10))
    for j, core_position in enumerate(core_positions):
        cx, cy = core_position[0], core_position[1]
        ax.plot(cx,
                cy,
                color=colors[domain_num - 1],
                marker=marker[domain_num - 1],
                alpha=0.7,
                fillstyle=fillstyle[j])
        graph.setaxes(ax, 0, 127, 0, 90)
        graph.labelaxes(ax, 'x [mm]', 'y [mm]')
        ax.invert_yaxis()
filename = 'trajectories_1'
graph.save(basedir + filename)
graph.show()