Introduction to JWST Pandeia python interface tutorial.
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.1.
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)
- Go to the Anaconda download page, and download the appropriate version of Anaconda
- Install Anaconda according to its documentation
- Once you have Anaconda installed, from a terminal with access to the conda environment, type "conda config --add channels http://ssb.stsci.edu/astroconda".
- 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
The first is a set of files for pandeia itself, which can be downloaded here: https://stsci.app.box.com/v/pandeia-refdata-v1p5p1
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.
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.
Setting conda to automatically set these environment variables when the environment is activated can be done as follows:
- 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 "
- 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.
- 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 "
The text file "$HOME/anaconda/envs/pandeia/etc/conda/activate.d/env_vars.sh" should contain the following lines:
The text file "
$HOME/anaconda/envs/pandeia/etc/conda/deactivate.d/env_vars.sh" should contain the following lines:
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.1" to install pandeia itself.
Test your installation
Test your installation by running the following command in python:
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:
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 "
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.1 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.