Installing Pandeia

Introduction to JWST Pandeia python interface tutorial.

On this page

This tutorial is intended for users who need to use Pandeia's python interface. If you are interested in doing JWST exposure time calculations for just a few observing scenarios, the JWST ETC Web UI is the recommended tool. The tutorial will assume that you have a basic working knowledge of python, and at least a passing familiarity with Conda and, preferably, AstroConda as well. This page provides a quick guide to installing Pandeia. Note that this tutorial is currently written for Pandeia 1.5.

Installing Pandeia 

In order to install Pandeia, you must either have Conda and AstroConda installed, or you must have Python 2.7 or later (as well as a number of additional modules) installed.

This tutorial does not provide a complete guide to installing and using AstroConda, but should be able to act as a quick reference if you are already familiar with Conda and AstroConda. Pandeia may be installed with either Python 2 or Python 3, but it has been more thoroughly tested with Python 2.

Installing Anaconda (if necessary)

Installing AstroConda

  • Once you have Anaconda installed, from a terminal with access to the conda environment, type "conda config --add channels".
  • Create an AstroConda environment with the STScI package installed. For example, to create an environment named "pandeia" working under python 2.7, type "conda create -n pandeia stsci python=2.7" from a terminal with access to the conda environment.

Setting up the Pandeia Environment

Data Files

Pandeia RefData:

The first is a set of files for pandeia itself, which can be downloaded here:

Download and unpack these files to an appropriate location; we recommend "$HOME/data/pandeia".

Pandeia requires that the "pandeia_refdata" environment variable be set to the location of its data files.

Pysynphot Data:

The second set of data files are for pysynphot. Pandeia uses pysynphot internally for handling spectra. The pysynphot reference files may be downloaded here.

Note that the tar.gz files will untar into the directory structure "grp/hst/cdbs", with the actual data files in an assortment of directories under "cdbs". pysynphot (and pandeia) expect that the "PYSYN_CDBS" environment variable will point to the "cdbs" directory. As such, you can either move the files out of "grp/hst/" to wherever you would like to store them, or point "PYSYN_CDBS" to "/path/to/data/files/grp/hst/cdbs" in order to allow pysynphot and pandeia to properly detect the reference files.

Note that pandeia does not require that pysynphot data be installed in order to operate, although it will generate warnings if the data is not available, or if the PYSYN_CDBS environment variable does not exist (or does not point to a valid pysynphot reference directory). Pandeia uses pysynphot data for the following:

  • Retrieving phoenix stellar spectra
  • Using HST filter bandpasses
  • Normalizing spectra in non-pandeia units (e.g., Johnson bandpasses)

If you do not require the above functionality, running pandeia without these pysynphot data files is entirely possible - warnings will be issued, but pandeia will otherwise function. The AstroConda environment does include pysynphot by default.

AstroConda configuration

Setting conda to automatically set these environment variables when the environment is activated can be done as follows:

  1. Find your anaconda installation (for the rest of this example, it will be assumed to be at "$HOME/anaconda/"). Likewise, as in the previous example, your Pandeia environment will be assumed to have the name "pandeia". Finally, your pysynphot reference data will be assumed to be located at "$HOME/data/pysynphot", and your pandeia reference data at "$HOME/data/pandeia".
  2. Go the "$HOME/anaconda/envs/pandeia/". If there is not a directory named "etc", create one there. In the "etc" directory, if there is not a directory named "conda", create one.
  3. In "$HOME/anaconda/envs/pandeia/etc/conda/", create the directories "activate.d" and "deactivate.d". In each of these directories, create a text file named "".
    1. The text file "$HOME/anaconda/envs/pandeia/etc/conda/activate.d/" should contain the following lines:

      export PYSYN_CDBS={$HOME}/data/pysynphot
      export pandeia_refdata={$HOME}/data/pandeia
    2. The text file "$HOME/anaconda/envs/pandeia/etc/conda/deactivate.d/" should contain the following lines:

      unset PYSYN_CDBS
      unset pandeia_refdata

Installing Pandeia

If you have not done so already, activate your Pandeia conda environment by typing "source activate pandeia". Then, in the same window, type "pip install pandeia.engine==1.5" to install pandeia itself.

Test your installation

Test your installation by running the following command in python:

import pandeia.engine


which should print out the version number of the installed engine and data version, and location of your Pysynphot data.

Installing Pandeia without AstroConda

It is strongly recommended that you install pandeia via AstroConda. Whilst some information is provided below for installing pandeia without AstroConda, it is entirely unsupported, and any issues you encounter will likely be much more difficult to resolve. This section assumes that you have python installed, that you are familiar with installing modules via pip, and that you are familiar with installing command-line software in general. If any of these do not apply, you should use the above instructions on installing Pandeia through AstroConda.

Pandeia requires the following python packages to operate:

  • astropy
  • numpy
  • scipy
  • pysynphot
  • photutils

Sample code

Setting up conda environment, activating conda, and installing Pandeia

This assumes that you have conda installed at "$HOME/anaconda", that you have the pysynphot data files installed at "$HOME/data/pysynphot", and that you have the pandeia data files installed at "$HOME/data/pandeia".

Environment Setup Script
conda config --add channels
conda create -n pandeia stsci python=2.7
mkdir -p ~/anaconda/envs/pandeia/etc/conda/activate.d
cat >>~/anaconda/envs/pandeia/etc/conda/activate.d/ <<EOF
export PYSYN_CDBS={$HOME}/data/pysynphot
export pandeia_refdata={$HOME}/data/pandeia
mkdir -p ~/anaconda/envs/pandeia/etc/conda/deactivate.d
cat >>~/anaconda/envs/pandeia/etc/conda/deactivate.d/ <<EOF
unset pandeia_refdata
source activate pandeia
pip install pandeia.engine==1.5

This sample setup does the following:

  • Adds the STScI astroconda channel to an existing conda installation
  • Creates a conda environment named "pandeia" which uses python 2.7 and includes all of the python packages from astroconda
  • Creates a configuration file in the anaconda directory belonging to the "pandeia" environment to hold instructions on setting up appropriate environment variables whenever the pandeia environment is activated
    • Sets up the PYSYN_CDBS and pandeia_refdata environment variables in the created file so that they will automatically be set to the correct value when the environment is activated.
  • Creates a configuration file in the anaconda directory belonging to the "pandeia" environment to hold instructions on removing environment variables whenever the pandeia environment is deactivated
    • Sets up the PYSYN_CDBS and pandeia_data environment variables in the created file so that they will be automatically removed when the environment is deactivated.
  • Activates the pandeia environment
  • Installs pandeia version 1.5 into the pandeia environment.

The above sample code will only need to be run once. After it has been run, typing "source activate pandeia" in a terminal window will activate the pandeia environment (which will now already have the pandeia module installed), and automatically set the environment variables PYSYN_CDBS and pandeia_refdata.



Latest updates
    Updated for ETC v.5. Updated the link for the Pandeia reference data download.

  • Updated for ETC 1.4. Updated the link for the Pandeia reference data download.

    Replaced data download link

    Removed instructions for the pysynphot anonymous FTP download, which is no longer supported.

    Updated the link for the Pandeia reference data download.

    Updated for ETC v1.3.