-
Notifications
You must be signed in to change notification settings - Fork 18
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
How to obtain BPM readings? #38
Comments
There is no MAD-X command called |
Thanks, Thomas from __future__ import division
import matplotlib.pylab as plt
from cpymad.madx import Madx
def readBpm(bpm, sequence="himm"):
"""
read the x value of BPM
"""
madx.command.twiss(sequence=sequence)
twiss = madx.get_table("twiss")
bpm = bpm
ind = []
for bpm0 in bpm:
ind.append([i for i, bpm1 in enumerate(twiss['name']) if bpm1 == bpm0])
#print ind
s = []
x = []
for i0 in ind:
s.append(twiss['s'][i0])
x.append(twiss['x'][i0])
return s, x
madx = Madx(command_log="HIMM_log.madx")
madx.command.call(file="HIMM_cpymad")
madx.command.twiss(sequence="himm")
#plot bpm data before correct
bpm = ['bpm11:1','bpm12:1','bpm21:1','bpm31:1','bpm32:1','bpm33:1','bpm42:1','bpm41:1']
sequence = "himm"
bpmData = readBpm(bpm, sequence)
s = bpmData[0]
x = bpmData[1]
plt.plot(s,x,'b-o',label="befor correct")
plt.legend()
plt.show() Max file, named as "HIMM_cpymad".
|
I'm not your personal advisor. And yes, this can be written much shorter - with just some knowledge in python programming. It has nothing to do with cpymad. |
Hi, Thomas
How to get the BPM readings? I write a small code, but it can't work anyway.
The text was updated successfully, but these errors were encountered: