Skip to main content

Python client for the EPICS Archiver Appliance

Project description

Build Status Coverage Status

Python code to retrieve data from the EPICS Archiver Appliance.

Usage

Note on timezones

When you pass a datetime to aapy it doesn't know by default what timezone that datetime is supposed to be in. It will assume that it is the local timezone, but will print a warning. If you pass it a timezone-aware datetime no warning will be printed. You can use utc_datetime() as a shortcut:

>>> from aa.utils import utc_datetime
>>> utc_datetime(2019, 10, 7, 17) # 5pm UTC on 7th October 2019

Fetching data

To retrieve data, create the appropriate fetcher

>>> from aa.js import JsonFetcher
>>> jf = JsonFetcher('archappl.diamond.ac.uk', 80)

You can request a single event, returning an ArchiveEvent object:

>>> from datetime import datetime
>>> event = jf.get_event_at('SR-DI-DCCT-01:SIGNAL', datetime.now())
WARNING:root:Assuming timezone for 2019-10-07 16:42:13.301672 is Europe/London
Archive event for PV SR-DI-DCCT-01:SIGNAL: timestamp 2019-10-07
15:42:04.876639 UTC value [301.33007915] severity 0
>>> event.value
array([300.77982715])
>>> event.utc_datetime
datetime.datetime(2019, 10, 7, 16, 2, 54, 928836, tzinfo=<UTC>)

You can also request a range of events, returning an ArchiveData object:

>>> data = jf.get_values('SR-DI-DCCT-01:SIGNAL', utc_datetime(2018, 1, 7), utc_datetime(2018, 1, 8))
>>> data.values
array([[2.51189843e-03],
   [1.56371643e-03],
   [5.54392030e-04],
   ...,
   [2.77373366e+02],
   [2.77329542e+02],
   [2.77287664e+02]])
>>> data.utc_datetimes
array([datetime.datetime(2018, 1, 6, 23, 59, 59, 3897, tzinfo=<UTC>),
   datetime.datetime(2018, 1, 7, 0, 0, 2, 3975, tzinfo=<UTC>),
   datetime.datetime(2018, 1, 7, 0, 0, 5, 4066, tzinfo=<UTC>), ...,
   datetime.datetime(2018, 1, 7, 23, 59, 53, 3885, tzinfo=<UTC>),
   datetime.datetime(2018, 1, 7, 23, 59, 56, 3825, tzinfo=<UTC>),
   datetime.datetime(2018, 1, 7, 23, 59, 59, 3726, tzinfo=<UTC>)],
  dtype=object)
>>> len(data)
28764

Development

aapy uses Pipenv to manage its dependencies.

To install development requirements:

pipenv install --dev

To run the tests and static checks:

pipenv run tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aapy-0.12.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

aapy-0.12-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file aapy-0.12.tar.gz.

File metadata

  • Download URL: aapy-0.12.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for aapy-0.12.tar.gz
Algorithm Hash digest
SHA256 df5b03eb233c4d8f1877d459f5cb85b4087ec011284dc4daa0670a0a08886eea
MD5 73637ccc8cb6916282504c617b0db848
BLAKE2b-256 1fe44a8dcca0323408a1f4ce8338112b8cd4e166769fd567df654fc4a979cc38

See more details on using hashes here.

File details

Details for the file aapy-0.12-py3-none-any.whl.

File metadata

  • Download URL: aapy-0.12-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for aapy-0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 6faee9b9edab0ab277176be7ffbfb7082f00955c3fbf3bf0f4968d2e9409fa9f
MD5 84b4eafacbcb483b218a0672d95c6c80
BLAKE2b-256 6424c85b0df0f2cef7df06e04a9fc69b1413bcd1eaf6315db0c6883f5f3dc882

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page