Skip to content

Commit

Permalink
DOC: Replace astropy.samp with pyvo.astropy_samp
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Mar 25, 2021
1 parent 5de526e commit 2ec74ba
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 54 deletions.
10 changes: 5 additions & 5 deletions docs/astropy_samp/advanced_embed_samp_hub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Overview
If you wish to embed a SAMP hub in your Python Graphical User Interface (GUI)
tool, you will need to start the hub programmatically using::

from astropy.samp import SAMPHubServer
from pyvo.astropy_samp import SAMPHubServer
hub = SAMPHubServer()
hub.start()

This launches the hub in a thread and is non-blocking. If you are not
interested in connections from web SAMP clients, then you can use::

from astropy.samp import SAMPHubServer
from pyvo.astropy_samp import SAMPHubServer
hub = SAMPHubServer(web_profile=False)
hub.start()

Expand All @@ -31,7 +31,7 @@ likely want to open a GUI dialog instead.

To do this, you will need to define a class that handles the dialog, and then
pass an **instance** of the class to |SAMPHubServer| (not the class itself).
This class should inherit from `astropy.samp.WebProfileDialog` and add the
This class should inherit from `pyvo.astropy_samp.WebProfileDialog` and add the
following:

1) A GUI timer callback that periodically calls
Expand Down Expand Up @@ -71,8 +71,8 @@ SAMP connections and opens the appropriate dialog::
import tkinter as tk
import tkinter.messagebox as tkMessageBox

from astropy.samp import SAMPHubServer
from astropy.samp.hub import WebProfileDialog
from pyvo.astropy_samp import SAMPHubServer
from pyvo.astropy_samp.hub import WebProfileDialog

