@rogeliotomas @alangner
Rogelio ran the new SegmentBySegment.py(sbs) script and received following error:
Traceback (most recent call last):
File "/afs/cern.ch/work/v/vimaier/public/Beta-Beat.src/SegmentBySegment/SegmentBySegment.py", line 2349, in
return_value = main(options)
File "/afs/cern.ch/work/v/vimaier/public/Beta-Beat.src/SegmentBySegment/SegmentBySegment.py", line 500, in main
getAndWriteData(namename,phases,betah,betav,disph,dispv,couple,chromatic,twisstwiss,modelcor,normal_pro,back_pro,savepath,elementswitch,accel)
File "/afs/cern.ch/work/v/vimaier/public/Beta-Beat.src/SegmentBySegment/SegmentBySegment.py", line 1550, in getAndWriteData
delta_phase = (phasey.PHASEY[phasex.indx[name]] - phasex.PHASEY[phasey.indx[first_bpm]]) %1
AttributeError: twiss instance has no attribute 'PHASEY'
The old sbs ran without errors.
Error is caused by this new line:
delta_phase = (phasey.PHASEY[phasex.indx[name]] - phasex.PHASEY[phasey.indx[first_bpm]]) %1
There are two logical errors.
- phasey.PHASEY[phasex.indx[name]] ; phasey-file but phasex index?
- phasex.PHASEY[phasey.indx[first_bpm]]) ; should probably be PHASEX
The second error caused the exception since phasex file has no PHASEY column.
I do not know which delta_phase is supposed to be calculated here. For now I changed the calculation to delta_phase_x between current bpm(name) and first_bpm:
delta_phase = abs(phasex.PHASEX[phasex.indx[name]] - phasex.PHASEX[phasex.indx[first_bpm]]) %1
Note that I took the absolute value. You have to pay attention with modulo.
Consider following code and output
print 0.00828579 - 0.0104637533333 --> -0.0021779633333
print (0.00828579 - 0.0104637533333) %1 --> 0.997822036667 !complementary value to delta and 1
print abs(0.00828579 - 0.0104637533333) %1 --> 0.0021779633333 !correct delta
These are real values from PHASEX and PHASEY.
Another thing. While debugging this case I noticed that phasex was the file getphasex_free.out and phasy was getphasey.out (no free version).
Another bug was here(checking of getphase_free.out):
try:
filephasex=twiss(path+"/getphasex_free.out")
except:
filephasex=twiss(path+"/getphasex.out")
try:
filephasey=twiss(path+"/getphasey.out")
except:
filephasey=twiss(path+"/getphasey_free.out")
try:
filephasextot=twiss(path+"/getphasetotx_free.out")
except:
filephasextot=twiss(path+"/getphasetotx.out")
try:
filephaseytot=twiss(path+"/getphasetoty_free.out")
except:
filephaseytot=twiss(path+"/getphasetoty.out")
Fixed this bug and replaced the excepts with except (IOError, ValueError).