@@ -106,19 +106,19 @@ def __init__(self, kwargs={}):
106106 super ().__init__ (kwargs = kwargs )
107107
108108 def __getitem__ (self , key ):
109- ''' This function wraps access to the pos4d matrix.
109+ """ This function wraps access to the pos4d matrix.
110110
111111 This is mostly a convenience method that gives access to
112112 vectors from the ``pos4d`` matrix in familiar terms with
113113 string labels:
114114
115- - ``center``: The ``center`` is the origin of the local coordiante system
116- of the optical elemement . Typically, if will be the center of the
115+ - ``center``: The ``center`` is the origin of the local coordinate system
116+ of the optical element . Typically, if will be the center of the
117117 active plane, e.g. the center of the mirror surface.
118118 - :math:`\hat v_{y,z}`: The box stretches in the y and z direction for
119119 :math:`\pm \hat v_y` and :math:`\pm \hat v_z`. In optics, the relevant
120120 interaction often happens on a surface, e.g. the surface of a mirror or
121- of a reflection grating. In the defaul configuration, this surface is in
121+ of a reflection grating. In the default configuration, this surface is in
122122 the yz-plane.
123123 - :math:`\hat v_x`: The thickness of the box is not as important in many
124124 cases,
@@ -138,7 +138,7 @@ def __getitem__(self, key):
138138 mirror does not really have a "plane").
139139 Access through this method is slower than direct indexing of ``self.pos4d``.
140140
141- '''
141+ """
142142
143143 if key == 'center' :
144144 return self .pos4d [:, 3 ]
@@ -160,7 +160,7 @@ def __getitem__(self, key):
160160 return val
161161
162162 def intersect (self , dir , pos ):
163- ''' Calculate the intersection point between a ray and the element
163+ """ Calculate the intersection point between a ray and the element
164164
165165 Parameters
166166 ----------
@@ -177,24 +177,24 @@ def intersect(self, dir, pos):
177177 homogeneous coordinates of the intersection point. Values are set
178178 to ``np.nan`` if no intersection point is found.
179179 interpos_local : `numpy.ndarray` of shape (N, 2)
180- y and z coordinates in the coordiante system of the active plane.
181- '''
180+ y and z coordinates in the coordinate system of the active plane.
181+ """
182182 raise NotImplementedError
183183
184184 def get_local_euklid_bases (self , interpos_local ):
185- ''' Obtain a local eukledian base at a set of positions.
185+ """ Obtain a local eucledian base at a set of positions.
186186
187187 Parameters
188188 ----------
189189 interpos_local : `numpy.ndarray` of shape (N, 2)
190- coordinates in the coordiante system of the geometry (e.g. (x, y),
190+ coordinates in the coordinate system of the geometry (e.g. (x, y),
191191 or (r, phi)).
192192
193193 Returns
194194 -------
195195 e_1, e_2, n : `numpy.ndarray` of shape (N, 4)
196196 Vectors pointing in direction 1, 2, and normal to the surface.
197- '''
197+ """
198198 raise NotImplementedError
199199
200200
@@ -209,7 +209,7 @@ class FinitePlane(Geometry):
209209 '''name for output columns with interaction point in local coordinates.'''
210210
211211 def intersect (self , dir , pos ):
212- ''' Calculate the intersection point between a ray and the element
212+ """ Calculate the intersection point between a ray and the element
213213
214214 Parameters
215215 ----------
@@ -226,15 +226,15 @@ def intersect(self, dir, pos):
226226 homogeneous coordinates of the intersection point. Values are set
227227 to ``np.nan`` if no intersection point is found.
228228 interpos_local : `numpy.ndarray` of shape (N, 2)
229- y and z coordinates in the coordiante system of the active plane
229+ y and z coordinates in the coordinate system of the active plane
230230 (not normalized to the dimensions of the element in question, but
231231 in absolute units).
232- '''
232+ """
233233 k_nominator = np .dot (self ['center' ] - pos , self ['e_x' ])
234234 k_denom = np .dot (dir , self ['e_x' ])
235235
236236 is_parallel = k_denom == 0
237- # To avoid warning for parallel rays, which is handeled expicitly below
237+ # To avoid warning for parallel rays, which is handled explicitly below
238238 with np .errstate (divide = 'ignore' ):
239239 k = k_nominator / k_denom
240240
@@ -261,18 +261,18 @@ def intersect(self, dir, pos):
261261 return intersect , interpos , interpos_local
262262
263263 def get_local_euklid_bases (self , interpos_local ):
264- ''' Obtain a local eukledian base at a set of positions.
264+ """ Obtain a local euclidean base at a set of positions.
265265
266266 Parameters
267267 ----------
268268 interpos_local : `numpy.ndarray` of shape (N, 2)
269- coordinates in the coordiante system of the geometry (x, y)
269+ coordinates in the coordinate system of the geometry (x, y)
270270
271271 Returns
272272 -------
273273 e_1, e_2, n : `numpy.ndarray` of shape (N, 4)
274274 Vectors pointing in direction 1, 2, and normal to the surface.
275- '''
275+ """
276276
277277 n = interpos_local .shape [0 ]
278278 x = np .tile (self ['e_x' ], (n , 1 ))
@@ -282,28 +282,27 @@ def get_local_euklid_bases(self, interpos_local):
282282
283283
284284class PlaneWithHole (FinitePlane ):
285-
286- shape = 'triangulation'
287- outer_factor = 3
285+ shape = "triangulation"
288286 inner_factor = 0
287+ outer_factor = 3
289288
290289 def __init__ (self , kwargs ):
291290 self ._geometry ['r_inner' ] = kwargs .pop ('r_inner' , 0. )
292291 super ().__init__ (kwargs )
293292
294293 def triangulate (self , display = {}):
295- ''' Return a triangulation of the aperture hole embedded in a square.
294+ """ Return a triangulation of the aperture hole embedded in a square.
296295
297296 The size of the outer square is determined by the ``'outer_factor'``
298297 element in ``self.display``.
299298
300299 Returns
301300 -------
302301 xyz : np.array
303- Numpy array of vertex positions in Eukeldian space
302+ Numpy array of vertex positions in Euclidean space
304303 triangles : np.array
305304 Array of index numbers that define triangles
306- '''
305+ """
307306 outer_disp = self .outer_display (display )
308307 outer_shape = self .outer_shape (display )
309308
@@ -320,16 +319,16 @@ def triangulate(self, display={}):
320319
321320 return xyz , triangles
322321
323- def outer_shape (self , diplay ):
322+ def outer_shape (self , display ):
324323 raise NotImplementedError
325324
326- def outer_display (self , diplay ):
325+ def outer_display (self , display ):
327326 raise NotImplementedError
328327
329- def inner_shape (self , diplay ):
328+ def inner_shape (self , display ):
330329 raise NotImplementedError
331330
332- def inner_display (self , diplay ):
331+ def inner_display (self , display ):
333332 raise NotImplementedError
334333
335334
@@ -356,7 +355,7 @@ def __init__(self, kwargs):
356355 super ().__init__ (kwargs )
357356
358357 def outer_display (self , display ):
359- ''' Return values in Eukledian space.'''
358+ """ Return values in Euclidean space."""
360359 return xyz_circle (self , r_factor = display ['outer_factor' ])
361360
362361 def outer_shape (self , display ):
@@ -374,6 +373,12 @@ def inner_display(self, display):
374373 r_factor = display ['inner_factor' ] * self ['r_inner' ] / np .linalg .norm (self ['v_y' ]),
375374 philim = self .phi )
376375
376+ def intersect (self , dir , pos ):
377+ intersect , interpos , interpos_local = super ().intersect (dir , pos )
378+ r = np .linalg .norm (interpos_local , axis = 1 )
379+ intersect &= r <= 1.0
380+ return intersect , interpos , interpos_local
381+
377382
378383class Cylinder (Geometry ):
379384 '''A Geometry shaped like a ring or tube.
0 commit comments