syned 1.0.43__tar.gz → 1.0.45__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.
Files changed (65) hide show
  1. {syned-1.0.43 → syned-1.0.45}/PKG-INFO +15 -2
  2. {syned-1.0.43 → syned-1.0.45}/setup.py +1 -1
  3. syned-1.0.45/syned/__test/__init__.py +46 -0
  4. syned-1.0.45/syned/__test/test.py +28 -0
  5. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/electron_beam.py +53 -39
  6. {syned-1.0.43 → syned-1.0.45}/syned/syned_object.py +0 -10
  7. syned-1.0.45/syned/util/__init__.py +22 -0
  8. {syned-1.0.43 → syned-1.0.45}/syned/widget/widget_decorator.py +2 -2
  9. {syned-1.0.43 → syned-1.0.45}/syned.egg-info/PKG-INFO +15 -2
  10. {syned-1.0.43 → syned-1.0.45}/syned.egg-info/SOURCES.txt +2 -5
  11. syned-1.0.43/examples/__init__.py +0 -1
  12. syned-1.0.43/examples/example_beamline.py +0 -106
  13. syned-1.0.43/examples/example_double_slit.py +0 -67
  14. syned-1.0.43/examples/example_json_input_output.py +0 -111
  15. syned-1.0.43/syned/version.py +0 -11
  16. syned-1.0.43/syned/widget/__init__.py +0 -0
  17. {syned-1.0.43 → syned-1.0.45}/LICENSE +0 -0
  18. {syned-1.0.43 → syned-1.0.45}/MANIFEST.in +0 -0
  19. {syned-1.0.43 → syned-1.0.45}/README.rst +0 -0
  20. {syned-1.0.43 → syned-1.0.45}/setup.cfg +0 -0
  21. {syned-1.0.43 → syned-1.0.45}/syned/__init__.py +0 -0
  22. {syned-1.0.43 → syned-1.0.45}/syned/beamline/__init__.py +0 -0
  23. {syned-1.0.43 → syned-1.0.45}/syned/beamline/beamline.py +0 -0
  24. {syned-1.0.43 → syned-1.0.45}/syned/beamline/beamline_element.py +0 -0
  25. {syned-1.0.43 → syned-1.0.45}/syned/beamline/element_coordinates.py +0 -0
  26. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_element.py +0 -0
  27. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_element_with_surface_shape.py +0 -0
  28. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/__init__.py +0 -0
  29. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/__init__.py +0 -0
  30. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/absorber.py +0 -0
  31. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/beam_stopper.py +0 -0
  32. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/filter.py +0 -0
  33. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/holed_filter.py +0 -0
  34. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/absorbers/slit.py +0 -0
  35. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/crystals/__init__.py +0 -0
  36. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/crystals/crystal.py +0 -0
  37. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/gratings/__init__.py +0 -0
  38. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/gratings/grating.py +0 -0
  39. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/__init__.py +0 -0
  40. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_element.py +0 -0
  41. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_fzp.py +0 -0
  42. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/ideal_lens.py +0 -0
  43. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/ideal_elements/screen.py +0 -0
  44. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/mirrors/__init__.py +0 -0
  45. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/mirrors/mirror.py +0 -0
  46. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/refractors/__init__.py +0 -0
  47. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/refractors/crl.py +0 -0
  48. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/refractors/interface.py +0 -0
  49. {syned-1.0.43 → syned-1.0.45}/syned/beamline/optical_elements/refractors/lens.py +0 -0
  50. {syned-1.0.43 → syned-1.0.45}/syned/beamline/shape.py +0 -0
  51. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/__init__.py +0 -0
  52. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/empty_light_source.py +0 -0
  53. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/light_source.py +0 -0
  54. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/magnetic_structure.py +0 -0
  55. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/magnetic_structures/__init__.py +0 -0
  56. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/magnetic_structures/bending_magnet.py +0 -0
  57. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/magnetic_structures/insertion_device.py +0 -0
  58. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/magnetic_structures/undulator.py +0 -0
  59. {syned-1.0.43 → syned-1.0.45}/syned/storage_ring/magnetic_structures/wiggler.py +0 -0
  60. {syned-1.0.43 → syned-1.0.45}/syned/util/json_tools.py +0 -0
  61. {syned-1.0.43/syned/util → syned-1.0.45/syned/widget}/__init__.py +0 -0
  62. {syned-1.0.43 → syned-1.0.45}/syned.egg-info/dependency_links.txt +0 -0
  63. {syned-1.0.43 → syned-1.0.45}/syned.egg-info/not-zip-safe +0 -0
  64. {syned-1.0.43 → syned-1.0.45}/syned.egg-info/requires.txt +0 -0
  65. {syned-1.0.43 → syned-1.0.45}/syned.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: syned
