Skip to content
Snippets Groups Projects
Commit 849a638d authored by Claudio Scafuri's avatar Claudio Scafuri :speech_balloon:
Browse files

work in progress

parent d18462b0
No related branches found
No related tags found
No related merge requests found
__pycache__
*.pyc
source diff could not be displayed: it is too large. Options to address this: view the blob.
#!/usr/bin/python3
# extract data of lattice elements dnf prepare auxiliary layout info
import LatticeInfo
latticetfile = "/home/claudio/src/gitlab/dt/machine/lattice/elettra2/srElettra2_9_4_beta.mat"
linfo = LatticeInfo.LatticeInfo(latticetfile, 2.4e9)
print(linfo.field_names())
linfo.printall()
"""
up to now the low_beta lattice file can be ignred. It will have the same structure of rElettra2_9_4_beta but different
magnet strenghts
ring=at.load_lattice("../../machine/lattice/elettra2/srElettra2_low_beta.mat",energy=2.4e9)
"""
#!/usr/bin/python3
# extract index of various elements and print them
import at
import re
#import matplotlib.pylab as mp
#ring=at.load_lattice("../../machine/lattice/elettra2/srElettra2_9_4_beta.mat",energy=2.4e9)
ring=at.load_lattice("../../machine/lattice/elettra2/srElettra2_low_beta.mat",energy=2.4e9)
refpts = range(len(ring) + 1)
# find index of quadrupoles in ring
iquads = ring.uint32_refpts(at.Quadrupole)
print("Name, Length,K,PolynomA,PolynomB")
for i in iquads:
q=ring[i]
print(q.FamName,q.Length,q.K,q.PolynomA[1],q.PolynomB[1])
#find index of reverse bends Q24R quads
print("Name, Length,K,PolynomA,PolynomB")
irb = ring.uint32_refpts("QAB*")
for i in irb:
q=ring[i]
print(q.FamName,q.Length,q.K,q.PolynomA[1],q.PolynomB[1])
# find index of sextupoles in ring
isexts = ring.uint32_refpts(at.Sextupole)
print("Name, Length,K,PolynomA,PolynomB,is_corr,is_skew")
for i in isexts:
q=ring[i]
dorder = q.DefaultOrder
morder = q.MaxOrder
if hasattr(q,'corID'):
iscorr = 'is_corr'
else:
iscorr = '-------'
if hasattr(q,'SkewID'):
isskew = 'is_skew'
else:
isskew = '-------'
print(q.FamName,q.Length,q.K,q.PolynomA[dorder],q.PolynomB[morder],iscorr,isskew)
#find index of octupoles in ring
iocts = ring.uint32_refpts(at.Octupole)
print("Name, Length,K,PolynomA,PolynomB,is_corr,is_skew")
for i in iocts:
q=ring[i]
dorder = q.DefaultOrder
morder = q.MaxOrder
if hasattr(q,'corID'):
iscorr = 'is_corr'
else:
iscorr = '-------'
if hasattr(q,'SkewID'):
isskew = 'is_skew'
else:
isskew = '-------'
print(q.FamName,q.Length,q.K,q.PolynomA[dorder],q.PolynomB[morder],iscorr,isskew)
#find index of b64 dipoles in ring
#this is triky..... We have to set name to indexes ... or modify something in the lattice.
ib64 = ring.uint32_refpts("b1")
for i in ib64:
q=ring[i]
dorder = q.DefaultOrder
morder = q.MaxOrder
print(q.FamName,q.Length,q.K,q.PolynomA[dorder],q.PolynomB[morder])
#find index of b80 dipoles in ring
#this is enven trikier! triky..... We have to set name to indexes and elemets are a composition of pieces
# TO DO
# get bpms and their s position
ibpms = ring.uint32_refpts("bpm")
print("ind. ,name, s[m]")
for i in ibpms:
bpm=ring[i]
sp=ring.get_s_pos(i)
print(i, bpm.FamName,sp[0])
# get corectors and their s position
ichv = ring.uint32_refpts("chv*")
print("ind. ,name, s[m]")
for i in ichv:
chv=ring[i]
sp=ring.get_s_pos(i)
print(i,chv.FamName,sp[0])
#get RF cavities
selector = "RF"
irfcavs = ring.uint32_refpts(selector)
for i in irfcavs:
rfcav=ring[i]
srf=ring.get_s_pos(i)
print(i,rfcav.FamName,srf[0])
#!/usr/bin/python3
# extract index and data of various elements and print them
"""
still missing: get TYPE of magnets etc... which must be got form another source
"""
import at
def lattlister(ring,geo,selector):
idlist = ring.uint32_refpts(selector)
for i in idlist:
elem = ring[i]
ename = elem.FamName
length = elem.Length
x=geo[i].x
y=geo[i].y
angle=geo[i].angle
if hasattr(elem,'corID'):
iscorr = '1'
else:
iscorr = '0'
if hasattr(elem,'SkewID'):
isskew = '1'
else:
isskew = '0'
spos = ring.get_s_pos(i)[0]
print(i,'\t',ename,'\t',length,'\t',spos,'\t',iscorr,'\t',isskew,'\t',x,'\t',y,'\t',angle)
#return i,ename,length,spos,iscorr,isskew
ring=at.load_lattice("../../machine/lattice/elettra2/srElettra2_9_4_beta.mat",energy=2.4e9)
"""
up to now the low_beta lattice file can be ignred. It will have the same structure of rElettra2_9_4_beta but different
magnet strenghts
ring=at.load_lattice("../../machine/lattice/elettra2/srElettra2_low_beta.mat",energy=2.4e9)
"""
#ring geometry
geo,radius=ring.get_geometry((0,0,0),True)
print('i','\t','ename','\t','length','\t','spos','\t','iscorr','\t','isskew','\t','x','\t','y','\t','angle')
# find index of quadrupoles in ring
lattlister(ring,geo,at.Quadrupole)
#find index of reverse bends Q24R quads
lattlister(ring,geo,"QAB*")
# find index of sextupoles in ring
lattlister(ring,geo,at.Sextupole)
#find index of octupoles in ring
lattlister(ring,geo,at.Octupole)
#find index of b64 dipoles in ring
#this is triky..... We have to set name to indexes ... or modify something in the lattice.
lattlister(ring,geo,"b1")
#find index of b80 dipoles in ring
#this is enven trikier! triky..... We have to set name to indexes and elemets are a composition of pieces
# TO DO
# get bpms and their s position
lattlister(ring,geo,"bpm*")
# get corectors
lattlister(ring,geo,"chv*")
#get RF cavities
lattlister(ring,geo,"RF")
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment