Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arc corr and glob check fix #437

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open

Conversation

fscarlier
Copy link
Contributor

It's all in a single pull request, since it was all entangled anyway:

changes:

  • added arc-by-arc corrections
  • added the fixes we made together
  • changed the .json corrector files to include the mqt and ats only, and the 2024 global correction lists.
  • Added the arc-by-arc-phase and include-ips to the global_corrections parameters input

Two things:

  • Can you check if it is ok for the opt. definitions?
  • One test seems to fail for macos, but it doesn't seem to be related to the changes.

@fscarlier fscarlier requested a review from JoschD March 6, 2024 12:08
Copy link
Member

@fsoubelet fsoubelet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe @JoschD has a few refactors & tests in mind. In the meantime, a few comments / suggestions.

A little bit of type hinting could go a long way for the new functions in omc3/correction/arc_by_arc.py

omc3/definitions/optics.py Show resolved Hide resolved
omc3/global_correction.py Outdated Show resolved Hide resolved
omc3/global_correction.py Outdated Show resolved Hide resolved
omc3/correction/arc_by_arc.py Outdated Show resolved Hide resolved
@JoschD
Copy link
Member

JoschD commented Apr 22, 2024

Hey @fscarlier . This still needs tests, have you progressed in that regard?

@JoschD
Copy link
Member

JoschD commented May 8, 2024

Hey @fscarlier . It would be great if you could implement some tests, so we can merge this back into master and avoid the clusterfudge we had last year with diverging branches.

@JoschD
Copy link
Member

JoschD commented Jul 9, 2024

Hey @fscarlier what is the status of these tests? Have you talked to @emaclean or @rogeliotomas that maybe someone else can take over this task if this cannot be done by you?

Copy link
Member

@JoschD JoschD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests

@JoschD
Copy link
Member

JoschD commented Oct 28, 2024

after mergin with master I had to delete the corrections.json files. If there is no stuff, needs to be checked

https://github.com/pylhc/omc3/pull/437/files#diff-d447a2bc45be9d9adfe4ad905a9c79bd1b46ef5c71f2f782c752610d47cbac65

@JoschD JoschD requested a review from a team as a code owner October 28, 2024 15:06
Copy link
Member

@fsoubelet fsoubelet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments / questions here and there, looking good.

@@ -1,5 +1,19 @@
# OMC3 Changelog

#### IN PROGRESS - v0.18.0 - _jdilly_, _fscarlier_, _fesoubel_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we waiting for more to release? The Kmod branch?

@@ -481,8 +481,10 @@ def _create_model_and_write_diff_to_measurements(
diff_columns = (
list(OPTICS_PARAMS_CHOICES[:-4]) +
[col for col in corr_model_elements.columns if col.startswith("F1")] +
list(PLANES)
list(PLANES) +
['MUX', 'MUY']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also probably be from constants

@@ -66,6 +66,9 @@ def correct(accel_inst: Accelerator, opt: DotDict) -> None:
meas_dict = filters.filter_measurement(optics_params, meas_dict, nominal_model, opt)
meas_dict = model_appenders.add_differences_to_model_to_measurements(nominal_model, meas_dict)

if opt.arc_by_arc_phase and accel_inst.NAME == 'lhc':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to hardcode here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with Lhc.NAME but yeah, hardcoded to filter LHC

model.loc[meas.index.to_numpy(), model_column].to_numpy())
model_phases_advances = (model.loc[meas["NAME2"].to_numpy(), model_column].to_numpy() -
model.loc[meas.index.to_numpy(), model_column].to_numpy())
model_phases_advances[model_phases_advances < 0] += tunes[plane]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a settingswithcopywarning, this PR could be the opportunity to use .loc and future proof a bit.

help="Set to perform arc-by-arc total phase correction.", )
params.add_parameter(name="include_ips_in_arc_by_arc",
type=str,
choices=("left", "right"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the choices correct here since the default is None?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "None" is always a choice when not required. I implemented this somewhen.

omc3/harpy/clean.py Outdated Show resolved Hide resolved
Comment on lines +332 to +343
excitation_name = "AC-Dipole"
possible_bpms = [f"BPMY{a_b}.6L4.B{beam}", f"BPM.7L4.B{beam}"]
element = f"MKQA.6L4.B{beam}"
elif self.excitation == AccExcitationMode.ADT:
excitation_name = "ADT-AC-Dipole"
possible_bpms = [f"BPMWA.B5{l_r}4.B{beam}", f"BPMWA.A5{l_r}4.B{beam}"]
element = f"ADTK{adt}5{l_r}4.B{beam}"
else:
return None

try:
return _first_one_in(possible_bpms, commonbpms), element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, thanks. Could you take the opportunity to write a mini docstring so we have written somewhere that this does not return the exciter BPM, but the exciter BPM and the exciter element name?

omc3/optics_measurements/measure_optics.py Show resolved Hide resolved
omc3/model/accelerators/generic.py Show resolved Hide resolved
Copy link

codeclimate bot commented Nov 15, 2024

Code Climate has analyzed commit a34f920 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 44.3% (50% is the threshold).

This pull request will bring the total coverage in the repository to 85.3% (-0.6% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants