Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 219a2c51 authored by hartmann_m's avatar hartmann_m
Browse files

Update beamtheta.py

parent 479efe62
No related branches found
No related tags found
No related merge requests found
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from matplotlib import ticker
def norm(data):
return(data)/(sum(data))
......@@ -31,31 +29,66 @@ def makeGaussian2(x_center=0, y_center=0, theta=0, sigma_x = 10, sigma_y=10, x_s
return np.exp(-(((a-a0)**2)/(2*(sx**2)) + ((b-b0)**2) /(2*(sy**2))))
framesize=23
framesize=30
theta=0
std = 12/2.
static_std = 8
rot_std= 6
z=np.zeros((2*framesize,2*framesize))
radius=18/2.
z1=np.zeros((2*framesize,2*framesize))
radius=9
r=0
for angle in np.arange(0,360,1):
x0=np.cos(angle)*radius
y0=np.sin(angle)*radius
z += makeGaussian2(x0, y0, angle, std, std, framesize, framesize)
z += makeGaussian2(x0, y0, angle, rot_std, rot_std, framesize, framesize)
plt.plot(np.arange(0,2*framesize,1),norm(z[framesize,:]), color='blue', linestyle='--', linewidth=3, marker="o", markerfacecolor='red')
plt.ylim(bottom=0)
for angle in np.arange(0,360,1):
x0=np.cos(angle)*r
y0=np.sin(angle)*r
z1 += makeGaussian2(x0, y0, angle, static_std, static_std, framesize, framesize)
plt.xlabel('${x[mm]}$',size=11)
plt.ylabel('${y[mm]}$',size=11)
plt.title('Sliced beam distribution at x=23mm')
plt.plot(np.arange(0,2*framesize,1),norm(z[framesize,:]), color='green', linestyle='--', linewidth=3, label='Rotating beam', marker="x", markerfacecolor='red')
plt.plot(np.arange(0,2*framesize,1),norm(z1[framesize,:]), color='red', linestyle='--', linewidth=3, label='Static beam', marker="x", markerfacecolor='black')
plt.ylim(bottom=0)
plt.legend()
plt.xlabel('${radius\ [mm]}$',size=11)
plt.ylabel('$norm.\ beam\ intensity$',size=11)
plt.title('Sliced beam distribution')
plt.axvline(x=53,color='black',linestyle='--')
plt.axvline(x=7,color='black',linestyle='--')
plt.text(53,0.025,'target',ha='center',va='center',rotation='vertical',backgroundcolor='white',bbox={'facecolor':'white','pad':5})
plt.text(7,0.025,'target',ha='center',va='center',rotation='vertical',backgroundcolor='white',bbox={'facecolor':'white','pad':5})
plt.show()
plt.imshow(z)
plt.xlabel('${x[mm]}$',size=11)
plt.ylabel('${y[mm]}$',size=11)
plt.title('2D Gaussian beam distribution z(x,y)')
plt.clim(0,100)
plt.colorbar()
plt.show()
fig= plt.figure(figsize=(10,10))
rows=2
columns=2
#relative intensities per sq.mm
print(z[30,30]/np.sum(z))
print(z1[30,30]/np.sum(z1))
#Plot 2D Gaussians for unrotated and rotated beams
#fig.add_subplot(rows,columns,1)
#plt.imshow(z1)
#plt.title('2D Gaussian beam distribution z1(x,y) - static beam')
#plt.clim(0,100)
#plt.colorbar()
#fig.add_subplot(rows,columns,4)
#plt.imshow(z)
#plt.title('2D Gaussian beam distribution z(x,y) - rotating beam')
#plt.clim(0,100)
#plt.colorbar()
#plt.xlabel('${x[mm]}$',size=11)
#plt.ylabel('${y[mm]}$',size=11)
#plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment