#

# Beam_Profile_Exercise_1.py

#

# This file will generate a plot of

# the irradiance I(x,y) of the TEM00 Gaussian Mode of a laser

# as a function of scaled x for several different values of scaled y.

#

# This file will also generate a plot of

# the scaled irradiance I(x,y) of the TEM00 Gaussian Mode of a laser

# as a function of scaled x for several different values of scaled y.

#

# Written by:

#

# Ernest R. Behringer

# Department of Physics and Astronomy

# Eastern Michigan University

# Ypsilanti, MI 48197

# (734) 487-8799

# ebehringe@emich.edu

#

# 20160628 ERB

#

from pylab import xlim,xlabel,ylim,ylabel,show,plot,figure,grid,legend

from numpy import linspace,exp,pi,zeros

# Generate scaled x and y values

max_xsc = 2.0 # maximum value of x position [mm]

min_xsc = -2.0 # minimum value of x position [mm]

Npts = 81

xsc = linspace(min_xsc,max_xsc,Npts) # array of scaled x values

ysc = [0.0,0.2,0.4,0.6,0.8,1.0]

# other inputs

w0 = 1.00 # beam width [mm]

P_0 = 1.00 # laser power [mW]

I_0 = 2.00*P_0/(pi*w0*w0) # maximum irradiance [mW/mm2]

# Set up array of irradiances

I = zeros((6,Npts))

for i in range(0,6):

I[i] = I_0 * exp(-2.0*(xsc*xsc + ysc[i]*ysc[i]))

# Generate the line plot of irradiance versus scaled x values

# for different scaled y values

figure()

# Here we plot unscaled I versus the scaled x for different scaled y values,

plot(xsc,I[0],'mo-',label='$\\tilde y = 0.0$',markevery=8)

plot(xsc,I[1],'bD-',label='$\\tilde y = 0.2$',markevery=4)

plot(xsc,I[2],'g>-',label='$\\tilde y = 0.4$',markevery=2)

plot(xsc,I[3],'ys-',label='$\\tilde y = 0.6$',markevery=5)

plot(xsc,I[4],color='#ffaa00',marker='^',linestyle='-',label='$\\tilde y = 0.8$',markevery=4)

plot(xsc,I[5],'r*-',label='$\\tilde y = 1.0$',markevery=3)

# Define the limits of the horizontal axis

xlim(min(xsc),max(xsc))

# Label the horizontal axis, with units

xlabel("$\\tilde x$", size = 16)

# Define the limits of the vertical axis

ylim(min(I[0]),max(I[0]))

# Label the vertical axis, with units

ylabel("$I$ [mW/mm$^2$]", size = 16)

grid('on')

legend()

show()

# Generate the line plot of scaled I versus scaled x

figure()

# Here we plot scaled I versus scaled x for different scaled y values,

plot(xsc,I[0]/max(I[0]),'mo-',label='$\\tilde y = 0.0$',markevery=8)

plot(xsc,I[1]/max(I[1]),'bD-',label='$\\tilde y = 0.2$',markevery=4)

plot(xsc,I[2]/max(I[2]),'g>-',label='$\\tilde y = 0.4$',markevery=2)

plot(xsc,I[3]/max(I[3]),'ys-',label='$\\tilde y = 0.6$',markevery=5)

plot(xsc,I[4]/max(I[4]),color='#ffaa00',marker='^',linestyle='-',label='$\\tilde y = 0.8$',markevery=4)

plot(xsc,I[5]/max(I[5]),'r*-',label='$\\tilde y = 1.0$',markevery=3)

# Define the limits of the horizontal axis

xlim(min(xsc),max(xsc))

# Label the horizontal axis, with units

xlabel("$\\tilde x$", size = 16)

# Define the limits of the vertical axis

ylim(0.0,1.0)

# Label the vertical axis, with units

ylabel("$I/I_{max,\\tilde{y}}$", size = 16)

grid('on')

legend()

show()