syned.beamline package
Subpackages
- syned.beamline.optical_elements package
- Subpackages
- syned.beamline.optical_elements.absorbers package
- Submodules
- syned.beamline.optical_elements.absorbers.absorber module
- syned.beamline.optical_elements.absorbers.beam_stopper module
- syned.beamline.optical_elements.absorbers.filter module
- syned.beamline.optical_elements.absorbers.holed_filter module
- syned.beamline.optical_elements.absorbers.slit module
- Module contents
- syned.beamline.optical_elements.crystals package
- syned.beamline.optical_elements.gratings package
- syned.beamline.optical_elements.ideal_elements package
- syned.beamline.optical_elements.mirrors package
- syned.beamline.optical_elements.multilayers package
- syned.beamline.optical_elements.refractors package
- syned.beamline.optical_elements.absorbers package
- Module contents
- Subpackages
Submodules
syned.beamline.beamline module
Represents a beamline. The beamline is composed by a light source ans a list of beamline elements.
- class syned.beamline.beamline.Beamline(light_source=<syned.storage_ring.light_source.LightSource object>, beamline_elements_list=None)[source]
Bases:
SynedObjectConstructor.
- Parameters:
light_source (instance of LightSource) – The light source
beamline_elements_list (list) – The beamline elements (each one an instance of BeamlineElement).
- append_beamline_element(beamline_element=<syned.beamline.beamline_element.BeamlineElement object>)[source]
Appends a beamline element.
- Parameters:
beamline_element (instance of BeamlineElement.) –
- duplicate()[source]
Returns a copy of the beamline element instance.
- Returns:
A copy of the object instance.
- Return type:
BeamlineElement instance
- get_beamline_element_at(index)[source]
gets an individual beamline element.
- Parameters:
index (int) – The index of the beamline element to be retrieved.
- Returns:
The wanted beamline element (referenced, not copied).
- Return type:
instance of BeamlineElement
- get_beamline_elements_number()[source]
Gets the number of beamline elements stored.
- Return type:
int
- get_light_source()[source]
Returns the light source
- Return type:
instance of LightSource
- set_light_source(light_source=<syned.storage_ring.light_source.LightSource object>)[source]
Sets a light source.
- Parameters:
light_source (instance of LightSource) –
syned.beamline.beamline_element module
Base class for all beamline elements. A beamline element is composed by an optical element (instance of OpticalElement) and its position in th ebeamline (an instance of ElementCoordinates).
- class syned.beamline.beamline_element.BeamlineElement(optical_element=<syned.beamline.optical_element.OpticalElement object>, coordinates=<syned.beamline.element_coordinates.ElementCoordinates object>)[source]
Bases:
SynedObjectConstructor
- Parameters:
optical_element (instance of OpticalElement) –
coordinates (instance of ElementCoordinates) –
- get_coordinates()[source]
Returns the element coordinates.
- Return type:
instance of ElementCoordinates
- get_optical_element()[source]
Returns the optical element.
- Return type:
instance of OpticalElement
- set_coordinates(value)[source]
Sets the coordinates.
- Parameters:
value (instance of ElementCoordinates.) –
- set_optical_element(value)[source]
Sets the optical element.
- Parameters:
value (instance of OpticalElement) –
syned.beamline.element_coordinates module
Position coordinates of a beamline component.
- class syned.beamline.element_coordinates.ElementCoordinates(p=0.0, q=0.0, angle_radial=0.0, angle_azimuthal=0.0, angle_radial_out=None)[source]
Bases:
SynedObject- get_angles()[source]
Get the angles.
- Returns:
(angle_radial, angle_radial_out, angle_azimuthal)
- Return type:
tuple
- get_positions()[source]
Gets the coordinates.
- Returns:
(p, q, angle_radial, angle_radial_out, angle_azimuthal)
- Return type:
tuple
- set_angles(angle_radial=0.0, angle_radial_out=None, angle_azimuthal=0.0)[source]
Sets the angles.
- Parameters:
angle_radial (float, optional) – Radial inclination angle in rads.
angle_azimuthal (float, optional) – Azimuthal inclination angle in rads.
angle_radial_out (float, optional) – The radial angle in rads in the output direction (default=None, the same as angle_radial).
- set_p_and_q(p=0.0, q=0.0)[source]
Set the distances p and q.
- Parameters:
p (float, optional) – distance from previous element in m.
q (float, optional) – distance to next element in m.
- set_positions(p=0.0, q=0.0, angle_radial=0.0, angle_radial_out=None, angle_azimuthal=0.0)[source]
Sets the coordinates.
- Parameters:
p (float, optional) – distance from previous element in m.
q (float, optional) – distance to next element in m.
angle_radial (float, optional) – Radial inclination angle in rads.
angle_azimuthal (float, optional) – Azimuthal inclination angle in rads.
angle_radial_out (float, optional) – The radial angle in rads in the output direction (default=None, the same as angle_radial).
syned.beamline.optical_element module
Base class for an optical element.
- class syned.beamline.optical_element.OpticalElement(name='Undefined', boundary_shape=None)[source]
Bases:
SynedObjectConstructor.
- Parameters:
name (str) – The element name.
boundary_shape (instance of BoundaryShape, optional) – The element shape. The default=None means no shape associated to the optical element.
- get_boundary_shape()[source]
Returns the boundary shape.
- Return type:
None or instance of BoundaryShape
syned.beamline.optical_element_with_surface_shape module
Base classes for optical elements with shape(s).
OpticalElementsWithSurfaceShape (e.g. an elliptical mirror).
OpticalElementsWithMultipleShapes (e.g. a lens that has two surfaces).
- class syned.beamline.optical_element_with_surface_shape.OpticalElementsWithMultipleShapes(name='', surface_shapes=None, boundary_shape=None)[source]
Bases:
OpticalElementConstructor.
- Parameters:
name (str) – The optical elemnt name.
surface_shapes (list) – List with surface shapes (instances of SurfaceShape)
boundary_shape (instance of BoundaryShape, optional) – The element shape. The default=None means no shape associated to the optical element.
- get_surface_shape(index)[source]
Gets the surface shape.
- Parameters:
index (int) – The index of the requested surface shape in the list.
- Returns:
The requested surface shape.
- Return type:
instance of SurfaceShape
- set_surface_shape(index, surface_shape=None)[source]
Sets a surface shape.
- Parameters:
index (int) – The index of the surface shape to be set in the list.
surface_shape (instances of SurfaceShape, optional) – The surface shape to be set (If None, initialize to SurfaceShape())
- class syned.beamline.optical_element_with_surface_shape.OpticalElementsWithSurfaceShape(name, surface_shape=None, boundary_shape=None)[source]
Bases:
OpticalElementsWithMultipleShapesConstructor.
- Parameters:
name (str) – The optical elemnt name.
surface_shape (instances of SurfaceShape) – The surface shape.
boundary_shape (instance of BoundaryShape, optional) – The element shape. The default=None means no shape associated to the optical element.
- get_surface_shape()[source]
Gets the surface shape.
- Returns:
The requested surface shape.
- Return type:
instance of SurfaceShape
- set_surface_shape(surface_shape=None)[source]
Sets a surface shape.
- Parameters:
surface_shape (instances of SurfaceShape, optional) – The surface shape to be set (If None, initialize to SurfaceShape())
syned.beamline.shape module
Classes with geometrical shapes.
Shape: Base class for all possible geometric shapes.
SurfaceShape: Base class to caracterize the shape (sphere, flat, etc.) of the optical element surface
BoundaryShape: Base class to characterize the optical element dimensions (rectangle, etc.).
- Additional classes help to define flags:
Convexity: NONE = -1, UPWARD = 0, DOWNWARD = 1
Direction: TANGENTIAL = 0, SAGITTAL = 1
Side: SOURCE = 0, IMAGE = 1
- class syned.beamline.shape.Circle(radius=5e-05, x_center=0.0, y_center=0.0)[source]
Bases:
BoundaryShapeConstructor.
- Parameters:
radius (float) – The radius of the circle.
x_center (float) – The x coordinate of the center of the circle.
y_center (float) – The y coordinate of the center of the circle.
- get_boundaries()[source]
Returns the circle parameters.
- Returns:
(radius, x_center, y_center).
- Return type:
tuple
- class syned.beamline.shape.Conic(conic_coefficients=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])[source]
Bases:
SurfaceShapeDefines a conic surface shape expresses via the 10 conic coeffcients.
- Parameters:
conic_coefficients (list, optional) – A list with the 10 coefficients.
- class syned.beamline.shape.Cylinder(cylinder_direction=0)[source]
Bases:
SynedObjectDefines that a surface shape is cylindrical in one direction.
Usage: must be used with double inheritance in other classes (e.g. ParabolicCylinder). It should not be used standalone.
- Parameters:
cylinder_direction (int, optional) – TANGENTIAL = 0, SAGITTAL = 1.
- class syned.beamline.shape.DoubleCircle(radius1=5e-05, x_center1=0.0, y_center1=0.0, radius2=5e-05, x_center2=0.0001, y_center2=0.0001)[source]
Bases:
MultiplePatchConstructor.
- Parameters:
radius1 (float) – The radius of the circle 1.
x_center1 (float) – The x coordinate of the center of the circle 1.
y_center1 (float) – The y coordinate of the center of the circle 1.
radius2 (float) – The radius of the circle 2.
x_center2 (float) – The x coordinate of the center of the circle 2.
y_center2 (float) – The y coordinate of the center of the circle 2.
- set_boundaries(radius1=5e-05, x_center1=0.0, y_center1=0.0, radius2=5e-05, x_center2=0.0001, y_center2=0.0001)[source]
Sets the coordinates of the circles.
- Parameters:
radius1 (float) – The radius of the circle 1.
x_center1 (float) – The x coordinate of the center of the circle 1.
y_center1 (float) – The y coordinate of the center of the circle 1.
radius2 (float) – The radius of the circle 2.
x_center2 (float) – The x coordinate of the center of the circle 2.
y_center2 (float) – The y coordinate of the center of the circle 2.
- class syned.beamline.shape.DoubleEllipse(a_axis_min1=-0.01, a_axis_max1=0.0, b_axis_min1=-0.02, b_axis_max1=0.0, a_axis_min2=-0.01, a_axis_max2=0.01, b_axis_min2=-0.001, b_axis_max2=0.02)[source]
Bases:
MultiplePatchConstructor.
- Parameters:
a_axis_min1 (float, optional) – The coordinate (signed) of the minimum (left) along the major axis of ellipse 1.
a_axis_max1 (float, optional) – The coordinate (signed) of the maximum (right) along the major axis of ellipse 1.
b_axis_min1 (float, optional) – The coordinate (signed) of the minimum (left) along the minor axis of ellipse 1.
b_axis_max1 (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis of ellipse 1.
a_axis_min2 (float, optional) – The coordinate (signed) of the minimum (left) along the major axis of ellipse 2.
a_axis_max2 (float, optional) – The coordinate (signed) of the maximum (right) along the major axis of ellipse 2.
b_axis_min2 (float, optional) – The coordinate (signed) of the minimum (left) along the minor axis of ellipse 2.
b_axis_max2 (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis of ellipse 2.
- set_boundaries(a_axis_min1=-0.01, a_axis_max1=0.0, b_axis_min1=-0.02, b_axis_max1=0.0, a_axis_min2=-0.01, a_axis_max2=0.01, b_axis_min2=-0.001, b_axis_max2=0.02)[source]
Sets the coordinates of the ellipses.
- Parameters:
a_axis_min1 (float, optional) – The coordinate (signed) of the minimum (left) along the major axis of ellipse 1.
a_axis_max1 (float, optional) – The coordinate (signed) of the maximum (right) along the major axis of ellipse 1.
b_axis_min1 (float, optional) – The coordinate (signed) of the minimum (left) along the minor axis of ellipse 1.
b_axis_max1 (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis of ellipse 1.
a_axis_min2 (float, optional) – The coordinate (signed) of the minimum (left) along the major axis of ellipse 2.
a_axis_max2 (float, optional) – The coordinate (signed) of the maximum (right) along the major axis of ellipse 2.
b_axis_min2 (float, optional) – The coordinate (signed) of the minimum (left) along the minor axis of ellipse 2.
b_axis_max2 (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis of ellipse 2.
- class syned.beamline.shape.DoubleRectangle(x_left1=-0.01, x_right1=0.0, y_bottom1=-0.02, y_top1=0.0, x_left2=-0.01, x_right2=0.01, y_bottom2=-0.001, y_top2=0.02)[source]
Bases:
MultiplePatchConstructor.
- Parameters:
x_left1 (float, optional) – The coordinate (signed) of the minimum (left) along the X axis of rectangle 1.
x_right1 (float, optional) – The coordinate (signed) of the maximum (right) along the X axis of rectangle 1.
y_bottom1 (float, optional) – The coordinate (signed) of the minimum (left) along the Y axis of rectangle 1.
y_top1 (float, optional) – The coordinate (signed) of the maximum (right) along the Y axis of rectangle 1.
x_left2 (float, optional) – The coordinate (signed) of the minimum (left) along the X axis of rectangle 2.
x_right2 (float, optional) – The coordinate (signed) of the maximum (right) along the X axis of rectangle 2.
y_bottom2 (float, optional) – The coordinate (signed) of the minimum (left) along the Y axis of rectangle 2.
y_top2 (float, optional) – The coordinate (signed) of the maximum (right) along the Y axis of rectangle 2.
- class syned.beamline.shape.Ellipse(a_axis_min=-1e-05, a_axis_max=1e-05, b_axis_min=-5e-06, b_axis_max=5e-06)[source]
Bases:
BoundaryShapeConstructor.
- Parameters:
a_axis_min (float, optional) – The coordinate (signed) of the minimum (left) along the major axis.
a_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the major axis.
b_axis_min (float, optional) – The coordinate (signed) of the minimum (left) along the minor axis.
b_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis.
- class syned.beamline.shape.Ellipsoid(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0)[source]
Bases:
SurfaceShapeConstructor.
Ellipsoid: Revolution ellipsoid (rotation around major axis). It is defined with three parameters: axes of the ellipse and an additional parameter defining the position of the origin of the mirror. This additional parameter can be “p”, “x0”, “y0” or the angle beta from the ellipsoid center (tan(beta)=y0/x0). For simplicity, we store “p” in syned.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
References
Conic Surfaces and Transformations for X-Ray Beamline Optics Modeling, Manuel Sanchez del Rio and Kenneth Goldberg (2024) https://arxiv.org/abs/2406.04079
- classmethod create_ellipsoid_from_axes(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0)[source]
Creates an ellipsoid.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Ellipsoid
- classmethod create_ellipsoid_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, convexity=0)[source]
Creates an ellipsoid from factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Ellipsoid
- get_angle_pole_from_origin()[source]
Return the angle from pole to origin (beta).
- Return type:
float
- get_axes()[source]
Returns the ellipsoid axes. Note that the third axis of the ellipsoid is the same as the minor axis (revolution ellipsoid).
- Returns:
(minor_axis, major_axis)
- Return type:
tuple
- classmethod get_axis_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Calculates the ellipse axes from the factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- Returns:
(minor_axis, major_axis).
- Return type:
tuple
- get_mirror_center()[source]
Returns the coordinates of the mirror pole or center.
- Returns:
(coor_along_axis_maj, coor_along_axis_min).
- Return type:
tuple
- get_p_q(grazing_angle=None)[source]
Returns p and q for a given grazing angle.
- Parameters:
grazing_angle (None, float) – The grazing angle in rad. If None it calculates it using a,b,p. ** This is not used, as it is calculated from the ellipsoid parameters **
- Returns:
(p, q)
- Return type:
tuple
- classmethod get_p_q_from_axis(min_axis=2.0, maj_axis=1.0, grazing_angle=0.003)[source]
Calculates the p and q values from axis and grazing angle.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
grazing_angle (float, optional) – grazing angle in rad.
- Returns:
(p, q).
- Return type:
tuple
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Sets the ellipsoid parameters as calculated from the factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- initialize_from_shadow_parameters(axmaj=2.0, axmin=1.0, ell_the=0.003, convexity=0)[source]
Sets the ellipsoid parameters as calculated from the parameters used in SHADOW.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
ell_the (float, optional) – the angle beta from the ellipsoid center in rads.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- class syned.beamline.shape.EllipticalCylinder(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0, cylinder_direction=0)[source]
-
Constructor.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- classmethod create_elliptical_cylinder_from_axes(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0, cylinder_direction=0)[source]
Returns an EllipticalCylinder instance from main parameters.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of EllipticalCylinder
- classmethod create_elliptical_cylinder_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, convexity=0, cylinder_direction=0)[source]
Returns an EllipticalCylinder instance from factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of EllipticalCylinder
- get_p_q(grazing_angle=None)[source]
Returns p and q distances for a given grazing angle.
- Parameters:
grazing_angle (float, None) – The grazing angle in rad. If None it calculates it using a,b,p. ** This is not longer used, as it is calculated from the Ellipse parameters **
- Returns:
(p, q).
- Return type:
tuple
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Sets the ellipsoid parameters for given factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- class syned.beamline.shape.HyperbolicCylinder(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0, cylinder_direction=0)[source]
Bases:
Hyperboloid,CylinderConstructor.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- classmethod create_hyperbolic_cylinder_from_axes(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0, cylinder_direction=0)[source]
Returns an HyperbolicCylinder instance from main parameters.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of HyperbolicCylinder
- classmethod create_hyperbolic_cylinder_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, convexity=0, cylinder_direction=0)[source]
Returns an HyperbolicCylinder instance from factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of HyperbolicCylinder
- get_p_q(grazing_angle=None)[source]
Returns p and q distances for a given grazing angle.
- Parameters:
grazing_angle (float) – The grazing angle in rad. If None it calculates it using a,b,p. ** This is not longer used as it is calculates from the Hyperbola parameters **
- Returns:
(p, q).
- Return type:
tuple
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Sets the hyperboloid parameters for given factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- class syned.beamline.shape.Hyperboloid(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0)[source]
Bases:
SurfaceShapeConstructor.
Hyperboloid: Revolution hyperboloid (two sheets: rotation around major axis). It is defined with three parameters: axes of the hyperbola and an additional parameter defining the position of the origin of the mirror. This additional parameter can be “p”, “x0”, “y0” or the angle beta from the ellipsoid center (tan(beta)=y0/x0). For simplicity, we store “p” in syned.
- Parameters:
min_axis (float, optional) – the hyperbola minor axis.
maj_axis (float, optional) – the hyperbola major axis.
p_focus (float, optional) – the distance from the first focus (source position) to the mirror pole.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
References
Some equations can be found here: https://github.com/srio/shadow3-docs/blob/master/doc/conics.pdf
- classmethod create_hyperboloid_from_axes(min_axis=0.0, maj_axis=0.0, p_focus=0.0, convexity=0)[source]
Creates an hyperboloid from main parameters.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
p_focus (float, optional) – the angle beta from the hyperbola center in rads.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Hyperboloid
- classmethod create_hyperboloid_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, convexity=0)[source]
Creates an hyperboloid from factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Hyoerboloid
- get_axes()[source]
Returns the hyperboloid axes. Note that the third axis of the ellipsoid is the same as the minor axis (revolution ellipsoid).
- Returns:
(minor_axis, major_axis)
- Return type:
tuple
- classmethod get_axis_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, branch_sign=None)[source]
Calculates the hyperbola axes from the factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
branch_sign (None, int) – +1 (positive) when p > q; or -1 (negative) when p < q.If None, it is internally calculated.
- Returns:
(minor_axis, major_axis).
- Return type:
tuple
- get_mirror_center()[source]
Returns the coordinates of the mirror pole or center.
- Returns:
(coor_along_axis_maj, coor_along_axis_min).
- Return type:
tuple
- get_p_q(grazing_angle=None)[source]
Returns p and q for a given grazing angle.
- Parameters:
grazing_angle (float, None) – The grazing angle in rad. If None it calculates it using a,b,p. ** This is not longer used as it is calculates from the Hyperbola parameters **
- Returns:
(p, q)
- Return type:
tuple
- classmethod get_p_q_from_axis(min_axis=2.0, maj_axis=1.0, grazing_angle=0.003, branch_sign=1)[source]
Calculates the p and q values from axis and grazing angle.
- Parameters:
min_axis (float, optional) – the ellipse minor axis.
maj_axis (float, optional) – the ellipse majot axis.
grazing_angle (float, optional) – grazing angle in rad.
- Returns:
(p, q).
- Return type:
tuple
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Sets the hyperboloid parameters as calculated from the factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- class syned.beamline.shape.MultiplePatch(patch_list=None)[source]
Bases:
BoundaryShapeConstructor.
- Parameters:
patch_list (list) – A list of patches (each one can be a Circle, Rectangle, Polygon, etc.)
- append_circle(radius, x_center=0.0, y_center=0.0)[source]
Appends a circle.
- Parameters:
radius (float) – The radius of the circle.
x_center (float) – The x coordinate of the center of the circle.
y_center (float) – The y coordinate of the center of the circle.
- append_ellipse(a_axis_min, a_axis_max, b_axis_min, b_axis_max)[source]
Appends an ellipse.
- Parameters:
a_axis_min (float, optional) – The coordinate (signed) of the minimum (left) along the major axis.
a_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the major axis.
b_axis_min (float, optional) – TThe coordinate (signed) of the minimum (left) along the minor axis.
b_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis.
- append_polygon(x, y)[source]
Appends a polygon.
- Parameters:
x (list) – The polygon X coordinates.
y (list) – The polygon Y coordinates.
- append_rectangle(x_left=-0.01, x_right=0.01, y_bottom=-0.02, y_top=0.02)[source]
Appends a rectangle.
- Parameters:
x_left (float, optional) – The coordinate (signed) of the minimum (left) along the X axis.
x_right (float, optional) – The coordinate (signed) of the maximum (right) along the X axis.
y_bottom (float, optional) – The coordinate (signed) of the minimum (left) along the Y axis.
y_top (float, optional) – The coordinate (signed) of the maximum (right) along the Y axis.
- get_boundaries()[source]
Returns a list with the concatenated boundaries of the sotred patches.
- Return type:
list
- get_name_of_patch(index)[source]
Returns the name of the patch with a given index.
- Parameters:
index (int) – The index of the wanted patch.
- Return type:
str
- get_patch(index)[source]
Returns the patch corresponding to a given index.
- Parameters:
index (int) – The index of the wanted patch.
- Return type:
instance of BoundaryShape (Circle, Rectangle, etc.).
- class syned.beamline.shape.NumericalMesh(xx=None, yy=None, zz=None, surface_data_file=None)[source]
Bases:
SurfaceShapeImplements an optical surface from a numerical mesh.
Constructor.
- Parameters:
xx (numpy array, optional) – The x vector.
yy (numpy array, optional) – The y vector.
zz (numpy array, optional) – The z (2D) array.
surface_data_file (str, optional) – a file name from where the dara may come.
Notes
This is exactly the same as OasysSurfaceData class OasysSurfaceData(object), with added methods.
- class syned.beamline.shape.ParabolicCylinder(parabola_parameter=0.0, at_infinity=0, pole_to_focus=None, convexity=0, cylinder_direction=0)[source]
Bases:
Paraboloid,CylinderConstructor.
- Parameters:
parabola_parameter (float, optional) – parabola_parameter = 2 * focal_distance = - 0.5 * ccc_9 / ccc_2.
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
pole_to_focus (float, optional) – The p distance.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- classmethod create_parabolic_cylinder_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, at_infinity=0, convexity=0, cylinder_direction=0)[source]
Returns a ParabolicCylinder instance from factory parameters.
- Parameters:
p (float) – The distance p (used if at_infinity=Side.IMAGE)
q (float) – The distance q (used if at_infinity=Side.SOURCE)
grazing_angle (float) – The distance p
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of ParabolicCylinder
- classmethod create_parabolic_cylinder_from_parabola_parameter(parabola_parameter=0.0, at_infinity=0, pole_to_focus=None, convexity=0, cylinder_direction=0)[source]
Returns a ParabolicCylinder instance.
- Parameters:
parabola_parameter (float, optional) – parabola_parameter = 2 * focal_distance = - 0.5 * ccc_9 / ccc_2.
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
pole_to_focus (float, optional) – The p distance.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of ParabolicCylinder
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, at_infinity=0)[source]
Sets the parameters calculated from factory parameters.
- Parameters:
p (float) – The distance p (used if at_infinity=Side.IMAGE)
q (float) – The distance q (used if at_infinity=Side.SOURCE)
grazing_angle (float) – The distance p
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
- Return type:
instance of ParabolicCylinder
- class syned.beamline.shape.Paraboloid(parabola_parameter=0.0, at_infinity=0, pole_to_focus=None, convexity=0)[source]
Bases:
SurfaceShapeConstructor.
Paraboloid: Revolution paraboloid (rotation around symmetry axis).
It is defined with three parameters: the parabola_parameter and two more parameters defining the position of the origin of the mirror.
The parabola_parameter = 2 * focal_length = - 0.5 * ccc_9 / ccc_2
The additional parameter can be the focal distances (“p” or “q”, one is infinity), “x0”, “y0” or the grazing angle. Here, we selected the at_infinity and the finite focal distance p or q or distance from the mirror pole to focus (pole to focus).
The parabola equation is:
ccc_2 y^2 + ccc_9 z = 0 or
y^2 = -ccc_9/ccc_2 z = 2 parabola_parameter z = 4 focal_length z
The focus is at (0, 0, focal_length).
The directrix is at (0, 0, -focal_length).
The distance from the directrix to focus is 2 * focal_length.
The radius of curvature at the vertex is 2 * focal_length.
- Parameters:
parabola_parameter (float, optional) – parabola_parameter = 2 * focal_length = - 0.5 * ccc_9 / ccc_2. Equation: y^2 = 2 parabola_parameter z.
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
pole_to_focus (float, optional) – The p distance.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
References
https://en.wikipedia.org/wiki/Parabola
https://doi.org/10.1107/S1600577522004593
https://arxiv.org/abs/2406.04079
- classmethod create_paraboloid_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, at_infinity=0, convexity=0)[source]
Creates a paraboloid from the factory parameters.
- Parameters:
p (float) – The distance p (used if at_infinity=Side.IMAGE)
q (float) – The distance q (used if at_infinity=Side.SOURCE)
grazing_angle (float) – The distance p
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Paraboloid
- classmethod create_paraboloid_from_parabola_parameter(parabola_parameter=0.0, at_infinity=0, pole_to_focus=None, convexity=0)[source]
Create a paraboloid.
- Parameters:
parabola_parameter (float, optional) – parabola_parameter = 2 * focal_distance = - 0.5 * ccc_9 / ccc_2.
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
pole_to_focus (float, optional) – The p distance.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Paraboloid
- get_at_infinity()[source]
Returns the “at_infinity” flag.
- Returns:
SOURCE = 0, IMAGE = 1.
- Return type:
int (as defined by Side)
- classmethod get_parabola_parameter_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, at_infinity=0)[source]
Calculates the parabola parameter from the factory parameters.
- Parameters:
p (float) – The distance p (used if at_infinity=Side.IMAGE)
q (float) – The distance q (used if at_infinity=Side.SOURCE)
grazing_angle (float) – The distance p
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
- Returns:
The parabola parameter.
- Return type:
float
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, at_infinity=0)[source]
Sets the paraboloid parameters as calculated from the factory parameters.
- Parameters:
p (float) – The distance p (used if at_infinity=Side.IMAGE)
q (float) – The distance q (used if at_infinity=Side.SOURCE)
grazing_angle (float) – The distance p
at_infinity (int (as defined by Side), optional) – SOURCE = 0, IMAGE = 1.
- Return type:
instance of Paraboloid
- class syned.beamline.shape.Plane[source]
Bases:
SurfaceShapeDefines a plane surface shape.
- class syned.beamline.shape.Polygon(x=[], y=[])[source]
Bases:
BoundaryShapeConstructor.
- Parameters:
x (list, optional) – A list with the X coordinates of the patch vertices.
y (list, optional) – A list with the Y coordinates of the patch vertices.
- check_inside(x, y)[source]
Checks if a set of points are inside the patch (closed as polygon).
- Parameters:
x0 (list) – The X coordinates of the points to check.
y0 (list) – The Y coordinates of the points to check.
- Returns:
0=No, 1=Yes (inside).
- Return type:
numpy array
References
- check_inside_one_point(x0, y0)[source]
Checks if a single point is inside the patch (closed as polygon).
- Parameters:
x0 (float) – The X coordinate pf the point to check.
y0 (float) – The Y coordinate pf the point to check.
- Return type:
boolean
References
- check_inside_vector(x0, y0)[source]
Checks if a set of points are inside the patch (closed as polygon).
- Parameters:
x0 (numpy array) – The X coordinates of the points to check.
y0 (numpy array) – The Y coordinates of the points to check.
- Returns:
0=No, 1=Yes (inside).
- Return type:
numpy array
References
- check_outside(x0, y0)[source]
Checks if a set of points are outside the patch (closed as polygon).
- Parameters:
x0 (list) – The X coordinates of the points to check.
y0 (list) – The Y coordinates of the points to check.
- Returns:
0=No, 1=Yes (outside).
- Return type:
numpy array
References
- get_boundaries()[source]
Returns the coordinates of the patch vertices.
- Returns:
(list_of_x_coordinates, list_of_y_coordinates).
- Return type:
tuple
- class syned.beamline.shape.Rectangle(x_left=-0.01, x_right=0.01, y_bottom=-0.02, y_top=0.02)[source]
Bases:
BoundaryShapeConstructor.
- Parameters:
x_left (float, optional) – The coordinate (signed) of the minimum (left) along the X axis.
x_right (float, optional) – The coordinate (signed) of the maximum (right) along the X axis.
y_bottom (float, optional) – The coordinate (signed) of the minimum (left) along the Y axis.
y_top (float, optional) – The coordinate (signed) of the maximum (right) along the Y axis.
- get_boundaries()[source]
Return the rectangle coordinates.
- Returns:
(x_left, x_right, y_bottom, y_top).
- Return type:
tuple
- set_boundaries(x_left=-0.01, x_right=0.01, y_bottom=-0.02, y_top=0.02)[source]
Sets the rectangle coordinates.
- Parameters:
x_left (float, optional) – The coordinate (signed) of the minimum (left) along the X axis.
x_right (float, optional) – The coordinate (signed) of the maximum (right) along the X axis.
y_bottom (float, optional) – The coordinate (signed) of the minimum (left) along the Y axis.
y_top (float, optional) – The coordinate (signed) of the maximum (right) along the Y axis.
- class syned.beamline.shape.Shape[source]
Bases:
SynedObjectConstructor.
- class syned.beamline.shape.Sphere(radius=1.0, convexity=0)[source]
Bases:
SurfaceShapeDefines an spherical surface.
- Parameters:
radius (float) – The sphere radius.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- classmethod create_sphere_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, convexity=0)[source]
Defines an spherical surface.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Sphere
- classmethod create_sphere_from_radius(radius=0.0, convexity=0)[source]
Defines an spherical surface.
- Parameters:
radius (float) – The sphere radius.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- Return type:
instance of Sphere
- get_radius()[source]
Returns the radius of the sphere.
- Returns:
The radius of the sphere.
- Return type:
float
- classmethod get_radius_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Calculates the radius of the sphere from factory parameters (1/p+1/q=2/(R sin theta_grazing)))
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- Returns:
the calculated radius.
- Return type:
float
- class syned.beamline.shape.SphericalCylinder(radius=1.0, convexity=0, cylinder_direction=0)[source]
-
Constructor.
- Parameters:
radius (float) – the radius of the circular section.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- classmethod create_spherical_cylinder_from_p_q(p=2.0, q=1.0, grazing_angle=0.003, convexity=0, cylinder_direction=0)[source]
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of SphericalCylinder
- classmethod create_spherical_cylinder_from_radius(radius=0.0, convexity=0, cylinder_direction=0)[source]
Creates a spherical cylinder.
- Parameters:
radius (float) – the radius of the circular section.
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
cylinder_direction (int (as defined by Direction), optional) – TANGENTIAL = 0, SAGITTAL = 1.
- Return type:
instance of SphericalCylinder
- classmethod get_radius_from_p_q_sagittal(p=2.0, q=1.0, grazing_angle=0.003)[source]
Calculates the sagittal radius from the factory parameters (1/p + 1/q = 2 sin(grazing_angle)/Rs).
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- Returns:
The calculated radius.
- Return type:
float
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Calculates and sets the radius of curvature in the corresponding direction (tangential or sagittal. :param p: distance source-optical element. :type p: float, optional :param q: distance optical element to focus. :type q: float, optional :param grazing_angle: grazing angle in rad. :type grazing_angle: float, optional
- class syned.beamline.shape.SurfaceShape(convexity=0)[source]
Bases:
ShapeConstructor.
- Parameters:
convexity (int (as defined by Convexity), optional) – NONE = -1, UPWARD = 0, DOWNWARD = 1.
- class syned.beamline.shape.Toroid(min_radius=0.0, maj_radius=0.0)[source]
Bases:
SurfaceShapeCreator.
- Parameters:
min_radius (float, optional) – The toroid minor radius
maj_radius (float, optional) – The toroid major radius. Note that this is the “optical” major radius at the farest surface from the center of the toroid. Indeed, it corresponds to the “toroid major radius” plus the min_radius.
- classmethod create_toroid_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
returns a Toroid from factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- Return type:
instance of Toroid
- classmethod create_toroid_from_radii(min_radius=0.0, maj_radius=0.0)[source]
returns a Toroid from main parameters (radii).
- Parameters:
min_radius (float, optional) – The toroid minor radius
maj_radius (float, optional) – The toroid major radius. Note that this is the “optical” major radius at the farest surface from the center of the toroid. Indeed, it corresponds to the “toroid major radius” plus the min_radius.
- Return type:
instance of Toroid
- initialize_from_p_q(p=2.0, q=1.0, grazing_angle=0.003)[source]
Sets the parameters calculated from the factory parameters.
- Parameters:
p (float, optional) – distance source-optical element.
q (float, optional) – distance optical element to focus.
grazing_angle (float, optional) – grazing angle in rad.
- class syned.beamline.shape.TwoEllipses(a1_axis_min=-1e-05, a1_axis_max=1e-05, b1_axis_min=-5e-06, b1_axis_max=5e-06, a2_axis_min=-2e-05, a2_axis_max=2e-05, b2_axis_min=-8e-06, b2_axis_max=8e-06)[source]
Bases:
BoundaryShapeConstructor.
- Parameters:
a1_axis_min (float, optional) – The coordinate (signed) of the minimum (left) along the major axis of ellipse 1.
a1_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the major axis of ellipse 1.
b1_axis_min (float, optional) – TThe coordinate (signed) of the minimum (left) along the minor axis of ellipse 1.
b1_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis of ellipse 1.
a2_axis_min (float, optional) – The coordinate (signed) of the minimum (left) along the major axis of ellipse 2.
a2_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the major axis of ellipse 2.
b2_axis_min (float, optional) – TThe coordinate (signed) of the minimum (left) along the minor axis of ellipse 2.
b2_axis_max (float, optional) – The coordinate (signed) of the maximum (right) along the minor axis of ellipse 2.