flame_utils.viz package

Submodules

flame_utils.viz.plotlat module

This module provides lattice picture from FLAME lattice file(.lat) or FLAME Machine object.

flame_utils.viz.plotlat.hplot(*args, **kws)[source]

Plot beam state history with input arguments.

Parameters
machineobject

FLAME machine or ModelFlame object.

result :

List of beam state, generated by Machine.propagete() or ModelFlame.run() method.

argsstr

Beam state attributes to plot, seprated by comma. (see Note)

colorsdict

Color definition of each args.

latticebool

Plot lattice layout.

legendbool

Plot legend of args

csint

Index of the charge state to plot.

Notes

List of supported BeamState arguments

posfloat

Longitudinally propagating position, [m].

ref_betafloat

Speed in the unit of light velocity in vacuum of reference charge state, Lorentz beta.

ref_bgfloat

Multiplication of beta and gamma of reference charge state.

ref_gammafloat

Relativistic energy of reference charge state, Lorentz gamma.

ref_IonEkfloat

Kinetic energy of reference charge state, [eV/u].

ref_IonEsfloat

Rest energy of reference charge state, [eV/u].

ref_IonQint

Macro particle number of reference charge state.

ref_IonWfloat

Total energy of reference charge state, [eV/u], i.e. \(W = E_s + E_k\).

ref_IonZfloat

Reference charge to mass ratio, e.g. \(^{33^{+}}_{238}U: Q[33]/A[238]\).

ref_phisfloat

Absolute synchrotron phase of reference charge state, [rad].

ref_SampleIonKfloat

Wave-vector in cavities with different beta values of reference charge state.

betaArray

Speed in the unit of light velocity in vacuum of all charge states, Lorentz beta.

bgArray

Multiplication of beta and gamma of all charge states.

gammaArray

Relativistic energy of all charge states, Lorentz gamma.

IonEkArray

Kinetic energy of all charge states, [eV/u].

IonEsArray

Rest energy of all charge states, [eV/u].

IonQArray

Macro particle number of all charge states.

IonWArray

Total energy of all charge states, [eV/u], i.e. \(W = E_s + E_k\).

IonZArray

All charge to mass ratios

phisArray

Absolute synchrotron phase of all charge states, [rad]

SampleIonKArray

Wave-vector in cavities with different beta values of all charge states.

x0_env, xcenfloat

Weight average of all charge states for x’, [rad].

y0_env, ycenfloat

Weight average of all charge states for y, [mm].

xp0_env, xpcenfloat

Weight average of all charge states for x’, [rad].

yp0_env, ypcenfloat

Weight average of all charge states for y’, [rad].

phi0_env, phicen, zcen: float

Weight average of all charge states for \(\phi\), [rad].

dEk0_env, dEkcen, zpcenfloat

Weight average of all charge states for \(\delta E_k\), [MeV/u].

x0, xcen_allArray

X centroid for all charge states, [mm].

y0, ycen_allArray

Y centroid for all charge states, [mm].

xp0, xpcen_allArray

X centroid divergence for all charge states, [rad].

yp0, ypcen_allArray

Y centroid divergence for all charge states, [rad].

phi0, phicen_all, zcen_allArray

Longitudinal beam length, measured in RF frequency for all charge states, [rad].

dEk0, dEkcen_all, zpcen_allArray

Kinetic energy deviation w.r.t. reference charge state, for all charge states, [MeV/u].

x0_rms, xrmsfloat

General rms beam envelope for x, [mm].

y0_rms, yrmsfloat

General rms beam envelope for y, [mm].

xp0_rms, xprmsfloat

General rms beam envelope for x’, [rad].

yp0_rms, yprmsfloat

General rms beam envelope for y’, [rad].

phi0_rms, phirms, zrmsfloat

General rms beam envelope for \(\phi\), [rad].

dEk0_rms, dEkrms, zprmsfloat

General rms beam envelope for \(\delta E_k\), [MeV/u].