MESSAGE = """
A Web application which declares to be
Expand Down
2 changes: 1 addition & 1 deletion docs/astropy_samp/example_clients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ First, start up a SAMP hub as described in :doc:`example_hub`.

Next, we create two clients and connect them to the hub::

>>> from astropy import samp
>>> from pyvo import astropy_samp as samp
>>> client1 = samp.SAMPIntegratedClient(name="Client 1", description="Test Client 1",
... metadata = {"client1.version":"0.01"})
>>> client2 = samp.SAMPIntegratedClient(name="Client 2", description="Test Client 2",
Expand Down
6 changes: 3 additions & 3 deletions docs/astropy_samp/example_hub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Using an Existing Hub

You can start up another application that includes a hub, such as
`TOPCAT <http://www.star.bris.ac.uk/~mbt/topcat/>`_,
`SAO Ds9 <http://ds9.si.edu/>`_, or
`SAO DS9 <http://ds9.si.edu/>`_, or
`Aladin Desktop <http://aladin.u-strasbg.fr>`_.

Using the Command-Line Hub Utility
==================================

You can make use of the ``samp_hub`` command-line utility, which is included in
``astropy``::
``pyvo``::

$ samp_hub

Expand All @@ -37,7 +37,7 @@ Starting a Hub Programmatically (Advanced)
You can start up a hub by creating a |SAMPHubServer| instance and starting it,
either from the interactive Python prompt, or from a Python script::

>>> from astropy.samp import SAMPHubServer
>>> from pyvo.astropy_samp import SAMPHubServer
>>> hub = SAMPHubServer()
>>> hub.start()

Expand Down
24 changes: 12 additions & 12 deletions docs/astropy_samp/example_table_image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In the following examples, we make use of:

TOPCAT and Aladin will run a SAMP Hub if none is found, so for the following
examples you can either start up one of these applications first, or you can
start up the `astropy.samp` hub. You can start this using the following
start up the `pyvo.astropy_samp` hub. You can start this using the following
command::

$ samp_hub
Expand All @@ -30,7 +30,7 @@ The easiest way to send a VO table to TOPCAT is to make use of the
|SAMPIntegratedClient| class. Once TOPCAT is open, first instantiate a
|SAMPIntegratedClient| instance and then connect to the hub::

>>> from astropy.samp import SAMPIntegratedClient
>>> from pyvo.astropy_samp import SAMPIntegratedClient
>>> client = SAMPIntegratedClient()
>>> client.connect()

Expand Down Expand Up @@ -59,15 +59,15 @@ and the details of the table that we set above)::

Finally, we can broadcast this to all clients that are listening for
``table.load.votable`` messages using
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.notify_all`::
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.notify_all`::

>>> client.notify_all(message)

The above message will actually be broadcast to all applications connected via
SAMP. For example, if we open `SAO DS9 <http://ds9.si.edu/>`_ in
addition to TOPCAT, and we run the above command, both applications will load
the table. We can use the
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.get_registered_clients` method to
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.get_registered_clients` method to
find all of the clients connected to the hub::

>>> client.get_registered_clients()
Expand All @@ -88,7 +88,7 @@ These IDs do not mean much, but we can find out more using::

We can see that ``c1`` is the TOPCAT client. We can now resend the data, but
this time only to TOPCAT, using the
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.notify` method::
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.notify` method::

>>> client.notify('c1', message)

Expand All @@ -103,7 +103,7 @@ To receive a table from TOPCAT, we have to set up a client that listens for
messages from the hub. As before, we instantiate a |SAMPIntegratedClient|
instance and connect to the hub::

>>> from astropy.samp import SAMPIntegratedClient
>>> from pyvo.astropy_samp import SAMPIntegratedClient
>>> client = SAMPIntegratedClient()
>>> client.connect()

Expand All @@ -128,9 +128,9 @@ And we instantiate it:
>>> r = Receiver(client)

We can now use the
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.bind_receive_call`
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.bind_receive_call`
and
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.bind_receive_notification`
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.bind_receive_notification`
methods to tell our receiver to listen to all ``table.load.votable`` messages::

>>> client.bind_receive_call("table.load.votable", r.receive_call)
Expand Down Expand Up @@ -178,7 +178,7 @@ reads the table once it has::

import time

from astropy.samp import SAMPIntegratedClient
from pyvo.astropy_samp import SAMPIntegratedClient
from astropy.table import Table

# Instantiate the client and connect to the hub
Expand Down Expand Up @@ -236,7 +236,7 @@ make use of the |SAMPIntegratedClient| class. Once Aladin or DS9 are open,
first instantiate a |SAMPIntegratedClient| instance and then connect to the hub
as before::

>>> from astropy.samp import SAMPIntegratedClient
>>> from pyvo.astropy_samp import SAMPIntegratedClient
>>> client = SAMPIntegratedClient()
>>> client.connect()

Expand Down Expand Up @@ -264,10 +264,10 @@ Finally, we can broadcast this to all clients that are listening for
>>> client.notify_all(message)

As for `Sending a Table to TOPCAT and DS9`_, the
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.notify_all`
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.notify_all`
method will broadcast the image to all listening clients, and for tables it
is possible to instead use the
:meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.notify` method
:meth:`~pyvo.astropy_samp.integrated_client.SAMPIntegratedClient.notify` method
to send it to a specific client.

Once finished, we should make sure we disconnect from the hub::
Expand Down
29 changes: 13 additions & 16 deletions docs/astropy_samp/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
.. _vo-samp:

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

`astropy.samp` is a Python implementation of the SAMP messaging system.
.. note:: `astropy.samp` is now `pyvo.astropy_samp`.

`pyvo.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
Expand All @@ -19,7 +21,7 @@ desktop astronomy tools, including `TOPCAT
<http://www.star.bris.ac.uk/~mbt/topcat/>`_, `SAO DS9 <http://ds9.si.edu/>`_,
and `Aladin <http://aladin.u-strasbg.fr>`_.

So by using the classes in `astropy.samp`, Python code can interact with
So by using the classes in `pyvo.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.
Expand All @@ -29,14 +31,14 @@ 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 <http://www.ivoa.net/documents/SAMP/>`_.

`astropy.samp` provides classes both to set up such a hub process, and to
`pyvo.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`:
The following classes are available in `pyvo.astropy_samp`:

* |SAMPHubServer|, which is used to instantiate a hub server that clients can
then connect to.
Expand All @@ -47,16 +49,16 @@ The following classes are available in `astropy.samp`:
* |SAMPIntegratedClient|, which is the same as |SAMPClient| except that it has
a self-contained |SAMPHubProxy| to provide a simpler user interface.

`astropy.samp` is a full implementation of `SAMP V1.3
`pyvo.astropy_samp` is a full implementation of `SAMP V1.3
<http://www.ivoa.net/documents/SAMP/20120411/>`_. 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
<http://astrojs.github.io/sampjs/>`_ library examples for more details.

.. _IVOA Simple Application Messaging Protocol: http://www.ivoa.net/documents/latest/SAMP.html

Using `astropy.samp`
====================
Using `pyvo.astropy_samp`
=========================

.. toctree::
:maxdepth: 2
Expand All @@ -66,15 +68,10 @@ Using `astropy.samp`
example_clients
advanced_embed_samp_hub

.. note that if this section gets too long, it should be moved to a separate
doc page - see the top of performance.inc.rst for the instructions on how to do
that
.. include:: performance.inc.rst

Reference/API
=============

.. automodapi:: astropy.samp
.. automodapi:: pyvo.astropy_samp

Acknowledgments
===============
Expand Down
12 changes: 0 additions & 12 deletions docs/astropy_samp/performance.inc.rst

This file was deleted.

10 changes: 5 additions & 5 deletions docs/astropy_samp/references.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. |SAMPClient| replace:: :class:`~astropy.samp.SAMPClient`
.. |SAMPIntegratedClient| replace:: :class:`~astropy.samp.SAMPIntegratedClient`
.. |SAMPHubServer| replace:: :class:`~astropy.samp.SAMPHubServer`
.. |SAMPHubProxy| replace:: :class:`~astropy.samp.SAMPHubProxy`
.. |SAMPMsgReplierWrapper| replace:: :class:`~astropy.samp.SAMPMsgReplierWrapper`
.. |SAMPClient| replace:: :class:`~pyvo.astropy_samp.SAMPClient`
.. |SAMPIntegratedClient| replace:: :class:`~pyvo.astropy_samp.SAMPIntegratedClient`
.. |SAMPHubServer| replace:: :class:`~pyvo.astropy_samp.SAMPHubServer`
.. |SAMPHubProxy| replace:: :class:`~pyvo.astropy_samp.SAMPHubProxy`
.. |SAMPMsgReplierWrapper| replace:: :class:`~pyvo.astropy_samp.SAMPMsgReplierWrapper`

0 comments on commit 2ec74ba

Please sign in to comment.