Skip to content

Commit

Permalink
review Felix
Browse files Browse the repository at this point in the history
  • Loading branch information
JoschD committed Jan 23, 2025
1 parent 108c1bd commit c28d775
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
12 changes: 8 additions & 4 deletions omc3/correction/arc_by_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
In a future implementation this should be extended to loop over each arc and
correct each individually with only the correctors available in the respective arc.
For now, the everything is very LHC specific, a future implementation should also
extract the accelator specific parts into the accelerator class.
For now everything is very LHC specific, a future implementation should also
extract the accelerator specific parts into the accelerator class.
See https://github.com/pylhc/omc3/issues/480 .
"""
from __future__ import annotations

from collections.abc import Sequence
from typing import Literal
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd
Expand All @@ -33,6 +32,11 @@
from omc3.correction.constants import DIFF, ERROR, MODEL, VALUE, WEIGHT
from omc3.optics_measurements.constants import NAME, NAME2, PHASE

if TYPE_CHECKING:
from collections.abc import Sequence
from typing import Literal


LHC_ARCS = ('81', '12', '23', '34', '45', '56', '67', '78')


Expand Down
7 changes: 6 additions & 1 deletion omc3/correction/model_appenders.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from __future__ import annotations

from collections import defaultdict
from collections.abc import Callable, Sequence
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd
Expand All @@ -22,6 +22,11 @@
from omc3.utils import logging_tools
from omc3.optics_measurements.toolbox import df_diff, df_rel_diff


if TYPE_CHECKING:
from collections.abc import Callable, Sequence


LOG = logging_tools.get_logger(__name__)


Expand Down
24 changes: 0 additions & 24 deletions tests/accuracy/test_global_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,26 +400,6 @@ def test_lhc_global_correct_dpp(tmp_path: Path, model_inj_beams: DotDict, dpp: f
previous_diff = current_diff


def reset_phase_advances(df, beam):
""" Reset phase advances to zero for each arc, i.e after the BPM name changes from L# to R#."""
# Do only BPMs in that arc, as the correction is based on these
df = df.copy()
df = df.loc[df.index.str.match("B"), :]


# Find the BPMs where the model changes from L# to R# and reset phase advances
left_of_ip = False
for name in df.index:
right_of_ip = re.match(fr".*R\d\.B{beam}", name)
if left_of_ip and right_of_ip:
left_of_ip = False

if not left_of_ip and not right_of_ip:
left_of_ip = True

return df


def _plot_arc_by_arc(beam, **kwargs):
""" Plot the arc-by-arc phase advance.
Expand All @@ -435,10 +415,6 @@ def _plot_arc_by_arc(beam, **kwargs):
df_error = kwargs["errors"]
df_iter1 = kwargs["iter1"]


# for name, df in kwargs.items():
# kwargs[name] = reset_phase_advances(df, beam)

for ax, plane in zip(axs, ["X", "Y"]):
for ip in df_model.index[df_model.index.str.startswith("IP")]:
ax.axvline(df_model.loc[ip, "S"], color="k", linestyle="--")
Expand Down

0 comments on commit c28d775

Please sign in to comment.