F2_live_model documentation

Add your content using reStructuredText syntax. See the reStructuredText documentation for details.

class bmad.BmadLiveModel(design_only=False, instanced=False, log_level='INFO', FileHandler=None)

Provides an instance of PyTao that is updated with live machine parameters. This class streams live accelerator settings data via asynchronus network monitoring and a daemon process that periodically updates Tao.

Has a limited API for common tasks, more sophisitcated tasks can manipulate the tao instance

Parameters:
  • design_only – disables connection to the controls system, defaults to False

  • instanced – take single-shot live data instead of streaming, defaults to False

  • log_level – desired logging level, defaults to ‘INFO’

  • FileHandler – (optional) FileHandler object for logging, otherwise logs to stdout

property L

length of all elements in s-order

property S

S position of all elements in s-order

property channels

control system channel access addresse of all elements in s-order

property design

design model data, identical interface to live model data

property ele_types

Bmad ‘key’ (element type) of all elements in s-order

get_rmat(ele, which='model')

returns 6x6 ndarray of single-element or (if given 2 elements) A-to-B transfer maps

Parameters:
  • ele – beamline element(s), may be a single element e or a tuple of (e1, e2)

  • which – which lattice to read from, default is ‘model’, can also choose ‘design’

Returns:

(R,v0) tuple of the map R (6x6 np.ndarray), and “0th order” map v0 (1x6 vector)

property ix

dictionary of numerical indicies of various beamline elements

BmadLiveModel.ix['<ele_name>'] returns numerical indices for the given element in model data arrays ex: BmadLiveModel.L[ix['QE10525']] would return the length of QE10525

There are also some shortcut masks for quickly selecting all elements of a given type ix['QUAD'] will return the indicies of every quadrupole magnet in the model, valid masks are: RF, SOLN, XCOR, YCOR, COR, BEND, QUAD, SEXT, DRIFT, BPMS, PROF

Note:

mask indicies are equivalent to: np.where(self.ele_types == '<Bmad ele.key>')

property live

Data structure containing live model data.

Live momentum profile and twiss parameters are stored an Numpy arrays in s-order, while single-device information is accessed through a dictionary of device data structures.

top-level attributes are: live.p0c, e_tot, gamma_rel, Brho, twiss, rf, quads, bends, cors

the twiss data structure contains the following fields (for x and y): twiss.beta_x, alpha_x, eta_x, etap_x, psi_x, gamma_x, ...

each device dictionary is indexed by element name (i.e. ‘QE10525’) and returns dataclasses describing the relevant live parameters, as well as s positions and lengths for convenience unique attributes are as follows: rf[<name>].voltage, rf[<name>].phi0, quads[<name>].b1_gradient

Note:

this interface is nonexhaustive, and only covers commonly used data

property names

Bmad model names of all elements in s-order

refresh_all(catch_errs=False)

single-shot model update (only for use with instanced models)

Parameters:

catch_errs – catch errors and log during update rather than halt, defaults to False

start()

starts daemon to monitor accelerator controls data & update PyTao

stop()

disconnects from all PVs and stops the background update thread

write_bmad(title=None)

save current lattice to a .bmad file, default title is f2_elec_<ymdhms>.bmad

Parameters:

title – absolute filepath for desired output file, default is the current directory