Model

Entry Points Model

Module model.manager

model.manager.get_accel_class(*args, **kwargs)[source]

Returns accelerator class

Keyword Arguments:
 accel -- Choose the accelerator to use. Can be the class already, which is then returned.
model.manager.get_accel_class_and_unkown(*args, **kwargs)[source]

Returns accelerator class

Keyword Arguments:
 accel -- Choose the accelerator to use. Can be the class already, which is then returned.
model.manager.get_accel_class_from_args(args=None)[source]

LEGACY-FUNCTION SHOULD BE REPLACED BY USING get_accel_class

model.manager.get_accel_instance(*args, **kwargs)[source]

Returns accelerator instance.

Module model.creator

Available Classes

Module model.accelerators.accelerator

class model.accelerators.accelerator.Accelerator[source]

Abstract class to serve as an interface to implement the rest of the accelerators.

get_basic_seq_job()[source]

Returns job (string) to create the basic accelerator sequence.

get_best_knowledge_model_tfs()[source]

Returns the best knowledge model tfs file.

classmethod get_class(*args, **kwargs)[source]

This method should return the accelerator class defined in the arguments.

static get_class_parameters()[source]

This method should return the parameter list of arguments needed to create the class.

classmethod get_correctors_variables(frm=None, to=None, classes=None)[source]

Returns the set of corrector variables between frm and to, with classes in classes. None means select all.

get_driven_tfs()[source]

Returns the driven model tfs file.

classmethod get_element_types_mask(list_of_elements, types)[source]

Return boolean mask for elements in list_of_elements that belong to any of the specified types. Needs to handle: “bpm”, “magnet”, “arc_bpm”

Parameters:
  • list_of_elements -- List of elements
  • types -- Kinds of elements to look for
Returns:

Boolean array of elements of specified kinds.

get_elements_tfs()[source]

Returns the elements tfs file.

get_exciter_bpm(plane, distance)[source]

Returns the BPM next to the exciter. The accelerator instance knows already which excitation method is used. distance: 1=nearest bpm 2=next to nearest bpm

get_exciter_name(plane)[source]

Returns the name of the exciter.

classmethod get_iteration_tmpl()[source]

Returns template to create fullresponse. TODO: only in _prepare_fullresponse in creator! Needs to be replaced by get_basic_seq

get_k_first_BPM(list_of_bpms)[source]

Returns the position of something in list_of_bpms TODO: ASK ANDREAS

get_model_tfs()[source]

Returns the model tfs file.

get_multi_dpp_job(dpp_list)[source]

Returns job (string) for model with multiple dp/p values (in W-Analysis)

classmethod get_nominal_tmpl()[source]

Returns template for nominal model (Model Creator)

get_s_first_BPM()[source]

Returns the position of the first BPM in turn by turn acquisition.

get_update_correction_job(tiwss_out_path, corrections_file_path)[source]

Returns job (string) to create an updated model from changeparameters input (used in iterative correction).

classmethod get_variables(frm=None, to=None, classes=None)[source]

Gets the variables with elements in the given range and the given classes. None means everything.

verify_object()[source]

Verifies that this instance of an accelerator is properly instantiated.

exception model.accelerators.accelerator.AcceleratorDefinitionError[source]

Raised when an accelerator instance is wrongly used, for example by calling a method that should have been overwritten.

class model.accelerators.accelerator.Element(name, s)[source]

Generic corrector element class that holds name and position (s) of the corrector. This element should represent a physical element of the accelerator.

class model.accelerators.accelerator.Variable(name, elements, classes)[source]

Generic corrector variable class that holds name, position (s) and physical elements it affectes. This variables should be logical variables that should have and effect in the model if modified.

model.accelerators.accelerator.get_commonbpm(key1, key2, commonbpms)[source]

Returns index and bpm name of key1, if found. Otherwise of key2. Raises KeyError if none is found. TODO: @Andreas, does that need to be here? Also why not use pythonic ways? TODO: @Andreas: DONT NAME SOMETHING COMMOMBPMS IF ITS A DATAFRAME ONLY HAVING AN INDEX WITH BPMS !!!!!!!!! FFS !!!!!!!!

try:
return list(commonbpms.index).index(key1), key1
except ValueError:
return list(commonbpms.index).index(key2), key2

(try-except around the second return for raising KeyError with message)

Module model.accelerators.lhc

class model.accelerators.lhc.HlLhc10(*args, **kwargs)[source]
class model.accelerators.lhc.HlLhc12(*args, **kwargs)[source]
class model.accelerators.lhc.HlLhc12NewCircuit(*args, **kwargs)[source]
class model.accelerators.lhc.HlLhc12NoQ2Trim(*args, **kwargs)[source]
class model.accelerators.lhc.HlLhc13(*args, **kwargs)[source]
class model.accelerators.lhc.Lhc(*args, **kwargs)[source]

Parent Class for Lhc-Types.

Keyword Arguments:
 
  • Required --
  • nat_tune_x (float) -- Natural tune X without integer part. Flags: [‘--nattunex’]
  • nat_tune_y (float) -- Natural tune Y without integer part. Flags: [‘--nattuney’]
  • optics (str) -- Path to the optics file to use (modifiers file). Flags: [‘--optics’]
  • Optional --
  • acd (bool) -- Activate excitation with ACD. Flags: [‘--acd’] Default: False
  • adt (bool) -- Activate excitation with ADT. Flags: [‘--adt’] Default: False
  • dpp (float or list) -- Delta p/p to use. Flags: [‘--dpp’] Default: 0.0
  • drv_tune_x (float) -- Driven tune X without integer part. Flags: [‘--drvtunex’]
  • drv_tune_y (float) -- Driven tune Y without integer part. Flags: [‘--drvtuney’]
  • energy (float) -- Energy in Tev. Flags: [‘--energy’]
  • fullresponse (bool) -- If True, fullresponse template will be filled
  • put in the output directory. (and) -- Flags: [‘--fullresponse’] Default: False
  • xing (bool) -- If True, x-ing angles will be applied to model Flags: [‘--xing’] Default: False
get_basic_seq_job()[source]

Return string for madx job of correting model

get_best_knowledge_model_tfs()[source]

Returns the best knowledge model tfs file.

classmethod get_class(*args, **kwargs)[source]

Returns LHC subclass .

Keyword Arguments:
 
  • Optional --
  • beam (int) -- Beam to use. Flags: [‘--beam’]
  • lhc_mode (str) -- LHC mode to use. Flags: [‘--lhcmode’] Choices: [‘lhc_runII_2016_ats’, ‘hllhc12’, ‘hllhc10’, ‘lhc_runI’, ‘lhc_runII’, ‘lhc_runII_2016’, ‘lhc_runII_2017’]
Returns:

Lhc subclass.

classmethod get_class_and_unknown(*args, **kwargs)[source]

Returns LHC subclass and unkown args .

For the desired philosophy of returning parameters all the time, try to avoid this function, e.g. parse outside parameters first.

get_driven_tfs()[source]

Returns the driven model tfs file.

classmethod get_element_types_mask(list_of_elements, types)[source]

Return boolean mask for elements in list_of_elements that belong to any of the specified types. Needs to handle: “bpm”, “magnet”, “arc_bpm”

Parameters:
  • list_of_elements -- List of elements
  • types -- Kinds of elements to look for
Returns:

Boolean array of elements of specified kinds.

get_elements_tfs()[source]

Returns the elements tfs file.

get_errordefspath()[source]