xrms_allArray

General rms beam envelope for x of all charge states, [mm].

yrms_allArray

General rms beam envelope for y of all charge states, [mm].

xprms_allArray

General rms beam envelope for x’ of all charge states, [rad].

yprms_allArray

General rms beam envelope for y’ of all charge states, [rad].

phirms_allArray

General rms beam envelope for \(\phi\) of all charge states, [rad].

dEkrms_allArray

General rms beam envelope for \(\delta E_k\) of all charge states, [MeV/u].

moment0_env, cenvectorArray

Weight average of centroid for all charge states, array of [x, x', y, y', phi, dEk, 1], with the units of [mm, rad, mm, rad, rad, MeV/u, 1].

moment0, cenvector_allArray

Centroid for all charge states, array of [x, x', y, y', phi, dEk, 1].

moment0_rms, rmsvectorArray

RMS beam envelope, part of statistical results from moment1.

moment1, beammatrix_allArray

Covariance matrices of all charge states, for each charge state.

moment1_env, beammatrixArray

Covariance matrices of all charge states, average over all charge states.

xemittance, xepsfloat

Weight average of geometrical x emittance, [mm-mrad].

yemittance, yepsfloat

Weight average of geometrical y emittance, [mm-mrad].

zemittance, zepsfloat

Weight average of geometrical z emittance, [rad-MeV/u].

xnemittance, xepsnfloat

Weight average of normalized x emittance, [mm-mrad].

ynemittance, yepsnfloat

Weight average of normalized y emittance, [mm-mrad].

znemittance, zepsnfloat

Weight average of normalized z emittance, [rad-MeV/u].

xemittance_all, xeps_allArray

Geometrical x emittance of all charge states, [mm-mrad].

yemittance_all, yeps_allArray

Geometrical y emittance of all charge states, [mm-mrad].

zemittance_all, zeps_allArray

Geometrical z emittance of all charge states, [rad-MeV/u].

xnemittance_all, xepsn_allArray

Normalized x emittance of all charge states, [mm-mrad].

ynemittance_all, yepsn_allArray

Normalized y emittance of all charge states, [mm-mrad].

znemittance_all, zepsn_allArray

Normalized z emittance of all charge states, [rad-MeV/u].

xtwiss_beta, xtwsbfloat

Weight average of twiss beta x, [m/rad].

ytwiss_beta, ytwsbfloat

Weight average of twiss beta y, [m/rad].

ztwiss_beta, ztwsbfloat

Weight average of twiss beta z, [rad/MeV/u].

xtwiss_alpha, xtwsafloat

Weight average of twiss alpha x, [1].

ytwiss_alpha, ytwsafloat

Weight average of twiss alpha y, [1].

ztwiss_alpha, ztwsafloat

Weight average of twiss alpha z, [1].

xtwiss_beta_all, xtwsb_allArray

Twiss beta x of all charge states, [m/rad].

ytwiss_beta_all, ytwsb_allArray

Twiss beta y of all charge states, [m/rad].

ztwiss_beta_all, ztwsb_allArray

Twiss beta z of all charge states, [rad/MeV/u].

xtwiss_alpha_all, xtwsa_allArray

Twiss alpha x of all charge states, [1].

ytwiss_alpha_all, ytwsa_allArray

Twiss alpha y of all charge states, [1].

ztwiss_alpha_all, ztwsa_allArray

Twiss alpha z of all charge states, [1].

couple_xy, cxyfloat

Weigth average of normalized x-y coupling term, [1].

couple_xpy, cxpyfloat

Weigth average of normalized xp-y coupling term, [1].

couple_xyp, cxypfloat

Weigth average of normalized x-yp coupling term, [1].

couple_xpyp, cxpypfloat

Weigth average of normalized xp-yp coupling term, [1].

couple_xy_all, cxy_allArray

Normalized x-y coupling term of all charge states, [1].

couple_xpy_all, cxpy_allArray

Normalized xp-y coupling term of all charge states, [1].

