#
# Beam_Profile_Exercise_3.py
#
# This file will generate a plot of
# the predicted knife-edge beam profile
# for the TEM00 laser mode
#
# Written by:
#
# Ernest R. Behringer
# Department of Physics and Astronomy
# Eastern Michigan University
# Ypsilanti, MI 48197
# (734) 487-8799
# ebehringe@emich.edu
#
# 20160614 by ERB
#
# import the commands needed to make the plot and fit the data
from pylab import xlim,xlabel,ylim,ylabel,grid,show,plot,title
from numpy import linspace,sqrt
from scipy.special import erf
# inputs
npts = 200 # number of intervals in x
w0 = 0.5 # beam width [mm]
# calculated quantity
x_max = 3.0*w0
# set up the array of knife-edge positions
x = linspace(-x_max,x_max,npts+1)
# calculate the scaled power
scaled_P = 0.5*(1.0 - erf(sqrt(2.0)*x/w0))
# Define the limits of the horizontal axis
xlim(-x_max,x_max)
# Label the horizontal axis, with units
xlabel("Knife-edge position $x$ [mm]", size = 16)
# Define the limits of the vertical axis
ylim(-0.1,1.1)
# Label the vertical axis, with units
ylabel("Scaled transmitted power $P(x)/P_0$", size = 16)
# Make a grid on the plot
grid(True)
# Make the title
title('Normalized knife-edge profile for $w_0 = $%s mm'%w0)
# Generate the plot. The line color is magenta (m).
plot(x,scaled_P,"m")
show()