A Python wrapping of CALS API

pip install pytimber==2.6.2



Python wrapping of the CERN Accelerator Logging Service (CALS) API.


Install a Python distribution (e.g. Anaconda) and a recent Java version (1.8), then install pytimber using pip:

pip install pytimber

or for the most updated version

pip install git+https://github.com/rdemaria/pytimber.git

This will also install cmmnbuild-dep-manager to provide automatic resolution of Java dependencies for CERN packages. It is required to use pytimber with other CERN libraries, such as PyJapc.

Installation notes

  • For Windows, this pre-compiled version of JPype seems to work best.

  • For CERN machines without internet access, you need to manually install the dependencies and use the mirrors on the Scripting Tools GitLab group:

    pip install git+https://gitlab.cern.ch/scripting-tools/jpype.git
    pip install git+https://gitlab.cern.ch/scripting-tools/cmmnbuild-dep-manager.git
    pip install git+https://gitlab.cern.ch/scripting-tools/pytimber.git



import pytimber
ldb = pytimber.LoggingDB()

Search for variables:


Get data:

t1 = '2015-05-13 00:00:00.000'
t2 = '2015-05-15 00:00:00.000'
d = ldb.get('HX:FILLN', t1, t2)
t1 = '2015-05-13 12:00:00.000'
t2 = '2015-05-13 12:00:01.000'
d = ldb.get('LHC.BQBBQ.CONTINUOUS_HS.B1:ACQ_DATA_H', t1, t2)

Explore variable hierarchies:


Get data for a particular LHC fill:

fill = ldb.getLHCFillData(4760)
t1 = fill['startTime']
t2 = fill['endTime']
d = ldb.get('LHC.BQBBQ.CONTINUOUS_HS.B1:ACQ_DATA_H', t1, t2)

Find all fill number in the last 48 hours that contained a ramp:

t2 = datetime.datetime.now()
t1 = t2 - datetime.timedelta(hours=48)
fills = ldb.getLHCFillsByTime(t1, t2, beam_modes='RAMP')
print([f['fillNumber'] for f in fills])

By default all times are returned as Unix timestamps. If you pass unixtime=False to get(), getAligned(), getLHCFillData() or getLHCFillsByTime() then datetime objects are returned instead.

Usage with PageStore

pytimber can be combined with PageStore for local data storage. Usage example:

import pytimber
from pytimber import pagestore

ldb = pytimber.LoggingDB()
mydb = pagestore.PageStore('mydata.db', './datadb')

t1 = time.mktime(time.strptime('Fri Apr 25 00:00:00 2016'))
mydb.store(ldb.get('%RQTD%I_MEAS', t1, t1+60))
mydb.store(ldb.get('%RQTD%I_MEAS', t1+60, t1+120))

mydata = mydb.get('RPMBB.UA47.RQTD.A45B2:I_MEAS', t1+90, t1+110)
data = ldb.get('RPMBB.UA47.RQTD.A45B2:I_MEAS', t1+90, t1+110)
for k in data:
  print(mydata[k][0] - data[k][0])
  print(mydata[k][1] - data[k][1])