Skip to content

Latest commit

 

History

History
414 lines (274 loc) · 13.6 KB

install.rst

File metadata and controls

414 lines (274 loc) · 13.6 KB

Installation

Here we provide short installation instructions for Gammapy and its dependencies.

Gammapy works with Python 2 and 3.

More specifically, in the Python 2 series we only support Python 2.7, and in the Python 3 series we support version 3.3 or later. Gammapy will not work with Python 2.6 or 3.2 (see development-python2and3 if you care why).

Due to the large variety of systems, package managers and setups in us it's not possible to give a detailed description for every option.

Using conda is a good option to get everything installed from scratch within minutes. It works on any Linux, Mac or Windows machine and doesn't require root access.

If you get stuck, have a look at the extensive installation instructions for Astropy at http://www.astropy.org/ or ask on the Gammapy mailing list.

The main way to improve the instructions is via your feedback!

Conda

To install the latest Gammapy stable version as well as the most common optional dependencies for Gammapy, first install Anaconda and then run these commands:

conda config --add channels astropy --add channels sherpa
conda install gammapy naima \
    scipy matplotlib ipython-notebook

We strongly recommend that you install the optional dependencies of Gammapy to have the full functionality available:

conda install \
    scikit-image scikit-learn h5py pandas \
    aplpy wcsaxes photutils

pip install reproject iminuit

Sherpa is the only Gammapy dependency that's not yet available on Python 3, so if you want to use Sherpa for modeling / fitting, install Anaconda Python 2 and

conda install sherpa

For a quick (depending on your download and disk speed, usually a few minutes), non-interactive install of Miniconda and Gammapy from scratch, use the commands from this script: gammapy-conda-install.sh.

Executing it like this should also work:

bash "$(curl -fsSL https://raw.githubusercontent.com/gammapy/gammapy/master/gammapy-conda-install.sh)"

To update to the latest version:

conda update --all
conda update gammapy

Overall conda is a great cross-platform package manager, you can quickly learn how to use it by reading the docs here.

pip

To install the latest Gammapy stable version (see Gammapy page on PyPI) using pip:

$ pip install gammapy

To install the current Gammapy development version using pip:

$ pip install git+https://github.com/gammapy/gammapy.git#egg=gammapy

setup.py

To download the latest stable version of Gammapy, download it from https://pypi.python.org/pypi/gammapy, if you have the wget tool available you can do this from the command line:

$ wget https://pypi.python.org/packages/source/g/gammapy/gammapy-0.3.tar.gz
$ tar zxf gammapy-0.3.tar.gz
$ cd gammapy-0.3

To download the latest development version of Gammapy:

$ git clone https://github.com/gammapy/gammapy.git
$ cd gammapy

Either way, you now can install, test or build the documentation:

$ python setup.py install
$ python setup.py test
$ python setup.py build_sphinx

Also you have easy access to the Python scripts from the tutorials and examples:

$ cd docs/tutorials
$ cd examples

If you want to contribute to Gammapy, but are not familiar with Python or git or Astropy yet, please have a look at the Astropy developer documentation.

Other package managers

Besides conda, Gammapy and some of the optional dependencies (Sherpa, Astropy-affiliated packages) as not yet available in other package managers (such as e.g. apt-get or yum on Linux or Macports or homebrew on Mac.

So installing Gammapy this way is not recommended at this time. (The recommended method is conda as mentioned above).

Still, it's possible and common on systems where users have root access to install some of the dependencies using those package managers, and then to use pip to do the rest of the installation.

So as a convenience, here we show the commands to install those packages that are available, so that you don't have to look up the package names.

We do hope this situation will improve in the future as more astronomy packages become available in those distributions and versions are updated.

apt-get

apt-get is a popular package manager on Linux, e.g. on Debian or Ubuntu.

The following packages are available:

sudo apt-get install \
    python3-pip python3-scipy python3-matplotlib python3-skimage python3-sklearn \
    python3-pandas python3-h5py python3-yaml ipython3-notebook python3-uncertainties \
    python3-astropy

The following packages have to be installed with pip:

pip3 install --user \
    gammapy naima photutils reproject wcsaxes gwcs astroplan \
    iminuit emcee healpy

Sherpa currently doesn't work on Python 3. You could try to use Python 2 and pip-installing Sherpa (don't know if that works).

A Debian package for Sherpa is in preparation: sherpa/sherpa#75

A Debian package for Gammapy is in preparation: #324

As far as I can see there's no HEALPIX or healpy package.

yum

yum is a popular package manager on Linux, e.g. on Scientific linux or Red Hat Linux.

If you are a yum user, please contribute the equivalent commands (see e.g. the Macports section below).

Macports

Macports is a popular package manager on Mac.

The following packages are available via Macports:

export PY=py34
sudo port install \
    $PY-pip $PY-scipy $PY-matplotlib $PY-scikit-image $PY-scikit-learn \
    $PY-pandas $PY-emcee $PY-h5py $PY-yaml $PY-ipython $PY-uncertainties \
    $PY-healpy $PY-astropy

If you want some other Python version, use a different suffix (e.g. py27 or py35). Having multiple Python versions simultaneously works well, but is only really useful for developers.

pip install --user \
    gammapy naima photutils reproject wcsaxes gwcs astroplan \
    iminuit