couple_xyp_all, cxyp_allArray

Normalized x-yp coupling term of all charge states, [1].

couple_xpyp_all, cxpyp_allArray

Normalized xp-yp coupling term of all charge states, [1].

Examples

>>> fm = ModelFlame(lat_file = 'userfile.lat')
>>> hplot('xrms', 'yrms', machine=fm)
class flame_utils.viz.plotlat.PlotLat(source, output=None, auto_scaling=False, starting_offset=0.0, **kws)[source]

Bases: object

Lattice picture class from FLAME lattice file or FLAME Machine object.

Parameters
sourcestr or callable

File path of the lattic file (str) or FLAME Machine object (callable)

outputstr (None), optional

Output file name. If defined, the lattice plot is generated automatically.

auto_scalingbool (True), optional

Flag for y-axis scaling by strength of the optical elements

starting_offsetfloat (0.0), optional

Position offset of starting point in the lattice file

Attributes
typesdict

Element type list of the lattice. Each element type contains on-off ‘flag’, plotting ‘color’, and y-axis ‘scale’.

generate(start=None, end=None, xlim=None, ycen=0.0, yscl=1.0, aspect=5.0, legend=True, option=True, axes=None)[source]

Generate matplotlib Axes class object from lattice file.

Parameters
startint

Index of the lattice start.

endint

Index of the lattice end.

xlimlist[2], optinal

Plot range of the lattice.

ycenfloat (0.0)

Vertical offset of the plot.

ysclfloat (1.0)

Plot scale of the element size

aspectfloat (5.0), optional

Aspect ratio of the picture.

legendbool

Add legend for the elements.

optionbool

Add optional setting for the plot.

Attributes
axescallable

Axes class object of matplotlib.

total_lengthfloat

Total length of the lattice.

output(window=True, fname=None, **kws)[source]

Output the lattice picture to window and/or file.

Parameters
windowbool (True)

Output flag to the window.

fnamestr, optional

File path of the output picutre.

**kwargs :

The same kwargs as pyplot.savefig() are available.

Module contents

class flame_utils.viz.PlotLat(source, output=None, auto_scaling=False, starting_offset=0.0, **kws)[source]

Bases: object

Lattice picture class from FLAME lattice file or FLAME Machine object.

Parameters
sourcestr or callable

File path of the lattic file (str) or FLAME Machine object (callable)

outputstr (None), optional

Output file name. If defined, the lattice plot is generated automatically.

auto_scalingbool (True), optional

Flag for y-axis scaling by strength of the optical elements

starting_offsetfloat (0.0), optional

Position offset of starting point in the lattice file

Attributes
typesdict

Element type list of the lattice. Each element type contains on-off ‘flag’, plotting ‘color’, and y-axis ‘scale’.

generate(start=None, end=None, xlim=None, ycen=0.0, yscl=1.0, aspect=5.0, legend=True, option=True, axes=None)[source]

Generate matplotlib Axes class object from lattice file.

Parameters
startint

Index of the lattice start.

endint

Index of the lattice end.

xlimlist[2], optinal

Plot range of the lattice.

ycenfloat (0.0)

Vertical offset of the plot.

ysclfloat (1.0)

Plot scale of the element size

aspectfloat (5.0), optional

Aspect ratio of the picture.

legendbool

Add legend for the elements.

optionbool

Add optional setting for the plot.

Attributes
axescallable

Axes class object of matplotlib.

total_lengthfloat

Total length of the lattice.

output(window=True, fname=None, **kws)[source]

Output the lattice picture to window and/or file.

Parameters
windowbool (True)

Output flag to the window.

fnamestr, optional

File path of the output picutre.

**kwargs :

The same kwargs as pyplot.savefig() are available.

flame_utils.viz.hplot(*args, **kws)[source]

Plot beam state history with input arguments.

Parameters
machineobject

FLAME machine or ModelFlame object.

result :

