xcoll 0.5.4__py3-none-any.whl → 0.5.5__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.

Potentially problematic release.


This version of xcoll might be problematic. Click here for more details.

xcoll/general.py CHANGED
@@ -12,5 +12,5 @@ citation = "F.F. Van der Veken, et al.: Recent Developments with the New Tools f
12
12
  # ======================
13
13
  # Do not change
14
14
  # ======================
15
- __version__ = '0.5.4'
15
+ __version__ = '0.5.5'
16
16
  # ======================
xcoll/line_tools.py CHANGED
@@ -4,84 +4,131 @@
4
4
  # ######################################### #
5
5
 
6
6
  import numpy as np
7
+ import warnings
8
+ warnings.simplefilter("always")
9
+
7
10
  import xtrack as xt
8
11
 
9
12
  from .beam_elements import element_classes, _all_collimator_classes
10
13
 
11
14
 
12
- class XcollLineAPI:
15
+ class XcollCollimatorAPI:
16
+ def __init__(self, line):
17
+ self._line = line
18
+
19
+ @property
20
+ def line(self):
21
+ return self._line
22
+
23
+
24
+ def get_optics_at(self, names, *, twiss=None):
25
+ if twiss is None:
26
+ if not self.line._has_valid_tracker():
27
+ raise Exception("Please build the tracker before computing the optics for the openings!")
28
+ twiss = self.line.twiss()
29
+ if not hasattr(names, '__iter__') and not isinstance(names, str):
30
+ names = [names]
31
+ coll_entry_indices = twiss.rows.indices[names]
32
+ tw_entry = twiss.rows[coll_entry_indices]
33
+ tw_exit = twiss.rows[coll_entry_indices+1]
34
+ tw_exit.name = tw_entry.name
35
+ return tw_entry, tw_exit
36
+
37
+ def assign_optics(self, nemitt_x=None, nemitt_y=None, twiss=None):
38
+ if not self.line._has_valid_tracker():
39
+ raise Exception("Please build tracker before setting the openings!")
40
+ names = self.line.get_elements_of_type(_all_collimator_classes)[1]
41
+ tw_upstream, tw_downstream = self.get_optics_at(names, twiss=twiss)
42
+ beta_gamma_rel = self.line.particle_ref._xobject.gamma0[0]*self.line.particle_ref._xobject.beta0[0]
43
+ for coll in names:
44
+ self.line[coll].assign_optics(name=coll, nemitt_x=nemitt_x, nemitt_y=nemitt_x, twiss_upstream=tw_upstream,
45
+ twiss_downstream=tw_downstream, beta_gamma_rel=beta_gamma_rel)
46
+
47
+ def open(self, names=None):
48
+ if names is None:
49
+ names = self.line.get_elements_of_type(_all_collimator_classes)[1]
50
+ if len(names) == 0:
51
+ print("No collimators found in line.")
52
+ else:
53
+ for coll in names:
54
+ self.line[coll].open_jaws(keep_tilts=False)
55
+ self.line[coll].gap = None
56
+
57
+ def to_parking(self, names=None):
58
+ if names is None:
59
+ names = self.line.get_elements_of_type(_all_collimator_classes)[1]
60
+ if len(names) == 0:
61
+ print("No collimators found in line.")
62
+ else:
63
+ raise NotImplementedError("Need to move this to new type manager or so.")
64
+
65
+
66
+ class XcollScatteringAPI:
13
67
  def __init__(self, line):
14
68
  self._line = line
15
69
 
70
+ @property
71
+ def line(self):
72
+ return self._line
73
+
74
+ def enable(self):
75
+ elements = self.line.get_elements_of_type(element_classes)[0]
76
+ if len(elements) == 0:
77
+ print("No xcoll elements found in line.")
78
+ else:
79
+ nemitt_x = None
80
+ nemitt_y = None
81
+ for el in elements:
82
+ if hasattr(el, 'optics') and el.optics is not None:
83
+ if nemitt_x is None:
84
+ nemitt_x = el.nemitt_x
85
+ if nemitt_y is None:
86
+ nemitt_y = el.nemitt_y
87
+ if not np.isclose(el.nemitt_x, nemitt_x) \
88
+ or not np.isclose(el.nemitt_x, nemitt_x):
89
+ raise ValueError("Not all collimators have the same "
90
+ + "emittance. This is not supported.")
91
+ if hasattr(el, 'enable_scattering'):
92
+ el.enable_scattering()
93
+
94
+ def disable(self):
95
+ elements = self.line.get_elements_of_type(element_classes)[0]
96
+ if len(elements) == 0:
97
+ print("No xcoll elements found in line.")
98
+ else:
99
+ for el in elements:
100
+ if hasattr(el, 'disable_scattering'):
101
+ el.disable_scattering()
102
+
103
+
104
+
16
105
 
17
106
  def assign_optics_to_collimators(line, nemitt_x=None, nemitt_y=None, twiss=None):