3
- Version: 1.0.43
3
+ Version: 1.0.45
4
4
  Summary: SYNED (SYNchrotron Elements Dictionary) kernel library
5
5
  Home-page: https://github.com/oasys-kit/syned
6
6
  Download-URL: https://github.com/oasys-kit/syned
@@ -26,6 +26,19 @@ License-File: LICENSE
26
26
  Requires-Dist: setuptools
27
27
  Requires-Dist: numpy
28
28
  Requires-Dist: scipy
29
+ Dynamic: author
30
+ Dynamic: author-email
31
+ Dynamic: classifier
32
+ Dynamic: description
33
+ Dynamic: download-url
34
+ Dynamic: home-page
35
+ Dynamic: keywords
36
+ Dynamic: license
37
+ Dynamic: license-file
38
+ Dynamic: maintainer
39
+ Dynamic: maintainer-email
40
+ Dynamic: requires-dist
41
+ Dynamic: summary
29
42
 
30
43
  =====
31
44
  syned
@@ -9,7 +9,7 @@ except AttributeError:
9
9
 
10
10
  NAME = 'syned'
11
11
 
12
- VERSION = '1.0.43'
12
+ VERSION = '1.0.45'
13
13
  ISRELEASED = True
14
14
 
15
15
  DESCRIPTION = 'SYNED (SYNchrotron Elements Dictionary) kernel library'
@@ -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,
@@ -136,17 +140,27 @@ class ElectronBeam(SynedObject):
136
140
  @classmethod
137
141
  def _get_twiss_from_moments(cls, moment_ss, moment_sa, moment_aa):
138
142
  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
143
+ if emittance == 0.0:
144
+ warnings.warn(message="All moments are 0.0 and the calculation is not possible. \u03b5 = \u03b1 = \u03b2 = \u03b3 = 0.0 is returned.",
145
+ category=UserWarning, stacklevel=2)
146
+ return 0.0, 0.0, 0.0, 0.0
147
+ else:
148
+ alpha = -moment_sa / emittance
149
+ beta = moment_ss / emittance
150
+ gamma = (1 + alpha**2) / beta
142
151
 
143
- alpha = 0.0 if alpha == 0 else alpha # to avoid -0.0
152
+ alpha = 0.0 if alpha == 0 else alpha # to avoid -0.0
144
153
 
145
- return emittance, alpha, beta, gamma
154
+ return emittance, alpha, beta, gamma
146
155
 
147
156
  @classmethod
148
157
  def _get_moments_from_twiss_without_dispersion(cls, emittance, alpha, beta):
149
- gamma = (1 + alpha ** 2) / beta
158
+ if beta == 0:
159
+ warnings.warn(message="With \u03b2 = 0.0 the calculation of \u03b3 is not possible. \u03b3 = 0.0 is used.",
160
+ category=UserWarning, stacklevel=2)
161
+ gamma = 0.0
162
+ else:
163
+ gamma = (1 + alpha ** 2) / beta
150
164
 
151
165
  moment_ss = beta * emittance
152
166
  moment_sa = -alpha * emittance
