pymad8¶
Module contents¶
pymad8 - python tools for working with MAD8 output and input.
pymad8.Input module¶
-
pymad8.Input.
decodeCollimator
(input)¶
-
pymad8.Input.
decodeDecapole
(input)¶
-
pymad8.Input.
decodeDrift
(input)¶
-
pymad8.Input.
decodeFileLine
(input)¶ decode line input is a string of a mad8 line
-
pymad8.Input.
decodeKicker
(input)¶
-
pymad8.Input.
decodeLcavity
(input)¶
-
pymad8.Input.
decodeLine
(input)¶
-
pymad8.Input.
decodeMultipole
(input)¶
-
pymad8.Input.
decodeNameAndType
(input)¶
-
pymad8.Input.
decodeNamed
(input)¶
-
pymad8.Input.
decodeOctupole
(input)¶
-
pymad8.Input.
decodeQuadrupole
(input)¶
-
pymad8.Input.
decodeSbend
(input)¶
-
pymad8.Input.
decodeSextupole
(input)¶
-
pymad8.Input.
removeComments
(input)¶ remove comment lines
-
pymad8.Input.
removeContinuationSymbols
(input)¶ remove continuation symbols from input input : list of file lines
-
pymad8.Input.
splitKeyValue
(t)¶
-
pymad8.Input.
tidy
(input)¶ tidy input, remove EOL, remove empty lines input : list of file lines
pymad8.Output module¶
-
class
pymad8.Output.
Chrom
¶ Bases:
pymad8.Output.General
Chromaticity data structure data : numpy array of data keys : key to data
-
getData
(index)¶
-
-
class
pymad8.Output.
Common
¶ Bases:
pymad8.Output.General
-
containsEnergyVariation
()¶ Method to determine if the energy is constant in the lattice Required if there is 1) RfCavities
-
getApertures
(raw=True)¶
-
getColumn
(colName)¶
-
getData
(index)¶
-
getRowByIndex
(index)¶
-
getRowByName
(name)¶
-
keys
= {'blmo': {'note': 10, 'E': 11, 'l': 0}, 'drif': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'ecol': {'aper': 9, 'E': 11, 'ysize': 5, 'l': 0, 'note': 10, 'xsize': 4}, 'elseparator': {'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'note': 10, 'efield': 5}, 'hkic': {'note': 10, 'aper': 9, 'E': 11, 'l': 0, 'hkick': 4}, 'hmonitor': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'imon': {'note': 10, 'E': 11, 'l': 0}, 'inst': {'note': 10, 'E': 11, 'l': 0}, 'kicker': {'aper': 9, 'E': 11, 'l': 0, 'note': 10, 'vkick': 5, 'hkick': 4}, 'lcav': {'aper': 9, 'E': 11, 'lag': 7, 'l': 0, 'note': 10, 'volt': 6, 'freq': 5}, 'mark': {'note': 10, 'E': 11, 'l': 0}, 'moni': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'mult': {'E': 11, 'aper': 9, 't2': 7, 't3': 8, 't0': 4, 't1': 6, 'note': 10, 'k2l': 3, 'k3l': 5, 'k0l': 1, 'k1l': 2}, 'octu': {'note': 10, 'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'k3': 5}, 'prof': {'note': 10, 'E': 11, 'l': 0}, 'quad': {'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'note': 10, 'k1': 2}, 'rben': {'E': 11, 'h2': 8, 'h1': 7, 'e1': 5, 'e2': 6, 'aper': 9, 'angle': 1, 'tilt': 4, 'l': 0, 'note': 10, 'k2': 3, 'k1': 2}, 'rcol': {'aper': 9, 'E': 11, 'ysize': 5, 'l': 0, 'note': 10, 'xsize': 4}, 'rfcavity': {'aper': 9, 'E': 11, 'lag': 7, 'l': 0, 'note': 10, 'volt': 6, 'freq': 5}, 'sben': {'E': 11, 'h2': 8, 'h1': 7, 'e1': 5, 'e2': 6, 'aper': 9, 'angle': 1, 'tilt': 4, 'l': 0, 'note': 10, 'k2': 3, 'k1': 2}, 'sext': {'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'note': 10, 'k2': 3}, 'solenoid': {'ks': 5, 'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'srot': {'note': 10, 'E': 11, 'aper': 9, 'angle': 5, 'l': 0}, 'vkic': {'note': 10, 'vkick': 5, 'aper': 9, 'E': 11, 'l': 0}, 'vmonitor': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'wire': {'note': 10, 'E': 11, 'l': 0}, 'yrot': {'note': 10, 'E': 11, 'aper': 9, 'angle': 5, 'l': 0}}¶
-
makeLocationList
(elementNames=[])¶
-
-
class
pymad8.Output.
Envelope
¶ Bases:
pymad8.Output.General
Beam envelope data structure data : numpy array of data keys : key to data
-
getData
(index)¶
-
keys
= {'s11': 0, 's12': 1, 's13': 2, 's14': 3, 's15': 4, 's16': 5, 's21': 6, 's22': 7, 's23': 8, 's24': 9, 's25': 10, 's26': 11, 's31': 12, 's32': 13, 's33': 14, 's34': 15, 's35': 16, 's36': 17, 's41': 18, 's42': 19, 's43': 20, 's44': 21, 's45': 22, 's46': 23, 's51': 24, 's52': 25, 's53': 26, 's54': 27, 's55': 28, 's56': 29, 's61': 30, 's62': 31, 's63': 32, 's64': 33, 's65': 34, 's66': 35, 'suml': 36}¶
-
-
class
pymad8.Output.
General
¶ General list of accelerator component infomation
-
addElement
(type, name, data)¶
-
findByName
(name)¶
-
findByType
(type)¶
-
getColumn
(key)¶
-
getIndex
(name)¶
-
getNElements
()¶
-
getNames
(ind)¶
-
getRowByIndex
(index)¶
-
getRowByName
(name)¶
-
makeArray
()¶
-
plotXY
(xkey, ykey)¶
-
subline
(start, end)¶
-
-
class
pymad8.Output.
OutputReader
¶ Class to load different Mad8 output files Usage : o = Mad8.OutputReader() [c, s] = o.readFile(‘./survey.tape’,’survey’) [c, r] = o.readFile(‘./rmat.tape’,’rmat’) [c, t] = o.readFile(‘./twiss.tape’,’twiss’) [c, c] = o.readFile(‘./chrom.tape’,’chrom’) [c, e] = o.readFile(‘./envelope.tape’,’envel’)
c : Common data r : Rmat object t : Twiss object c : Chrom object e : Envelope object
-
readChromFile
(f=None)¶
-
readEnvelopeFile
(f=None)¶
-
readFile
(fileName='', type='twiss')¶ read mad8 output file
-
readRmatFile
(f=None)¶
-
readSurveyFile
()¶
-
readTwissFile
(f=None)¶
-
-
class
pymad8.Output.
Rmat
¶ Bases:
pymad8.Output.General
Rmatrix data structure data : numpy array of data keys : key to data
-
getData
(index)¶
-
keys
= {'r11': 0, 'r12': 1, 'r13': 2, 'r14': 3, 'r15': 4, 'r16': 5, 'r21': 6, 'r22': 7, 'r23': 8, 'r24': 9, 'r25': 10, 'r26': 11, 'r31': 12, 'r32': 13, 'r33': 14, 'r34': 15, 'r35': 16, 'r36': 17, 'r41': 18, 'r42': 19, 'r43': 20, 'r44': 21, 'r45': 22, 'r46': 23, 'r51': 24, 'r52': 25, 'r53': 26, 'r54': 27, 'r55': 28, 'r56': 29, 'r61': 30, 'r62': 31, 'r63': 32, 'r64': 33, 'r65': 34, 'r66': 35, 'suml': 36}¶
-
-
class
pymad8.Output.
Saveline
(fileName, lineName='EBDS')¶ -
expandLine
()¶
-
findNamedDict
(name)¶
-
findNamedIndex
(name)¶
-
findRenamedNamedDict
(name)¶
-
findRenamedNamedIndex
(name)¶
-
makeSubLines
()¶
-
parseFile
()¶
-
readFile
(fileName)¶
-
removeDuplicates
()¶
-
removeReplacements
()¶
-
writeRenamed
(filename)¶
-
-
class
pymad8.Output.
Survey
¶ Bases:
pymad8.Output.General
Survey data structure data : numpy array of data keys : key to data
-
keys
= {'phi': 5, 'psi': 6, 'suml': 3, 'theta': 4, 'x': 0, 'y': 1, 'z': 2}¶
-
-
class
pymad8.Output.
Track
(folderpath, filemapname, twissname)¶ -
appendDir
(folderpath)¶ Loop over all mad8 track output files in the target directory and append the data to the existing data structure.
-
readDir
()¶ Loop over all mad8 track output files in the target directory and build a dictionary of the data. File map is used to match data from track files to observation plane in the twiss file.
-
-
class
pymad8.Output.
Twiss
¶ Bases:
pymad8.Output.General
Twiss data structure data : numpy array of data keys : key to data
-
keys
= {'alfx': 0, 'alfy': 5, 'betx': 1, 'bety': 6, 'dpx': 4, 'dpy': 9, 'dx': 3, 'dy': 8, 'mux': 2, 'muy': 7, 'px': 11, 'py': 13, 'suml': 14, 'x': 10, 'y': 12}¶
-
nameFromNearestS
(s)¶
-
plotAlf
()¶
-
plotBeta
()¶
-
plotEta
()¶
-
plotEtaPrime
()¶
-
plotMu
()¶
-
-
pymad8.Output.
getValueByName
(name, key, common, table)¶
-
pymad8.Output.
writeContinuation
(f, l)¶
pymad8.Mad8 module¶
-
class
pymad8.Mad8.
Chrom
¶ Bases:
pymad8.Mad8.General
Chromaticity data structure data : numpy array of data keys : key to data
-
getData
(index)¶
-
-
class
pymad8.Mad8.
Common
¶ Bases:
pymad8.Mad8.General
-
containsEnergyVariation
()¶ Method to determine if the energy is constant in the lattice Required if there is 1) RfCavities
-
getApertures
(raw=True)¶
-
getColumn
(colName)¶
-
getData
(index)¶
-
getRowByIndex
(index)¶
-
getRowByName
(name)¶
-
keys
= {'blmo': {'note': 10, 'E': 11, 'l': 0}, 'drif': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'ecol': {'aper': 9, 'E': 11, 'ysize': 5, 'l': 0, 'note': 10, 'xsize': 4}, 'elseparator': {'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'note': 10, 'efield': 5}, 'hkic': {'note': 10, 'aper': 9, 'E': 11, 'l': 0, 'hkick': 4}, 'hmonitor': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'imon': {'note': 10, 'E': 11, 'l': 0}, 'inst': {'note': 10, 'E': 11, 'l': 0}, 'kicker': {'aper': 9, 'E': 11, 'l': 0, 'note': 10, 'vkick': 5, 'hkick': 4}, 'lcav': {'aper': 9, 'E': 11, 'lag': 7, 'l': 0, 'note': 10, 'volt': 6, 'freq': 5}, 'mark': {'note': 10, 'E': 11, 'l': 0}, 'moni': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'mult': {'E': 11, 'aper': 9, 't2': 7, 't3': 8, 't0': 4, 't1': 6, 'note': 10, 'k2l': 3, 'k3l': 5, 'k0l': 1, 'k1l': 2}, 'octu': {'note': 10, 'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'k3': 5}, 'prof': {'note': 10, 'E': 11, 'l': 0}, 'quad': {'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'note': 10, 'k1': 2}, 'rben': {'E': 11, 'h2': 8, 'h1': 7, 'e1': 5, 'e2': 6, 'aper': 9, 'angle': 1, 'tilt': 4, 'l': 0, 'note': 10, 'k2': 3, 'k1': 2}, 'rcol': {'aper': 9, 'E': 11, 'ysize': 5, 'l': 0, 'note': 10, 'xsize': 4}, 'rfcavity': {'aper': 9, 'E': 11, 'lag': 7, 'l': 0, 'note': 10, 'volt': 6, 'freq': 5}, 'sben': {'E': 11, 'h2': 8, 'h1': 7, 'e1': 5, 'e2': 6, 'aper': 9, 'angle': 1, 'tilt': 4, 'l': 0, 'note': 10, 'k2': 3, 'k1': 2}, 'sext': {'aper': 9, 'E': 11, 'tilt': 4, 'l': 0, 'note': 10, 'k2': 3}, 'solenoid': {'ks': 5, 'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'srot': {'note': 10, 'E': 11, 'aper': 9, 'angle': 5, 'l': 0}, 'vkic': {'note': 10, 'vkick': 5, 'aper': 9, 'E': 11, 'l': 0}, 'vmonitor': {'note': 10, 'aper': 9, 'E': 11, 'l': 0}, 'wire': {'note': 10, 'E': 11, 'l': 0}, 'yrot': {'note': 10, 'E': 11, 'aper': 9, 'angle': 5, 'l': 0}}¶
-
makeLocationList
(elementNames=[])¶
-
-
class
pymad8.Mad8.
Envelope
¶ Bases:
pymad8.Mad8.General
Beam envelope data structure data : numpy array of data keys : key to data
-
getData
(index)¶
-
keys
= {'s11': 0, 's12': 1, 's13': 2, 's14': 3, 's15': 4, 's16': 5, 's21': 6, 's22': 7, 's23': 8, 's24': 9, 's25': 10, 's26': 11, 's31': 12, 's32': 13, 's33': 14, 's34': 15, 's35': 16, 's36': 17, 's41': 18, 's42': 19, 's43': 20, 's44': 21, 's45': 22, 's46': 23, 's51': 24, 's52': 25, 's53': 26, 's54': 27, 's55': 28, 's56': 29, 's61': 30, 's62': 31, 's63': 32, 's64': 33, 's65': 34, 's66': 35, 'suml': 36}¶
-
-
class
pymad8.Mad8.
General
¶ General list of accelerator component infomation
-
addElement
(type, name, data)¶
-
findByName
(name)¶
-
findByType
(type)¶
-
getColumn
(key)¶
-
getIndex
(name)¶
-
getNElements
()¶
-
getNames
(ind)¶
-
getRowByIndex
(index)¶
-
getRowByName
(name)¶
-
makeArray
()¶
-
plotXY
(xkey, ykey)¶
-
subline
(start, end)¶
-
-
class
pymad8.Mad8.
OutputReader
¶ Class to load different Mad8 output files Usage : o = Mad8.OutputReader() [c, s] = o.readFile(‘./survey.tape’,’survey’) [c, r] = o.readFile(‘./rmat.tape’,’rmat’) [c, t] = o.readFile(‘./twiss.tape’,’twiss’) [c, c] = o.readFile(‘./chrom.tape’,’chrom’) [c, e] = o.readFile(‘./envelope.tape’,’envel’)
c : Common data r : Rmat object t : Twiss object c : Chrom object e : Envelope object
-
readChromFile
(f=None)¶
-
readEnvelopeFile
(f=None)¶
-
readFile
(fileName='', type='twiss')¶ read mad8 output file
-
readRmatFile
(f=None)¶
-
readSurveyFile
()¶
-
readTwissFile
(f=None)¶
-
-
class
pymad8.Mad8.
Rmat
¶ Bases:
pymad8.Mad8.General
Rmatrix data structure data : numpy array of data keys : key to data
-
getData
(index)¶
-
keys
= {'r11': 0, 'r12': 1, 'r13': 2, 'r14': 3, 'r15': 4, 'r16': 5, 'r21': 6, 'r22': 7, 'r23': 8, 'r24': 9, 'r25': 10, 'r26': 11, 'r31': 12, 'r32': 13, 'r33': 14, 'r34': 15, 'r35': 16, 'r36': 17, 'r41': 18, 'r42': 19, 'r43': 20, 'r44': 21, 'r45': 22, 'r46': 23, 'r51': 24, 'r52': 25, 'r53': 26, 'r54': 27, 'r55': 28, 'r56': 29, 'r61': 30, 'r62': 31, 'r63': 32, 'r64': 33, 'r65': 34, 'r66': 35, 'suml': 36}¶
-
-
class
pymad8.Mad8.
Survey
¶ Bases:
pymad8.Mad8.General
Survey data structure data : numpy array of data keys : key to data
-
keys
= {'phi': 5, 'psi': 6, 'suml': 3, 'theta': 4, 'x': 0, 'y': 1, 'z': 2}¶
-
-
class
pymad8.Mad8.
Twiss
¶ Bases:
pymad8.Mad8.General
Twiss data structure data : numpy array of data keys : key to data
-
keys
= {'alfx': 0, 'alfy': 5, 'betx': 1, 'bety': 6, 'dpx': 4, 'dpy': 9, 'dx': 3, 'dy': 8, 'mux': 2, 'muy': 7, 'px': 11, 'py': 13, 'suml': 14, 'x': 10, 'y': 12}¶
-
nameFromNearestS
(s)¶
-
plotAlf
()¶
-
plotBeta
()¶
-
plotEta
()¶
-
plotEtaPrime
()¶
-
plotMu
()¶
-
-
pymad8.Mad8.
getValueByName
(name, key, common, table)¶
pymad8.Plot module¶
-
pymad8.Plot.
apertures
(twissfile='ebds1', envelfile='ebds1')¶
-
pymad8.Plot.
dispersion
(twissfile='ebds1')¶
-
pymad8.Plot.
dispersionPrime
(twissfile='ebds1')¶
-
pymad8.Plot.
drawMachineLattice
(mad8c, mad8t)¶
-
pymad8.Plot.
energy
(twissfile='ebds1')¶
-
pymad8.Plot.
linearOptics
(twissfile='ebds1')¶
-
pymad8.Plot.
phaseAdvance
(twissfile='ebds1')¶
-
pymad8.Plot.
setCallbacks
(figure, axm, axplot, twiss)¶
-
pymad8.Plot.
survey
(surveyfile='ebds1')¶
pymad8.Visualisation module¶
-
class
pymad8.Visualisation.
OneDim
(common, survey, debug)¶ -
drawBend
(c, s, suml, colour=True)¶
-
drawElement
(elem, colour=True)¶
-
drawElements
(type, colour=True)¶
-
drawHkic
(c, s, suml, colour=True)¶
-
drawInst
(c, s, suml, colour=True)¶
-
drawMark
(c, s, suml, colour=True)¶
-
drawMoni
(c, s, suml, colour=True)¶
-
drawMult
(c, s, suml, colour=True)¶
-
drawProf
(c, s, suml, colour=True)¶
-
drawQuad
(c, s, suml, colour=True)¶
-
drawSext
(c, s, suml, colour=True)¶
-
drawVkic
(c, s, suml, colour=True)¶
-
drawWire
(c, s, suml, colour=True)¶
-
plot
(colour=True)¶
-
-
class
pymad8.Visualisation.
TwoDim
(common, survey, debug=False, annotate=False, fancy=False)¶ -
drawBend
(c, s, x, y, z)¶
-
drawElement
(elem)¶
-
drawElements
(type)¶
-
drawMark
(c, s, x, y, z)¶
-
drawMoni
(c, s, x, y, z)¶
-
drawQuad
(c, s, x, y, z)¶
-
plot
(event=None)¶
-
plotUpdate
(event)¶
-
-
pymad8.Visualisation.
testOneDim
()¶
-
pymad8.Visualisation.
testTwoDim
()¶
-
pymad8.Visualisation.
transformedPoly
(xy, xyc, theta)¶
-
pymad8.Visualisation.
transformedRect
(xyc, dx, dy, theta)¶