18
- if not line._has_valid_tracker():
19
- raise Exception("Please build tracker before setting the openings!")
20
- names = line.get_elements_of_type(_all_collimator_classes)[1]
21
- tw_upstream, tw_downstream = get_optics_at(names, twiss=twiss, line=line)
22
- beta_gamma_rel = line.particle_ref._xobject.gamma0[0]*line.particle_ref._xobject.beta0[0]
23
- for coll in names:
24
- line[coll].assign_optics(name=coll, nemitt_x=nemitt_x, nemitt_y=nemitt_x, twiss_upstream=tw_upstream,
25
- twiss_downstream=tw_downstream, beta_gamma_rel=beta_gamma_rel)
107
+ warnings.warn("The function xcoll.assign_optics_to_collimators() is deprecated and will be "
108
+ + "removed in the future. Please use line.scattering.assign_optics() instead.", DeprecationWarning)
109
+ line.collimators.assign_optics(nemitt_x=nemitt_x, nemitt_y=nemitt_y, twiss=twiss)
26
110
 
27
111
  def get_optics_at(names, *, twiss=None, line=None):
28
- if twiss is None:
29
- if not line._has_valid_tracker():
30
- raise Exception("Please pass a line and build tracker before computing the optics for the openings!")
31
- twiss = line.twiss()
32
- if not hasattr(names, '__iter__') and not isinstance(names, str):
33
- names = [names]
34
- coll_entry_indices = twiss.rows.indices[names]
35
- tw_entry = twiss.rows[coll_entry_indices]
36
- tw_exit = twiss.rows[coll_entry_indices+1]
37
- tw_exit.name = tw_entry.name
38
- return tw_entry, tw_exit
39
-
112
+ warnings.warn("The function xcoll.get_optics_at() is deprecated and will be "
113
+ + "removed in the future. Please use line.scattering.get_optics_at() instead.", DeprecationWarning)
114
+ return line.collimators.get_optics_at(names=names, twiss=twiss)
40
115
 
41
116
  def open_collimators(line, names=None):
42
- if names is None:
43
- names = line.get_elements_of_type(_all_collimator_classes)[1]
44
- if len(names) == 0:
45
- print("No collimators found in line.")
46
- else:
47
- for coll in names:
48
- line[coll].open_jaws(keep_tilts=False)
49
- line[coll].gap = None
117
+ warnings.warn("The function xcoll.open_collimators() is deprecated and will be "
118
+ + "removed in the future. Please use line.scattering.open_collimators() instead.", DeprecationWarning)
119
+ line.collimators.open(names=names)
50
120
 
51
121
  def send_to_parking(line, names=None):
52
- if names is None:
53
- names = line.get_elements_of_type(_all_collimator_classes)[1]
54
- if len(names) == 0:
55
- print("No collimators found in line.")
56
- else:
57
- raise NotImplementedError("Need to move this to new type manager or so.")
58
-
122
+ warnings.warn("The function xcoll.send_to_parking() is deprecated and will be "
123
+ + "removed in the future. Please use line.scattering.send_to_parking() instead.", DeprecationWarning)
124
+ line.collimators.to_parking(names=names)
59
125
 
60
126
  def enable_scattering(line):
61
- elements = line.get_elements_of_type(element_classes)[0]
62
- if len(elements) == 0:
63
- print("No xcoll elements found in line.")
64
- else:
65
- nemitt_x = None
66
- nemitt_y = None
67
- for el in elements:
68
- if hasattr(el, 'optics') and el.optics is not None:
69
- if nemitt_x is None:
70
- nemitt_x = el.nemitt_x
71
- if nemitt_y is None:
72
- nemitt_y = el.nemitt_y
73
- if not np.isclose(el.nemitt_x, nemitt_x) \
74
- or not np.isclose(el.nemitt_x, nemitt_x):
75
- raise ValueError("Not all collimators have the same "
76
- + "emittance. This is not supported.")
77
- if hasattr(el, 'enable_scattering'):
78
- el.enable_scattering()
127
+ warnings.warn("The function xcoll.enable_scattering() is deprecated and will be "
128
+ + "removed in the future. Please use line.scattering.enable() instead.", DeprecationWarning)
129
+ line.scattering.enable()
79
130
 
80
131
  def disable_scattering(line):
81
- elements = line.get_elements_of_type(element_classes)[0]
82
- if len(elements) == 0:
83
- print("No xcoll elements found in line.")
84
- else:
85
- for el in elements:
86
- if hasattr(el, 'disable_scattering'):
87
- el.disable_scattering()
132
+ warnings.warn("The function xcoll.disable_scattering() is deprecated and will be "
133
+ + "removed in the future. Please use line.scattering.disable() instead.", DeprecationWarning)
134
+ line.scattering.disable()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xcoll
3
- Version: 0.5.4
3
+ Version: 0.5.5
4
4
  Summary: Xsuite collimation package
5
5
  Home-page: https://github.com/xsuite/xcoll
