Skip to main content

Karoo Array Telescope - Telescope State Client

Project description

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)

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.6.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

katsdptelstate-0.6-py2.py3-none-any.whl (24.1 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for katsdptelstate-0.6.tar.gz
Algorithm Hash digest
SHA256 84f0faaeaa626bd19d27a876326e9dc553d50b7d803ac834ef4324da1f6a8001
MD5 c2d53d91b99e88d93b55e0d922330558
BLAKE2b-256 ab4267a18f64ff963979e179e0759cfc997a4bff8277fa2b390d8fec5d87dd81

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for katsdptelstate-0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 16d86168104303bf157f808626afdf4bcb17c5cac14ccc4af302c43d9f89564a
MD5 d2cbf74fc6bab87782aa4ac1300f67f1
BLAKE2b-256 710ef7ff93229e1c9237862178a07c4d10ed4555a874c576aa5a2b4ad79cd8bf

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