pySoleilControl
Useful python tools for SOLEIL control system.
The ultimate aim is to provide tools that can be used in a shell prompt, ipython prompt or in python applications (such as GUI).
Under construction, the first brick is a module to retrieve data from the Tango Archiver.
ArchiveExtractor
This module brings some functions to extract data from HDB/TDB.
Usage example, with an ipython prompt
In [1]: import pySoleilControl.ArchiveExtractor as AE
In [2]: # Looking for an attribute in HDB
...: AE.findattr("ans/dg/*dcct*")
Out[2]:
['ANS/DG/DCCT-CTRL/State',
'ANS/DG/DCCT-CTRL/Status',
'ANS/DG/DCCT-CTRL/current',
'ANS/DG/DCCT-CTRL/dose',
'ANS/DG/DCCT-CTRL/lifeTime',
'ANS/DG/DCCT-CTRL/lifeTimeErr']
In [3]: # Get data between two dates, this return a pandas.Dataframe object
...: AE.ExtrBetweenDates('ANS/DG/DCCT-CTRL/current', '2021-12-13', '2021-12-13-12:00')
INFO:Perform ExtractBetweenDates (ans/dg/dcct-ctrl/current, 2021-12-13 00:00:00, 2021-12-13 12:00:00)
Out[3]:
2021-12-13 00:00:00 450.993568
2021-12-13 00:00:01 450.981979
2021-12-13 00:00:02 450.971455
2021-12-13 00:00:03 450.950542
2021-12-13 00:00:04 450.939951
...
2021-12-13 11:59:56 15.004553
2021-12-13 11:59:57 15.004243
2021-12-13 11:59:58 15.004942
2021-12-13 11:59:59 15.004878
2021-12-13 12:00:00 15.005410
Length: 42725, dtype: float64
In [4]: # Get min, max and mean with a 10 minute window
...: d=AE.ExtrBetweenDates_MinMaxMean('ANS/DG/DCCT-CTRL/current', '2021-12-13', '2021-12-13-12:00', timeInterval='10m')
In [5]: d
Out[5]:
Min Mean Max
2021-12-13 00:05:00 449.762286 450.619654 451.617095
2021-12-13 00:15:00 449.761171 450.676306 451.595391
2021-12-13 00:25:00 449.764910 450.684333 451.606520
2021-12-13 00:35:00 449.766284 450.688881 451.655843
2021-12-13 00:45:00 449.766808 450.716444 451.678886
... ... ... ...
2021-12-13 11:15:00 15.435944 15.495834 15.552427
2021-12-13 11:25:00 15.325022 15.383286 15.437459
2021-12-13 11:35:00 15.214556 15.270340 15.326395
2021-12-13 11:45:00 15.106309 15.163566 15.219333
2021-12-13 11:55:00 15.003812 15.056515 15.110022
[72 rows x 3 columns]
In [6]: # Activate inline matplotlib
...: %matplotlib
Using matplotlib backend: TkAgg
In [6]: # Simply plot
...: d.plot()
In [7]: # ipython prompt supports autocompletion. The doc of function can be quickly read by adding a '?'
...: AE.ExtrBetweenDates?
Signature: AE.ExtrBetweenDates(attribute, dateStart, dateStop=None, db='H')
Docstring:
Query attribute data from an archiver database, get all points between dates.
Use ExtractBetweenDates.
Parameters
----------
attribute : String
Name of the attribute. Full Tango name i.e. "test/dg/panda/current".
dateStart : datetime.datetime, string
Start date for extraction. If string, it will be parsed.
Example of string format %Y-%m-%d-%H:%M:%S or less precise.
dateStop : datetime.datetime, string, None
Stop date for extraction.
If string, it will be parsed.
Example of string format %Y-%m-%d-%H:%M:%S or less precise.
If None, it takes the current date and time.
Default is None (now).
db: str
Which database to look in, 'H' or 'T'.
Exceptions
----------
ValueError
The attribute is not found in the database.
Returns
-------
[date, value] : array
date : numpy.ndarray of datetime.datime objects
Dates of the values
value : numpy.ndarray
Archived values
File: ~/GrpDiagnostics/RBT/pySoleilControl/ArchiveExtractor.py
Type: function