6
6
  License: Apache 2.0
@@ -16,7 +16,7 @@ xcoll/beam_elements/elements_src/everest_crystal.h,sha256=w1wHWhrvodvcJ2Atr8LSaV
16
16
  xcoll/beam_elements/everest.py,sha256=PA_VWpnPrIuO1xN__eKyT_ejbGZK7p93QHDVi3re7cM,8541
17
17
  xcoll/beam_elements/monitor.py,sha256=zzMdN3JMFSAs-30_ntRvd5qZGdsXfGtColhiFDuMcIk,16928
18
18
  xcoll/colldb.py,sha256=IyWozG_37gRf7LGYDz4LMB2HzjexMOapFgIqzeym31w,31027
19
- xcoll/general.py,sha256=Q-plrkrApBD3PIKVMmo1mLTY16WxTMrijDLJgHjtDNc,534
19
+ xcoll/general.py,sha256=7KCioNHNLS4wm9VU9iPFm0N2E6MlhkKCLpPULrQagAg,534
20
20
  xcoll/headers/checks.h,sha256=qdXsOTBOK1MwW6bdFF93j4yE648mcDtEv5rGN1w9sfk,1582
21
21
  xcoll/headers/particle_states.h,sha256=DZa_ZSaJrjnA8aHFriZKfRCkArQ8nK1t445MRwevDtA,840
22
22
  xcoll/initial_distribution.py,sha256=0O4hmO69CuTFDD6QA5G7iEMNx47vaMHn0A9IPw1dYi0,8799
@@ -25,7 +25,7 @@ xcoll/interaction_record/__init__.py,sha256=UFoLiKa-z2oX7YoszP-7Vgdt1nM6kT382v1C
25
25
  xcoll/interaction_record/interaction_record.py,sha256=G2sFXgfmkgpDMaHWJaC80aAreHbY2rGhbkhaMhWKQBg,13192
26
26
  xcoll/interaction_record/interaction_record_src/interaction_record.h,sha256=0rNagnfSGc2i1jauOMIcDbj9QFic9dV_MOyqVx1kw5Q,6067
27
27
  xcoll/interaction_record/interaction_types.py,sha256=Vh6oFYKdRNOx9hc_E0iT8auNZVKC0qYVp_p7oyClZ8o,2894
28
- xcoll/line_tools.py,sha256=j74DFJm4zD5pcYctEz4KeF9LAJ3dKXMafdNve_Gf3Rc,3348
28
+ xcoll/line_tools.py,sha256=1yrw9b3j-yO3uyRpnKhlU0iHxDNeTj5M1jj9v3GqBj0,5634
29
29
  xcoll/lossmap.py,sha256=pV6uf-CKt6PROK_EZ2_DieJftRI2NcsE3CLG23Fth-I,8087
30
30
  xcoll/rf_sweep.py,sha256=P2X1S9pGi4OpNYnzYfQVyblFt2p8aw9EWHsKDkAuYt0,8936
31
31
  xcoll/scattering_routines/everest/__init__.py,sha256=7lkkeZ1liBjXVHCuRpgzZI6ohzHVMj5uJBO792147XY,286
@@ -407,8 +407,8 @@ xcoll/scattering_routines/geometry/rotation.h,sha256=lO3RaQBys9r0ROMjR8T8Rr7UsIE
407
407
  xcoll/scattering_routines/geometry/segments.h,sha256=7nKnnin2ByxkKyaYwGvFaqgLQg5uBba4CdLHL7L3iQs,7667
408
408
  xcoll/scattering_routines/geometry/sort.h,sha256=b1MkFO2ddzv1fWGeQzsLuz46qo2pKyRSXHjoAEVU7Ts,5763
409
409
  xcoll/scattering_routines/geometry/temp.c,sha256=uak0prUg6e441GuR8A9fvAUSfg-E_jaAfGw9fu2Ogms,32437
410
- xcoll-0.5.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
411
- xcoll-0.5.4.dist-info/METADATA,sha256=t429keDIvX-dlJNohluxRuvEASLS9LbuiXtUYJaz_N4,2709
412
- xcoll-0.5.4.dist-info/NOTICE,sha256=6DO_E7WCdRKc42vUoVVBPGttvQi4mRt9fAcxj9u8zy8,74
413
- xcoll-0.5.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
414
- xcoll-0.5.4.dist-info/RECORD,,
410
+ xcoll-0.5.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
411
+ xcoll-0.5.5.dist-info/METADATA,sha256=uN-Ple230sy6CY2egyegJCG9mSGd3nO3C5aWDMWU42M,2709
412
+ xcoll-0.5.5.dist-info/NOTICE,sha256=6DO_E7WCdRKc42vUoVVBPGttvQi4mRt9fAcxj9u8zy8,74
413
+ xcoll-0.5.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
414
+ xcoll-0.5.5.dist-info/RECORD,,
File without changes
File without changes
File without changes