Data Extraction

PyLSA

This module provides useful functions to conveniently wrap the functionality of pjlsa.

class pylhc.data_extract.lsa.LSA[source]

Import this class to use LSA like the client without the need to instantiate it. Disadvantage: It will always use the default Server.

class pylhc.data_extract.lsa.LSAClient(*args: Any, **kwargs: Any)[source]

Extension of the LSAClient.

find_active_beamprocess_at_time(acc_time: AccDatetime, accelerator: str = 'lhc', bp_group: str = 'POWERCONVERTERS')[source]

Find the active beam process at the time given. Same as what online model extractor (KnobExtractor) does.

Parameters:
  • acc_time (AccDatetime) -- Accelerator datetime object.

  • accelerator (str) -- Name of the accelerator.

  • bp_group (str) -- BeamProcess Group, choices : ‘POWERCONVERTERS’, ‘ADT’, ‘KICKERS’, ‘SPOOLS’, ‘COLLIMATORS’

Returns:

‘cern.lsa.domain.settings.spi.StandAloneBeamProcessImpl’

find_beamprocess_history(t_start: AccDatetime, t_end: AccDatetime, accelerator: str = 'lhc', source: str = 'nxcals') Dict[source]

Finds the BeamProcesses between t_start and t_end and sorts then by fills. Adapted from pjlsa’s FindBeamProcessHistory but with source pass-through and trial-loop.

Parameters:
  • t_start (AccDatetime) -- start time

  • t_end (AccDatetime) -- end time

  • accelerator (str) -- Name of the accelerator.

  • source (str) -- pytimber source

Returns:

Dictionary of fills (keys) with a list of Timestamps and BeamProcesses.

find_existing_knobs(knobs: List[str]) List[str][source]

Return only the knobs that exist from the given list. This function was created out of the need to filter these first, as knobs that exist but do not belong to a beamprocess return noting in _getTrimsByBeamprocess, while knobs that do not exist at all crashed pjlsa. This filter should probably have been in pjlsa’s _buildParameterList.

Parameters:

knobs (list) -- List of strings of the knobs to check.

Returns:

A list of the knob names that actually exist.

find_knob_names(accelerator: str = 'lhc', regexp: str = '') list[source]

Return knobs for accelerator.

Parameters:
  • accelerator -- Accelerator name.

  • regexp -- Regular Expression to filter knob names.

Returns:

Sorted list of knob names.

find_last_fill(acc_time: AccDatetime, accelerator: str = 'lhc', source: str = 'nxcals') Tuple[str, list][source]

Return last fill name and BeamProcesses.

Args:

acc_time (AccDatetime): Accelerator datetime object. accelerator (str): Name of the accelerator. source (str): pytimber source

Returns:

Last fill name (str), Beamprocesses of last fill (list).

Return type:

tuple

get_beamprocess_info(beamprocess: str | object) Dict[source]

Get context info of the given beamprocess.

Parameters:

beamprocess (str, object) -- Name of the beamprocess or Beamprocess object.

Returns:

Dictionary with context info.

get_knob_circuits(knob_name: str, optics: str) TfsDataFrame[source]

Get a dataframe of the structure of the knob. Similar to online model extractor (KnobExtractor.getKnobHiercarchy)

Parameters:
  • knob_name -- name of the knob.

  • optics -- name of the optics.

Returns:

A TfsDataFrame of the knob circuits.

get_madx_name_from_circuit(circuit: str)[source]

Returns the MAD-X Strength Name (Circuit/Knob) from the given circuit name.

get_trim_history(beamprocess: str, knobs: list, start_time: AccDatetime = None, end_time: AccDatetime = None, accelerator: str = 'lhc') dict[source]

Get trim history for knobs between specified times. If any of the times are not given, all available data in that time-direction is extracted.

Parameters:
  • beamprocess (str) -- Name of the beamprocess.

  • knobs (list) -- List of strings of the knobs to check.

  • start_time (AccDatetime) -- Accelerator datetime object.

  • end_time (AccDatetime) -- Accelerator datetime object.

  • accelerator (str) -- Name of the accelerator.

Returns:

Dictionary of trims and their data (as TrimTuples, i.e. NamedTuple of lists of time and data).

class pylhc.data_extract.lsa.LSAMeta[source]

Metaclass for single instance LSAClient.

pylhc.data_extract.lsa.try_to_acquire_data(function: Callable, *args, **kwargs)[source]

Tries to get data from function multiple times. TODO: Move to omc3 as is also used there in BBQ extraction.

Args:

function (Callable): function to be called, e.g. db.get args, kwargs: arguments passed to function

Returns:

Return arguments of function

Timber

This module provides useful functions to conveniently wrap the functionality of pytimber.

pylhc.data_extract.timber.find_exact_time_for_beamprocess(acc_time: AccDatetime) AccDatetime[source]

Finds the last entry where HX:SRMP-POW equals 123. Which is, according to the online model KnobExtractor, the timing event for SQUEEZE or RAMP. I don’t think this is correct (jdilly).