Returns the path to the uncertainty definitions file (formerly called error definitions file.

get_exciter_bpm(plane, commonbpms)[source]

Returns the BPM next to the exciter. The accelerator instance knows already which excitation method is used. distance: 1=nearest bpm 2=next to nearest bpm

get_exciter_name(plane)[source]

Returns the name of the exciter.

classmethod get_ips()[source]

Returns an iterable with this accelerator IPs.

Returns:(“ip name”, “left BPM name”, “right BPM name”)
Return type:An iterator returning tuples with
classmethod get_iteration_tmpl()[source]

Returns template to create fullresponse. TODO: only in _prepare_fullresponse in creator! Needs to be replaced by get_basic_seq

get_k_first_BPM(index)[source]

Returns the position of something in list_of_bpms TODO: ASK ANDREAS

get_model_tfs()[source]

Returns the model tfs file.

get_multi_dpp_job(dpp_list)[source]

Return madx job to create twisses (models) with dpps from dpp_list

classmethod get_nominal_tmpl()[source]

Returns template for nominal model (Model Creator)

get_s_first_BPM()[source]

Returns the position of the first BPM in turn by turn acquisition.

get_update_correction_job(tiwss_out_path, corrections_file_path)[source]

Return string for madx job of correcting model

classmethod get_variables(frm=None, to=None, classes=None)[source]

Gets the variables with elements in the given range and the given classes. None means everything.

classmethod init_and_get_unknowns(args=None)[source]

Initializes but also returns unknowns.

For the desired philosophy of returning parameters all the time, try to avoid this function, e.g. parse outside parameters first.

verify_object()[source]

Verifies if everything is defined which should be defined

class model.accelerators.lhc.LhcAts(*args, **kwargs)[source]
class model.accelerators.lhc.LhcRunI(*args, **kwargs)[source]
class model.accelerators.lhc.LhcRunII2015(*args, **kwargs)[source]
class model.accelerators.lhc.LhcRunII2016(*args, **kwargs)[source]
class model.accelerators.lhc.LhcRunII2016Ats(*args, **kwargs)[source]
class model.accelerators.lhc.LhcRunII2017(*args, **kwargs)[source]
class model.accelerators.lhc.LhcRunII2018(*args, **kwargs)[source]

Module model.accelerators.esrf

class model.accelerators.esrf.Esrf[source]
classmethod get_class()[source]

This method should return the accelerator class defined in the arguments.

classmethod get_element_types_mask(list_of_elements, types)[source]

Return boolean mask for elements in list_of_elements that belong to any of the specified types. Needs to handle: “bpm”, “magnet”, “arc_bpm”, “amp_bpm” TODO: implement “magnet”

arc_bpms are the ones with high beta, which are:
bpms 1-5 in even cells. bpms 3-7 in odd cells.
Parameters:
  • list_of_elements -- List of elements
  • types -- Kinds of elements to look for
Returns:

Boolean array of elements of specified kinds.

Module model.accelerators.psbooster

class model.accelerators.psbooster.Psbooster(*args, **kwargs)[source]

Parent Class for Psbooster-Types.

Keyword Arguments:
 
  • Required --
  • ring (int) -- Ring number. Flags: [‘--ring’]
  • nat_tune_x (float) -- Natural tune X without integer part. Flags: [‘--nattunex’]
  • nat_tune_y (float) -- Natural tune Y without integer part. Flags: [‘--nattuney’]
  • Optional --
  • acd (bool) -- Activate excitation with ACD. Flags: [‘--acd’] Default: False
  • drv_tune_x (float) -- Driven tune X without integer part. Flags: [‘--drvtunex’]
  • drv_tune_y (float) -- Driven tune Y without integer part. Flags: [‘--drvtuney’]
  • energy (float) -- Energy in Tev. Flags: [‘--energy’]
  • fullresponse (bool) -- If present, fullresponse template willbe filled and put in the output directory. Flags: [‘--fullresponse’] Default: False
classmethod get_class(*args, **kwargs)[source]

Returns Psbooster class.

Keyword Arguments:
 
  • Optional --
  • ring (int) -- Ring to use. Flags: [‘--ring’] Choices: [1, 2, 3, 4]
Returns:

Psbooster class.

classmethod get_class_and_unknown(*args, **kwargs)[source]

Returns Psbooster subclass and unkown args .

For the desired philosophy of returning parameters all the time, try to avoid this function, e.g. parse outside parameters first.

classmethod get_element_types_mask(list_of_elements, types)[source]

Return boolean mask for elements in list_of_elements that belong to any of the specified types. Needs to handle: “bpm”, “magnet”, “arc_bpm”

Parameters:
  • list_of_elements -- List of elements
  • types -- Kinds of elements to look for
Returns:

Boolean array of elements of specified kinds.

classmethod get_iteration_tmpl()[source]

Returns template to create fullresponse. TODO: only in _prepare_fullresponse in creator! Needs to be replaced by get_basic_seq

classmethod get_nominal_tmpl()[source]

Returns template for nominal model (Model Creator)

classmethod init_and_get_unknowns(args=None)[source]

Initializes but also returns unknowns.

For the desired philosophy of returning parameters all the time, try to avoid this function, e.g. parse outside parameters first.

verify_object()[source]

Verifies that this instance of an accelerator is properly instantiated.