SPEX X-ray spectral fitting package

This dataset contains compiled versions of the SPEX X-ray spectral fitting package. Until version 3.05.00, the source code contained some proprietary routines that prevented us to make the entire source tree public. If you are looking for the SPEX source code, then search for version number >=3.05.00.

Table of contents:

  • Running a Linux or Mac universal binary
  • Running an old version of SPEX using Docker

Running a Linux or Mac universal binary

This directory contains a statically linked SPEX installation for a 64-bit system, which should work on most linux distributions with GLIBC version >=2.24 and Mac systems >=10.13. The installation instructions for Linux and Mac are the same.

Installation instructions

  1. Download spex-3.02.00-Linux-amd64.tar.gz or spex-3.02.00-MacOSX.tar.gz from this directory.

  2. Unpack the tar file in the destination directory (for example /usr/local/):

    tar xvfz spex-3.02.00-Linux-amd64.tar.gz

    The tar file will create a directory called SPEX-3.02.00-Linux in which the program will be installed.

  3. Set the environment variable SPEX90 to the installation directory (for example /usr/local/SPEX-3.02.00-Linux):

    export SPEX90=/usr/local/SPEX-3.02.00-Linux (bash shell)
    setenv SPEX90 /usr/local/SPEX-3.02.00-Linux (C-type shell)
  4. Source the script provided by the distribution:

    source $SPEX90/spexdist.sh (bash shell)
    source $SPEX90/spexdist.csh (C-type shell)
  5. Remove the tar file:

    rm SPEX-3.02.00-Linux-amd64.tar.gz

If the Linux universal binary does not work, then please try the Docker option below.

Running an old version of SPEX using Docker

SPEX is written mostly in Fortran 90 and depends on a few system libraries. This makes it difficult to provide a few binary versions that will continue to run on multiple platforms over many years. Therefore, we have also created a Docker image for SPEX that can be run on the Docker platform, which is available for Linux, Mac OS and Windows.

Step 1: Download and install Docker on your computer

To run a Docker image, please install Docker on your computer. See the Docker website for details. Once you have downloaded and installed Docker, you can continue with this tutorial.

Step 2: Download the SPEX docker image from Zenodo

The SPEX Docker image is available on this Zenodo page as a tar.gz file. Please download the file called spex-[version]-docker.tar.gz, for example:


Step 3: Import the SPEX image into Docker

Before you can run the docker file, it should be imported into the docker system. This can be done on the command line:

    user@linux:~> docker load -i spex-3.02.00-docker.tar.gz

The image will be named spexxray/spex with the tag 3.02.00 and can be found with the command:

    user@linux:~> docker images
    spexxray/spex  3.02.00  0a0a0a0a0a0   1 minute ago   288MB

Step 4: Run SPEX on Docker

Using the docker run command, the image can be executed and SPEX can be run in a so-called container. To enjoy all the capabilities of SPEX, two things need to be arranged in the docker run command: access to local directories and a graphical X11 connection. To arrange this, additional flags need to be specified on the command line.

Mounting local directories to the container

If you would like to mount your own home directory into the SPEX container such that you can use some spo and res files there or save the output files, then you need the following flags:

-e LOCAL_USER_ID=`id -u $USER`
-v /home/myusername:/home/user

The first flag arranges that the user in the container will have the same user ID as you. This will allow you to read and write to your home directory from within the container.

The second flag arranges that your true local home directory called /home/myusername is mounted to /home/user inside the SPEX container.

MAC users: Please note that on OSX your home directory is in /Users/myusername.

Arranging the X11 connection

To make sure PGPLOT can connect to the X11 server on the host, we need to make a few connections from the container to the host machine. This is done with the following flags:

-v /tmp/.X11-unix:/tmp/.X11-unix

The first flag sets the DISPLAY variable inside the container to the DISPLAY variable of the host machine. The second flag mounts the X11 temporary directory of the host to the same directory inside the container.

MAC users: To use X11 on Mac, you need to install XQuartz (or a similar X11 server) and set it to 'Allow connections from network clients' in the XQuartz settings. In addition, the X server should be set to allow incoming connections from localhost on the command line:

    user@macos:~> xhost +

Then the DISPLAY variable on the docker run line should be set to host.docker.internal:0

The complete docker run command

The full run commands for docker now look like below, where -w means that the container will start in working directory /home/user.

For Linux:

docker run -it \
           -e DISPLAY=$DISPLAY \
           -e LOCAL_USER_ID=`id -u $USER` \
           -v /tmp/.X11-unix:/tmp/.X11-unix \
           -v /home/myusername:/home/user \
           -w /home/user \

For Mac:

docker run -it \
           -e DISPLAY=host.docker.internal:0 \
           -e LOCAL_USER_ID=`id -u $USER` \
           -v /tmp/.X11-unix:/tmp/.X11-unix \
           -v /Users/myusername:/home/user \
           -w /home/user \

The docker run command above will provide you with a prompt that will allow you to run spex:

user@linux:~> docker run -it -e DISPLAY=$DISPLAY -e LOCAL_USER_ID=`id -u $USER` \ 
-v /tmp/.X11-unix:/tmp/.X11-unix -v /home/myusername:/home/user -w /home/user \

Welcome to the SPEX Docker Container!
Just type 'spex' to start the program.

In this environment, you can just run spex or trafo:

user@0922f2e4ff85:~> spex
 Welcome user to SPEX version 3.02.00

 NEW in this version of SPEX:
04-08-2016 Updated pion model
04-08-2016 Re-installed tri-electronic transitions
04-08-2016 Introduced SPEXACT versioning for atomic database and code
19-08-2016 SPEX 3.02.00 released


More information about using SPEX can be found in the SPEX reference manual, which is also available in this Zenodo dataset.