syned 1.0.44__tar.gz → 1.0.46__tar.gz
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.
- {syned-1.0.44/syned.egg-info → syned-1.0.46}/PKG-INFO +1 -1
- {syned-1.0.44 → syned-1.0.46}/setup.py +1 -1
- syned-1.0.46/syned/__test/__init__.py +46 -0
- syned-1.0.46/syned/__test/test.py +28 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/electron_beam.py +64 -48
- {syned-1.0.44 → syned-1.0.46}/syned/syned_object.py +0 -10
- syned-1.0.46/syned/util/__init__.py +22 -0
- {syned-1.0.44 → syned-1.0.46/syned.egg-info}/PKG-INFO +1 -1
- {syned-1.0.44 → syned-1.0.46}/syned.egg-info/SOURCES.txt +2 -0
- syned-1.0.44/syned/widget/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/LICENSE +0 -0
- {syned-1.0.44 → syned-1.0.46}/MANIFEST.in +0 -0
- {syned-1.0.44 → syned-1.0.46}/README.rst +0 -0
- {syned-1.0.44 → syned-1.0.46}/setup.cfg +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/beamline.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/beamline_element.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/element_coordinates.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_element.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_element_with_surface_shape.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/absorbers/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/absorbers/absorber.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/absorbers/beam_stopper.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/absorbers/filter.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/absorbers/holed_filter.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/absorbers/slit.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/crystals/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/crystals/crystal.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/gratings/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/gratings/grating.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/ideal_elements/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/ideal_elements/ideal_element.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/ideal_elements/ideal_fzp.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/ideal_elements/ideal_lens.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/ideal_elements/screen.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/mirrors/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/mirrors/mirror.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/refractors/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/refractors/crl.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/refractors/interface.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/refractors/lens.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/beamline/shape.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/empty_light_source.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/light_source.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/magnetic_structure.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/magnetic_structures/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/magnetic_structures/bending_magnet.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/magnetic_structures/insertion_device.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/magnetic_structures/undulator.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/storage_ring/magnetic_structures/wiggler.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/util/json_tools.py +0 -0
- {syned-1.0.44/syned/util → syned-1.0.46/syned/widget}/__init__.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned/widget/widget_decorator.py +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned.egg-info/dependency_links.txt +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned.egg-info/not-zip-safe +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned.egg-info/requires.txt +0 -0
- {syned-1.0.44 → syned-1.0.46}/syned.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ----------------------------------------------------------------------- #
|
|
4
|
+
# Copyright (c) 2025, UChicago Argonne, LLC. All rights reserved. #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright 2025. UChicago Argonne, LLC. This software was produced #
|
|
7
|
+
# under U.S. Government contract DE-AC02-06CH11357 for Argonne National #
|
|
8
|
+
# Laboratory (ANL), which is operated by UChicago Argonne, LLC for the #
|
|
9
|
+
# U.S. Department of Energy. The U.S. Government has rights to use, #
|
|
10
|
+
# reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR #
|
|
11
|
+
# UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR #
|
|
12
|
+
# ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is #
|
|
13
|
+
# modified to produce derivative works, such modified software should #
|
|
14
|
+
# be clearly marked, so as not to confuse it with the version available #
|
|
15
|
+
# from ANL. #
|
|
16
|
+
# #
|
|
17
|
+
# Additionally, redistribution and use in source and binary forms, with #
|
|
18
|
+
# or without modification, are permitted provided that the following #
|
|
19
|
+
# conditions are met: #
|
|
20
|
+
# #
|
|
21
|
+
# * Redistributions of source code must retain the above copyright #
|
|
22
|
+
# notice, this list of conditions and the following disclaimer. #
|
|
23
|
+
# #
|
|
24
|
+
# * Redistributions in binary form must reproduce the above copyright #
|
|
25
|
+
# notice, this list of conditions and the following disclaimer in #
|
|
26
|
+
# the documentation and/or other materials provided with the #
|
|
27
|
+
# distribution. #
|
|
28
|
+
# #
|
|
29
|
+
# * Neither the name of UChicago Argonne, LLC, Argonne National #
|
|
30
|
+
# Laboratory, ANL, the U.S. Government, nor the names of its #
|
|
31
|
+
# contributors may be used to endorse or promote products derived #
|
|
32
|
+
# from this software without specific prior written permission. #
|
|
33
|
+
# #
|
|
34
|
+
# THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS #
|
|
35
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
|
|
36
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS #
|
|
37
|
+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago #
|
|
38
|
+
# Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, #
|
|
39
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, #
|
|
40
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #
|
|
41
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
|
|
42
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
|
|
43
|
+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN #
|
|
44
|
+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
|
|
45
|
+
# POSSIBILITY OF SUCH DAMAGE. #
|
|
46
|
+
# ----------------------------------------------------------------------- #
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import traceback
|
|
2
|
+
import warnings
|
|
3
|
+
warnings.simplefilter("always")
|
|
4
|
+
|
|
5
|
+
from syned.storage_ring.electron_beam import ElectronBeam
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
a = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,
|
|
9
|
+
current=0.2,
|
|
10
|
+
energy_spread=0.00095,
|
|
11
|
+
moment_xx =1.0,
|
|
12
|
+
moment_xxp =1.0,
|
|
13
|
+
moment_xpxp =1.0,
|
|
14
|
+
moment_yy =1.0,
|
|
15
|
+
moment_yyp =1.0,
|
|
16
|
+
moment_ypyp =1.0,
|
|
17
|
+
dispersion_x =1.0,
|
|
18
|
+
dispersion_y =1.0,
|
|
19
|
+
dispersionp_x=1.0,
|
|
20
|
+
dispersionp_y=1.0)
|
|
21
|
+
a.set_twiss_horizontal (0, 0, 0)
|
|
22
|
+
a.set_twiss_vertical (0, 1, 1, eta_y=2.0, etap_y=3.0)
|
|
23
|
+
|
|
24
|
+
print(a.info())
|
|
25
|
+
|
|
26
|
+
print(a.get_twiss_no_dispersion_all())
|
|
27
|
+
except:
|
|
28
|
+
traceback.print_exc()
|
|
@@ -4,9 +4,13 @@ Base class for electron beams.
|
|
|
4
4
|
This class is intentionally shorten for simplicity.
|
|
5
5
|
Usually we would need to consider also the electron distribution within the beam.
|
|
6
6
|
"""
|
|
7
|
-
from syned.syned_object import SynedObject
|
|
8
7
|
import scipy.constants as codata
|
|
9
8
|
import numpy
|
|
9
|
+
import warnings
|
|
10
|
+
|
|
11
|
+
from syned.util import deprecated
|
|
12
|
+
from syned.syned_object import SynedObject
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class ElectronBeam(SynedObject):
|
|
12
16
|
def __init__(self,
|
|
@@ -126,27 +130,39 @@ class ElectronBeam(SynedObject):
|
|
|
126
130
|
|
|
127
131
|
@classmethod
|
|
128
132
|
def _emittance_without_dispersion(cls, moment_ss, moment_sa, moment_aa):
|
|
129
|
-
return numpy.sqrt(moment_ss * moment_aa - moment_sa**2)
|
|
133
|
+
return float(numpy.sqrt(moment_ss * moment_aa - moment_sa**2))
|
|
130
134
|
|
|
131
135
|
@classmethod
|
|
132
136
|
def _emittance_with_dispersion(cls, moment_ss, moment_sa, moment_aa, energy_spread, dispersion_s, dispersion_a):
|
|
133
|
-
return numpy.sqrt((moment_ss + (dispersion_s * energy_spread) ** 2) *
|
|
134
|
-
|
|
137
|
+
return float(numpy.sqrt((moment_ss + (dispersion_s * energy_spread) ** 2) *
|
|
138
|
+
(moment_aa + (dispersion_a * energy_spread) ** 2) -
|
|
139
|
+
(moment_sa + dispersion_s * dispersion_a * energy_spread ** 2) ** 2))
|
|
135
140
|
|
|
136
141
|
@classmethod
|
|
137
142
|
def _get_twiss_from_moments(cls, moment_ss, moment_sa, moment_aa):
|
|
138
143
|
emittance = cls._emittance_without_dispersion(moment_ss, moment_sa, moment_aa)
|
|
139
|
-
alpha = -moment_sa / emittance
|
|
140
|
-
beta = moment_ss / emittance
|
|
141
|
-
gamma = (1 + alpha**2) / beta
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
if emittance == 0.0:
|
|
146
|
+
warnings.warn(message="All moments are 0.0 and the calculation is not possible. \u03b5 = \u03b1 = \u03b2 = \u03b3 = 0.0 is returned.",
|
|
147
|
+
category=UserWarning, stacklevel=2)
|
|
148
|
+
return 0.0, 0.0, 0.0, 0.0
|
|
149
|
+
else:
|
|
150
|
+
alpha = -moment_sa / emittance
|
|
151
|
+
beta = moment_ss / emittance
|
|
152
|
+
gamma = (1 + alpha**2) / beta
|
|
153
|
+
|
|
154
|
+
alpha = 0.0 if alpha == 0 else alpha # to avoid -0.0
|
|
144
155
|
|
|
145
|
-
|
|
156
|
+
return emittance, alpha, beta, gamma
|
|
146
157
|
|
|
147
158
|
@classmethod
|
|
148
159
|
def _get_moments_from_twiss_without_dispersion(cls, emittance, alpha, beta):
|
|
149
|
-
|
|
160
|
+
if beta == 0:
|
|
161
|
+
warnings.warn(message="With \u03b2 = 0.0 the calculation of \u03b3 is not possible. \u03b3 = 0.0 is used.",
|
|
162
|
+
category=UserWarning, stacklevel=2)
|
|
163
|
+
gamma = 0.0
|
|
164
|
+
else:
|
|
165
|
+
gamma = (1 + alpha ** 2) / beta
|
|
150
166
|
|
|
151
167
|
moment_ss = beta * emittance
|
|
152
168
|
moment_sa = -alpha * emittance
|
|
@@ -154,7 +170,7 @@ class ElectronBeam(SynedObject):
|
|
|
154
170
|
|
|
155
171
|
moment_sa = 0.0 if moment_sa == 0 else moment_sa # to avoid -0.0
|
|
156
172
|
|
|
157
|
-
return moment_ss, moment_sa, moment_aa
|
|
173
|
+
return float(moment_ss), float(moment_sa), float(moment_aa)
|
|
158
174
|
|
|
159
175
|
@classmethod
|
|
160
176
|
def _get_moments_with_dispersion(cls, moment_ss, moment_sa, moment_aa, energy_spread, dispersion_s, dispersion_a):
|
|
@@ -162,13 +178,13 @@ class ElectronBeam(SynedObject):
|
|
|
162
178
|
moment_sa_disp = moment_sa + dispersion_s * dispersion_a * (energy_spread ** 2)
|
|
163
179
|
moment_aa_disp = moment_aa + (dispersion_a * energy_spread) ** 2
|
|
164
180
|
|
|
165
|
-
return moment_ss_disp, moment_sa_disp, moment_aa_disp
|
|
181
|
+
return float(moment_ss_disp), float(moment_sa_disp), float(moment_aa_disp)
|
|
166
182
|
|
|
167
183
|
|
|
168
184
|
# --- GETTERS
|
|
169
185
|
# # ---------------------------------------------------------------------------------------------------------------------------------------------
|
|
170
186
|
#
|
|
171
|
-
def get_sigmas_horizontal(self, dispersion=
|
|
187
|
+
def get_sigmas_horizontal(self, dispersion=True):
|
|
172
188
|
"""
|
|
173
189
|
Returns the sigmas in horizontal direction.
|
|
174
190
|
|
|
@@ -181,9 +197,9 @@ class ElectronBeam(SynedObject):
|
|
|
181
197
|
|
|
182
198
|
moment_xx, _, moment_xpxp = self.get_moments_horizontal(dispersion)
|
|
183
199
|
|
|
184
|
-
return numpy.sqrt(moment_xx), numpy.sqrt(moment_xpxp)
|
|
200
|
+
return float(numpy.sqrt(moment_xx)), float(numpy.sqrt(moment_xpxp))
|
|
185
201
|
|
|
186
|
-
def get_sigmas_vertical(self, dispersion=
|
|
202
|
+
def get_sigmas_vertical(self, dispersion=True):
|
|
187
203
|
"""
|
|
188
204
|
Returns the sigmas in vertical direction.
|
|
189
205
|
|
|
@@ -195,9 +211,9 @@ class ElectronBeam(SynedObject):
|
|
|
195
211
|
"""
|
|
196
212
|
moment_yy, _, moment_ypyp = self.get_moments_vertical(dispersion)
|
|
197
213
|
|
|
198
|
-
return numpy.sqrt(moment_yy), numpy.sqrt(moment_ypyp)
|
|
214
|
+
return float(numpy.sqrt(moment_yy)), float(numpy.sqrt(moment_ypyp))
|
|
199
215
|
|
|
200
|
-
def get_sigmas_all(self, dispersion=
|
|
216
|
+
def get_sigmas_all(self, dispersion=True):
|
|
201
217
|
"""
|
|
202
218
|
Returns all sigmas.
|
|
203
219
|
|
|
@@ -213,7 +229,7 @@ class ElectronBeam(SynedObject):
|
|
|
213
229
|
|
|
214
230
|
return sigma_x, sigmap_x, sigma_y, sigmap_y
|
|
215
231
|
|
|
216
|
-
def get_moments_horizontal(self, dispersion=
|
|
232
|
+
def get_moments_horizontal(self, dispersion=True):
|
|
217
233
|
"""
|
|
218
234
|
Returns the moments in the horizontal direction.
|
|
219
235
|
|
|
@@ -223,7 +239,7 @@ class ElectronBeam(SynedObject):
|
|
|
223
239
|
( <x^2>, <x x'>, <x'^2>)
|
|
224
240
|
|
|
225
241
|
"""
|
|
226
|
-
if not dispersion: return self._moment_xx, self._moment_xxp, self._moment_xpxp
|
|
242
|
+
if not dispersion: return float(self._moment_xx), float(self._moment_xxp), float(self._moment_xpxp)
|
|
227
243
|
else: return self._get_moments_with_dispersion(self._moment_xx,
|
|
228
244
|
self._moment_xxp,
|
|
229
245
|
self._moment_xpxp,
|
|
@@ -231,7 +247,7 @@ class ElectronBeam(SynedObject):
|
|
|
231
247
|
self._dispersion_x,
|
|
232
248
|
self._dispersionp_x)
|
|
233
249
|
|
|
234
|
-
def get_moments_vertical(self, dispersion=
|
|
250
|
+
def get_moments_vertical(self, dispersion=True):
|
|
235
251
|
"""
|
|
236
252
|
Returns the moments in the vertical direction.
|
|
237
253
|
|
|
@@ -242,7 +258,7 @@ class ElectronBeam(SynedObject):
|
|
|
242
258
|
|
|
243
259
|
"""
|
|
244
260
|
|
|
245
|
-
if not dispersion: return self._moment_yy, self._moment_yyp, self._moment_ypyp
|
|
261
|
+
if not dispersion: return float(self._moment_yy), float(self._moment_yyp), float(self._moment_ypyp)
|
|
246
262
|
else: return self._get_moments_with_dispersion(self._moment_yy,
|
|
247
263
|
self._moment_yyp,
|
|
248
264
|
self._moment_ypyp,
|
|
@@ -250,7 +266,7 @@ class ElectronBeam(SynedObject):
|
|
|
250
266
|
self._dispersion_y,
|
|
251
267
|
self._dispersionp_y)
|
|
252
268
|
|
|
253
|
-
def get_moments_all(self, dispersion=
|
|
269
|
+
def get_moments_all(self, dispersion=True):
|
|
254
270
|
"""
|
|
255
271
|
Returns all moments.
|
|
256
272
|
|
|
@@ -542,16 +558,16 @@ class ElectronBeam(SynedObject):
|
|
|
542
558
|
self._moment_xpxp = moment_xpxp
|
|
543
559
|
|
|
544
560
|
# RETROCOMPATIBILITY
|
|
545
|
-
eta_x
|
|
546
|
-
etap_x = kwargs.get("etap_x",
|
|
561
|
+
eta_x = kwargs.get("eta_x", 0.0)
|
|
562
|
+
etap_x = kwargs.get("etap_x", 0.0)
|
|
547
563
|
|
|
548
|
-
if eta_x
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
564
|
+
if eta_x != 0.0 or etap_x != 0.0:
|
|
565
|
+
warnings.warn(message="Setting dispersion parameters with `set_twiss_horizontal(..., eta_x, etap_x)` is deprecated "
|
|
566
|
+
"and will be removed in a future version. "
|
|
567
|
+
"Use `set_dispersion_horizontal(eta_x, etap_x)` separately instead.",
|
|
568
|
+
category=DeprecationWarning, stacklevel=2)
|
|
569
|
+
self.set_dispersion_horizontal(0.0 if eta_x is None else eta_x,
|
|
570
|
+
0.0 if etap_x is None else etap_x)
|
|
555
571
|
|
|
556
572
|
def set_twiss_vertical(self, emittance_y, alpha_y, beta_y, **kwargs):
|
|
557
573
|
"""
|
|
@@ -578,12 +594,15 @@ class ElectronBeam(SynedObject):
|
|
|
578
594
|
self._moment_ypyp = moment_ypyp
|
|
579
595
|
|
|
580
596
|
# RETROCOMPATIBILITY
|
|
581
|
-
eta_y = kwargs.get("eta_y",
|
|
582
|
-
etap_y = kwargs.get("etap_y",
|
|
597
|
+
eta_y = kwargs.get("eta_y", 0.0)
|
|
598
|
+
etap_y = kwargs.get("etap_y", 0.0)
|
|
599
|
+
|
|
600
|
+
if eta_y != 0.0 or etap_y != 0.0:
|
|
601
|
+
warnings.warn(message="Setting dispersion parameters with `set_twiss_vertical(..., eta_y, etap_y)` is deprecated "
|
|
602
|
+
"and will be removed in a future version. "
|
|
603
|
+
"Use `set_dispersion_vertical(eta_y, etap_y)` separately instead.",
|
|
604
|
+
category=DeprecationWarning, stacklevel=2)
|
|
583
605
|
|
|
584
|
-
if eta_y is not None or etap_y is not None:
|
|
585
|
-
self._send_deprectation_warning("Setting dispersion parameters with set_twiss_vertical(..., eta_y, etap_y)",
|
|
586
|
-
"set_dispersion_vertical(eta_y, etap_y) separately")
|
|
587
606
|
self.set_dispersion_vertical(0.0 if eta_y is None else eta_y,
|
|
588
607
|
0.0 if etap_y is None else etap_y)
|
|
589
608
|
|
|
@@ -646,7 +665,7 @@ class ElectronBeam(SynedObject):
|
|
|
646
665
|
"""
|
|
647
666
|
return numpy.sqrt(1.0 - 1.0 / self.lorentz_factor() ** 2)
|
|
648
667
|
|
|
649
|
-
def emittance(self, dispersion=
|
|
668
|
+
def emittance(self, dispersion=True):
|
|
650
669
|
if not dispersion:
|
|
651
670
|
emittance_x = self._emittance_without_dispersion(self._moment_xx, self._moment_xxp, self._moment_xpxp)
|
|
652
671
|
emittance_y = self._emittance_without_dispersion(self._moment_yy, self._moment_yyp, self._moment_ypyp)
|
|
@@ -668,17 +687,14 @@ class ElectronBeam(SynedObject):
|
|
|
668
687
|
#
|
|
669
688
|
# backcompatibility (deprecated)
|
|
670
689
|
#
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
return self.get_twiss_all()
|
|
690
|
+
@deprecated("Use `get_twiss_all()` instead")
|
|
691
|
+
def get_twiss_no_dispersion_all(self): return self.get_twiss_all()
|
|
674
692
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
return self.get_twiss_horizontal()
|
|
693
|
+
@deprecated("Use `get_twiss_horizontal()` instead")
|
|
694
|
+
def get_twiss_no_dispersion_horizontal(self): return self.get_twiss_horizontal()
|
|
678
695
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return self.get_twiss_vertical()
|
|
696
|
+
@deprecated("Use `get_twiss_vertical()` instead")
|
|
697
|
+
def get_twiss_no_dispersion_vertical(self): return self.get_twiss_vertical()
|
|
682
698
|
|
|
683
699
|
|
|
684
700
|
if __name__ == "__main__":
|
|
@@ -779,10 +795,10 @@ if __name__ == "__main__":
|
|
|
779
795
|
# yyp = 1.0488e-14
|
|
780
796
|
# ypyp = 3.7609e-12
|
|
781
797
|
print("moments (with dispersion): ", a.get_moments_all(dispersion=True))
|
|
782
|
-
print("moments (without dispersion): ", a.get_moments_all(dispersion=
|
|
798
|
+
print("moments (without dispersion): ", a.get_moments_all(dispersion=True))
|
|
783
799
|
# sigma x = 3.1199e-05
|
|
784
800
|
# sigma x' = 4.5183e-06
|
|
785
801
|
# sigma y = 5.1565e-06
|
|
786
802
|
# sigma y' = 1.9393e-06
|
|
787
803
|
print("sigmas (with dispersion): ", a.get_sigmas_all(dispersion=True))
|
|
788
|
-
print("sigmas (without dispersion): ", a.get_sigmas_all(dispersion=
|
|
804
|
+
print("sigmas (without dispersion): ", a.get_sigmas_all(dispersion=True))
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import copy
|
|
2
|
-
import warnings
|
|
3
2
|
from collections import OrderedDict
|
|
4
3
|
try:
|
|
5
4
|
import json_tricks as json # to save numpy arrays
|
|
@@ -263,12 +262,3 @@ class SynedObject(object):
|
|
|
263
262
|
|
|
264
263
|
"""
|
|
265
264
|
return copy.deepcopy(self)
|
|
266
|
-
|
|
267
|
-
@classmethod
|
|
268
|
-
def _send_deprectation_warning(cls, function_name_use, new_function_use):
|
|
269
|
-
warnings.warn(
|
|
270
|
-
f"{function_name_use} is deprecated and will be removed in a future version. "
|
|
271
|
-
f"Use {new_function_use} instead.",
|
|
272
|
-
DeprecationWarning,
|
|
273
|
-
stacklevel=2
|
|
274
|
-
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import warnings
|
|
3
|
+
|
|
4
|
+
def deprecated(reason: str = ""):
|
|
5
|
+
"""
|
|
6
|
+
Decorator to mark functions as deprecated.
|
|
7
|
+
It will result in a warning being emitted when the function is used.
|
|
8
|
+
"""
|
|
9
|
+
def decorator(func):
|
|
10
|
+
msg = f"The function `{func.__name__}` is deprecated."
|
|
11
|
+
if reason:
|
|
12
|
+
msg += f" {reason}"
|
|
13
|
+
|
|
14
|
+
@functools.wraps(func)
|
|
15
|
+
def wrapper(*args, **kwargs):
|
|
16
|
+
warnings.simplefilter("always", DeprecationWarning) # show even if filtered
|
|
17
|
+
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
|
|
18
|
+
warnings.simplefilter("default", DeprecationWarning) # reset filter
|
|
19
|
+
return func(*args, **kwargs)
|
|
20
|
+
return wrapper
|
|
21
|
+
|
|
22
|
+
return decorator
|
|
@@ -10,6 +10,8 @@ syned.egg-info/dependency_links.txt
|
|
|
10
10
|
syned.egg-info/not-zip-safe
|
|
11
11
|
syned.egg-info/requires.txt
|
|
12
12
|
syned.egg-info/top_level.txt
|
|
13
|
+
syned/__test/__init__.py
|
|
14
|
+
syned/__test/test.py
|
|
13
15
|
syned/beamline/__init__.py
|
|
14
16
|
syned/beamline/beamline.py
|
|
15
17
|
syned/beamline/beamline_element.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{syned-1.0.44 → syned-1.0.46}/syned/beamline/optical_elements/ideal_elements/ideal_element.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|