List of beam state, generated by Machine.propagete() or ModelFlame.run() method.

argsstr

Beam state attributes to plot, seprated by comma. (see Note)

colorsdict

Color definition of each args.

latticebool

Plot lattice layout.

legendbool

Plot legend of args

csint

Index of the charge state to plot.

Notes

List of supported BeamState arguments

posfloat

Longitudinally propagating position, [m].

ref_betafloat

Speed in the unit of light velocity in vacuum of reference charge state, Lorentz beta.

ref_bgfloat

Multiplication of beta and gamma of reference charge state.

ref_gammafloat

Relativistic energy of reference charge state, Lorentz gamma.

ref_IonEkfloat

Kinetic energy of reference charge state, [eV/u].

ref_IonEsfloat

Rest energy of reference charge state, [eV/u].

ref_IonQint

Macro particle number of reference charge state.

ref_IonWfloat

Total energy of reference charge state, [eV/u], i.e. \(W = E_s + E_k\).

ref_IonZfloat

Reference charge to mass ratio, e.g. \(^{33^{+}}_{238}U: Q[33]/A[238]\).

ref_phisfloat

Absolute synchrotron phase of reference charge state, [rad].

ref_SampleIonKfloat

Wave-vector in cavities with different beta values of reference charge state.

betaArray

Speed in the unit of light velocity in vacuum of all charge states, Lorentz beta.

bgArray

Multiplication of beta and gamma of all charge states.

gammaArray

Relativistic energy of all charge states, Lorentz gamma.

IonEkArray

Kinetic energy of all charge states, [eV/u].

IonEsArray

Rest energy of all charge states, [eV/u].

IonQArray

Macro particle number of all charge states.

IonWArray

Total energy of all charge states, [eV/u], i.e. \(W = E_s + E_k\).

IonZArray

All charge to mass ratios

phisArray

Absolute synchrotron phase of all charge states, [rad]

SampleIonKArray

Wave-vector in cavities with different beta values of all charge states.

x0_env, xcenfloat

Weight average of all charge states for x’, [rad].

y0_env, ycenfloat

Weight average of all charge states for y, [mm].

xp0_env, xpcenfloat

Weight average of all charge states for x’, [rad].

yp0_env, ypcenfloat

Weight average of all charge states for y’, [rad].

phi0_env, phicen, zcen: float

Weight average of all charge states for \(\phi\), [rad].

dEk0_env, dEkcen, zpcenfloat

Weight average of all charge states for \(\delta E_k\), [MeV/u].

x0, xcen_allArray

X centroid for all charge states, [mm].

y0, ycen_allArray

Y centroid for all charge states, [mm].

xp0, xpcen_allArray

X centroid divergence for all charge states, [rad].

yp0, ypcen_allArray

Y centroid divergence for all charge states, [rad].

phi0, phicen_all, zcen_allArray

Longitudinal beam length, measured in RF frequency for all charge states, [rad].

dEk0, dEkcen_all, zpcen_allArray

Kinetic energy deviation w.r.t. reference charge state, for all charge states, [MeV/u].

x0_rms, xrmsfloat

General rms beam envelope for x, [mm].

y0_rms, yrmsfloat

General rms beam envelope for y, [mm].

xp0_rms, xprmsfloat

General rms beam envelope for x’, [rad].

yp0_rms, yprmsfloat

General rms beam envelope for y’, [rad].

phi0_rms, phirms, zrmsfloat

General rms beam envelope for \(\phi\), [rad].

dEk0_rms, dEkrms, zprmsfloat

General rms beam envelope for \(\delta E_k\), [MeV/u].

xrms_allArray

General rms beam envelope for x of all charge states, [mm].

yrms_allArray

General rms beam envelope for y of all charge states, [mm].

xprms_allArray

General rms beam envelope for x’ of all charge states, [rad].

yprms_allArray

General rms beam envelope for y’ of all charge states, [rad].

phirms_allArray

General rms beam envelope for \(\phi\) of all charge states, [rad].

