Cylinder

class marxs.math.geometry.Cylinder(kwargs={})[source] [edit on github]

Bases: Geometry

A Geometry shaped like a ring or tube.

This object is shaped like a tube. The form is a circle in the xy plane and flat along the z-direction. This can be used, for example to simulate a setup that can follow the Rowland circle geometry exactly which is useful, e.g. to study the resolution of a spectrograph without worrying about the details of the detector geometry.

Parameters:
position, orientation, zoom, pos4dsee description of pos4d

The radius of the tube is given by the zoom keyword, see pos4d. Use zoom[0] == zoom[1] to make a circular tube. zoom[0] != zoom[1] gives an elliptical profile. zoom[2] sets the extension in the z direction.

phi_limlist

If a cylinder does not cover the full circle, set phi_lim to the limits, e.g. [-np.pi / 2, np.pi / 2] makes a “half-pipe”.

Attributes Summary

coos_limits

loc_coos_name

shape

Methods Summary

from_rowland(rowland, width[, rotation, kwargs])

Generate a Cylinder from a RowlandTorus.

get_local_euklid_bases(interpos_local)

Obtain a local eukledian base at a set of positions.

intersect(dir, pos[, transform])

Calculate the intersection point between a ray and the element

parametric_surface([phi, z, display])

Parametric description of the tube.

Attributes Documentation

coos_limits = [array([-3.14159265,  3.14159265]), array([-1,  1])]
loc_coos_name = ['phi', 'z']
shape = 'surface'

Methods Documentation

classmethod from_rowland(rowland, width, rotation=0.0, kwargs={})[source] [edit on github]

Generate a Cylinder from a RowlandTorus.

According to the definition of the marxs.design.rowland.RowlandTorus the origin phi=0 is at the “top”. When this class method is used to make a detector that catches all dispersed grating signal on the Rowland torus, a rotation=np.pi places the center of the Cylinder close to the center of the torus (the location of the focal point in the standard Rowland geometry).

Parameters:
rowlandRowlandTorus

The circular detector is constructed to fit exactly into the Rowland Circle defined by rowland.

widthfloat

Half-width of the tube in the flat direction (z-axis) in mm

rotationfloat

Rotation angle of the Cylinder around its z-axis compared to the phi=0 position of the Rowland torus.

get_local_euklid_bases(interpos_local)[source] [edit on github]

Obtain a local eukledian base at a set of positions.

Parameters:
interpos_localnumpy.ndarray of shape (N, 2)

coordinates in the coordiante system of the geometry (e.g. (x, y), or (r, phi)).

Returns:
e_1, e_2, nnumpy.ndarray of shape (N, 4)

Vectors pointing in direction 1, 2, and normal to the surface.

intersect(dir, pos, transform=True)[source] [edit on github]

Calculate the intersection point between a ray and the element

Parameters:
dirnumpy.ndarray of shape (N, 4)

homogeneous coordinates of the direction of the ray

posnumpy.ndarray of shape (N, 4)

homogeneous coordinates of a point on the ray

transformbool

If True, input is in global coordinates and needs to be transformed here for the calculations; if False input is in local coordinates.

Returns:
intersectboolean array of length N

True if an intersection point is found.

interposnumpy.ndarray of shape (N, 4)

homogeneous coordinates of the intersection point. Values are set to np.nan is no intersecton point is found.

interpos_localnumpy.ndarray of shape (N, 2)

phi, z coordiantes (in the local frame) for one of the intersection points. If both intersection points are required, reset self.inner and call this function again.

parametric_surface(phi=None, z=None, display={})[source] [edit on github]

Parametric description of the tube.

This is just another way to obtain the shape of the tube, e.g. for visualization.

Parameters:
phinp.array

phi is the angle around the tube profile. Set to None to use the extend of the element itself.

znp.array

The coordiantes along the radius coordinate. Set to None to use the extend of the element itself.

Returns:
xyzwnp.array

Ring coordinates in global homogeneous coordinate system. The array has the following shape (npoints, 2, 4). xyzw[:, 0, :] describes one rim of the cylinder, xyzw[:, 1, :] the other rim.