Homebrew

Homebrew is a popular package manager on Mac.

If you are a brew user, please contribute the equivalent commands (see e.g. the Macports section above).

Check Gammapy installation

To check if Gammapy is correctly installed, start up python or ipython, import Gammapy and run the unit tests:

$ python -c 'import gammapy; gammapy.test()'

To check if the Gammapy command line tools are on your $PATH try this:

$ gammapy-info --tools

To check which dependencies of Gammapy you have installed:

$ gammapy-info --dependencies

Common issues

If you have an issue with Gammapy installation or usage, please check this list. If your issue is not adressed, please send an email to the mailing list.

  • Q: I get an error mentioning something (e.g. Astropy) isn't available, but I did install it.

    A: Check that you're using the right python and that your PYTHONPATH isn't pointing to places that aren't appropriate for this Python (usually it's best to not set it at all) using these commands:

    which python
    echo $PYTHONPATH
    python -c 'import astropy'

Dependencies

Note

The philosophy of Gammapy is to build on the existing scientific Python stack. This means that you need to install those dependencies to use Gammapy.

We are aware that too many dependencies is an issue for deployment and maintenance. That's why currently Gammapy only has two core dependencies --- Numpy and Astropy. We are considering making Sherpa, Scipy, scikit-image, photutils, reproject and naima core dependencies.

In addition there are about a dozen optional dependencies that are OK to import from Gammapy because they are potentially useful (not all of those are actually currently imported).

Before the Gammapy 1.0 release we will re-evaluate and clarify the Gammapy dependencies.

The required core dependencies of Gammapy are:

  • Numpy - the fundamental package for scientific computing with Python
  • Astropy - the core package for Astronomy in Python

Currently optional dependencies that are being considered as core dependencies:

Allowed optional dependencies:

  • matplotlib for plotting
  • wcsaxes for sky image plotting (provides a low-level API)
  • aplpy for sky image plotting (provides a high-level API)
  • pandas CSV read / write; DataFrame
  • scikit-learn for some data analysis tasks
  • GammaLib and ctools for simulating data and likelihood fitting
  • ROOT and rootpy conversion helper functions (still has some Python 3 issues)
  • imfun for a trous wavelet decomposition
  • uncertainties for Gaussian error propagation
  • gwcs for generalised world coordinate transformations
  • astroplan for observation planning and scheduling
  • iminuit for fitting by optimization
  • emcee for fitting by MCMC sampling
  • h5py for HDF5 data handling
  • PyYAML for YAML data handling
  • healpy for HEALPIX data handling

Fermi ScienceTools

The Fermi ScienceTools ships with it's own Python 2.7 interpreter.

If you want to use Astropy or Gammapy with that Python, you have to install it using that Python interpreter, other existing Python interpreters or installed packages can't be used (when they have C extensions, like Astropy does).

Fermi ScienceTools version v10r0p5 (released Jun 24, 2015) includes Python 2.7.8, Numpy 1.9.1, Scipy 0.14.0, matplotlib 1.1.1, PyFITS 3.1.2. Unfortunately pip, ipython or Astropy are not included.

So first in stall pip (see instructions), and then

$ pip install ipython astropy gammapy

If this doesn't work (which is not uncommon, this is known to fail to compile the C extensions of Astropy on some platforms), ask your Python-installation-savvy co-worker or on the Astropy or Gammapy mailing list.

CIAO

Note

The main reason to use Gammapy with CIAO was that CIAO was the easiest way to get Sherpa. Since 2015, Sherpa can be easily installed via conda, so we recommend you do that instead of installing Gammapy into CIAO as described in this section.

The CIAO ("Chandra Interactive Analysis of Observations") package, which includes Sherpa, ships with it's own Python 2.7 interpreter.

If you want to use Astropy or Gammapy with that Python, you have to install it using that Python interpreter, other existing Python interpreters or installed packages can't be used (when they have C extensions, like Astropy does).

CIAO version 4.7 (released December 16, 2014) includes Python 2.7.6, Numpy 1.8.1 and IPython 2.0.0. Unfortunately pip, PyFITS, Astropy, Scipy or Matplotlib are not included.

Building Sherpa and all the required libraries from source is very difficult. You should install the binary version of CIAO as described here, make sure you include Sherpa and exclude the Chandra CALDB. But then the Sherpa Python and Numpy will not work with the existing Python, Numpy, Astropy, Gammapy, ... on your system.

You have to re-install Astropy, Gammapy and any other Python packages that you want to use in the same script as Sherpa into the CIAO Python. Sometimes this just works, but sometimes you'll run into compilation errors when e.g. the C extensions in astropy.wcs or astropy.io.fits are compiled.

Here's a few tricks that might help you make it work.

$ cd $CIAO_DIR
$ bash bin/ciao-python-fix
  • Set LDFLAGS and use ciaorun before installing a Python package with C extensions:
$ export LDFLAGS="-L${ASCDS_INSTALL}/ots/lib"
$ ciaorun python setup.py install
  • Add these folders to your PATH and PYTHONPATH so that the right command line tools or Python packages are picked up instead of the ones in other system folders:
$ export PATH=$CIAO_DIR/ots/bin:$PATH
$ export PYTHONPATH=$CIAO_DIR/ots/lib/python2.7/site-packages/:$PYTHONPATH