Skip to main content

Karoo Array Telescope - Telescope State Client

Project description

MeerKAT Science Data Processor Telescope State

This is a client package that allows connection to the Redis database that stores telescope state information for the Science Data Processor of the MeerKAT radio telescope.

The Redis database acts as a key-value store. Each key is either a sensor or an attribute. A sensor has multiple timestamped values organised into an ordered set. An attribute (or immutable key) has a single value without a timestamp that is not allowed to change.

The keys are strings and values are arbitrary Python objects stored as pickles. Keys can be accessed using attribute syntax or dict syntax.

Getting Started

You will need a relatively recent version of Redis installed (2.8.9 or newer).

  • macOS: brew install redis

  • Ubuntu: apt-get install redis-server

Then pip install katsdptelstate and run a local redis-server. If you also want to load RDB files, do pip install katsdptelstate[rdb].

A Simple Example

import time
import katsdptelstate

# Connect to an actual Redis server
telstate = katsdptelstate.TelescopeState('localhost:6379')
# Or use a fake Redis instance (key/values stored in memory, useful for testing)
telstate = katsdptelstate.TelescopeState()
# Load dump file into Redis if katsdptelstate is installed with [rdb] option
telstate.load_from_file('dump.rdb')

# Attribute / dict style access returns the latest value
telstate.add('n_chans', 32768)
print(telstate.n_chans)
print(telstate['n_chans'])

# List all keys (attributes and sensors)
print(telstate.keys())

# Sensors are timestamped underneath
st = time.time()
telstate.add('n_chans', 4096)
et = time.time()
telstate.add('n_chans', 16384)
# Time ranges can be used and are really fast
telstate.get_range('n_chans', st=st, et=et)
# Add an item 10 seconds back
telstate.add('n_chans', 1024, ts=time.time() - 10)

# Attributes cannot be changed (only deleted)
telstate.add('no_change', 1234, immutable=True)
# Adding it again is OK as long as the value doesn't change
telstate.add('no_change', 1234, immutable=True)
# Will raise katsdptelstate.ImmutableKeyError
telstate.add('no_change', 456)

History

0.7 (2019-02-12)

  • Introduce encodings and add msgpack encoding as alternative to pickle (#64, #65)

  • Introduce backends and add in-memory backend as alternative to redis (#71, #72)

  • Simplify setting attributes via __setitem__ (#68)

  • Let keys be bytes internally, but allow specification as unicode strings (#63)

  • The GitHub repository is now public as well

0.6 (2018-05-10)

  • Initial release of katsdptelstate

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

katsdptelstate-0.7.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

katsdptelstate-0.7-py2.py3-none-any.whl (39.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file katsdptelstate-0.7.tar.gz.

File metadata

  • Download URL: katsdptelstate-0.7.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for katsdptelstate-0.7.tar.gz
Algorithm Hash digest
SHA256 5bb542278693b10441a1b1a52661f448c8523b027dee9519604791343091324e
MD5 251e836a7184a512cccc2b269df2569b
BLAKE2b-256 6fa5502acd7e6325d90e8ea4014be6861fc145803f46f414894d44824999854d

See more details on using hashes here.

Provenance

File details

Details for the file katsdptelstate-0.7-py2.py3-none-any.whl.

File metadata

  • Download URL: katsdptelstate-0.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for katsdptelstate-0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9076e69be571fedd775840cf7bc285a5eacf51d82d49495c755cb907b5687072
MD5 2e54ff292652e3105ee5d3a6c5a8a3af
BLAKE2b-256 c5eb9a24b2eb9441f751b0342ef3e359b2e75049844d433cb8a6321ca9af292c

See more details on using hashes here.

Provenance

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