From e15172f7013c3a260e17db8987ea762b83522302 Mon Sep 17 00:00:00 2001 From: Romain Broucquart <romain.broucquart@synchrotron-soleil.fr> Date: Thu, 17 Nov 2022 16:48:22 +0100 Subject: [PATCH] Add Readme, mode core to root, change module name --- ...ArchiveExtractor.py => ArchiveExtractor.py | 0 README.md | 117 ++++++++++++++++++ __init__.py | 1 - core/__init__.py | 1 - 4 files changed, 117 insertions(+), 2 deletions(-) rename core/ArchiveExtractor.py => ArchiveExtractor.py (100%) create mode 100644 README.md delete mode 100644 core/__init__.py diff --git a/core/ArchiveExtractor.py b/ArchiveExtractor.py similarity index 100% rename from core/ArchiveExtractor.py rename to ArchiveExtractor.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..64b7954 --- /dev/null +++ b/README.md @@ -0,0 +1,117 @@ +# 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 + +```python +In [1]: import pySoleilControl.ArchiveExtractor as AE + +In [2]: # For now, we need manual initialization of the module + ...: AE.init() + +In [3]: # Looking for an attribute in HDB + ...: AE.findattr("ans/dg/*dcct*") +Out[3]: +['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 [4]: # 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[4]: +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 [5]: # 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 [6]: d +Out[6]: + 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 [7]: # Activate inline matplotlib + ...: %matplotlib +Using matplotlib backend: TkAgg + +In [7]: # Simply plot + ...: d.plot() + +In [8]: # 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 + + + +``` \ No newline at end of file diff --git a/__init__.py b/__init__.py index 12d2a16..e69de29 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +0,0 @@ -from pythontools.core import * diff --git a/core/__init__.py b/core/__init__.py deleted file mode 100644 index 4fa5714..0000000 --- a/core/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from pythontools.core import ArchiveExtractor as ArchiveExtractor -- GitLab