""" import scipy.io as spio import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rc('font',family='Times New Roman') matplotlib.rc('xtick', labelsize=18) matplotlib.rc('ytick', labelsize=18) import sys sys.path.append('/Users/nneveu/Documents/PythonScripts') import myplots as mplt dataopal = mplt.load('46grid1mill.stat') #dataopal = mplt.load('1nCR0pt75LaserAstraM273.stat', 57) datagpt = mplt.loadgpt('OUTAnlysGun2.mat') astrax = np.loadtxt('awa_gunSCon.Xemit.001', skiprows=0) astray = np.loadtxt('awa_gunSCon.Yemit.001', skiprows=0) astraz = np.loadtxt('awa_gunSCon.Zemit.001', skiprows=0) # Four axes, returned as a 2-d array f, axarr = plt.subplots(2, 2, figsize=(7.5,6)) f.subplots_adjust(hspace=.6) f.subplots_adjust(wspace=.4) #==============================================================================
import numpy as np import matplotlib.pyplot as plt import matplotlib import sys sys.path.append('/Users/nneveu/Documents/PythonScripts') import myplots as mplt #matplotlib.rc('font',family='Times New Roman') matplotlib.rc('xtick', labelsize=18) matplotlib.rc('ytick', labelsize=18) dataopal1 = mplt.load('1nCR0pt75LaserAstraM273.stat') fig, ax1 = plt.subplots() ax1.plot(dataopal1['z'], dataopal1['Ez'], 'k-', label='Electric field, Ez') ax1.set_xlabel('Z [m]', size=18) ax1.axis([0.0, 0.5, -60, 5.0]) # Make the y-axis label, ticks and tick labels match the line color. ax1.set_ylabel('Electric Field [MV/m]', color='k', size=18) ax1.tick_params('y', colors='k') ax2 = ax1.twinx() ax2.plot(dataopal1['z'], dataopal1['Bz'], 'b--', label='Magnetic field, Bz') ax2.set_ylabel('Magnetic Field [T]', color='b', size=18) ax2.tick_params('y', colors='b') ax2.axis([0.0, 0.5, -0.4, 0.05]) lines, labels = ax1.get_legend_handles_labels() lines2, labels2 = ax2.get_legend_handles_labels() ax2.legend(lines + lines2, labels + labels2, loc='lower right')
#import matplotlib.pyplot as plt sys.path.append('/Users/nneveu/Documents/PythonScripts') import myplots as mplt #Making a list of SDDS files files = glob.glob( 'C:/Users/nneveu/Desktop/Scripts/benchmark/gridcompare/*3D*.stat') emittanceMin = 1000000 filemin = '.' #Looping through every .stat file for filename in files: #filename = 'optLinac.stat' #print filename.split('.')[0] data = mplt.load(filename) zloc = np.argmax(data['z'] > 0.3) #zloc = np.where(data['z']>0.3)[0][0] tempmin = np.min(data['xemit'][zloc:]) print(filename) print(tempmin) #print tempmin if tempmin < emittanceMin: emittanceMin = tempmin filemin = filename #print data['z'][np.where(data['xemit']==emittanceMin)[0]] #print emittanceMin #print filemin.split('\\')[1]
@author: nneveu """ import scipy.io as spio import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rc('font', family='Times New Roman') matplotlib.rc('xtick', labelsize=18) matplotlib.rc('ytick', labelsize=18) import sys sys.path.append('/Users/nneveu/Documents/PythonScripts') import myplots as mplt dataopal = mplt.load('46grid1mill.stat') #dataopal2 = mplt.load('RFphotoinjector.stat', 57) dataopal2 = mplt.load('optgun_273_0_0.00075.stat') datagpt = mplt.loadgpt('OUTAnlysGun2.mat') #============================================================================== # astrax = np.loadtxt('awa_gunSCon.Xemit.001', skiprows=0) # astray = np.loadtxt('awa_gunSCon.Yemit.001', skiprows=0) # astraz = np.loadtxt('awa_gunSCon.Zemit.001', skiprows=0) # # # # # Four axes, returned as a 2-d array # f, axarr = plt.subplots(2, 2, figsize=(7.5,6)) # f.subplots_adjust(hspace=.6) # f.subplots_adjust(wspace=.4)
@author: nneveu """ import scipy.io as spio import numpy as np import matplotlib.pyplot as plt import matplotlib #matplotlib.rc('font',family='Times New Roman') matplotlib.rc('xtick', labelsize=18) matplotlib.rc('ytick', labelsize=18) import sys sys.path.append('/Users/nneveu/Documents/PythonScripts') import myplots as mplt dataopal1 = mplt.load('tba_guass1.stat') dataopal2 = mplt.load('tba_guass.stat') v1 = 'tba 1' #str(1.4) v2 = 'tba 2' #str(1.9) # Four axes, returned as a 2-d array f, axarr = plt.subplots(2, 2, figsize=(7.5, 6)) f.subplots_adjust(hspace=.6) f.subplots_adjust(wspace=.4) #============================================================================== # axarr[0, 0].plot(astrax[:,0], astrax[:,3], 'g-', label = 'ASTRA', markevery=5) #xrms # axarr[0, 0].plot(datagpt['z'], datagpt['xrms']*10.0**3.0, 'k-o', label = 'GPT', markevery = 5, markersize =3) # axarr[0, 0].plot(dataopal['z'], dataopal['xrms'], '--', label = 'OPAL') # axarr[0, 0].set_title('Transverse Beam Size',fontsize=18)
x and y max, min trajectories """ import numpy as np import matplotlib.pyplot as plt import sys import h5py sys.path.append('/Users/nneveu/Documents/PythonScripts') import myplots as mplt run = 'zoomedin' myfile = 'dipoleKicker20m.h5' angledata = mplt.load('dipoleKicker20m.stat', 56) hf = h5py.File(myfile, 'r') steps = len(hf.keys()) - 1 #steps = 120 xmin = np.zeros((steps, 1)) xmax = np.zeros((steps, 1)) ymin = np.zeros((steps, 1)) ymax = np.zeros((steps, 1)) avez = np.zeros((steps, 1)) for i in np.arange(0, steps): x = np.asarray(hf.get('/Step#' + str(i) + '/x')) * 10.0**3.0 #px = np.asarray(hf.get('/Step#'+str(steps-1)+'/px' ))*0.511 #py = np.asarray(hf.get('/Step#'+str(steps-1)+'/py' ))*0.511
times = np.loadtxt('timings.txt', skiprows=1) tstep = times[:, 0] seconds = times[:, 1] plt.title('Timing results') plt.xlabel('time step [s]') plt.ylabel('simulation time [s]') plt.plot(tstep, seconds, '*--') plt.savefig('./time_vs_timestep.pdf', format='pdf', dpi=1000, bbox_inches='tight') #data1 = mplt.load('5e-10.stat') #data2 = mplt.load('1e-10.stat') data3 = mplt.load('5e-11.stat') #data4 = mplt.load('1e-11.stat') #data5 = mplt.load('5e-12.stat') #data6 = mplt.load('1e-12.stat') datah = mplt.load('1e5_np.stat') datan = mplt.load('optLinac_40nC.stat') #data = [data1, data2, data3, data4, data5, data6, datan] #v = [str(5e-10), str(1e-10), str(5e-11), str(1e-11), str(5e-12), str(1e-12), 'multi-steps np=1e5'] data = [data3, datan, datah] v = ['low fidelity', 'low fidelity adjusted dT', 'mid fidelity'] markers = ['b--', 'k-', 'y--', 'r-', 'k--', 'm-', '--']
import numpy as np import matplotlib import matplotlib.pyplot as plt from glob import glob from natsort import natsorted, ns import sys sys.path.append('/home/nicole/Documents/thesis_code') import myplots as mplt matplotlib.rc('xtick', labelsize=18) matplotlib.rc('ytick', labelsize=18) opal1 = mplt.load('optLinac_M185_GPhase-20_R8.5mm_FWHM1.5e-12_L1-L6_0_3D.stat') #_3D.stat') opal2 = mplt.load('optLinac_M250_GPhase-20_R8.5mm_FWHM1.5e-12_L1-L6_0_3D.stat') #_3D.stat') beamfiles = glob('./output/1nC/*beamsizes_1nC.npy') n_points = len(beamfiles) #https://stackoverflow.com/questions/4836710/does-python-have-a-built-in-function-for-string-natural-sort natsorted(beamfiles, key=lambda y: y.lower()) #natsorted(beamfiles, alg=ns.IGNORECASE) ave_sigx = {} #np.zeros((n_points)) ave_sigy = {} #np.zeros((n_points)) max_barx = {} #np.zeros((n_points)) max_bary = {} #np.zeros((n_points)) error_barsx = {} #np.zeros((n_points)) error_barsy = {} #np.zeros((n_points)) std_sigx = {}
@author: nneveu """ import numpy as np import matplotlib.pyplot as plt import sys import myplots as mplt run = 'dipole_test' #opalfilebase = 'dipoleKickerBaselineK0-0pt012' #file1 = mplt.load('optLinac_weight3.stat') #file1 = mplt.load('optLinac_weight5_linacon.stat') #file2 = mplt.load('optLinac_weight5_linacon.stat') file1 = mplt.load('./data/optLinac3Dgun3DLinac.stat') file2 = mplt.load('./data/optLinac3Dgun3DLinac.stat') file1_label = 'weight 3'#'Linac on'# file2_label = 'weight 5'#'weight 5' for i in np.arange(6, 8, 1): if i ==1: #Energy Plot plt.figure(1) #plt.show(block=False) #plt.axis((0, 20, 0, 70)) plt.title( r'Energy Vs. Z' , size=18) plt.xlabel(r'z [m]', size=18)