Example #1
0
 def test_reflect(self):
     sphere = Sphere(1)
     rays = Rays([(0, 0, -1)], array([(A, B, 1)]) / sqrt(A**2 + B**2 + 1), None)
     reflection = sphere.reflect(rays)
     self.assertTrue(allclose(reflection.endpoints + reflection.directions,
                              [(0, 0, -1)]))
Example #2
0
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt("rowland.dat").T
p = plt.scatter(data[0], data[1], c=data[2], s=0.1, linewidth=0)
"""

# parameters for a Rowland spectrometer, SI units unless otherwise stated
angle = 2        # incidence angle on the grating (degrees)
energy = 500     # center energy of the incident light (eV)
order = -1       # diffraction order to look at
R = 5.0          # radius of the grating
d = 1200e3       # grating line density, m^-1

# Grating, centered at origin
s = Sphere(5.0, xsize=0.1, ysize=0.1)
sg = ReflectiveGrating(d=1/d, order=order, geometry=s,
                       rotation=(90, 0, 0))

# Detector
p = Plane(xsize=0.1, ysize=0.1)
row = Rowland(R_gr=R, d_gr=d/1000, theta_in=angle)
detx, dety = row.add_ray(energy, order, 0)   # calculate the focal
det = Detector(geometry=p, position=(0, dety, detx),
               rotation=(90-degrees(2*atan(dety/detx)), 0., 0.))

# Incoming light distribution
xdisp = 10e-3     # divergence angle in horizontal direction (sigma, rad)
ydisp = 1e-3     # vertical divergence
xslit = 1e-4      # horizontal entrance slit / source size (sigma)
yslit = 1e-5      # vertical slit size