Introduction to pySAS

What is pySAS?

pySAS is the official Python wrapper for XMM-Newton’s Science Analysis System (SAS). It allows a SAS user to use Python to analize XMM-Newton data, using either Python scripts or a Jupyter Notebook.

pySAS can be used on your own computer or can be used on an online data analysis platform.

There are free to use online data analysis platforms to analize astronomy data. These platforms are accessed through a browser and use a Jupyter Lab environment as an interface. Currently there are three online platforms available where you can use pySAS.

  • Fornax: A collaboration between NASA Goddard Space Flight Center and NASA’s science archives; HEASARC, IRSA, and MAST. (Link to get an account on Fornax)

  • SciServer: Operated by the Institute for Data-Intensive Engineering and Science at Johns Hopkins University. (Link to SciServer)

  • Datalabs: Operated by the European Space Agency (ESA). (Link to Datalabs)

Both SAS and pySAS come preinstalled on Fornax, SciServer, and Datalabs.

Return to top

pySAS Tutuorials

There are several tutuorials demonstrating how to use pySAS using Jupyter Notebooks. These notebooks can be found on GitHub.

You can clone the repository with the example notebooks by running the following command in a directory of your choosing:

git clone https://github.com/XMMGOF/pysas_docs.git

Return to top

How do I install pySAS on my own computer?

You can install pySAS on your local machine to do data analysis. Before you can use pySAS you first have to install SAS following the installation instructions.

Note: pySAS contains a function to download and update XMM-Newton calibration files. When you configure pySAS you have the option to download the calibration files. See below for instructions.

Then pySAS can be installed using pip.

pip install xmmpysas

Note: Make sure you install xmmpysas. There is different Python module called pysas that has nothing to with pySAS for XMM-Newton.

pySAS will occationally be updated with bug fixes and new features. You can update pySAS to the latest version using:

pip install xmmpysas --upgrade

Return to top

How do I configure pySAS on my local machine?

Note: Configuring pySAS on Fornax, SciServer, and Datalabs is different than configuring pySAS for your own computer. See below for instructions on configuring pySAS on Fornax, SciServer, and Datalabs.

Before you use pySAS for data analysis you will need to configure pySAS so that it knows where you have SAS installed and where the XMM calibration files are located. After installing pySAS using pip, in Python run:

from pysas import config_pysas
config_pysas.run_config()

This script will ask you for the full path to three directories:

  • sas_dir: The directory where SAS is installed (i.e. /path/to/xmmsas_XX.X.X).

  • sas_ccfpath: The directory where the calibration files are stored. If you already have them downloaded, just enter the directory where they are. But if you have not downloaded them yet, you will be given the option to download them after the setup. The script will even create the directory for you.

  • data_dir: All observation data files will be downloaded into this directory. If the data directory does not exist it will be created for you.

After pySAS has been configured you can import pySAS like normal.

import pysas

Return to top

Using pySAS on Fornax, SciServer, or Datalabs

  • On Fornax use the sas Python environment.

  • On SciServer use the xmmsas Python environment.

  • On Datalabs use the xmmsas image. (Note July 8, 2026: The XMM SAS image on Datalabs is still being updated. pySAS will work, but a number of pySAS features are not available without some manipulation of the environment.)

On Fornax, SciServer, and Datalabs the paths to SAS and the calibration files are pre-set and the user does not have to do anything. But you still have to set your default data directory by running the following command in Python:

Note July 8, 2026: simple_config currently doesn’t work on Datalabs.

from pysas import sas_cfg
sas_cfg.simple_config()

Return to top

Document last updated: 2026-07-15