SAMP (Simple Application Messaging Protocol) (astropy.samp)

astropy.samp is a Python implementation of the SAMP messaging system.

Simple Application Messaging Protocol (SAMP) is an inter-process communication system that allows different client programs, usually running on the same computer, to communicate with each other by exchanging short messages that may reference external data files. The protocol has been developed within the International Virtual Observatory Alliance (IVOA) and is understood by many desktop astronomy tools, including TOPCAT, SAO DS9, and Aladin.

So by using the classes in astropy.samp, Python code can interact with other running desktop clients, for instance displaying a named FITS file in DS9, prompting Aladin to recenter on a given sky position, or receiving a message identifying the row when a user highlights a plotted point in TOPCAT.

The way the protocol works is that a SAMP “Hub” process must be running on the local host, and then various client programs can connect to it. Once connected, these clients can send messages to each other via the hub. The details are described in the SAMP standard.

astropy.samp provides classes both to set up such a hub process, and to help implement a client that can send and receive messages. It also provides a stand-alone program samp_hub which can run a persistent hub in its own process. Note that setting up the hub from Python is not always necessary, since various other SAMP-aware applications may start up a hub independently; in most cases, only one running hub is used during a SAMP session.

The following classes are available in astropy.samp:

astropy.samp is a full implementation of SAMP V1.3. As well as the Standard Profile, it supports the Web Profile, which means that it can be used to also communicate with web SAMP clients; see the sampjs library examples for more details.

Using astropy.samp

Reference/API

astropy.samp Package

This subpackage provides classes to communicate with other applications via the Simple Application Messaging Protocol (SAMP).

Before integration into Astropy it was known as SAMPy, and was developed by Luigi Paioro (INAF - Istituto Nazionale di Astrofisica).

Classes

Conf()

Configuration parameters for astropy.samp.

SAMPClient(hub[, name, description, ...])

Utility class which provides facilities to create and manage a SAMP compliant XML-RPC server that acts as SAMP callable client application.

SAMPClientError

SAMP Client exceptions.

SAMPHubError

SAMP Hub exception.

SAMPHubProxy()

Proxy class to simplify the client interaction with a SAMP hub (via the standard profile).

SAMPHubServer([secret, addr, port, ...])

SAMP Hub Server.

SAMPIntegratedClient([name, description, ...])

A Simple SAMP client.

SAMPMsgReplierWrapper(cli)

Function decorator that allows to automatically grab errors and returned maps (if any) from a function bound to a SAMP call (or notify).

SAMPProxyError(faultCode, faultString, **extra)

SAMP Proxy Hub exception

SAMPWarning

SAMP-specific Astropy warning class

WebProfileDialog()

A base class to make writing Web Profile GUI consent dialogs easier.

Class Inheritance Diagram

Inheritance diagram of astropy.samp.Conf, astropy.samp.client.SAMPClient, astropy.samp.errors.SAMPClientError, astropy.samp.errors.SAMPHubError, astropy.samp.hub_proxy.SAMPHubProxy, astropy.samp.hub.SAMPHubServer, astropy.samp.integrated_client.SAMPIntegratedClient, astropy.samp.utils.SAMPMsgReplierWrapper, astropy.samp.errors.SAMPProxyError, astropy.samp.errors.SAMPWarning, astropy.samp.hub.WebProfileDialog

Acknowledgments

This code is adapted from the SAMPy package written by Luigi Paioro, who has granted the Astropy Project permission to use the code under a BSD license.