def make_movie(M, Range=None, field=['E', 'vorticity'], Dirbase=None, Dt=1): if Dirbase == None: Dirbase = '/Users/stephane/Documents/Experiences_local/Accelerated_grid/PIV_data' # local saving nx, ny, nt = M.shape() axes = panel(M) if Range is not None: start, stop, step = tuple(Range) else: start, stop, step = tuple([0, nt, 1]) frames = range(start, stop, step) # field = ['Ux','Uy'] # field = ['E','vorticity'] figs = {} Dirname = Dirbase + '/' + M.Id.get_id() + '/' + graphes.remove_special_chars(str(field)) + '/' print(Dirname) for i, f in enumerate(field): if not hasattr(M, f): M, field_n[i] = vgradient.compute(M, field[i], Dt=Dt) field = field_n # M,field[1] = vgradient.compute(M,field[1],Dt=Dt) if Dt > 1: print('Smoothed data') Dirname = Dirname + 'Smooth_Dt_' + str(int(Dt)) + '/' for i in frames: graphes.set_fig(1) for axe in axes: plt.sca(axe) plt.cla() axes = panel(M, fignum=1) plt.sca(axes[1]) print(i) graphes.Mplot(M, field[0], i, fignum=1, log=True) plt.text(-10, 80, field[0], fontsize=20) plt.sca(axes[2]) graphes.Mplot(M, field[1], i, fignum=1, log=True) plt.text(-10, 80, field[1], fontsize=20) figs.update(graphes.legende('', '', 'Front view', cplot=True)) graphes.save_figs(figs, savedir=Dirname, suffix='_' + str(i), dpi=100, frmt='png', display=False) return axes
def make_2dmovie(M, name, Range=None, fignum=1, local=True, log=False, vmin=0, vmax=1, filt=False): """ Movie of the colormap of the velocity modulus U over time INPUT ----- M : Mdata class instance, or any other object that contains the following fields : methods : shape() attributes : Ux, Uy Sdata object Ids object ... name : name of the field to be plotted. example : Ux,Uy, vorticity, strain Range : np array fignum : int. default value is 1 Dirname : string Directory to save the figures log : bool. default value is True OUTPUT ----- None """ if Range is not None: start, stop, step = tuple(Range) else: start, stop, step = tuple([0, M.shape()[-1], 5]) # U=np.sqrt(S.Ux**2+S.Uy**2) # by default, pictures are save here : if local: Dirlocal = '/Users/stephane/Documents/Experiences_local/Accelerated_grid' else: Dirlocal = os.path.dirname(M.Sdata.fileCine) Dirname = name if filt: Dirname = Dirname + '_filtered' Dir = Dirlocal + '/PIV_data/' + M.Id.get_id() + '/' + Dirname + '/' print(Dir) fig = graphes.set_fig(fignum) graphes.set_fig(0) # clear current figure print('Compute ' + name) M, field = vgradient.compute(M, name, filter=filt) for i in range(start, stop, step): # Z = energy(M,i) graphes.Mplot(M, field, i, fignum=fignum, vmin=vmin, vmax=vmax, log=log, auto_axis=True) # graphes.color_plot(Xp,Yp,-Z,fignum=fignum,vmax=700,vmin=0) if i == start: cbar = graphes.colorbar() # fignum=fignum,label=name+'(mm^2 s^{-2})') else: print('update') # cbar.update_normal(fig) filename = Dir + 'V' + str(i) graphes.save_fig(fignum, filename, frmt='png')
def example(M, i=None): figs = {} if i == None: nx, ny, nt = M.shape() i = nt // 4 fields, names, vmin, vmax, labels, units = std_fields() for j, field in enumerate(fields): figs.update(graphes.Mplot(M, field, i, fignum=j + 1, colorbar=True, vmin=vmin[j], vmax=vmax[j])) ### add label on colorbar return figs
def example(M, Range=None, field=['E', 'vorticity']): nx, ny, nt = M.shape() axes = panel(M) if Range is not None: start, stop, step = tuple(Range) else: start, stop, step = tuple([0, nt, 1]) frames = range(start, stop, step) # field = ['Ux','Uy'] # field = ['E','vorticity'] figs = {} Dirbase = '/Users/stephane/Documents/Experiences_local/Accelerated_grid/PIV_data' # local saving Dirname = Dirbase + '/' + M.Id.get_id() + '/' + graphes.remove_special_chars(str(field)) + '/' print(Dirname) M, field[0] = vgradient.compute(M, field[0]) M, field[1] = vgradient.compute(M, field[1]) for i in frames: graphes.set_fig(1) for axe in axes: plt.sca(axe) plt.cla() axes = panel(M, fignum=1) plt.sca(axes[1]) graphes.Mplot(M, field[0], i, log=True) plt.text(-10, 20, field[0], fontsize=20) plt.sca(axes[2]) graphes.Mplot(M, field[1], i, fignum=1, log=True) plt.text(-10, 20, field[1], fontsize=20) figs.update(graphes.legende('', '', 'Front view', cplot=True)) graphes.save_figs(figs, savedir=Dirname, suffix='_' + str(i), dpi=100, frmt='png') return axes
def make_plot(M, Range=None, color='k', field=['E', 'vorticity'], Dirbase=None, Dt=1, example=False, total=True, fignum=1, save=True): if Dirbase == None: Dirbase = '/Users/stephane/Documents/Experiences_local/Accelerated_grid/PIV_data/Test6/' # local saving Dirbase = './Stat_avg/Panel/' + M.Id.date axes = flex_panel(M, fignum=fignum) # for axe in axes: # plt.sca(axe) # plt.cla() frames = select_range(M, Range) # field = ['Ux','Uy'] # field = ['E','vorticity'] figs = {} if hasattr(M, 'id'): Dirname = Dirbase + '/' + M.Id.get_id() + '/' + graphes.remove_special_chars(str(field)) + '/' else: Dirname = Dirbase + '/JHTD_Data/' + graphes.remove_special_chars(str(field)) + '/' print(Dirname) if Dt > 1: print('Smoothed data') Dirname = Dirname + 'Smooth_Dt_' + str(int(Dt)) + '/' # Dt = 50 t_moy, E_moy = access.avg_vs_t(M, 'E', frames, Dt=Dt) t_moy, Omega_moy = access.avg_vs_t(M, 'omega', frames, Dt=Dt) t_moy, Strain_moy = access.avg_vs_t(M, 'strain', frames, Dt=Dt) t_moy, Y_pdf_moy = access.avg_vs_t(M, field[1], frames, Dt=Dt) epsilon = scale.dissipation_rate(Omega_moy) # dissipation rate eta = scale.K_scale(epsilon) # dissipative scale micro_1 = np.sqrt(1. / 4 * E_moy / Strain_moy ** 2) micro_2 = np.sqrt(E_moy / (Omega_moy) ** 2) Re = scale.Re(micro_1, eta) Re_lambda_1 = scale.Re_lambda(E_moy, micro_1) Re_lambda_2 = scale.Re_lambda(E_moy, micro_2) L = scale.I_scale(Re, E_moy) # plt.sca(axes[2]) # graphes.graphloglog(t_moy,E_moy,fignum=1,label=color+'o-') # Fourier.add_theory(t_moy,E_moy,[-2.],fignum=1) # graphes.graphloglog(t_moy,Y_pdf_moy,fignum=1,label=color+'s-') # graphes.graphloglog(t_moy,epsilon,fignum=1,label='gv-') # Fourier.add_theory(t_moy,epsilon,[-3.],fignum=1) # figs.update(graphes.legende('t (s)','E (mm^2/s^2), epsilon(mm^2/s^-3)','')) plt.sca(axes[1]) graphes.graphloglog(t_moy, eta, fignum=fignum, label=color + 'o-') graphes.graphloglog(t_moy, micro_1, fignum=fignum, label=color + 's-') graphes.graphloglog(t_moy, micro_2, fignum=fignum, label='cp-') graphes.graphloglog(t_moy, L, fignum=fignum, label='gv-') figs.update(graphes.legende('t (s)', 'eta (mm), lambda (mm)', '')) plt.sca(axes[2]) graphes.graphloglog(t_moy, Re, fignum=fignum, label=color + 'o-') graphes.graphloglog(t_moy, Re_lambda_1, fignum=fignum, label=color + 's-') graphes.graphloglog(t_moy, Re_lambda_2, fignum=fignum, label='cp-') figs.update(graphes.legende('t (s)', 'Re , Re_lambda', '')) # print(t_moy) # print(Y_moy) # print(t) # print(Y_moy) indices = [0, 1] # indices = [1,4] cla_axes = [axes[i] for i in indices] if save: graphes.save_figs(figs, savedir=Dirname, prefix='General', suffix='_vs_t', dpi=300, frmt='png', display=True) individual = False if example: frames_disp = [1200] else: step = frames[1] - frames[0] frames_disp = range(frames[0] + step * 10, frames[-1], step * 10) if individual: for frame in frames_disp: # print(frame) # print(frames) i = frames.index(frame) graphes.set_fig(1) for axe in cla_axes: plt.sca(axe) plt.cla() axes = flex_panel(M, fignum=1) if total: plt.sca(axes[0]) graphes.Mplot(M, field[0], frame, fignum=1, log=True) plt.text(-10, 80, field[0], fontsize=20) plt.sca(axes[1]) # graphes.graphloglog(t_moy,eta,fignum=1,label='ko-') # graphes.graphloglog(t_moy,micro,fignum=1,label='ks-') graphes.graph([t_moy[i]], [eta[i]], fignum=1, label='ro') graphes.graph([t_moy[i]], [micro_1[i]], fignum=1, label='rs') graphes.graph([t_moy[i]], [micro_2[i]], fignum=1, label='rp') graphes.graphloglog([t_moy[i]], [L[i]], fignum=1, label='rv-') plt.sca(axes[2]) graphes.graphloglog([t_moy[i]], [Re[i]], fignum=1, label='ro-') graphes.graphloglog([t_moy[i]], [Re_lambda_1[i]], fignum=1, label='rs-') graphes.graphloglog([t_moy[i]], [Re_lambda_2[i]], fignum=1, label='rp-') plt.sca(axes[3]) figs.update(graphes.pdf(M, 'Ux', frame, Dt=Dt, fignum=1, label='m^')) figs.update(graphes.pdf(M, 'Uy', frame, Dt=Dt, fignum=1, label='b>')) figs.update(graphes.legende('t (s)', 'Re , Re_lambda', '')) plt.sca(axes[4]) figs.update(graphes.pdf(M, field[1], frame, Dt=Dt, fignum=1, label=color + '-')) # graphes.Mplot(M,field[1],i,fignum=1,log=True) # plt.text(-10,80,'PDF '+field[1],fontsize=20) # figs.update(graphes.legende('','','Front view',cplot=True)) graphes.save_figs(figs, savedir=Dirname, suffix='_' + str(frame), dpi=100, frmt='png', display=False) return axes
print M.shape() print M.Uy[10, :, 0] print M.Id.date print M.Id.index for M in Mlist: print(M.Sdata.fileCine[-20:-5]) print(M.Sdata.fileDir) print(M.Sdata.filename) # name of the file(SData) that stores measures (M) print(M.Sdata.param) print M.shape() # Plot the time averaged energy frame = 10 # args are (M, variable, frame, vmin, vman) graphes.Mplot(M, 'E', frame, vmin=0, vmax=100000) graphes.colorbar() # Plot the vorticity at a particular time graphes.Mplot(M, 'omega', frame, vmin=-300, vmax=300) graphes.colorbar() # Plot the enstrophy at a particular time (frame#) graphes.Mplot(M, 'enstrophy', frame, vmin=0, vmax=90000) graphes.colorbar() ######################################################## figs = {} fields, names, vmin, vmax, labels, units = comp.std_fields() # print(M.param.v) indices = range(50, M.Ux.shape[2])