The following statements are completely useless except of the assignment of tune_d.q1 and tune_d.q2.
Nothing else will be used further:
if twiss_d.has_non_zero_dpp_y() and twiss_d.has_non_zero_dpp_x():
if len(twiss_d.non_zero_dpp_x) != len(twiss_d.non_zero_dpp_y):
raise ValueError("list of dppx is not equal list of dppy")
for j in range(len(twiss_d.non_zero_dpp_x)):
dpop = float(twiss_d.non_zero_dpp_x[j].DPP)
list_with_single_twiss_x = []
list_with_single_twiss_y = []
list_with_single_twiss_x.append(twiss_d.non_zero_dpp_x[j])
list_with_single_twiss_y.append(twiss_d.non_zero_dpp_y[j])
### coupling
try:
mad_twiss.Cmatrix()
except:
pass
if getllm_d.accel == "SPS" or "RHIC" in getllm_d.accel:
#TODO: check parameter. Q seems missing in calls get_phases (vimaier)
plane = 'H'
[phasexp, tune_d.q1, MUX, bpmsx] = algorithms.helper.get_phases(getllm_d, mad_twiss, pseudo_list_x, plane)
plane = 'V'
[phaseyp, tune_d.q2, MUY, bpmsy] = algorithms.helper.get_phases(getllm_d, mad_twiss, pseudo_list_y, plane)
[fwqw, bpms] = algorithms.helper.GetCoupling2(mad_twiss, pseudo_list_x, pseudo_list_y, tune_d.q1, tune_d.q2, phasexp, phaseyp, getllm_d.beam_direction, getllm_d.accel)
elif getllm_d.num_beams_for_coupling == 1:
[fwqw, bpms] = algorithms.helper.GetCoupling1(mad_twiss, list_with_single_twiss_x, list_with_single_twiss_y, tune_d.q1, tune_d.q2)
elif getllm_d.num_beams_for_coupling == 2:
[fwqw, bpms] = algorithms.helper.GetCoupling2(mad_twiss, list_with_single_twiss_x, list_with_single_twiss_y, tune_d.q1, tune_d.q2, phasexlist[j], phaseylist[j], getllm_d.beam_direction, getllm_d.accel)
if getllm_d.with_ac_calc:
[fwqw, bpms] = algorithms.helper.getFreeCoupling(tune_d.q1f, tune_d.q2f, tune_d.q1, tune_d.q2, fwqw, mad_twiss, bpms)
else:
raise ValueError('Number of monitors for coupling analysis (option -n) should be 1 or 2.')
fwqw['DPP'] = dpop
The code could be minimized to:
if twiss_d.has_non_zero_dpp_y() and twiss_d.has_non_zero_dpp_x():
if len(twiss_d.non_zero_dpp_x) != len(twiss_d.non_zero_dpp_y):
raise ValueError("list of dppx is not equal list of dppy")
for j in range(len(twiss_d.non_zero_dpp_x)):
### coupling
try:
mad_twiss.Cmatrix()
except:
pass
if getllm_d.accel == "SPS" or "RHIC" in getllm_d.accel:
#TODO: check parameter. Q seems missing in calls get_phases (vimaier)
plane = 'H'
[phasexp, tune_d.q1, MUX, bpmsx] = algorithms.helper.get_phases(getllm_d, mad_twiss, pseudo_list_x, plane)
plane = 'V'
[phaseyp, tune_d.q2, MUY, bpmsy] = algorithms.helper.get_phases(getllm_d, mad_twiss, pseudo_list_y, plane)
Q1 and Q2 will only be assigned if accel is SPS or RHIC. The invocations of get_phases with these accelerators are wrong(Tune is missing, see issue #23 ).
Not sure but it seems the last time the scripts were running with these accelerators is long time ago.
@rogeliotomas @Eothred @alangner
Does it have any effect to call mad_twiss.Cmatrix() multiple times like in the snippet above?
The following statements are completely useless except of the assignment of tune_d.q1 and tune_d.q2. Nothing else will be used further:
The code could be minimized to:
Q1 and Q2 will only be assigned if accel is SPS or RHIC. The invocations of get_phases with these accelerators are wrong(Tune is missing, see issue #23 ). Not sure but it seems the last time the scripts were running with these accelerators is long time ago.
@rogeliotomas @Eothred @alangner Does it have any effect to call mad_twiss.Cmatrix() multiple times like in the snippet above?