@@ -168,7 +182,7 @@ class ElectronBeam(SynedObject):
168
182
  # --- GETTERS
169
183
  # # ---------------------------------------------------------------------------------------------------------------------------------------------
170
184
  #
171
- def get_sigmas_horizontal(self, dispersion=False):
185
+ def get_sigmas_horizontal(self, dispersion=True):
172
186
  """
173
187
  Returns the sigmas in horizontal direction.
174
188
 
@@ -183,7 +197,7 @@ class ElectronBeam(SynedObject):
183
197
 
184
198
  return numpy.sqrt(moment_xx), numpy.sqrt(moment_xpxp)
185
199
 
186
- def get_sigmas_vertical(self, dispersion=False):
200
+ def get_sigmas_vertical(self, dispersion=True):
187
201
  """
188
202
  Returns the sigmas in vertical direction.
189
203
 
@@ -197,7 +211,7 @@ class ElectronBeam(SynedObject):
197
211
 
198
212
  return numpy.sqrt(moment_yy), numpy.sqrt(moment_ypyp)
199
213
 
200
- def get_sigmas_all(self, dispersion=False):
214
+ def get_sigmas_all(self, dispersion=True):
201
215
  """
202
216
  Returns all sigmas.
203
217
 
@@ -213,7 +227,7 @@ class ElectronBeam(SynedObject):
213
227
 
214
228
  return sigma_x, sigmap_x, sigma_y, sigmap_y
215
229
 
216
- def get_moments_horizontal(self, dispersion=False):
230
+ def get_moments_horizontal(self, dispersion=True):
217
231
  """
218
232
  Returns the moments in the horizontal direction.
219
233
 
@@ -231,7 +245,7 @@ class ElectronBeam(SynedObject):
231
245
  self._dispersion_x,
232
246
  self._dispersionp_x)
233
247
 
234
- def get_moments_vertical(self, dispersion=False):
248
+ def get_moments_vertical(self, dispersion=True):
235
249
  """
236
250
  Returns the moments in the vertical direction.
237
251
 
@@ -250,7 +264,7 @@ class ElectronBeam(SynedObject):
250
264
  self._dispersion_y,
251
265
  self._dispersionp_y)
252
266
 
253
- def get_moments_all(self, dispersion=False):
267
+ def get_moments_all(self, dispersion=True):
254
268
  """
255
269
  Returns all moments.
256
270
 
@@ -542,16 +556,16 @@ class ElectronBeam(SynedObject):
542
556
  self._moment_xpxp = moment_xpxp
543
557
 
544
558
  # RETROCOMPATIBILITY
545
- eta_x = kwargs.get("eta_x", None)
546
- etap_x = kwargs.get("etap_x", None)
547
-
548
- if eta_x is not None or etap_x is not None:
549
- self._send_deprectation_warning("Setting dispersion parameters with set_twiss_horizontal(..., eta_x, etap_x)",
550
- "set_dispersion_horizontal(eta_x, etap_x) separately")
551
- self.set_dispersion_vertical(0.0 if eta_x is None else eta_x,
552
- 0.0 if etap_x is None else etap_x)
559
+ eta_x = kwargs.get("eta_x", 0.0)
560
+ etap_x = kwargs.get("etap_x", 0.0)
553
561
 
554
- self.set_dispersion_horizontal(eta_x, etap_x)
562
+ if eta_x != 0.0 or etap_x != 0.0:
563
+ warnings.warn(message="Setting dispersion parameters with `set_twiss_horizontal(..., eta_x, etap_x)` is deprecated "
564
+ "and will be removed in a future version. "
565
+ "Use `set_dispersion_horizontal(eta_x, etap_x)` separately instead.",
566
+ category=DeprecationWarning, stacklevel=2)
567
+ self.set_dispersion_horizontal(0.0 if eta_x is None else eta_x,
568
+ 0.0 if etap_x is None else etap_x)
555
569
 
556
570
  def set_twiss_vertical(self, emittance_y, alpha_y, beta_y, **kwargs):
557
571
  """
@@ -578,12 +592,15 @@ class ElectronBeam(SynedObject):
578
592
  self._moment_ypyp = moment_ypyp
579
593
 
580
594
  # RETROCOMPATIBILITY
581
- eta_y = kwargs.get("eta_y", None)
582
- etap_y = kwargs.get("etap_y", None)
595
+ eta_y = kwargs.get("eta_y", 0.0)
596
+ etap_y = kwargs.get("etap_y", 0.0)
597
+
598
+ if eta_y != 0.0 or etap_y != 0.0:
599
+ warnings.warn(message="Setting dispersion parameters with `set_twiss_vertical(..., eta_y, etap_y)` is deprecated "
600
+ "and will be removed in a future version. "
601
+ "Use `set_dispersion_vertical(eta_y, etap_y)` separately instead.",
602
+ category=DeprecationWarning, stacklevel=2)
583
603
 
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
604
  self.set_dispersion_vertical(0.0 if eta_y is None else eta_y,
588
605
  0.0 if etap_y is None else etap_y)
589
606
 
@@ -646,7 +663,7 @@ class ElectronBeam(SynedObject):
646
663
  """
647
664
  return numpy.sqrt(1.0 - 1.0 / self.lorentz_factor() ** 2)
648
665
 
649
- def emittance(self, dispersion=False):
666
+ def emittance(self, dispersion=True):
650
667
  if not dispersion:
651
668
  emittance_x = self._emittance_without_dispersion(self._moment_xx, self._moment_xxp, self._moment_xpxp)
652
669
  emittance_y = self._emittance_without_dispersion(self._moment_yy, self._moment_yyp, self._moment_ypyp)
@@ -668,17 +685,14 @@ class ElectronBeam(SynedObject):
668
685
  #
669
686
  # backcompatibility (deprecated)
670
687
  #
671
- def get_twiss_no_dispersion_all(self):
672
- self._send_deprectation_warning("get_twiss_no_dispersion_all()", "get_twiss_all(dispersion=False)")
673
- return self.get_twiss_all()
688
+ @deprecated("Use `get_twiss_all()` instead")
689
+ def get_twiss_no_dispersion_all(self): return self.get_twiss_all()
674
690
 
675
- def get_twiss_no_dispersion_horizontal(self):
676
- self._send_deprectation_warning("get_twiss_no_dispersion_horizontal()", "get_twiss_horizontal(dispersion=False)")
677
- return self.get_twiss_horizontal()
691
+ @deprecated("Use `get_twiss_horizontal()` instead")
692
+ def get_twiss_no_dispersion_horizontal(self): return self.get_twiss_horizontal()
678
693
 
679
- def get_twiss_no_dispersion_vertical(self):
680
- self._send_deprectation_warning("get_twiss_no_dispersion_vertical()", "get_twiss_vertical(dispersion=False)")
681
- return self.get_twiss_vertical()
694
+ @deprecated("Use `get_twiss_vertical()` instead")
695
+ def get_twiss_no_dispersion_vertical(self): return self.get_twiss_vertical()
682
696
 
683
697
 
684
698
  if __name__ == "__main__":
@@ -779,10 +793,10 @@ if __name__ == "__main__":
779
793
  # yyp = 1.0488e-14
780
794
  # ypyp = 3.7609e-12
781
795
  print("moments (with dispersion): ", a.get_moments_all(dispersion=True))
782
- print("moments (without dispersion): ", a.get_moments_all(dispersion=False))
796
+ print("moments (without dispersion): ", a.get_moments_all(dispersion=True))
783
797
  # sigma x = 3.1199e-05
784
798
  # sigma x' = 4.5183e-06
785
799
  # sigma y = 5.1565e-06
786
800
  # sigma y' = 1.9393e-06
787
801
  print("sigmas (with dispersion): ", a.get_sigmas_all(dispersion=True))
