GithubHelp home page GithubHelp logo

danielballan / channelarchiver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eschuhmacher/channelarchiver

0.0 3.0 0.0 152 KB

Python client for the EPICS Channel Archiver

License: MIT License

Python 100.00%

channelarchiver's Introduction

A python client for retrieving data from an EPICS Channel Archiver.

To get started just import the Archiver class and specify the address of your Channel Archiver server:

from channelarchiver import Archiver
archiver = Archiver('http://xf23id-ca/cgi-bin/ArchiveDataServer.cgi')

You then fetch data with the archiver.get() method:

>>> data = archiver.get('XF:23IDA-VA:0{DP:1-IP:1}P-I', '2013-08-11', '2014-08-12')
>>> print data
               time  value    status     severity
               2014-06-28 22:11:53      0  NO_ALARM  ARCHIVE_OFF

...
>>> data.values
[0.0]

The returned ChannelData object has the following fields:

  • channel: The channel name.
  • times: A list of datetimes.
  • values: A list of the channel's values corresponding to times.
  • severities and statuses: Diagnostic information about the channel state for each time.
  • units: The units of values.
  • states: String values for enum type channels.
  • data_type: Whether the channel values are string, enum, int or double (see codes.data_type).
  • elements: The number of elements in an array type channel.
  • display_limits, warn_limits, alarm_limits: Low and high limits
  • display_precision: The recommended number of decimal places to to display values with in user interfaces.
  • archive_key: The archive the data was retrieved from.
  • interpolation: The interpolation method that was used (see codes.interpolation).

Get multiple channels

If you pass a list of channel names to .get() you will get a list of data objects back:

>>> channels = ['XF:23IDA-VA:0{DP:1-IP:1}P-I', ' XF:23IDA-VA:0{DP:1-CCG:1}P-I']
>>> x, y = archiver.get(channels, '2013-08-24 09:00', '2014-08-24 19:00')
>>> print x.values
[ 0.0]
>>> print y.values
[]

Times and timezones

The start and end times over which to fetch data can be datetimes or strings in ISO 8601 format (eg 2013-08-10T21:30:00).

If no timezone is specified, your local timezone will be used. If a timezone is given, the returned channel data times will also be in this timezone.

>>> start = datetime.datetime(2012, 6, 1, tzinfo=pytz.UTC)
>>> end = datetime.datetime(2012, 6, 30, tzinfo=pytz.UTC)
>>> data_in_utc = archiver.get('BR00EXS01:TUNNEL_TEMPERATURE_MONITOR', start, end)

Interpolating

You can control how much data is returned from the archiver with the limit parameter. This is roughly equal to how many data points will be returned but the actual value will differ depending on how much data is available and the interpolation method.

The interpolation method is determined by the interpolation parameter. The allowed values are the 'raw', 'spreadsheet', 'averaged', 'plot-binning' and 'linear'. The default value is 'linear'.

>>> from channelarchiver import codes
>>> channel = 'SR00MOS01:FREQUENCY_MONITOR'
>>> data = archiver.get(channel, '2012', '2013', limit=10000, interpolation='raw')

Speeding up data retrieval

By default, for each .get call Archive will scan the archives to determine which one contains data for the specified channels. This will cause a slight delay in retrieving the data. This can be avoided by calling the .scan_archives() method once and then passing scan_archives=False to .get():

>>> archiver.scan_archives()
>>> d1 = archiver.get('XF:23IDA-VA:0{DP:1-IP:1}P-I', '2013-07', '2014-08', scan_archives=False)

channelarchiver's People

Contributors

robbieclarken avatar eschuhmacher avatar

Watchers

James Cloos avatar Dan Allan avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.