Skip to content

Commit a9b8998

Browse files
authored
SbS Coupling and Dispersion Propagation (#491)
1 parent 458d3ab commit a9b8998

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+15934
-15046
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# OMC3 Changelog
22

3+
#### 2025-04-03 - v0.24.0 - _jdilly_
4+
5+
- Added:
6+
- Additional Propagables: Dispersion (but not really working [#498](https://github.com/pylhc/omc3/issues/498)), Coupling (only forward working [#498](https://github.com/pylhc/omc3/issues/498])).
7+
38
#### 2025-04-01 - v0.23.01 - _jdilly_, _jgray_
49

510
- Changed:

doc/_static/css/custom.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,24 @@ em.sig-param span.default_value {
272272
padding-top: 10px;
273273
padding-bottom: 5px;
274274
}
275-
}
275+
}
276+
277+
/* Custom styles for bibliography */
278+
.citation {
279+
display: block!important;
280+
}
281+
282+
.citation .label {
283+
display: block;
284+
font-weight: bold;
285+
margin-bottom: 0.5em;
286+
}
287+
288+
.citation p {
289+
margin: 0;
290+
padding-left: 1em;
291+
}
292+
293+
.citation cite {
294+
display: block;
295+
}

doc/bibliography.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Bibliography
2+
************
3+
4+
.. [LangnerDevelopmentsSegmentbySegmentTechnique2015]
5+
A. Langner et al.,
6+
`Developments of the Segment-by-Segment Technique for Optics Corrections in the LHC,`
7+
Proceedings of the 6th International Particle Accelerator Conference (2015).
8+
https://doi.org/10.18429/JACoW-IPAC2015-MOPJE054

doc/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ Package Reference
2424

2525
modules/*
2626

27+
.. toctree::
28+
:caption: Bibliography
29+
:maxdepth: 1
30+
31+
bibliography
32+
33+
2734
Citing
2835
======
2936

doc/modules/definitions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ Definitions
1010
:members:
1111
:noindex:
1212

13+
14+
.. automodule:: omc3.definitions.optics
15+
:members:
16+
:noindex:

omc3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__title__ = "omc3"
1212
__description__ = "An accelerator physics tools package for the OMC team at CERN."
1313
__url__ = "https://github.com/pylhc/omc3"
14-
__version__ = "0.23.1"
14+
__version__ = "0.24.0"
1515
__author__ = "pylhc"
1616
__author_email__ = "[email protected]"
1717
__license__ = "MIT"

omc3/__main__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
from pathlib import Path
2+
23
this_dir = Path(__file__).parent
4+
5+
# Welcome ---
6+
print("Welcome to omc3!\n")
7+
8+
# Scripts ---
39
scripts = this_dir.glob("[a-zA-Z]*.py")
4-
print("Welcome to omc3!")
510
print("Available entrypoints:\n")
611
for script in scripts:
712
print(f"omc3.{script.stem}")
13+
print()
14+
15+
# Modules ---
16+
modules = this_dir.glob("*/**/__main__.py")
17+
print("Other Modules:\n")
18+
for module in modules:
19+
print(f"omc3.{module.parent.stem}")
820
print()

omc3/definitions/formats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Formats
3-
-------------
3+
-------
44
55
Recurring formats are defined here.
66
"""

omc3/definitions/optics.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
"""
2+
Optics
3+
------
4+
5+
Definitions for the optics measurements.
6+
"""
7+
from __future__ import annotations
8+
19
from dataclasses import dataclass, fields
210

311
import tfs
412
from omc3.correction.constants import EXPECTED, DIFF
513
from omc3.optics_measurements.constants import (
6-
BETA_NAME, AMP_BETA_NAME, ORBIT_NAME, DISPERSION_NAME, NORM_DISP_NAME,
14+
ALPHA, BETA_NAME, AMP_BETA_NAME, ORBIT_NAME, DISPERSION_NAME, NORM_DISP_NAME,
715
PHASE_NAME, TOTAL_PHASE_NAME, AMPLITUDE, REAL, IMAG, DISPERSION, NORM_DISPERSION,
8-
PHASE_ADV, MDL, S, KMOD_BETA_NAME,
16+
PHASE_ADV, MDL, S, S_MODEL, KMOD_BETA_NAME,
917
EXT, NAME, DELTA, ERR, DRIVEN_TOTAL_PHASE_NAME, DRIVEN_PHASE_NAME, IP_NAME,
1018
KMOD_IP_NAME, KICK_NAME, BETA, PHASE, ORBIT, F1001_NAME, F1010_NAME, TUNE, RMS, MASKED)
1119
from omc3.plotting.utils.annotations import ylabels
@@ -37,8 +45,8 @@ class OpticsMeasurement(TfsCollection):
3745
kick = Tfs(KICK_NAME)
3846
ip = Tfs(IP_NAME)
3947
ip_kmod = Tfs(KMOD_IP_NAME)
40-
f1001 = Tfs(F1001_NAME, two_planes=False)
41-
f1010 = Tfs(F1010_NAME, two_planes=False)
48+
f1001: TfsDataFrame = Tfs(F1001_NAME, two_planes=False)
49+
f1010: TfsDataFrame = Tfs(F1010_NAME, two_planes=False)
4250

4351
def _get_filename(self, name, plane="") -> str:
4452
""" Default way `optics_measurements` filenames are defined,
@@ -82,7 +90,7 @@ class ColumnsAndLabels:
8290
# Other
8391
needs_plane: bool = True
8492

85-
def set_plane(self, plane: str):
93+
def set_plane(self, plane: str) -> ColumnsAndLabels:
8694
""" Fixes the plane in a new object. """
8795
if not self.needs_plane:
8896
raise AttributeError("Cannot set the plane of a non-planed definition.")
@@ -91,6 +99,13 @@ def set_plane(self, plane: str):
9199
needs_plane=False,
92100
**values_fixed_plane,
93101
)
102+
103+
def set_label_formatted(self, name: str) -> ColumnsAndLabels:
104+
""" Fixes the label in a new object (for RDTs). """
105+
if self._label is None:
106+
raise AttributeError("No label defined.")
107+
new_label = self._label.format(name)
108+
return ColumnsAndLabels(**{f.name: getattr(self, f.name) for f in fields(self) if f.name != "_label"}, _label=new_label)
94109

95110
# Properties ----
96111
@property
@@ -190,6 +205,7 @@ def delta_label(self):
190205
# Defined Columns --------------------------------------------------------------
191206
TUNE_COLUMN = ColumnsAndLabels(TUNE, _expected_column=f"{EXPECTED}{TUNE}{{0}}", _label=ylabels['tune'], _text_label='tune')
192207
BETA_COLUMN = ColumnsAndLabels(BETA, _label=ylabels['beta'], _text_label='beta', _delta_label=ylabels['betabeat'])
208+
ALPHA_COLUMN = ColumnsAndLabels(ALPHA, _label=ylabels['alpha'], _text_label='alpha')
193209
ORBIT_COLUMN = ColumnsAndLabels(ORBIT, _label=ylabels['co'], _text_label='orbit')
194210
DISPERSION_COLUMN = ColumnsAndLabels(DISPERSION, _label=ylabels['dispersion'], _text_label='dispersion')
195211
NORM_DISPERSION_COLUMN = ColumnsAndLabels(NORM_DISPERSION, _label=ylabels['norm_dispersion'], _text_label='normalized dispersion')
@@ -198,6 +214,7 @@ def delta_label(self):
198214
MU_COLUMN = ColumnsAndLabels(PHASE_ADV, _label=ylabels['phasetot'], _text_label='total phase')
199215
PHASE_ADVANCE_COLUMN = ColumnsAndLabels(f'{PHASE_ADV}{{0}}{MDL}', _label=r'Phase Advance [$2 \pi$]', _text_label='phase advance')
200216
S_COLUMN = ColumnsAndLabels(S, _label='Location [m]', _text_label='longitudinal location', needs_plane=False)
217+
S_MODEL_COLUMN = ColumnsAndLabels(S_MODEL, _label='Location [m]', _text_label='longitudinal location', needs_plane=False)
201218

202219
RDT_AMPLITUDE_COLUMN = ColumnsAndLabels(AMPLITUDE, _label=ylabels['absolute'], _text_label='amplitude', needs_plane=False) # label needs rdt
203220
RDT_PHASE_COLUMN = ColumnsAndLabels(PHASE, _label=ylabels['phase'], _text_label='phase', needs_plane=False) # label needs rdt
@@ -227,4 +244,4 @@ def delta_label(self):
227244
}
228245

229246
""" Find the Column Dataclass by column name for RDTs. """
230-
RDT_COLUMN_MAPPING = {c.column: c for c in [RDT_AMPLITUDE_COLUMN, RDT_PHASE_COLUMN, RDT_IMAG_COLUMN, RDT_REAL_COLUMN]}
247+
RDT_COLUMN_MAPPING = {c.column: c for c in [RDT_AMPLITUDE_COLUMN, RDT_PHASE_COLUMN, RDT_IMAG_COLUMN, RDT_REAL_COLUMN]}

omc3/model/model_creators/abstract_model_creator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
measurement_madx,
3939
)
4040
from omc3.segment_by_segment.propagables import Propagable
41+
from omc3.segment_by_segment.propagables.coupling import Coupling
4142
from omc3.segment_by_segment.segments import Segment
4243
from omc3.utils import iotools, logging_tools
4344

0 commit comments

Comments
 (0)