syned 1.0.47__py3-none-any.whl → 1.0.49__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. syned/beamline/__init__.py +1 -1
  2. syned/beamline/beamline.py +155 -155
  3. syned/beamline/beamline_element.py +76 -76
  4. syned/beamline/element_coordinates.py +199 -199
  5. syned/beamline/optical_element.py +47 -47
  6. syned/beamline/optical_element_with_surface_shape.py +126 -126
  7. syned/beamline/optical_elements/__init__.py +1 -1
  8. syned/beamline/optical_elements/absorbers/absorber.py +21 -21
  9. syned/beamline/optical_elements/absorbers/beam_stopper.py +63 -63
  10. syned/beamline/optical_elements/absorbers/filter.py +61 -61
  11. syned/beamline/optical_elements/absorbers/holed_filter.py +67 -67
  12. syned/beamline/optical_elements/absorbers/slit.py +80 -80
  13. syned/beamline/optical_elements/crystals/__init__.py +1 -1
  14. syned/beamline/optical_elements/crystals/crystal.py +70 -70
  15. syned/beamline/optical_elements/gratings/__init__.py +1 -1
  16. syned/beamline/optical_elements/gratings/grating.py +279 -279
  17. syned/beamline/optical_elements/ideal_elements/__init__.py +1 -1
  18. syned/beamline/optical_elements/ideal_elements/ideal_element.py +15 -15
  19. syned/beamline/optical_elements/ideal_elements/ideal_fzp.py +183 -183
  20. syned/beamline/optical_elements/ideal_elements/ideal_lens.py +54 -54
  21. syned/beamline/optical_elements/ideal_elements/screen.py +15 -15
  22. syned/beamline/optical_elements/mirrors/__init__.py +1 -1
  23. syned/beamline/optical_elements/mirrors/mirror.py +39 -39
  24. syned/beamline/optical_elements/multilayers/__init__.py +46 -46
  25. syned/beamline/optical_elements/multilayers/multilayer.py +45 -45
  26. syned/beamline/optical_elements/refractors/__init__.py +1 -1
  27. syned/beamline/optical_elements/refractors/crl.py +79 -79
  28. syned/beamline/optical_elements/refractors/interface.py +60 -60
  29. syned/beamline/optical_elements/refractors/lens.py +105 -105
  30. syned/beamline/shape.py +2884 -2803
  31. syned/storage_ring/__init__.py +1 -1
  32. syned/storage_ring/electron_beam.py +804 -804
  33. syned/storage_ring/empty_light_source.py +40 -40
  34. syned/storage_ring/light_source.py +90 -90
  35. syned/storage_ring/magnetic_structure.py +8 -8
  36. syned/storage_ring/magnetic_structures/__init__.py +1 -1
  37. syned/storage_ring/magnetic_structures/bending_magnet.py +329 -329
  38. syned/storage_ring/magnetic_structures/insertion_device.py +169 -169
  39. syned/storage_ring/magnetic_structures/undulator.py +413 -413
  40. syned/storage_ring/magnetic_structures/wiggler.py +27 -27
  41. syned/syned_object.py +273 -264
  42. syned/util/__init__.py +21 -21
  43. syned/util/json_tools.py +196 -198
  44. syned/widget/widget_decorator.py +66 -66
  45. {syned-1.0.47.dist-info → syned-1.0.49.dist-info}/METADATA +88 -88
  46. syned-1.0.49.dist-info/RECORD +52 -0
  47. {syned-1.0.47.dist-info → syned-1.0.49.dist-info}/WHEEL +1 -1
  48. {syned-1.0.47.dist-info → syned-1.0.49.dist-info}/licenses/LICENSE +20 -20
  49. syned/__test/__init__.py +0 -46
  50. syned/__test/test.py +0 -28
  51. syned-1.0.47.dist-info/RECORD +0 -54
  52. {syned-1.0.47.dist-info → syned-1.0.49.dist-info}/top_level.txt +0 -0