dEkrms_allArray

General rms beam envelope for \(\delta E_k\) of all charge states, [MeV/u].

moment0_env, cenvectorArray

Weight average of centroid for all charge states, array of [x, x', y, y', phi, dEk, 1], with the units of [mm, rad, mm, rad, rad, MeV/u, 1].

moment0, cenvector_allArray

Centroid for all charge states, array of [x, x', y, y', phi, dEk, 1].

moment0_rms, rmsvectorArray

RMS beam envelope, part of statistical results from moment1.

moment1, beammatrix_allArray

Covariance matrices of all charge states, for each charge state.

moment1_env, beammatrixArray

Covariance matrices of all charge states, average over all charge states.

xemittance, xepsfloat

Weight average of geometrical x emittance, [mm-mrad].

yemittance, yepsfloat

Weight average of geometrical y emittance, [mm-mrad].

zemittance, zepsfloat

Weight average of geometrical z emittance, [rad-MeV/u].

xnemittance, xepsnfloat

Weight average of normalized x emittance, [mm-mrad].

ynemittance, yepsnfloat

Weight average of normalized y emittance, [mm-mrad].

znemittance, zepsnfloat

Weight average of normalized z emittance, [rad-MeV/u].

xemittance_all, xeps_allArray

Geometrical x emittance of all charge states, [mm-mrad].

yemittance_all, yeps_allArray

Geometrical y emittance of all charge states, [mm-mrad].

zemittance_all, zeps_allArray

Geometrical z emittance of all charge states, [rad-MeV/u].

xnemittance_all, xepsn_allArray

Normalized x emittance of all charge states, [mm-mrad].

ynemittance_all, yepsn_allArray

Normalized y emittance of all charge states, [mm-mrad].

znemittance_all, zepsn_allArray

Normalized z emittance of all charge states, [rad-MeV/u].

xtwiss_beta, xtwsbfloat

Weight average of twiss beta x, [m/rad].

ytwiss_beta, ytwsbfloat

Weight average of twiss beta y, [m/rad].

ztwiss_beta, ztwsbfloat

Weight average of twiss beta z, [rad/MeV/u].

xtwiss_alpha, xtwsafloat

Weight average of twiss alpha x, [1].

ytwiss_alpha, ytwsafloat

Weight average of twiss alpha y, [1].

ztwiss_alpha, ztwsafloat

Weight average of twiss alpha z, [1].

xtwiss_beta_all, xtwsb_allArray

Twiss beta x of all charge states, [m/rad].

ytwiss_beta_all, ytwsb_allArray

Twiss beta y of all charge states, [m/rad].

ztwiss_beta_all, ztwsb_allArray

Twiss beta z of all charge states, [rad/MeV/u].

xtwiss_alpha_all, xtwsa_allArray

Twiss alpha x of all charge states, [1].

ytwiss_alpha_all, ytwsa_allArray

Twiss alpha y of all charge states, [1].

ztwiss_alpha_all, ztwsa_allArray

Twiss alpha z of all charge states, [1].

couple_xy, cxyfloat

Weigth average of normalized x-y coupling term, [1].

couple_xpy, cxpyfloat

Weigth average of normalized xp-y coupling term, [1].

couple_xyp, cxypfloat

Weigth average of normalized x-yp coupling term, [1].

couple_xpyp, cxpypfloat

Weigth average of normalized xp-yp coupling term, [1].

couple_xy_all, cxy_allArray

Normalized x-y coupling term of all charge states, [1].

couple_xpy_all, cxpy_allArray

Normalized xp-y coupling term of all charge states, [1].

couple_xyp_all, cxyp_allArray

Normalized x-yp coupling term of all charge states, [1].

couple_xpyp_all, cxpyp_allArray

Normalized xp-yp coupling term of all charge states, [1].

Examples

>>> fm = ModelFlame(lat_file = 'userfile.lat')
>>> hplot('xrms', 'yrms', machine=fm)