syned 1.0.48__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 -275
  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.48.dist-info → syned-1.0.49.dist-info}/METADATA +88 -87
  46. syned-1.0.49.dist-info/RECORD +52 -0
  47. {syned-1.0.48.dist-info → syned-1.0.49.dist-info}/WHEEL +1 -1
  48. {syned-1.0.48.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.48.dist-info/RECORD +0 -54
  52. {syned-1.0.48.dist-info → syned-1.0.49.dist-info}/top_level.txt +0 -0
@@ -1,183 +1,183 @@
1
- import numpy
2
- from syned.beamline.optical_elements.ideal_elements.ideal_element import IdealElement
3
-
4
- class IdealFZP(IdealElement):
5
- """
6
- Defines an ideal Fresnel Zone Plate.
7
-
8
- Constructor.
9
-
10
- Parameters
11
- ----------
12
- name : str, optional
13
- The name of the optical element.
14
- focusing_direction : int
15
- 0=None, 1=x (sagittal), 2=z (meridional), 3=2D focusing.
16
- focal : float
17
- The focal length in meters.
18
- nominal_wavelength : float
19
- The nominal wavelength in m for where the focal length is defined.
20
- diameter : float
21
- The FZP diameter in m.
22
-
23
- """
24
- def __init__(self,
25
- name="Undefined",
26
- focusing_direction=3, # 0=None, 1=x (sagittal), 2=z (meridional), 3=2D focusing.
27
- focal=1.0, # focal distance (m)
28
- nominal_wavelength=1e-10, # nominal wavelength in m
29
- # r0=10.0e-6, # inner zone radius (m)
30
- diameter=0.001, # FZP diameter in m
31
- ):
32
- IdealElement.__init__(self, name=name)
33
- self._focusing_direction = focusing_direction
34
- self._focal = focal
35
- self._nominal_wavelength = nominal_wavelength
36
- self._diameter = diameter
37
-
38
- # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
39
- self._set_support_text([
40
- ("name" , "Name" , ""),
41
- ("boundary_shape" , "" , ""),
42
- ("focusing_direction", "Focusing direction: 0=None, 1=1D along X, 2=1D along Z, 3=2D", ""),
43
- ("focal" , "Focal length" , "m"),
44
- ("nominal_wavelength", "Nominal wavelength" , "m"),
45
- ("diameter" , "FZP diameter" , "m"),
46
- ] )
47
-
48
- def focusing_direction(self):
49
- """
50
- Returns the focusing direction.
51
-
52
- Returns
53
- -------
54
- int
55
- 0=None,
56
- 1=1D along X,
57
- 2=1D along Z,
58
- 3=2D.
59
- """
60
- return self._focusing_direction
61
-
62
- def focal(self):
63
- """
64
- Returns the focal length.
65
-
66
- Returns
67
- -------
68
- float
69
-
70
- """
71
- return self._focal
72
-
73
- def nominal_wavelength(self):
74
- """
75
- Returns the nominal wavelength.
76
-
77
- Returns
78
- -------
79
- float
80
-
81
- """
82
- return self._nominal_wavelength
83
-
84
- def diameter(self):
85
- """
86
- Returns the FZP diameter.
87
-
88
- Returns
89
- -------
90
- float
91
-
92
- """
93
- return self._diameter
94
-
95
- #
96
- # calculated. The exact expression is rn = sqrt( n lambda f + (n lambda / 2)**2 )
97
- #
98
- def rn(self):
99
- return 0.5 * self.diameter()
100
-
101
- def r0(self):
102
- """
103
- Returns the innermost radius (approximated calculation r0=sqrt(wavelength * focal)).
104
-
105
- Returns
106
- -------
107
- float
108
-
109
- """
110
- return numpy.sqrt(self.nominal_wavelength() * self.focal())
111
-
112
- def r0_exact(self):
113
- """
114
- Returns the innermost radius (exact calculation r0=sqrt(wavelength * focal + (wavelength/2)**2)).
115
-
116
- Returns
117
- -------
118
- float
119
-
120
- """
121
- return numpy.sqrt(self.nominal_wavelength() * self.focal() + (0.5 * self.nominal_wavelength())**2)
122
-
123
- def n_vs_r(self, r): # approximated if f >> diameter; eq 855 in Michette
124
- """
125
- Returns the zone number for a given distance r (approximated calculation).
126
-
127
- Returns
128
- -------
129
- float
130
-
131
- """
132
- return (r ** 2 / self.nominal_wavelength() / self.focal())
133
-
134
- def n_exact_vs_r(self, r): # Exact, solving n from rn = sqrt( n lambda f + (n lambda / 2)**2 )
135
- """
136
- Returns the zone number for a given distance r
137
- (exact calculation solving n from rn = sqrt( n lambda f + (n lambda / 2)**2).
138
-
139
- Returns
140
- -------
141
- float
142
-
143
- """
144
- nn = -2 * self.focal() + 2 * numpy.sqrt(self.focal()**2 + r**2)
145
- return nn / self.nominal_wavelength()
146
-
147
- def n(self):
148
- """
149
- Returns the zone number for a outermost zone (approximated calculation).
150
-
151
- Returns
152
- -------
153
- float
154
-
155
- """
156
- return self.n_vs_r( self.rn() )
157
-
158
- def n_exact(self):
159
- """
160
- Returns the zone number for a outermost zone (exact calculation using n_exact_vs_r() ).
161
-
162
- Returns
163
- -------
164
- float
165
-
166
- """
167
- return self.n_exact_vs_r(self.rn())
168
-
169
- if __name__ == "__main__":
170
- fzp = IdealFZP(
171
- name = "Undefined",
172
- focusing_direction = 3, # 0=None, 1=x (sagittal), 2=z (meridional), 3=2D focusing.
173
- focal = 1.0, # focal distance (m)
174
- nominal_wavelength = 1e-10, # nominal wavelength in m
175
- diameter = 0.001, # FZP diameter in m
176
- )
177
-
178
- print(fzp.info())
179
- print("r0, r0_exact: ", fzp.r0(), fzp.r0_exact())
180
- print("rn: ", fzp.rn())
181
- print("n, n_exact: ", fzp.n(), fzp.n_exact())
182
-
183
-
1
+ import numpy
2
+ from syned.beamline.optical_elements.ideal_elements.ideal_element import IdealElement
3
+
4
+ class IdealFZP(IdealElement):
5
+ """
6
+ Defines an ideal Fresnel Zone Plate.
7
+
8
+ Constructor.
9
+
10
+ Parameters
11
+ ----------
12
+ name : str, optional
13
+ The name of the optical element.
14
+ focusing_direction : int
15
+ 0=None, 1=x (sagittal), 2=z (meridional), 3=2D focusing.
16
+ focal : float
17
+ The focal length in meters.
18
+ nominal_wavelength : float
19
+ The nominal wavelength in m for where the focal length is defined.
20
+ diameter : float
21
+ The FZP diameter in m.
22
+
23
+ """
24
+ def __init__(self,
25
+ name="Undefined",
26
+ focusing_direction=3, # 0=None, 1=x (sagittal), 2=z (meridional), 3=2D focusing.
27
+ focal=1.0, # focal distance (m)
28
+ nominal_wavelength=1e-10, # nominal wavelength in m
29
+ # r0=10.0e-6, # inner zone radius (m)
30
+ diameter=0.001, # FZP diameter in m
31
+ ):
32
+ IdealElement.__init__(self, name=name)
33
+ self._focusing_direction = focusing_direction
34
+ self._focal = focal
35
+ self._nominal_wavelength = nominal_wavelength
36
+ self._diameter = diameter
37
+
38
+ # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
39
+ self._set_support_text([
40
+ ("name" , "Name" , ""),
41
+ ("boundary_shape" , "" , ""),
42
+ ("focusing_direction", "Focusing direction: 0=None, 1=1D along X, 2=1D along Z, 3=2D", ""),
43
+ ("focal" , "Focal length" , "m"),
44
+ ("nominal_wavelength", "Nominal wavelength" , "m"),
45
+ ("diameter" , "FZP diameter" , "m"),
46
+ ] )
47
+
48
+ def focusing_direction(self):
49
+ """
50
+ Returns the focusing direction.
51
+
52
+ Returns
53
+ -------
54
+ int
55
+ 0=None,
56
+ 1=1D along X,
57
+ 2=1D along Z,
58
+ 3=2D.
59
+ """
60
+ return self._focusing_direction
61
+
62
+ def focal(self):
63
+ """
64
+ Returns the focal length.
65
+
66
+ Returns
67
+ -------
68
+ float
69
+
70
+ """
71
+ return self._focal
72
+
73
+ def nominal_wavelength(self):
74
+ """
75
+ Returns the nominal wavelength.
76
+
77
+ Returns
78
+ -------
79
+ float
80
+
81
+ """
82
+ return self._nominal_wavelength
83
+
84
+ def diameter(self):
85
+ """
86
+ Returns the FZP diameter.
87
+
88
+ Returns
89
+ -------
90
+ float
91
+
92
+ """
93
+ return self._diameter
94
+
95
+ #
96
+ # calculated. The exact expression is rn = sqrt( n lambda f + (n lambda / 2)**2 )
97
+ #
98
+ def rn(self):
99
+ return 0.5 * self.diameter()
100
+
101
+ def r0(self):
102
+ """
103
+ Returns the innermost radius (approximated calculation r0=sqrt(wavelength * focal)).
104
+
105
+ Returns
106
+ -------
107
+ float
108
+
109
+ """
110
+ return numpy.sqrt(self.nominal_wavelength() * self.focal())
111
+
112
+ def r0_exact(self):
113
+ """
114
+ Returns the innermost radius (exact calculation r0=sqrt(wavelength * focal + (wavelength/2)**2)).
115
+
116
+ Returns
117
+ -------
118
+ float
119
+
120
+ """
121
+ return numpy.sqrt(self.nominal_wavelength() * self.focal() + (0.5 * self.nominal_wavelength())**2)
122
+
123
+ def n_vs_r(self, r): # approximated if f >> diameter; eq 855 in Michette
124
+ """
125
+ Returns the zone number for a given distance r (approximated calculation).
126
+
127
+ Returns
128
+ -------
129
+ float
130
+
131
+ """
132
+ return (r ** 2 / self.nominal_wavelength() / self.focal())
133
+
134
+ def n_exact_vs_r(self, r): # Exact, solving n from rn = sqrt( n lambda f + (n lambda / 2)**2 )
135
+ """
136
+ Returns the zone number for a given distance r
137
+ (exact calculation solving n from rn = sqrt( n lambda f + (n lambda / 2)**2).
138
+
139
+ Returns
140
+ -------
141
+ float
142
+
143
+ """
144
+ nn = -2 * self.focal() + 2 * numpy.sqrt(self.focal()**2 + r**2)
145
+ return nn / self.nominal_wavelength()
146
+
147
+ def n(self):
148
+ """
149
+ Returns the zone number for a outermost zone (approximated calculation).
150
+
151
+ Returns
152
+ -------
153
+ float
154
+
155
+ """
156
+ return self.n_vs_r( self.rn() )
157
+
158
+ def n_exact(self):
159
+ """
160
+ Returns the zone number for a outermost zone (exact calculation using n_exact_vs_r() ).
161
+
162
+ Returns
163
+ -------
164
+ float
165
+
166
+ """
167
+ return self.n_exact_vs_r(self.rn())
168
+
169
+ if __name__ == "__main__":
170
+ fzp = IdealFZP(
171
+ name = "Undefined",
172
+ focusing_direction = 3, # 0=None, 1=x (sagittal), 2=z (meridional), 3=2D focusing.
173
+ focal = 1.0, # focal distance (m)
174
+ nominal_wavelength = 1e-10, # nominal wavelength in m
175
+ diameter = 0.001, # FZP diameter in m
176
+ )
177
+
178
+ print(fzp.info())
179
+ print("r0, r0_exact: ", fzp.r0(), fzp.r0_exact())
180
+ print("rn: ", fzp.rn())
181
+ print("n, n_exact: ", fzp.n(), fzp.n_exact())
182
+
183
+
@@ -1,54 +1,54 @@
1
- from syned.beamline.optical_elements.ideal_elements.ideal_element import IdealElement
2
-
3
- class IdealLens(IdealElement):
4
- """
5
- Defines an ideal lens. It converts a plane wave into:
6
- * an spherical converging wave (if focal_x=focal_y).
7
- * a toroidal converging wave (if focal_x != focal_y).
8
- * a cylindrical wave (if focal_x or focal_y is infinity).
9
-
10
- Constructor.
11
-
12
- Parameters
13
- ----------
14
- name : str, optional
15
- The name of the optical element.
16
- focal_x : float
17
- The focal length in meters along the X direction.
18
- focal_y : float
19
- The focal length in meters along the Y direction.
20
-
21
- """
22
- def __init__(self, name="Undefined", focal_x=1.0, focal_y=1.0):
23
- IdealElement.__init__(self, name=name)
24
- self._focal_x = focal_x
25
- self._focal_y = focal_y
26
- # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
27
- self._set_support_text([
28
- ("name" , "Name" , ""),
29
- ("boundary_shape", "" , ""),
30
- ("focal_x" , "Focal length in x [horizontal]", "m" ),
31
- ("focal_y" , "Focal length in y [vertical]" , "m" ),
32
- ] )
33
-
34
- def focal_x(self):
35
- """
36
- Returns the focal length in the X direction.
37
-
38
- Returns
39
- -------
40
- float
41
-
42
- """
43
- return self._focal_x
44
-
45
- def focal_y(self):
46
- """
47
- Returns the focal length in the Y direction.
48
-
49
- Returns
50
- -------
51
- float
52
-
53
- """
54
- return self._focal_y
1
+ from syned.beamline.optical_elements.ideal_elements.ideal_element import IdealElement
2
+
3
+ class IdealLens(IdealElement):
4
+ """
5
+ Defines an ideal lens. It converts a plane wave into:
6
+ * an spherical converging wave (if focal_x=focal_y).
7
+ * a toroidal converging wave (if focal_x != focal_y).
8
+ * a cylindrical wave (if focal_x or focal_y is infinity).
9
+
10
+ Constructor.
11
+
12
+ Parameters
13
+ ----------
14
+ name : str, optional
15
+ The name of the optical element.
16
+ focal_x : float
17
+ The focal length in meters along the X direction.
18
+ focal_y : float
19
+ The focal length in meters along the Y direction.
20
+
21
+ """
22
+ def __init__(self, name="Undefined", focal_x=1.0, focal_y=1.0):
23
+ IdealElement.__init__(self, name=name)
24
+ self._focal_x = focal_x
25
+ self._focal_y = focal_y
26
+ # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
27
+ self._set_support_text([
28
+ ("name" , "Name" , ""),
29
+ ("boundary_shape", "" , ""),
30
+ ("focal_x" , "Focal length in x [horizontal]", "m" ),
31
+ ("focal_y" , "Focal length in y [vertical]" , "m" ),
32
+ ] )
33
+
34
+ def focal_x(self):
35
+ """
36
+ Returns the focal length in the X direction.
37
+
38
+ Returns
39
+ -------
40
+ float
41
+
42
+ """
43
+ return self._focal_x
44
+
45
+ def focal_y(self):
46
+ """
47
+ Returns the focal length in the Y direction.
48
+
49
+ Returns
50
+ -------
51
+ float
52
+
53
+ """
54
+ return self._focal_y
@@ -1,16 +1,16 @@
1
- from syned.beamline.optical_elements.ideal_elements.ideal_element import IdealElement
2
-
3
- class Screen(IdealElement):
4
- """
5
- Defines an ideal screen (a plane perpendiculat to the optical axis).
6
-
7
- Constructor.
8
-
9
- Parameters
10
- ----------
11
- name : str, optional
12
- The name of the optical element.
13
-
14
- """
15
- def __init__(self, name="Undefined"):
1
+ from syned.beamline.optical_elements.ideal_elements.ideal_element import IdealElement
2
+
3
+ class Screen(IdealElement):
4
+ """
5
+ Defines an ideal screen (a plane perpendiculat to the optical axis).
6
+
7
+ Constructor.
8
+
9
+ Parameters
10
+ ----------
11
+ name : str, optional
12
+ The name of the optical element.
13
+
14
+ """
15
+ def __init__(self, name="Undefined"):
16
16
  IdealElement.__init__(self, name=name)
@@ -1 +1 @@
1
-
1
+
@@ -1,39 +1,39 @@
1
- from syned.beamline.shape import SurfaceShape
2
- from syned.beamline.optical_element_with_surface_shape import OpticalElementsWithSurfaceShape
3
-
4
- class Mirror(OpticalElementsWithSurfaceShape):
5
- """
6
- Constructor.
7
-
8
- Parameters
9
- ----------
10
- name : str
11
- The name of the optical element.
12
- surface_shape : instance of SurfaceShape, optional
13
- The geometry of the crystal surface. if None, it is initialized to SurfaceShape().
14
- boundary_shape : instance of BoundaryShape, optional
15
- The geometry of the slit aperture. if None, it is initialized to BoundaryShape().
16
- coating : str, optional
17
- The grating coating material.
18
- coating_thickness : float, optional
19
- The grating coating thickness in m.
20
- """
21
- def __init__(self,
22
- name="Undefined",
23
- surface_shape=SurfaceShape(),
24
- boundary_shape=None,
25
- coating=None,
26
- coating_thickness=None):
27
-
28
- super().__init__(name, surface_shape, boundary_shape)
29
- self._coating = coating
30
- self._coating_thickness = coating_thickness
31
- # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
32
- self._set_support_text([
33
- ("name", "Name" , "" ),
34
- ("surface_shape", "Surface shape", "" ),
35
- ("boundary_shape", "Boundary shape", "" ),
36
- ("coating", "Coating (element, compound or name)", "" ),
37
- ("coating_thickness", "Coating thickness", "m"),
38
- ] )
39
-
1
+ from syned.beamline.shape import SurfaceShape
2
+ from syned.beamline.optical_element_with_surface_shape import OpticalElementsWithSurfaceShape
3
+
4
+ class Mirror(OpticalElementsWithSurfaceShape):
5
+ """
6
+ Constructor.
7
+
8
+ Parameters
9
+ ----------
10
+ name : str
11
+ The name of the optical element.
12
+ surface_shape : instance of SurfaceShape, optional
13
+ The geometry of the crystal surface. if None, it is initialized to SurfaceShape().
14
+ boundary_shape : instance of BoundaryShape, optional
15
+ The geometry of the slit aperture. if None, it is initialized to BoundaryShape().
16
+ coating : str, optional
17
+ The grating coating material.
18
+ coating_thickness : float, optional
19
+ The grating coating thickness in m.
20
+ """
21
+ def __init__(self,
22
+ name="Undefined",
23
+ surface_shape=SurfaceShape(),
24
+ boundary_shape=None,
25
+ coating=None,
26
+ coating_thickness=None):
27
+
28
+ super().__init__(name, surface_shape, boundary_shape)
29
+ self._coating = coating
30
+ self._coating_thickness = coating_thickness
31
+ # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
32
+ self._set_support_text([
33
+ ("name", "Name" , "" ),
34
+ ("surface_shape", "Surface shape", "" ),
35
+ ("boundary_shape", "Boundary shape", "" ),
36
+ ("coating", "Coating (element, compound or name)", "" ),
37
+ ("coating_thickness", "Coating thickness", "m"),
38
+ ] )
39
+