Prerequisites¶
In order to run this sample code, you will need Python >= 3.8 on a Unix-like operating system (Linux or macOS) and a few third-party Python packages.
Python Packages¶
If you want to consume notices over Kafka (recommended), you will need one of either:
gcn-kafka for connecting to GCN Kafka to receive JSON-serialized notices over Kafka
hop-client for connecting to HOPSKOTCH to receive Avro-serialized notices over Kafka
Note
The Kafka servers hosted by GCN Kafka and HOPSKOTCH should be accessible using any Kafka client, however we will only provide directions in this guide that use gcn-kafka for the former and hop-client for the latter.
If you want to consume notices from GCN Classic, you will need:
lxml for parsing VOEvent XML packets (see also the voevent-parse and VOEventLib helper libraries, both of which are based on lxml)
The following libraries are needed for working with the sky maps associated with notices:
Healpy for decoding HEALPix coordinates (alternatives: astropy-healpix, the official C/C++/Fortran/Java/IDL HEALPix bindings for HEALPix, DS9, Aladin)
astropy for astronomical coordinate transformations, observability, etc.
numpy and matplotlib, popular math and plotting packages for Python
Installation¶
The fastest way to install the dependencies is with pip, a package manager that comes with most Python distributions. Another option is the Anaconda Python distribution.
Pip¶
Run the following command to install gcn-kafka and the packages needed to work with sky maps:
$ pip install gcn-kafka healpy
Run the following command to install hop-client and the packages needed to work with sky maps:
$ pip install hop-client healpy
Run the following command to install PyGCN, lxml, and the packages needed to work with sky maps:
$ pip install pygcn healpy
Anaconda¶
To install these packages using Anaconda, first install conda.
Run the following command to install gcn-kafka and the packages needed to work with sky maps:
$ conda install -c conda-forge gcn-kafka healpy
Run the following command to install hop-client and the packages needed to work with sky maps:
$ conda install -c conda-forge hop-client healpy
Run the following command to install PyGCN, lxml, and the packages needed to work with sky maps:
$ conda install -c conda-forge pygcn healpy