788
- print("sigmas (without dispersion): ", a.get_sigmas_all(dispersion=False))
802
+ 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
@@ -24,14 +24,14 @@ class WidgetDecorator(object):
24
24
  if not multi_input:
25
25
  from orangewidget.widget import Input
26
26
 
27
- return Input(name="SynedData",
27
+ return Input(name="Syned Data",
28
28
  type=Beamline,
29
29
  id="SynedData",
30
30
  default=True, auto_summary=False)
31
31
  else:
32
32
  from orangewidget.widget import MultiInput
33
33
 
34
- return MultiInput(name="SynedData",
34
+ return MultiInput(name="Syned Data",
35
35
  type=Beamline,
36
36
  id="SynedData",
37
37
  default=True, auto_summary=False)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: syned
3
- Version: 1.0.43
3
+ Version: 1.0.45
4
4
  Summary: SYNED (SYNchrotron Elements Dictionary) kernel library
5
5
  Home-page: https://github.com/oasys-kit/syned
6
6
  Download-URL: https://github.com/oasys-kit/syned
@@ -26,6 +26,19 @@ License-File: LICENSE
26
26
  Requires-Dist: setuptools
27
27
  Requires-Dist: numpy
28
28
  Requires-Dist: scipy
29
+ Dynamic: author
30
+ Dynamic: author-email
31
+ Dynamic: classifier
32
+ Dynamic: description
33
+ Dynamic: download-url
34
+ Dynamic: home-page
35
+ Dynamic: keywords
36
+ Dynamic: license
37
+ Dynamic: license-file
38
+ Dynamic: maintainer
39
+ Dynamic: maintainer-email
40
+ Dynamic: requires-dist
41
+ Dynamic: summary
29
42
 
30
43
  =====
31
44
  syned
@@ -2,19 +2,16 @@ LICENSE
2
2
  MANIFEST.in
3
3
  README.rst
4
4
  setup.py
5
- examples/__init__.py
6
- examples/example_beamline.py
7
- examples/example_double_slit.py
8
- examples/example_json_input_output.py
9
5
  syned/__init__.py
10
6
  syned/syned_object.py
11
- syned/version.py
12
7
  syned.egg-info/PKG-INFO
13
8
  syned.egg-info/SOURCES.txt
14
9
  syned.egg-info/dependency_links.txt
15
10
  syned.egg-info/not-zip-safe
16
11
  syned.egg-info/requires.txt
17
12
  syned.egg-info/top_level.txt
13
+ syned/__test/__init__.py
14
+ syned/__test/test.py
18
15
  syned/beamline/__init__.py
19
16
  syned/beamline/beamline.py
20
17
  syned/beamline/beamline_element.py
@@ -1 +0,0 @@
1
- __author__ = 'srio'
@@ -1,106 +0,0 @@
1
-
2
- from syned.storage_ring.electron_beam import ElectronBeam
3
- from syned.storage_ring.magnetic_structures.undulator import Undulator
4
- from syned.storage_ring.light_source import LightSource
5
- from syned.beamline.shape import *
6
-
7
- from syned.beamline.optical_elements.ideal_elements.screen import Screen
8
- from syned.beamline.optical_elements.ideal_elements.ideal_lens import IdealLens
9
- from syned.beamline.optical_elements.absorbers.filter import Filter
10
- from syned.beamline.optical_elements.absorbers.slit import Slit
11
- from syned.beamline.optical_elements.absorbers.beam_stopper import BeamStopper
12
-
13
- from syned.beamline.optical_elements.mirrors.mirror import Mirror
14
- from syned.beamline.optical_elements.crystals.crystal import Crystal
15
- from syned.beamline.optical_elements.gratings.grating import Grating
16
-
17
- from syned.beamline.beamline import BeamlineElement, Beamline
18
- from syned.beamline.element_coordinates import ElementCoordinates
19
-
20
- from syned.util.json_tools import load_from_json_file
21
-
22
- #
23
- # example of setting a beamline in SYNED.
24
- #
25
- if __name__ == "__main__":
26
-
27
-
28
- print("==================== LightSource: ==================")
29
-
30
- src1 = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,current=0.2)
31
-
32
- src2 = Undulator()
33
- src2.set_value_from_key_name("K_horizontal",33)
34
- # just to be sure...
35
- assert (33 == src2.get_value_from_key_name("K_horizontal"))
36
-
37
- src = LightSource("test",src1,src2)
38
-
39
- # check file o/i for test
40
- src.to_json("tmp.json") # write to file
41
- tmp = load_from_json_file("tmp.json") # read from file
42
- print("returned class: ", type(tmp))
43
- print(src.to_dictionary())
44
- print(tmp.to_dictionary())
45
- assert(src.to_dictionary() == tmp.to_dictionary())
46
-
47
-
48
- print("==================== Optical elements: ==================")
49
-
50
- #
51
- # ideal elements
52
- #
53
-
54
- screen1 = Screen("screen1")
55
- lens1 = IdealLens("lens1",3.0)
56
-
57
- #
58
- # absorbers
59
- #
60
- filter1 = Filter("filter1","H2O",3.0e-6)
61
-
62
- slit1 = Slit(name="slit1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
63
-
64
- slit2 = Slit(name="slit2")
65
- slit2.set_rectangle(width=3e-4,height=5e-4)
66
- slit2.set_circle(radius=3e-4)
67
-
68
- stopper1 = BeamStopper(name="stopper1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
69
-
70
- stopper2 = BeamStopper(name="stopper2")
71
-
72
- stopper2.set_rectangle(width=3e-4,height=5e-4)
73
- stopper2.set_circle(radius=3e-4)
74
-
75
- #
76
- # elements with shape: mirror, gratings, crystals
77
- #
78
-
79
- mirror1 = Mirror(name="mirror1")
80
-
81
- crystal1 = Crystal(name="crystal1")
82
-
83
- grating1 = Grating(name="grating1")
84
-
85
-
86
- print("==================== BeamLine: ==================")
87
-
88
- beamline1 = Beamline()
89
-
90
- beamline1.set_light_source(src)
91
-
92
- list_oe = [screen1, lens1, filter1, slit1, slit2, stopper1, stopper2, mirror1, crystal1, grating1]
93
- for i, optical_element in enumerate(list_oe):
94
- coordinates=ElementCoordinates(p=1.1*i, q=1.2*i)
95
- be = BeamlineElement(optical_element=optical_element, coordinates=coordinates)
96
- beamline1.append_beamline_element(be)
97
-
98
- print(beamline1.info())
99
-
100
- # check file o/i for test
101
- beamline1.to_json("tmp_beamline1.json")
102
- tmp = load_from_json_file("tmp_beamline1.json")
103
- print("returned class: ",type(tmp))
104
- print(beamline1.to_dictionary())
105
- print(tmp.to_dictionary())
106
- assert(beamline1.to_dictionary() == tmp.to_dictionary())
@@ -1,67 +0,0 @@
1
-
2
- from syned.util.json_tools import load_from_json_file
3
-
4
- from syned.storage_ring.electron_beam import ElectronBeam
5
- from syned.storage_ring.magnetic_structures.undulator import Undulator
6
- from syned.beamline.optical_elements.ideal_elements.screen import Screen
7
- from syned.beamline.optical_elements.absorbers.slit import Slit
8
-
9
- from syned.storage_ring.light_source import LightSource
10
-
11
- from syned.beamline.beamline import Beamline
12
- from syned.beamline.beamline_element import BeamlineElement
13
- from syned.beamline.element_coordinates import ElementCoordinates
14
-
15
- from syned.beamline.shape import MultiplePatch
16
-
17
- # this is an example of a double slit (a slit with two rectangular apertures).
18
- if __name__ == "__main__":
19
-
20
-
21
- # source
22
- src1 = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,current=0.2)
23
- src2 = Undulator()
24
-
25
- lightsource1 = LightSource("test_source",src1, src2)
26
-
27
- # check file o/i for test
28
- lightsource1.to_json("tmp.json")
29
- tmp = load_from_json_file("tmp.json")
30
- print("returned class: ",type(tmp))
31
- print(lightsource1.to_dictionary())
32
- print(tmp.to_dictionary())
33
- assert (lightsource1.to_dictionary() == tmp.to_dictionary())
34
-
35
- #optical elements
36
- patches = MultiplePatch()
37
- patches.append_rectangle(-0.02,-0.01,-0.001,0.001)
38
- patches.append_rectangle(0.01,0.02,-0.001,0.001)
39
- slit1 = Slit(name="slit1", boundary_shape=patches)
40
-
41
- # check file o/i for test individual elements
42
- mylist = [src1, src2, slit1]
43
- for i,element in enumerate(mylist):
44
- element.to_json("tmp_%d.json"%i)
45
-
46
- for i, element in enumerate(mylist):
47
- print("\nloading element %d"%i)
48
- tmp = load_from_json_file("tmp_%d.json"%i)
49
- print("returned class: ",type(tmp))
50
- print(mylist[i].to_dictionary())
51
- print(tmp.to_dictionary())
52
- assert (mylist[i].to_dictionary() == tmp.to_dictionary())
53
-
54
- # test Beamline
55
-
56
- bl_slit1 = BeamlineElement(optical_element=slit1, coordinates=ElementCoordinates(p=10.0,q=3.0))
57
- BL = Beamline(light_source=lightsource1, beamline_elements_list=[bl_slit1])
58
-
59
- # check file o/i for test full beamline
60
- BL.to_json("tmp_bl.json")
61
- tmp = load_from_json_file("tmp_bl.json")
62
- print("returned class: ",type(tmp))
63
- print(BL.to_dictionary())
64
- print(tmp.to_dictionary())
65
- assert(BL.to_dictionary() == tmp.to_dictionary())
66
-
67
- print(BL.info())
@@ -1,111 +0,0 @@
1
-
2
- from syned.util.json_tools import load_from_json_file
3
-
4
- from syned.storage_ring.electron_beam import ElectronBeam
5
- from syned.storage_ring.magnetic_structures.undulator import Undulator
6
- from syned.beamline.optical_elements.ideal_elements.screen import Screen
7
- from syned.beamline.optical_elements.ideal_elements.ideal_lens import IdealLens
8
- from syned.beamline.optical_elements.absorbers.filter import Filter
9
- from syned.beamline.optical_elements.absorbers.slit import Slit
10
- from syned.beamline.optical_elements.absorbers.beam_stopper import BeamStopper
11
- from syned.beamline.optical_elements.mirrors.mirror import Mirror
12
- from syned.beamline.optical_elements.crystals.crystal import Crystal
13
- from syned.beamline.optical_elements.gratings.grating import Grating
14
-
15
- from syned.beamline.shape import SurfaceShape, Conic, Ellipsoid, Plane, Toroid
16
- from syned.beamline.shape import Rectangle
17
- from syned.storage_ring.light_source import LightSource
18
-
19
- from syned.beamline.beamline import Beamline
20
- from syned.beamline.beamline_element import BeamlineElement
21
- from syned.beamline.element_coordinates import ElementCoordinates
22
-
23
-
24
-
25
- if __name__ == "__main__":
26
-
27
-
28
-
29
- src1 = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,current=0.2)
30
- src2 = Undulator()
31
- lightsource1 = LightSource("test_source", src1, src2)
32
-
33
- screen1 = Screen("screen1")
34
- lens1 = IdealLens(name="lens1",focal_y=6.0,focal_x=None,)
35
- filter1 = Filter("filter1","H2O",3.0e-6)
36
- slit1 = Slit(name="slit1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
37
- stopper1 = BeamStopper(name="stopper1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
38
- mirror1 = Mirror(name="mirror1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3), surface_shape=Toroid())
39
- grating1 = Grating(name="grating1",surface_shape=Conic())
40
- crystal1 = Crystal(name="crystal1",surface_shape=Plane())
41
-
42
- mylist = [lightsource1, screen1, lens1, filter1, slit1, stopper1, mirror1, crystal1, grating1]
43
-
44
- #
45
- # test individual elements
46
- #
47
-
48
- for i,element in enumerate(mylist):
49
- element.to_json("tmp_%d.json"%i)
50
-
51
- for i,element in enumerate(mylist):
52
- print("loading element %d"%i)
53
- tmp = load_from_json_file("tmp_%d.json"%i)
54
- print("returned class: ",type(tmp))
55
- print(element.to_dictionary())
56
- print(tmp.to_dictionary())
57
- # assert (element.to_dictionary() == tmp.to_dictionary())
58
-
59
-
60
-
61
- #
62
- # test full beamline
63
- #
64
-
65
- SCREEN1 = BeamlineElement(screen1, coordinates=ElementCoordinates(p=11.0))
66
- LENS1 = BeamlineElement(lens1, coordinates=ElementCoordinates(p=12.0))
67
- FILTER1 = BeamlineElement(filter1, coordinates=ElementCoordinates(p=13.0))
68
- SLIT1 = BeamlineElement(slit1, coordinates=ElementCoordinates(p=15.0))
69
- STOPPER1 = BeamlineElement(stopper1, coordinates=ElementCoordinates(p=16.0))
70
- MIRROR1 = BeamlineElement(mirror1, coordinates=ElementCoordinates(p=17.0))
71
- GRATING1 = BeamlineElement(grating1, coordinates=ElementCoordinates(p=18.0))
72
- CRYSTAL1 = BeamlineElement(crystal1, coordinates=ElementCoordinates(p=19.0))
73
-
74
- MyList = [SCREEN1,LENS1,FILTER1,SLIT1,STOPPER1,MIRROR1,CRYSTAL1,GRATING1]
75
-
76
-
77
- #
78
- # test BeamlineElement
79
- #
80
-
81
-
82
- # for i,element in enumerate(MyList):
83
- #
84
- # element.to_json("tmp_%d.json"%(100+i))
85
- # tmp = load_from_json_file("tmp_%d.json"%(100+i))
86
- # print("returned class: ",type(tmp))
87
- # print("\n-----------Info on: \n",tmp.info(),"----------------\n\n")
88
-
89
- #
90
- # test Beamline
91
- #
92
-
93
- BL = Beamline(LightSource(name="test",electron_beam=src1,magnetic_structure=src2),
94
- [SCREEN1,LENS1,FILTER1,SLIT1,STOPPER1,MIRROR1,CRYSTAL1,GRATING1])
95
-
96
- BL.to_json("tmp_200.json")
97
-
98
- tmp = load_from_json_file("tmp_200.json")
99
- print("returned class: ",type(tmp))
100
- print(BL.to_full_dictionary())
101
- print(tmp.to_full_dictionary())
102
- # assert(BL.to_full_dictionary() == tmp.to_full_dictionary())
103
-
104
- #
105
- # print(tmp.get_light_source().info())
106
- # for element in tmp.get_beamline_elements():
107
- # print("list element class: ",type(element))
108
- # print(element.info())
109
- # #
110
- # #
111
- # print("\n-----------Info on: \n",tmp.info(),"----------------\n\n")
@@ -1,11 +0,0 @@
1
-
2
- # THIS FILE IS GENERATED FROM syned SETUP.PY
3
- short_version = '1.0.38'
4
- version = '1.0.38'
5
- full_version = '1.0.38'
6
- git_revision = ''
7
- release = True
8
-
9
- if not release:
10
- version = full_version
11
- short_version += ".dev"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes