-
Notifications
You must be signed in to change notification settings - Fork 8
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
fscarlier
wants to merge
31
commits into
master
Choose a base branch
from
arc_corr_and_glob_check_fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
68f6d8b
Added arc-by-arc corrections, and new .json lists
fscarlier 284544e
fixed passing of opt for include_ips
fscarlier 49354ae
minor import removal
fscarlier 2cf3400
small fixes, renaming of parameters, +fake arcbyarc test data
fscarlier 0eead2b
version bump and flag as store_true
JoschD d908b34
get bpms per plane
JoschD 0b34c5f
fixed check corrections
JoschD 2488022
lines in correction test style
JoschD e861a08
plot test marker style
JoschD 9406ea8
knob extractor hack
JoschD f977613
remove kq5.l2b1 from MQM_INJ_2024
JoschD a7cf7e9
removed kq4.r6b2
JoschD 8c762a1
removed kq4.r6b2 also from TOP
JoschD 5e0257a
changed optics measurements style
JoschD 0904fae
Print exciter BPM in error message
JoschD b56bd02
Merge branch 'master' into arc_corr_and_glob_check_fix
JoschD aecbb3c
fix lhc
JoschD 23e41b3
added NaN check
JoschD 3020b80
made warning
JoschD 5cfe24c
added generic accelerator
JoschD 099c42d
skip coupling for generic and sps
JoschD 7d4c1ad
Merge branch 'master' into arc_corr_and_glob_check_fix
JoschD 51c2400
fixed changelog bugs
JoschD 67570e0
Merge branch 'master' into arc_corr_and_glob_check_fix
JoschD 5ac386f
nan in output
JoschD ee71a70
CHANGELOG
JoschD 4d18da9
bad bpm message
JoschD c97a9ff
fix no data in plane
JoschD bba82c7
changelog
JoschD 33b67ce
Merge 'main' into 'arc_corr_and_glob_check_fix'
jgray-19 a34f920
Merege 'master' into 'arc_corr_and_glob_check_fix'
jgray-19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
__title__ = "omc3" | ||
__description__ = "An accelerator physics tools package for the OMC team at CERN." | ||
__url__ = "https://github.com/pylhc/omc3" | ||
__version__ = "0.14.1" | ||
__version__ = "0.15.0" | ||
__author__ = "pylhc" | ||
__author_email__ = "[email protected]" | ||
__license__ = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
def identify_closest_arc_bpm_to_ip(ip, side, beam, bpms): | ||
indices = range(1,15) | ||
for ii in indices: | ||
bpm = f'BPM.{ii}{side}{ip}.B{beam}' | ||
if bpm in bpms: | ||
return bpm | ||
|
||
|
||
def get_left_right_pair(arc, beam, bpms): | ||
left_of_arc = identify_closest_arc_bpm_to_ip(int(arc[0]), 'R', beam, bpms) | ||
right_of_arc = identify_closest_arc_bpm_to_ip(int(arc[1]), 'L', beam, bpms) | ||
return [left_of_arc, right_of_arc] | ||
|
||
|
||
def get_arc_by_arc_bpm_pairs(meas_dict, opt, plane): | ||
bpms = meas_dict[f'PHASE{plane}'].index | ||
beam = bpms[0][-1] | ||
bpm_pairs = {} | ||
bpm_pairs_with_ips = {} | ||
|
||
arcs_to_cycle = ['81', '12', '23', '34', '45', '56', '67', '78'] | ||
|
||
for lhc_arc in arcs_to_cycle: | ||
bpm_pairs[lhc_arc] = get_left_right_pair(lhc_arc, beam, bpms) | ||
|
||
if opt.include_ips_in_arc_by_arc == 'left': | ||
bpm_pairs_with_ips['81'] = [bpm_pairs['78'][1], bpm_pairs['81'][1]] | ||
bpm_pairs_with_ips['12'] = [bpm_pairs['81'][1], bpm_pairs['12'][1]] | ||
bpm_pairs_with_ips['23'] = [bpm_pairs['12'][1], bpm_pairs['23'][1]] | ||
bpm_pairs_with_ips['34'] = [bpm_pairs['23'][1], bpm_pairs['34'][1]] | ||
bpm_pairs_with_ips['45'] = [bpm_pairs['34'][1], bpm_pairs['45'][1]] | ||
bpm_pairs_with_ips['56'] = [bpm_pairs['45'][1], bpm_pairs['56'][1]] | ||
bpm_pairs_with_ips['67'] = [bpm_pairs['56'][1], bpm_pairs['67'][1]] | ||
bpm_pairs_with_ips['78'] = [bpm_pairs['67'][1], bpm_pairs['78'][1]] | ||
bpm_pairs = bpm_pairs_with_ips | ||
elif opt.include_ips_in_arc_by_arc == 'right': | ||
bpm_pairs_with_ips['81'] = [bpm_pairs['78'][0], bpm_pairs['81'][0]] | ||
bpm_pairs_with_ips['12'] = [bpm_pairs['81'][0], bpm_pairs['12'][0]] | ||
bpm_pairs_with_ips['23'] = [bpm_pairs['12'][0], bpm_pairs['23'][0]] | ||
bpm_pairs_with_ips['34'] = [bpm_pairs['23'][0], bpm_pairs['34'][0]] | ||
bpm_pairs_with_ips['45'] = [bpm_pairs['34'][0], bpm_pairs['45'][0]] | ||
bpm_pairs_with_ips['56'] = [bpm_pairs['45'][0], bpm_pairs['56'][0]] | ||
bpm_pairs_with_ips['67'] = [bpm_pairs['56'][0], bpm_pairs['67'][0]] | ||
bpm_pairs_with_ips['78'] = [bpm_pairs['67'][0], bpm_pairs['78'][0]] | ||
bpm_pairs = bpm_pairs_with_ips | ||
|
||
return bpm_pairs | ||
|
||
|
||
def circular_sum_phase(phase_df, tune, bpm_pair, key): | ||
idx_0 = phase_df[key].index.get_loc(bpm_pair[0]) | ||
idx_1 = phase_df[key].index.get_loc(bpm_pair[1]) | ||
if idx_0 > idx_1: | ||
inverted_result = sum(phase_df[key][bpm_pair[1]:bpm_pair[0]]) | ||
result = tune - inverted_result | ||
else: | ||
result = sum(phase_df[key][bpm_pair[0]:bpm_pair[1]]) | ||
return result | ||
|
||
|
||
def circular_sum_phase_error(phase_df, bpm_pair): | ||
idx_0 = phase_df['ERROR'].index.get_loc(bpm_pair[0]) | ||
idx_1 = phase_df['ERROR'].index.get_loc(bpm_pair[1]) | ||
if idx_0 > idx_1: | ||
selection = pd.concat([phase_df['ERROR'].loc[:bpm_pair[1]], phase_df['ERROR'].loc[bpm_pair[0]:]]) | ||
result = np.sqrt(np.sum(selection**2)) | ||
else: | ||
result = np.sqrt(np.sum(phase_df['ERROR'][bpm_pair[0]:bpm_pair[1]]**2)) | ||
return result | ||
|
||
def get_arc_phases(bpm_pairs, meas_dict, tune, plane): | ||
arc_meas = [] | ||
for arc, bpm_pair in bpm_pairs.items(): | ||
results = {} | ||
results['NAME'] = bpm_pair[0] | ||
results['NAME2'] = bpm_pair[1] | ||
results['WEIGHT'] = meas_dict[f'PHASE{plane}'].loc[bpm_pair[0], 'WEIGHT'] | ||
results['VALUE'] = circular_sum_phase(meas_dict[f'PHASE{plane}'], tune, bpm_pair, 'VALUE') | ||
results['MODEL'] = circular_sum_phase(meas_dict[f'PHASE{plane}'], tune, bpm_pair, 'MODEL') | ||
results['ERROR'] = circular_sum_phase_error(meas_dict[f'PHASE{plane}'], bpm_pair) | ||
results['DIFF'] = results['VALUE'] - results['MODEL'] | ||
arc_meas.append(results) | ||
|
||
meas_dict[f'PHASE{plane}'] = pd.DataFrame(arc_meas).set_index('NAME') | ||
|
||
return meas_dict | ||
|
||
|
||
def reduce_to_arc_extremities(meas_dict, nominal_model, opt): | ||
bpm_pairs_x = get_arc_by_arc_bpm_pairs(meas_dict, opt, "X") | ||
bpm_pairs_y = get_arc_by_arc_bpm_pairs(meas_dict, opt, "Y") | ||
meas_dict = get_arc_phases(bpm_pairs_x, meas_dict, nominal_model.headers['Q1'], 'X') | ||
meas_dict = get_arc_phases(bpm_pairs_y, meas_dict, nominal_model.headers['Q2'], 'Y') | ||
return meas_dict |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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