@@ -1,126 +1,126 @@
1
- """
2
- Base classes for optical elements with shape(s).
3
-
4
- * OpticalElementsWithSurfaceShape (e.g. an elliptical mirror).
5
- * OpticalElementsWithMultipleShapes (e.g. a lens that has two surfaces).
6
- """
7
- from syned.beamline.optical_element import OpticalElement
8
- from syned.beamline.shape import SurfaceShape
9
-
10
- class OpticalElementsWithMultipleShapes(OpticalElement):
11
- """
12
- Constructor.
13
-
14
- Parameters
15
- ----------
16
- name : str
17
- The optical elemnt name.
18
- surface_shapes : list
19
- List with surface shapes (instances of SurfaceShape)
20
- boundary_shape : instance of BoundaryShape, optional
21
- The element shape. The default=None means no shape associated to the optical element.
22
-
23
- """
24
-
25
- def __init__(self, name="",
26
- surface_shapes=None,
27
- boundary_shape=None):
28
- super().__init__(name, boundary_shape)
29
- if surface_shapes is None: surface_shapes = [SurfaceShape()]
30
- if not isinstance(surface_shapes, list): raise ValueError("surface_shapes must of type 'list'")
31
- self._surface_shapes = surface_shapes
32
-
33
- def get_surface_shape(self, index):
34
- """
35
- Gets the surface shape.
36
-
37
- Parameters
38
- ----------
39
- index : int
40
- The index of the requested surface shape in the list.
41
-
42
- Returns
43
- -------
44
- instance of SurfaceShape
45
- The requested surface shape.
46
-
47
- """
48
- try: return self._surface_shapes[index]
49
- except: raise Exception("only " + str(len(self._surface_shapes)) + " shapes in OpticalElementsWithMultipleShapes")
50
-
51
- def set_surface_shape(self, index, surface_shape=None):
52
- """
53
- Sets a surface shape.
54
-
55
- Parameters
56
- ----------
57
- index : int
58
- The index of the surface shape to be set in the list.
59
- surface_shape : instances of SurfaceShape, optional
60
- The surface shape to be set (If None, initialize to SurfaceShape())
61
-
62
- """
63
- if surface_shape is None: surface_shape = SurfaceShape()
64
- try: self._surface_shapes[index] = surface_shape
65
- except: raise Exception("only " + str(len(self._surface_shapes)) + " shapes in OpticalElementsWithMultipleShapes")
66
-
67
- class OpticalElementsWithSurfaceShape(OpticalElementsWithMultipleShapes):
68
- """
69
- Constructor.
70
-
71
- Parameters
72
- ----------
73
- name : str
74
- The optical elemnt name.
75
- surface_shape : instances of SurfaceShape
76
- The surface shape.
77
- boundary_shape : instance of BoundaryShape, optional
78
- The element shape. The default=None means no shape associated to the optical element.
79
- """
80
- def __init__(self, name, surface_shape=None, boundary_shape=None):
81
- super(OpticalElementsWithSurfaceShape, self).__init__(name=name,
82
- boundary_shape=boundary_shape,
83
- surface_shapes=[surface_shape])
84
-
85
- # these definitions are necessary to define self._surface_shape which is needed to
86
- # build the object instance from json files.
87
- @property
88
- def _surface_shape(self):
89
- return self.get_surface_shape()
90
-
91
- @_surface_shape.setter
92
- def _surface_shape(self, value):
93
- self.set_surface_shape(value)
94
-
95
- def get_surface_shape(self):
96
- """
97
- Gets the surface shape.
98
-
99
- Returns
100
- -------
101
- instance of SurfaceShape
102
- The requested surface shape.
103
-
104
- """
105
- return super(OpticalElementsWithSurfaceShape, self).get_surface_shape(index=0)
106
-
107
- def set_surface_shape(self, surface_shape=None):
108
- """
109
- Sets a surface shape.
110
-
111
- Parameters
112
- ----------
113
- surface_shape : instances of SurfaceShape, optional
114
- The surface shape to be set (If None, initialize to SurfaceShape())
115
-
116
- """
117
- super(OpticalElementsWithSurfaceShape, self).set_surface_shape(index=0, surface_shape=surface_shape)
118
-
119
-
120
- if __name__=="__main__":
121
- from syned.beamline.shape import Cylinder, EllipticalCylinder
122
-
123
- oe = OpticalElementsWithSurfaceShape(name="TEST", surface_shape=Cylinder())
124
- print(oe.get_surface_shape())
125
- oe.set_surface_shape(surface_shape=EllipticalCylinder())
126
- print(oe.get_surface_shape())
1
+ """
2
+ Base classes for optical elements with shape(s).
3
+
4
+ * OpticalElementsWithSurfaceShape (e.g. an elliptical mirror).
5
+ * OpticalElementsWithMultipleShapes (e.g. a lens that has two surfaces).
6
+ """
7
+ from syned.beamline.optical_element import OpticalElement
8
+ from syned.beamline.shape import SurfaceShape
9
+
10
+ class OpticalElementsWithMultipleShapes(OpticalElement):
11
+ """
12
+ Constructor.
13
+
14
+ Parameters
15
+ ----------
16
+ name : str
17
+ The optical elemnt name.
18
+ surface_shapes : list
19
+ List with surface shapes (instances of SurfaceShape)
20
+ boundary_shape : instance of BoundaryShape, optional
21
+ The element shape. The default=None means no shape associated to the optical element.
22
+
23
+ """
24
+
25
+ def __init__(self, name="",
26
+ surface_shapes=None,
27
+ boundary_shape=None):
28
+ super().__init__(name, boundary_shape)
29
+ if surface_shapes is None: surface_shapes = [SurfaceShape()]
30
+ if not isinstance(surface_shapes, list): raise ValueError("surface_shapes must of type 'list'")
31
+ self._surface_shapes = surface_shapes
32
+
33
+ def get_surface_shape(self, index):
34
+ """
35
+ Gets the surface shape.
36
+
37
+ Parameters
38
+ ----------
39
+ index : int
40
+ The index of the requested surface shape in the list.
41
+
42
+ Returns
43
+ -------
44
+ instance of SurfaceShape
45
+ The requested surface shape.
46
+
47
+ """
48
+ try: return self._surface_shapes[index]
49
+ except: raise Exception("only " + str(len(self._surface_shapes)) + " shapes in OpticalElementsWithMultipleShapes")
50
+
51
+ def set_surface_shape(self, index, surface_shape=None):
52
+ """
53
+ Sets a surface shape.
54
+
55
+ Parameters
56
+ ----------
57
+ index : int
58
+ The index of the surface shape to be set in the list.
59
+ surface_shape : instances of SurfaceShape, optional
60
+ The surface shape to be set (If None, initialize to SurfaceShape())
61
+
62
+ """
63
+ if surface_shape is None: surface_shape = SurfaceShape()
64
+ try: self._surface_shapes[index] = surface_shape
65
+ except: raise Exception("only " + str(len(self._surface_shapes)) + " shapes in OpticalElementsWithMultipleShapes")
66
+
67
+ class OpticalElementsWithSurfaceShape(OpticalElementsWithMultipleShapes):
68
+ """
69
+ Constructor.
70
+
71
+ Parameters
72
+ ----------
73
+ name : str
74
+ The optical elemnt name.
75
+ surface_shape : instances of SurfaceShape
76
+ The surface shape.
77
+ boundary_shape : instance of BoundaryShape, optional
78
+ The element shape. The default=None means no shape associated to the optical element.
79
+ """
80
+ def __init__(self, name, surface_shape=None, boundary_shape=None):
81
+ super(OpticalElementsWithSurfaceShape, self).__init__(name=name,
82
+ boundary_shape=boundary_shape,
83
+ surface_shapes=[surface_shape])
84
+
85
+ # these definitions are necessary to define self._surface_shape which is needed to
86
+ # build the object instance from json files.
87
+ @property
88
+ def _surface_shape(self):
89
+ return self.get_surface_shape()
90
+
91
+ @_surface_shape.setter
92
+ def _surface_shape(self, value):
93
+ self.set_surface_shape(value)
94
+
95
+ def get_surface_shape(self):
96
+ """
97
+ Gets the surface shape.
98
+
99
+ Returns
100
+ -------
101
+ instance of SurfaceShape
102
+ The requested surface shape.
103
+
104
+ """
105
+ return super(OpticalElementsWithSurfaceShape, self).get_surface_shape(index=0)
106
+
107
+ def set_surface_shape(self, surface_shape=None):
108
+ """
109
+ Sets a surface shape.
110
+
111
+ Parameters
112
+ ----------
113
+ surface_shape : instances of SurfaceShape, optional
114
+ The surface shape to be set (If None, initialize to SurfaceShape())
115
+
116
+ """
117
+ super(OpticalElementsWithSurfaceShape, self).set_surface_shape(index=0, surface_shape=surface_shape)
118
+
119
+
120
+ if __name__=="__main__":
121
+ from syned.beamline.shape import Cylinder, EllipticalCylinder
122
+
123
+ oe = OpticalElementsWithSurfaceShape(name="TEST", surface_shape=Cylinder())
124
+ print(oe.get_surface_shape())
125
+ oe.set_surface_shape(surface_shape=EllipticalCylinder())
126
+ print(oe.get_surface_shape())
@@ -1 +1 @@
1
-
1
+
@@ -1,21 +1,21 @@
1
-
2
- from syned.beamline.optical_element import OpticalElement
3
- from syned.beamline.shape import BoundaryShape
4
-
5
- class Absorber(OpticalElement):
6
- """
7
- Base class for optical element category "absorbers" (filters, slits, etc.)
8
-
9
- Constructor.
10
-
11
- Parameters
12
- ----------
13
- name : str
14
- The name of the optical element.
15
- boundary_shape : instance of BoundaryShape, optional
16
- if None, it is initialized to BoundaryShape().
17
-
18
- """
19
- def __init__(self, name="Undefined", boundary_shape=None):
20
- if boundary_shape is None: boundary_shape = BoundaryShape()
21
- OpticalElement.__init__(self, name=name, boundary_shape=boundary_shape)
1
+
2
+ from syned.beamline.optical_element import OpticalElement
3
+ from syned.beamline.shape import BoundaryShape
4
+
5
+ class Absorber(OpticalElement):
6
+ """
7
+ Base class for optical element category "absorbers" (filters, slits, etc.)
8
+
9
+ Constructor.
10
+
11
+ Parameters
12
+ ----------
13
+ name : str
14
+ The name of the optical element.
15
+ boundary_shape : instance of BoundaryShape, optional
16
+ if None, it is initialized to BoundaryShape().
17
+
18
+ """
19
+ def __init__(self, name="Undefined", boundary_shape=None):
20
+ if boundary_shape is None: boundary_shape = BoundaryShape()
21
+ OpticalElement.__init__(self, name=name, boundary_shape=boundary_shape)
@@ -1,64 +1,64 @@
1
-
2
- from syned.beamline.shape import BoundaryShape
3
- from syned.beamline.shape import Rectangle, Ellipse
4
-
5
- from syned.beamline.optical_elements.absorbers.absorber import Absorber
6
-
7
- class BeamStopper(Absorber):
8
- """
9
- Beam-stopper or obstruction.
10
-
11
- Constructor.
12
-
13
- Note that:
14
- Slit BeamStopper Filter HoledFilter
15
- beam pass at center Yes No Yes No
16
- apply attenuation No No Yes Yes
17
-
18
- Parameters
19
- ----------
20
- name : str
21
- The name of the optical element.
22
- boundary_shape : instance of BoundaryShape, optional
23
- The geometry of the slit aperture. if None, it is initialized to BoundaryShape().
24
-
25
- """
26
- def __init__(self, name="Undefined", boundary_shape=None):
27
- if boundary_shape is None: boundary_shape = BoundaryShape()
28
- Absorber.__init__(self, name=name, boundary_shape=boundary_shape)
29
-
30
- def set_rectangle(self,width=3e-3,height=4e-3):
31
- """
32
- Sets the stopper as a rectangle.
33
-
34
- Parameters
35
- ----------
36
- width : float, optional
37
- The rectangle width.
38
- length : float, optional
39
- The rectangle length.
40
- center_x : float, optional
41
- The center coordinate X.
42
- center_y : float, optional
43
- The center coordinate Y.
44
-
45
- """
46
- self._boundary_shape=Rectangle(-0.5*width,0.5*width,-0.5*height,0.5*height)
47
-
48
- def set_circle(self,radius=3e-3):
49
- """
50
- Sets the stopper as a circle.
51
-
52
- Parameters
53
- ----------
54
- radius : float
55
- The radius of the circle.
56
- center_x : float
57
- The x coordinate of the center of the circle.
58
- center_y : float
59
- The y coordinate of the center of the circle.
60
-
61
- """
62
- self._boundary_shape=Ellipse(-0.5*radius,0.5*radius,-0.5*radius,0.5*radius)
63
-
1
+
2
+ from syned.beamline.shape import BoundaryShape
3
+ from syned.beamline.shape import Rectangle, Ellipse
4
+
5
+ from syned.beamline.optical_elements.absorbers.absorber import Absorber
6
+
7
+ class BeamStopper(Absorber):
8
+ """
9
+ Beam-stopper or obstruction.
10
+
11
+ Constructor.
12
+
13
+ Note that:
14
+ Slit BeamStopper Filter HoledFilter
15
+ beam pass at center Yes No Yes No
16
+ apply attenuation No No Yes Yes
17
+
18
+ Parameters
19
+ ----------
20
+ name : str
21
+ The name of the optical element.
22
+ boundary_shape : instance of BoundaryShape, optional
23
+ The geometry of the slit aperture. if None, it is initialized to BoundaryShape().
24
+
25
+ """
26
+ def __init__(self, name="Undefined", boundary_shape=None):
27
+ if boundary_shape is None: boundary_shape = BoundaryShape()
28
+ Absorber.__init__(self, name=name, boundary_shape=boundary_shape)
29
+
30
+ def set_rectangle(self,width=3e-3,height=4e-3):
31
+ """
32
+ Sets the stopper as a rectangle.
33
+
34
+ Parameters
35
+ ----------
36
+ width : float, optional
37
+ The rectangle width.
38
+ length : float, optional
39
+ The rectangle length.
40
+ center_x : float, optional
41
+ The center coordinate X.
42
+ center_y : float, optional
43
+ The center coordinate Y.
44
+
45
+ """
46
+ self._boundary_shape=Rectangle(-0.5*width,0.5*width,-0.5*height,0.5*height)
47
+
48
+ def set_circle(self,radius=3e-3):
49
+ """
50
+ Sets the stopper as a circle.
51
+
52
+ Parameters
53
+ ----------
54
+ radius : float
55
+ The radius of the circle.
56
+ center_x : float
57
+ The x coordinate of the center of the circle.
58
+ center_y : float
59
+ The y coordinate of the center of the circle.
60
+
61
+ """
62
+ self._boundary_shape=Ellipse(-0.5*radius,0.5*radius,-0.5*radius,0.5*radius)
63
+
64
64
  #TODO: add set_ellipse (like in slit).
@@ -1,61 +1,61 @@
1
-
2
- from syned.beamline.optical_elements.absorbers.absorber import Absorber
3
-
4
- class Filter(Absorber):
5
- """
6
- Filter or absorber or attenuator.
7
-
8
- Note that:
9
- Slit BeamStopper Filter HoledFilter
10
- beam pass at center Yes No Yes No
11
- apply attenuation No No Yes Yes
12
-
13
- Constructor.
14
-
15
- Parameters
16
- ----------
17
- name : str
18
- The name of the optical element.
19
- material : str
20
- A string defining the material.
21
- thickness : float
22
- The filter thickness in m.
23
- boundary_shape : instance of BoundaryShape, optional
24
- if None, it is initialized to BoundaryShape().
25
- """
26
- def __init__(self,
27
- name="Undefined",
28
- material="Be",
29
- thickness=1e-3,
30
- boundary_shape=None):
31
- Absorber.__init__(self, name=name, boundary_shape=boundary_shape)
32
- self._material = material
33
- self._thickness = thickness
34
-
35
- # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
36
- self._set_support_text([
37
- ("material" , "Material (symbol, formula or name)", "" ),
38
- ("thickness" , "Thickness ", "m" ),
39
- ])
40
-
41
- def get_material(self):
42
- """
43
- Returns the material name.
44
-
45
- Returns
46
- -------
47
- str
48
-
49
- """
50
- return self._material
51
-
52
- def get_thickness(self):
53
- """
54
- Retuirns the filter thickness in m.
55
-
56
- Returns
57
- -------
58
- float
59
-
60
- """
61
- return self._thickness
1
+
2
+ from syned.beamline.optical_elements.absorbers.absorber import Absorber
3
+
4
+ class Filter(Absorber):
5
+ """
6
+ Filter or absorber or attenuator.
7
+
8
+ Note that:
9
+ Slit BeamStopper Filter HoledFilter
10
+ beam pass at center Yes No Yes No
11
+ apply attenuation No No Yes Yes
12
+
13
+ Constructor.
14
+
15
+ Parameters
16
+ ----------
17
+ name : str
18
+ The name of the optical element.
19
+ material : str
20
+ A string defining the material.
21
+ thickness : float
22
+ The filter thickness in m.
23
+ boundary_shape : instance of BoundaryShape, optional
24
+ if None, it is initialized to BoundaryShape().
25
+ """
26
+ def __init__(self,
27
+ name="Undefined",
28
+ material="Be",
29
+ thickness=1e-3,
30
+ boundary_shape=None):
31
+ Absorber.__init__(self, name=name, boundary_shape=boundary_shape)
32
+ self._material = material
33
+ self._thickness = thickness
34
+
35
+ # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
36
+ self._set_support_text([
37
+ ("material" , "Material (symbol, formula or name)", "" ),
38
+ ("thickness" , "Thickness ", "m" ),
39
+ ])
40
+
41
+ def get_material(self):
42
+ """
43
+ Returns the material name.
44
+
45
+ Returns
46
+ -------
47
+ str
48
+
49
+ """
50
+ return self._material
51
+
52
+ def get_thickness(self):
53
+ """
54
+ Retuirns the filter thickness in m.
55
+
56
+ Returns
57
+ -------
58
+ float
59
+
60
+ """
61
+ return self._thickness