def make_plot(rundir, file_no): my_path = os.getcwd() working_dir = my_path + '/' + rundir efield_dir = working_dir + '/MS/FLD/e1/' laser_dir = working_dir + '/MS/FLD/e2/' eden_dir = working_dir + '/MS/DENSITY/electrons/charge/' phase_space_dir = working_dir + '/MS/PHA/p1x1/electrons/' p2x1_dir = working_dir + '/MS/PHA/p2x1/electrons/' efield_prefix = 'e1-' laser_prefix = 'e2-' phase_prefix = 'p1x1-electrons-' p2x1_prefix = 'p2x1-electrons-' eden_prefix = 'charge-electrons-' filename1 = phase_space_dir + phase_prefix + repr(file_no).zfill( 6) + '.h5' fig = plt.figure(figsize=(12, 5)) phase_space = np.abs(osh5io.read_h5(filename1)) time = phase_space.run_attrs['TIME'][0] fig.suptitle('Time = ' + repr(time) + '$\omega_p^{-1}$', fontsize=18) filename2 = eden_dir + eden_prefix + repr(file_no).zfill(6) + '.h5' filename3 = efield_dir + efield_prefix + repr(file_no).zfill(6) + '.h5' eden = osh5io.read_h5(filename2) ex = osh5io.read_h5(filename3) psi = osh5io.read_h5(filename3) den_plot = plt.subplot(121) osh5vis.osplot(eden, title='Electron Density') ex_plot = plt.subplot(122) for i in range(psi.shape[0] - 2, -1, -1): psi[i] = psi[i + 1] + psi.axes[0].increment * psi[i] osh5vis.osplot(psi, title='Wake $\psi$ ', ylabel='$\psi [m_e c^2/e]$') second_x = plt.twinx() second_x.plot(ex.axes[0], ex, 'g', linestyle='-.') second_x.set_ylabel('$E_{z}$', color='g') second_x.tick_params(axis='y', labelcolor='g')
def make_plot(rundir, file_no): my_path = os.getcwd() #print(my_path) working_dir = my_path + '/' + rundir #print(working_dir) efield_dir = working_dir + '/MS/FLD/e1/' laser_dir = working_dir + '/MS/FLD/e2/' eden_dir = working_dir + '/MS/DENSITY/electrons/charge/' phase_space_dir = working_dir + '/MS/PHA/p1x1/electrons/' p2x1_dir = working_dir + '/MS/PHA/p2x1/electrons/' efield_prefix = 'e1-' laser_prefix = 'e2-' phase_prefix = 'p1x1-electrons-' p2x1_prefix = 'p2x1-electrons-' eden_prefix = 'charge-electrons-' filename1 = phase_space_dir + phase_prefix + repr(file_no).zfill( 6) + '.h5' fig = plt.figure(figsize=(12, 5)) phase_space = np.abs(osh5io.read_h5(filename1)) time = phase_space.run_attrs['TIME'][0] fig.suptitle('Time = ' + repr(time) + '$\omega_p^{-1}$', fontsize=18) filename4 = laser_dir + laser_prefix + repr(file_no).zfill(6) + '.h5' ey = osh5io.read_h5(filename4) ey_plot = plt.subplot(121) osh5vis.osplot(ey, title='Laser Electric Field') ey_plot_k = plt.subplot(122) osh5vis.osplot(np.abs(osh5utils.fft(ey)), xlim=[0, 20], linestyle='-', title='k spectrum')
def make_plot(rundir, file_no): my_path = os.getcwd() working_dir = my_path + '/' + rundir efield_dir = working_dir + '/MS/FLD/e1/' laser_dir = working_dir + '/MS/FLD/e2/' eden_dir = working_dir + '/MS/DENSITY/electrons/charge/' phase_space_dir = working_dir + '/MS/PHA/p1x1/electrons/' p2x1_dir = working_dir + '/MS/PHA/p2x1/electrons/' efield_prefix = 'e1-' laser_prefix = 'e2-' phase_prefix = 'p1x1-electrons-' p2x1_prefix = 'p2x1-electrons-' eden_prefix = 'charge-electrons-' filename1 = phase_space_dir + phase_prefix + repr(file_no).zfill( 6) + '.h5' fig = plt.figure(figsize=(12, 5)) phase_space = np.abs(osh5io.read_h5(filename1)) time = phase_space.run_attrs['TIME'][0] fig.suptitle('Time = ' + repr(time) + '$\omega_p^{-1}$', fontsize=18) filename2 = eden_dir + eden_prefix + repr(file_no).zfill(6) + '.h5' filename3 = efield_dir + efield_prefix + repr(file_no).zfill(6) + '.h5' eden = osh5io.read_h5(filename2) ex = osh5io.read_h5(filename3) den_plot = plt.subplot(121) osh5vis.osplot(eden, title='Electron Density') for i in range(ex.shape[0] - 2, -1, -1): ex[i] = ex[i + 1] + ex.axes[0].increment * ex[i] ex_plot = plt.subplot(122) osh5vis.osplot(ex, title='Wake $\psi$ ', ylabel='$\psi [m_e c^2/e]$')
def something(rundir, file_no): my_path = os.getcwd() #print(my_path) working_dir = my_path + '/' + rundir #print(working_dir) efield_dir = working_dir + '/MS/FLD/e1/' laser_dir = working_dir + '/MS/FLD/e2/' eden_dir = working_dir + '/MS/DENSITY/electrons/charge/' iden_dir = working_dir + '/MS/DENSITY/ions/charge/' phase_space_dir = working_dir + '/MS/PHA/p1x1/ions/' p1x1_dir = working_dir + '/MS/PHA/p1x1/electrons/' efield_prefix = 'e1-' laser_prefix = 'e2-' phase_prefix = 'p1x1-ions-' p1x1_prefix = 'p1x1-electrons-' eden_prefix = 'charge-electrons-' iden_prefix = 'charge-ions-' fig = plt.figure(figsize=(12, 16)) # filename1=phase_space_dir+phase_prefix+repr(file_no).zfill(6)+'.h5' filename2 = eden_dir + eden_prefix + repr(file_no).zfill(6) + '.h5' filename3 = efield_dir + efield_prefix + repr(file_no).zfill(6) + '.h5' filename4 = laser_dir + laser_prefix + repr(file_no).zfill(6) + '.h5' filename5 = p1x1_dir + p1x1_prefix + repr(file_no).zfill(6) + '.h5' # filename6=iden_dir+iden_prefix+repr(file_no).zfill(6)+'.h5' #print(filename1) #print(filename2) phase_space = np.abs(osh5io.read_h5(filename5)) # print(repr(phase_space)) eden = osh5io.read_h5(filename2) ex = osh5io.read_h5(filename3) ey = osh5io.read_h5(filename4) # p1x1=np.abs(osh5io.read_h5(filename5)) # iden = osh5io.read_h5(filename6) phase_plot = plt.subplot(224) #print(repr(phase_space.axes[0].min)) #print(repr(phase_space.axes[1].min)) title = phase_space.data_attrs['LONG_NAME'] time = phase_space.run_attrs['TIME'][0] fig.suptitle('Time = ' + repr(time) + '$\omega_p^{-1}$', fontsize=24) ext_stuff = [ phase_space.axes[1].min, phase_space.axes[1].max, phase_space.axes[0].min, phase_space.axes[0].max ] data_max = max(np.abs(np.amax(phase_space)), 100) #print(repr(data_max)) phase_contour = plt.contourf( np.abs(phase_space + 0.000000001), levels=[ 0.000001 * data_max, 0.00001 * data_max, 0.0001 * data_max, 0.001 * data_max, 0.005 * data_max, 0.01 * data_max, 0.02 * data_max, 0.05 * data_max ], extent=ext_stuff, cmap='Spectral', vmin=1e-6 * data_max, vmax=1.5 * data_max, norm=colors.LogNorm(vmin=0.000001 * data_max, vmax=1.5 * data_max)) phase_plot.set_title('Ion P1X1 Phase Space') phase_plot.set_xlabel('Position [$c / \omega_{p}$]') phase_plot.set_ylabel('Proper Velocity $\gamma v_1$ [ c ]') # second_x = plt.twinx() # second_x.plot(ex.axes[0],ex,'g',linestyle='-.') #plt.colorbar() #osh5vis.oscontour(phase_space,levels=[10**-5,10**-3,10**-1,1,10,100],colors='black',linestyles='dashed',vmin=1e-5,vmax=1000) # plt.contour(np.abs(phase_space+0.000001),levels=[0.0001,0.001,0.01,0.05,0.1,0.2,0.5,1],extent=ext_stuff,colors='black',linestyles='dashed') plt.colorbar(phase_contour) den_plot = plt.subplot(223) osh5vis.osplot(np.log(np.sum(np.abs(phase_space), axis=1) + 0.001), title='f(v)') ex_plot = plt.subplot(222) osh5vis.osplot(ex, title='Wake E-field ', ylabel='$E_1 [m_e c^2/e]$') ey_plot = plt.subplot(221) osh5vis.osplot(ey, title='Laser Electric Field')
def something_2(rundir, file_no): my_path = os.getcwd() #print(my_path) working_dir = my_path + '/' + rundir #print(working_dir) dir_0 = rundir + '/Vx_x/' dir_1 = rundir + '/Ex/' output_dir = rundir + '/movies/' try: os.mkdir(output_dir) except OSError as exc: if exc.errno != errno.EEXIST: raise pass quan_0_prefix = 'vx_x_' quan_1_prefix = 'Ex-0_' output_prefix = 'frame_' fig = plt.figure(figsize=(10, 8)) phase_space_filename = dir_0 + quan_0_prefix + repr(file_no).zfill( 6) + '.h5' e1_filename = dir_1 + quan_1_prefix + repr(file_no).zfill(6) + '.h5' output_filename = output_dir + '/' + output_prefix + repr(file_no).zfill( 6) + '.png' phase_space_data = osh5io.read_h5(phase_space_filename) e1_data = np.average(osh5io.read_h5(e1_filename), axis=0) p1_x1_plot = plt.subplot(221) osh5vis.osplot(np.log(np.abs(phase_space_data) + 1e-10), title='Phase Space', vmax=10, vmin=-2, cmap='Blues') e1_plot = plt.subplot(222) osh5vis.osplot(e1_data, title='Electric Field') e1_plot.set_ylim([-0.1, 0.1]) plt.tight_layout() fv_plot = plt.subplot(223) # print(hdf5_data) xmin = phase_space_data.axes[0].min xmax = phase_space_data.axes[0].max ymin = phase_space_data.axes[1].min ymax = phase_space_data.axes[1].max # dx=(xmax-xmin)/float(nx[0]-1) # dy=(ymax-ymin)/float(nx[1]-1) # print(dx) # print(dy) # xmax=xmax-dx # ymax=ymax-dy # xmin=xmin+10.0*dx # ymin=ymin-10.0*dy # print(repr(xmin)+' '+repr(xmax)+' '+repr(ymin)+' '+repr(ymax)) nx = phase_space_data.shape xaxis = np.linspace(xmin, xmax, num=nx[0]) yaxis = np.linspace(ymin, ymax, num=nx[1]) plt.plot(xaxis, np.average(phase_space_data, axis=1)) plt.xlabel('$v/v_{th}$') plt.ylabel('f(v) [a.u]') fv_plot.set_ylim([0, 1500]) fv_slices = plt.subplot(224) # print(hdf5_data) xmin = phase_space_data.axes[0].min xmax = phase_space_data.axes[0].max ymin = phase_space_data.axes[1].min ymax = phase_space_data.axes[1].max # dx=(xmax-xmin)/float(nx[0]-1) # dy=(ymax-ymin)/float(nx[1]-1) # print(dx) # print(dy) # xmax=xmax-dx # ymax=ymax-dy # xmin=xmin+10.0*dx # ymin=ymin-10.0*dy # print(repr(xmin)+' '+repr(xmax)+' '+repr(ymin)+' '+repr(ymax)) nx = phase_space_data.shape xaxis = np.linspace(xmin, xmax, num=nx[0]) yaxis = np.linspace(ymin, ymax, num=nx[1]) plt.plot(xaxis, np.average(phase_space_data[:, 492:532], axis=1)) plt.plot(xaxis, np.average(phase_space_data[:, 352:372], axis=1), 'r') plt.plot(xaxis, np.average(phase_space_data[:, 652:672], axis=1), 'g') plt.xlabel('$v/v_{th}$') plt.ylabel('f(v) [a.u]') fv_slices.set_ylim([0, 1500]) plt.savefig(output_filename)
def something_2(rundir,file_no): v_phase = 1/.3 v_group = 3/v_phase my_path=os.getcwd() #print(my_path) working_dir=my_path+'/'+rundir #print(working_dir) dir_0=rundir+'/Vx_x/' dir_1=rundir+'/Ex/' quan_0_prefix='vx_x_' quan_1_prefix='Ex-0_' fig = plt.figure(figsize=(10,8) ) phase_space_filename=dir_0+quan_0_prefix+repr(file_no).zfill(6)+'.h5' e1_filename=dir_1+quan_1_prefix+repr(file_no).zfill(6)+'.h5' phase_space_data = osh5io.read_h5(phase_space_filename) e1_data = np.average(osh5io.read_h5(e1_filename),axis=0) fig.suptitle('Landau Boundary Problem, time = '+repr(phase_space_data.run_attrs['TIME'][0])+' $\omega_p^{-1}$ \n \n') p1_x1_plot = plt.subplot(221) osh5vis.osplot(np.log(np.abs(phase_space_data)+1e-10),title='Phase Space',vmax=10,vmin=-2,cmap='Blues') # ===================================================================== # ===================================================================== # the following lines draw vertical axis indicating the group velocity # p1_x1_plot.axvline(x=512-v_group*phase_space_data.run_attrs['TIME'][0]) # p1_x1_plot.axvline(x=512+v_group*phase_space_data.run_attrs['TIME'][0]) # ===================================================================== # ===================================================================== e1_plot = plt.subplot(222) osh5vis.osplot(e1_data,title='Electric Field') # plt.tight_layout() fig.subplots_adjust(top=0.82) fv_plot = plt.subplot(223) # print(hdf5_data) xmin=phase_space_data.axes[0].min xmax=phase_space_data.axes[0].max ymin=phase_space_data.axes[1].min ymax=phase_space_data.axes[1].max # dx=(xmax-xmin)/float(nx[0]-1) # dy=(ymax-ymin)/float(nx[1]-1) # print(dx) # print(dy) # xmax=xmax-dx # ymax=ymax-dy # xmin=xmin+10.0*dx # ymin=ymin-10.0*dy # print(repr(xmin)+' '+repr(xmax)+' '+repr(ymin)+' '+repr(ymax)) nx=phase_space_data.shape xaxis=np.linspace(xmin,xmax,num=nx[0]) yaxis=np.linspace(ymin,ymax,num=nx[1]) plt.plot(xaxis,np.average(phase_space_data,axis=1)) plt.xlabel('$v/v_{th}$') plt.ylabel('f(v) [a.u]') fv_plot.set_ylim([0, 1500]) fig.subplots_adjust(top=0.82) fv_slices = plt.subplot(224) # print(hdf5_data) xmin=phase_space_data.axes[0].min xmax=phase_space_data.axes[0].max ymin=phase_space_data.axes[1].min ymax=phase_space_data.axes[1].max # dx=(xmax-xmin)/float(nx[0]-1) # dy=(ymax-ymin)/float(nx[1]-1) # print(dx) # print(dy) # xmax=xmax-dx # ymax=ymax-dy # xmin=xmin+10.0*dx # ymin=ymin-10.0*dy # print(repr(xmin)+' '+repr(xmax)+' '+repr(ymin)+' '+repr(ymax)) nx=phase_space_data.shape xaxis=np.linspace(xmin,xmax,num=nx[0]) yaxis=np.linspace(ymin,ymax,num=nx[1]) plt.plot(xaxis,np.average(phase_space_data[:,492:532],axis=1)) plt.plot(xaxis,np.average(phase_space_data[:,352:372],axis=1),'r') plt.plot(xaxis,np.average(phase_space_data[:,652:672],axis=1),'g') plt.xlabel('$v/v_{th}$') plt.ylabel('f(v) [a.u]') fv_slices.set_ylim([0, 1500]) plt.tight_layout() plt.show()
def srs_quick_look(path,fileno): path_e1=path_main+'/MS/FLD/e1/' file_prefix_e1='e1-' path_e2=path_main+'/MS/FLD/e2/' file_prefix_e2='e2-' path_e3=path_main+'/MS/FLD/e3/' file_prefix_e3='e3-' path_b1=path_main+'/MS/FLD/b1/' file_prefix_b1='b1-' path_b2=path_main+'/MS/FLD/b2/' file_prefix_b2='b2-' path_b3=path_main+'/MS/FLD/b3/' file_prefix_b3='b3-' path_p1x1_e = path_main+'/MS/PHA/p1x1/species_1/' file_prefix_p1x1_e = 'p1x1-species_1-' # fileno = 22500 interval = 30 nfiles=10 path_p1p2_e = path_main+'/MS/PHA/p1p2/species_1/' file_prefix_p1p2_e = 'p1p2-species_1-' from scipy import signal filename_e1=path_e1+file_prefix_e1+repr(fileno).zfill(6)+'.h5' filename_e2=path_e2+file_prefix_e2+repr(fileno).zfill(6)+'.h5' filename_e3=path_e3+file_prefix_e3+repr(fileno).zfill(6)+'.h5' filename_b1=path_b1+file_prefix_b1+repr(fileno).zfill(6)+'.h5' filename_b2=path_b2+file_prefix_b2+repr(fileno).zfill(6)+'.h5' filename_b3=path_b3+file_prefix_b3+repr(fileno).zfill(6)+'.h5' filename_p1x1_e = path_p1x1_e+file_prefix_p1x1_e+repr(fileno).zfill(6)+'.h5' filename_p1p2_e = path_p1p2_e+file_prefix_p1p2_e+repr(fileno).zfill(6)+'.h5' # print(filename) e1 = osh5io.read_h5(filename_e1) e2 = osh5io.read_h5(filename_e2) e3 = osh5io.read_h5(filename_e3) b1 = osh5io.read_h5(filename_b1) b2 = osh5io.read_h5(filename_b2) b3 = osh5io.read_h5(filename_b3) # print(e1.axes[0].attrs) # Method 1: Just read files # p1x1_e = osh5io.read_h5(filename_p1x1_e) # p1p2_e = osh5io.read_h5(filename_p1p2_e) # Method 2: Average over N steps interval=30 nfiles = 20 p1x1_e = phase_space_average_new(path_p1x1_e,file_prefix_p1x1_e,fileno,interval,nfiles) p1p2_e = phase_space_average_new(path_p1p2_e,file_prefix_p1p2_e,fileno,interval,nfiles) SMALL_SIZE = 12 MEDIUM_SIZE = 14 BIGGER_SIZE = 18 plt.rc('font', size=SMALL_SIZE) # controls default text sizes plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title s1 = e2*b3 - e3 * b2 s1.data_attrs['NAME']='S1' s1.data_attrs['LONG_NAME']='S_1' n_smooth=200 smoothing=np.ones((1,n_smooth))/n_smooth n_avg = 200 smooth_array=np.ones((1,n_avg))/n_avg temp=signal.convolve2d(s1,smooth_array,mode='same',boundary='wrap') s1[:,:]=temp[:,:] s1 = np.average(s1,axis=0) plt.figure(figsize=(10,7.0)) plt.subplot(222) temp=signal.convolve2d(e1,smoothing,mode='same',boundary='wrap') osh5vis.osplot(np.average(e1,axis=0)) plt.ylim(-0.02,0.02) # plt.subplot(222) # osh5vis.osplot(e2,cmap='seismic',vmin=-0.02,vmax=0.02) # plt.subplot(223) # osh5vis.osplot(s1,cmap='PuBu',vmin=0,vmax=0.000025) plt.subplot(221) p1x1_e = numpy.abs(p1x1_e) data_max= numpy.amax(p1x1_e) p1x1_e=p1x1_e/data_max osh5vis.oscontourf(p1x1_e,levels=[10**-5,3.0*10**-3,5*10**-3,1*10**-2,10**-1,3*10**-1,5*10**1],norm=LogNorm(),cmap='terrain',vmin=1e-3,vmax=100) osh5vis.oscontour(p1x1_e,levels=[10**-5,3.0*10**-3,5*10**-3,1*10**-2,10**-1,3*10**-1,5*10**1],norm=LogNorm(),colors='black',linestyles='dashed',vmin=1e-5,vmax=500,colorbar=False) plt.subplot(223) # osh5vis.osplot(np.log(np.abs(p1p2_e)+1e-5),cmap='hsv') p1p2_e = numpy.abs(p1p2_e) data_max= numpy.amax(p1p2_e) p1p2_e=p1p2_e/data_max osh5vis.oscontourf(p1p2_e,levels=[10**-6,3.0*10**-3,5*10**-3,1*10**-2,10**-1,3*10**-1,5*10**1],norm=LogNorm(),cmap='terrain',vmin=1e-3,vmax=100) osh5vis.oscontour(p1p2_e,levels=[10**-6,3.0*10**-3,5*10**-3,1*10**-2,10**-1,3*10**-1,5*10**1],norm=LogNorm(),colors='black',linestyles='dashed',vmin=1e-5,vmax=500,colorbar=False) # plt.xlim(-0.8,0.8) plt.xlim(-0.35,0.35) plt.subplot(224) osh5vis.osplot(s1, title='Axial <Poynting Flux>') plt.ylim(0,0.00009) plt.tight_layout() plt.show()