Installing the HASP/HSLA Spectral-Combination Script#

This Notebook is designed to walk you through downloading, installing, and running the spectral-combination script used by the Hubble Advanced Spectral Products (HASP) and the Hubble Spectral Legacy Archive (HSLA).#

Learning Goals:#

By the end of this tutorial, you will:

  • Learn how to download micromamba and create the stenv environment

  • Learn how to download and install the HASP/HSLA co-add script

  • Learn how to run the script

  • Understand the naming conventions of the co-added output files

Table of Contents#

0. Introduction

1. Downloading and Installing micromamba

- 1.1 Installing micromamba

- 1.2 Creating the stenv Environment

2. Downloading and Installing the HASP/HSLA Script

3. Running the Co-add Script

- 3.1 Retrieving the Data

- 3.2 Running the Script

- 3.3 Understanding the Output Files

0. Introduction#

The Hubble Advanced Spectral Products (HASP) and Hubble Spectroscopic Legacy Archive (HSLA) combine data taken with the Space Telescope Imaging Spectrograph (STIS) and the Cosmic Origins Spectrograph (COS) aboard the Hubble Space Telescope (HST) into high-quality spectra with broad wavelength coverage (from the ultraviolet to the near-infrared if the data exist) that are publicly available to the scientific community. HASP combines all of the STIS and COS data for each target within a single program. HSLA combines all of the STIS and COS data in the MAST archive – across multiple programs – into a single spectrum for each target.

The same script is used by both projects; it is available for use by observers who wish to produce custom products beyond those provided by HASP and HSLA through MAST. Briefly, the code co-adds all of the spectra taken with the same grating, then splices together (or abuts) the spectra from multiple gratings into a single spectrum with the broadest possible wavelength range. In particular, the script combines multiple orders from the STIS echelle modes and multiple central-wavelength settings for a single STIS or COS grating, tasks that that the current STIS and COS pipelines do not perform. For a detailed explanation of the logic used to combine spectra, see the HASP and HSLA ISRs.

This notebook focuses on the installation of the co-add script and provides a quick overview of its use. To see an example of downloading COS and STIS datasets, running the script, and analyzing the output, please review the HASP Coadd Tutorial notebook. For an overview of the HSLA products, see the notebook, Introduction to the HSLA Data Products and Tools.

1. Downloading and Installing micromamba#

1.1 Installing micromamba#

Conda is a package, dependency, and environment manager that runs on Windows, Mac, and Linux. Conda allows us to install Python packages and create isolated conda environments, each with its own packages and dependencies. By switching between conda environments, we avoid conflicts between different versions of packages. mamba is a rewrite of conda that is much faster at resolving dependencies with near-parity of commands. micromamba is mamba packaged into a single binary, which makes installation and maintenance much easier. For these reasons, we recommended that you use micromamba.

We will create a micromamba environment to install the packages needed for the HASP/HSLA script. First check whether micromamba is already installed by running this command:

!micromamba --version
2.3.3

Running the command should print out the version of micromamba that you have installed (in this case, micromamba 2.3.0). If the command returns a message saying that the package is unknown, then micromamba is not installed on your machine.

To install it, follow the directions for micromamba on the Getting Started page for stenv. There are a couple of options. One is to enter the following in a terminal window:

"${SHELL}" <(curl -L micro.mamba.pm/install.sh)

When you’re done, run the version command again to confirm that micromamba is installed.

1.2 Creating the stenv Environment#

The next step is to install the stenv environment, which contains all of the software packages used by the HASP/HSLA software. Continue to follow the instructions on the Getting Started page for stenv. It will direct you to the Releases page, from which you must retrieve the yaml file appropriate for your system. Install the environment using the command

!micromamba env create --name stenv --file ~/Downloads/stenv-Linux-X64-py3.13-2025.07.16.yaml
info     libmamba ****************** Backtrace Start ******************
debug    libmamba Loading configuration
trace    libmamba Compute configurable 'create_base'
trace    libmamba Compute configurable 'no_env'
trace    libmamba Compute configurable 'no_rc'
trace    libmamba Compute configurable 'rc_files'
trace    libmamba Compute configurable 'root_prefix'
trace    libmamba Get RC files configuration from locations up to HomeDir
trace    libmamba Configuration found at '/home/runner/work/_temp/setup-micromamba/.condarc'
trace    libmamba Update configurable 'no_env'
trace    libmamba Compute configurable 'envs_dirs'
trace    libmamba Compute configurable 'file_specs'
error    libmamba YAML spec file '/home/runner/Downloads/stenv-Linux-X64-py3.13-2025.07.16.yaml' not found
critical libmamba File not found. Aborting.
info     libmamba ****************** Backtrace End ********************

(Replace the file name with that of the yaml file that you’ve just retrieved.) This will take a few minutes. Activate the new environment using the command

!micromamba activate stenv
Your parent process name is Name:	python.
If your shell is xonsh, please use "-s xonsh".

'micromamba' is running as a subprocess and can't modify the parent shell.
Thus you must initialize your shell before using activate and deactivate.

To initialize the current bash shell, run:
    $ eval "$(micromamba shell hook --shell bash)"
and then activate or deactivate with:
    $ micromamba activate
To automatically initialize all future (bash) shells, run:
    $ micromamba shell init --shell bash --root-prefix=~/.local/share/mamba
If your shell was already initialized, reinitialize your shell with:
    $ micromamba shell reinit --shell bash
Otherwise, this may be an issue. In the meantime you can run commands. See:
    $ micromamba run --help

Supported shells are {bash, zsh, csh, posix, xonsh, cmd.exe, powershell, fish, nu}.
critical libmamba Shell not initialized

Now that you have created and activated an stenv environment, you can download the co-add script.

2. Downloading and Installing the HASP/HSLA Script#

Download the HASP/HSLA co-add script from the HASP Github repository.

You only need to run one of the two options below, depending on your computer and Git settings. (If you have no idea which option to choose, try Option A. It will probably work.)

Option A, using pip:#

pip install clones the repository and installs the packages according to the setup configuration of the repository. You may need to create a Personal Access Token (PAT) to use instead of your Github account’s password, since support for password authentication was removed in 2021. You can learn how to create a PAT here.

!pip install git+https://github.com/spacetelescope/hasp.git
Collecting git+https://github.com/spacetelescope/hasp.git
  Cloning https://github.com/spacetelescope/hasp.git to /tmp/pip-req-build-eqi6go6y
  Running command git clone --filter=blob:none --quiet https://github.com/spacetelescope/hasp.git /tmp/pip-req-build-eqi6go6y
  Resolved https://github.com/spacetelescope/hasp.git to commit e0f5e8c82a45c0145dbb23579097647409dd0778
  Installing build dependencies ... ?25l-
 \
 done
?25h  Getting requirements to build wheel ... ?25l-
 done
?25h  Preparing metadata (pyproject.toml) ... ?25l-
 done
?25hRequirement already satisfied: astropy>=5.0.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from hasp==1.2.5) (7.1.1)
Requirement already satisfied: ullyses>=4.1.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from hasp==1.2.5) (4.1.0)
Requirement already satisfied: numpy>=1.23.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp==1.2.5) (2.3.4)
Requirement already satisfied: pyerfa>=2.0.1.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp==1.2.5) (2.0.1.5)
Requirement already satisfied: astropy-iers-data>=0.2025.9.29.0.35.48 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp==1.2.5) (0.2025.11.10.0.38.31)
Requirement already satisfied: PyYAML>=6.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp==1.2.5) (6.0.3)
Requirement already satisfied: packaging>=22.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp==1.2.5) (25.0)
Requirement already satisfied: datetime in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (5.5)
Requirement already satisfied: cython in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (3.2.0)
Requirement already satisfied: ullyses-utils>=3.1.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (3.1.0)
Requirement already satisfied: pandas>2.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (2.3.3)
Requirement already satisfied: calcos>=3.4.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (3.6.1)
Requirement already satisfied: costools in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (1.2.6)
Requirement already satisfied: stistools>=1.4.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (1.4.6)
Requirement already satisfied: matplotlib in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (3.10.7)
Requirement already satisfied: plotly in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (6.4.0)
Requirement already satisfied: scipy>=1.11.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp==1.2.5) (1.16.3)
Requirement already satisfied: stsci.tools>=4.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from calcos>=3.4.0->ullyses>=4.1.0->hasp==1.2.5) (4.2.0)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pandas>2.0->ullyses>=4.1.0->hasp==1.2.5) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pandas>2.0->ullyses>=4.1.0->hasp==1.2.5) (2025.2)
Requirement already satisfied: tzdata>=2022.7 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pandas>2.0->ullyses>=4.1.0->hasp==1.2.5) (2025.2)
Requirement already satisfied: six>=1.5 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas>2.0->ullyses>=4.1.0->hasp==1.2.5) (1.17.0)
Requirement already satisfied: pysiaf in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (0.24.1)
Requirement already satisfied: astroquery in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (0.4.11)
Requirement already satisfied: contourpy>=1.0.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp==1.2.5) (1.3.3)
Requirement already satisfied: cycler>=0.10 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp==1.2.5) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp==1.2.5) (4.60.1)
Requirement already satisfied: kiwisolver>=1.3.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp==1.2.5) (1.4.9)
Requirement already satisfied: pillow>=8 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp==1.2.5) (12.0.0)
Requirement already satisfied: pyparsing>=3 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp==1.2.5) (3.2.5)
Requirement already satisfied: requests>=2.19 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2.32.5)
Requirement already satisfied: beautifulsoup4>=4.8 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (4.14.2)
Requirement already satisfied: html5lib>=0.999 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (1.1)
Requirement already satisfied: keyring>=15.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (25.6.0)
Requirement already satisfied: pyvo>=1.5 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (1.7.1)
Requirement already satisfied: soupsieve>1.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from beautifulsoup4>=4.8->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2.8)
Requirement already satisfied: typing-extensions>=4.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from beautifulsoup4>=4.8->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (4.15.0)
Requirement already satisfied: webencodings in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from html5lib>=0.999->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (0.5.1)
Requirement already satisfied: SecretStorage>=3.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (3.4.1)
Requirement already satisfied: jeepney>=0.4.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (0.9.0)
Requirement already satisfied: importlib_metadata>=4.11.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (8.7.0)
Requirement already satisfied: jaraco.classes in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (3.4.0)
Requirement already satisfied: jaraco.functools in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (4.3.0)
Requirement already satisfied: jaraco.context in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (6.0.1)
Requirement already satisfied: zipp>=3.20 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from importlib_metadata>=4.11.4->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (3.23.0)
Requirement already satisfied: charset_normalizer<4,>=2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (3.4.4)
Requirement already satisfied: idna<4,>=2.5 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (3.11)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2.5.0)
Requirement already satisfied: certifi>=2017.4.17 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2025.10.5)
Requirement already satisfied: cryptography>=2.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from SecretStorage>=3.2->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (46.0.3)
Requirement already satisfied: cffi>=2.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from cryptography>=2.0->SecretStorage>=3.2->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2.0.0)
Requirement already satisfied: pycparser in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from cffi>=2.0.0->cryptography>=2.0->SecretStorage>=3.2->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2.22)
Requirement already satisfied: zope.interface in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from datetime->ullyses>=4.1.0->hasp==1.2.5) (8.1)
Requirement already satisfied: more-itertools in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from jaraco.classes->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (10.8.0)
Requirement already satisfied: backports.tarfile in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from jaraco.context->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (1.2.0)
Requirement already satisfied: narwhals>=1.15.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from plotly->ullyses>=4.1.0->hasp==1.2.5) (2.11.0)
Requirement already satisfied: lxml>=4.6.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pysiaf->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (6.0.2)
Requirement already satisfied: openpyxl>=3.0.9 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pysiaf->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (3.1.5)
Requirement already satisfied: et-xmlfile in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from openpyxl>=3.0.9->pysiaf->stistools>=1.4.2->ullyses>=4.1.0->hasp==1.2.5) (2.0.0)

Option B, using git clone:#

While git clone also downloads the repository, it differs from pip in that it also downloads all of the history and files of the repository. If you have a password-protected SSH key, rather than a PAT, you can clone the repo by running the following code in your terminal. If you want to setup a SSH key, you can learn how to do so here.

!git clone git@github.com:spacetelescope/hasp.git
Cloning into 'hasp'...
git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This will install additional dependencies using the pyproject.toml file.

After you’ve downloaded the code using Option A or B, run this command to download the script’s dependencies:#

!pip install hasp
Requirement already satisfied: hasp in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (1.2.5)
Requirement already satisfied: astropy>=5.0.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from hasp) (7.1.1)
Requirement already satisfied: ullyses>=4.1.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from hasp) (4.1.0)
Requirement already satisfied: numpy>=1.23.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp) (2.3.4)
Requirement already satisfied: pyerfa>=2.0.1.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp) (2.0.1.5)
Requirement already satisfied: astropy-iers-data>=0.2025.9.29.0.35.48 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp) (0.2025.11.10.0.38.31)
Requirement already satisfied: PyYAML>=6.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp) (6.0.3)
Requirement already satisfied: packaging>=22.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astropy>=5.0.4->hasp) (25.0)
Requirement already satisfied: datetime in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (5.5)
Requirement already satisfied: cython in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (3.2.0)
Requirement already satisfied: ullyses-utils>=3.1.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (3.1.0)
Requirement already satisfied: pandas>2.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (2.3.3)
Requirement already satisfied: calcos>=3.4.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (3.6.1)
Requirement already satisfied: costools in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (1.2.6)
Requirement already satisfied: stistools>=1.4.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (1.4.6)
Requirement already satisfied: matplotlib in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (3.10.7)
Requirement already satisfied: plotly in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (6.4.0)
Requirement already satisfied: scipy>=1.11.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from ullyses>=4.1.0->hasp) (1.16.3)
Requirement already satisfied: stsci.tools>=4.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from calcos>=3.4.0->ullyses>=4.1.0->hasp) (4.2.0)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pandas>2.0->ullyses>=4.1.0->hasp) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pandas>2.0->ullyses>=4.1.0->hasp) (2025.2)
Requirement already satisfied: tzdata>=2022.7 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pandas>2.0->ullyses>=4.1.0->hasp) (2025.2)
Requirement already satisfied: six>=1.5 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas>2.0->ullyses>=4.1.0->hasp) (1.17.0)
Requirement already satisfied: pysiaf in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from stistools>=1.4.2->ullyses>=4.1.0->hasp) (0.24.1)
Requirement already satisfied: astroquery in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from stistools>=1.4.2->ullyses>=4.1.0->hasp) (0.4.11)
Requirement already satisfied: contourpy>=1.0.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp) (1.3.3)
Requirement already satisfied: cycler>=0.10 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp) (4.60.1)
Requirement already satisfied: kiwisolver>=1.3.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp) (1.4.9)
Requirement already satisfied: pillow>=8 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp) (12.0.0)
Requirement already satisfied: pyparsing>=3 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from matplotlib->ullyses>=4.1.0->hasp) (3.2.5)
Requirement already satisfied: requests>=2.19 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2.32.5)
Requirement already satisfied: beautifulsoup4>=4.8 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (4.14.2)
Requirement already satisfied: html5lib>=0.999 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (1.1)
Requirement already satisfied: keyring>=15.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (25.6.0)
Requirement already satisfied: pyvo>=1.5 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (1.7.1)
Requirement already satisfied: soupsieve>1.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from beautifulsoup4>=4.8->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2.8)
Requirement already satisfied: typing-extensions>=4.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from beautifulsoup4>=4.8->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (4.15.0)
Requirement already satisfied: webencodings in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from html5lib>=0.999->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (0.5.1)
Requirement already satisfied: SecretStorage>=3.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (3.4.1)
Requirement already satisfied: jeepney>=0.4.2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (0.9.0)
Requirement already satisfied: importlib_metadata>=4.11.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (8.7.0)
Requirement already satisfied: jaraco.classes in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (3.4.0)
Requirement already satisfied: jaraco.functools in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (4.3.0)
Requirement already satisfied: jaraco.context in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (6.0.1)
Requirement already satisfied: zipp>=3.20 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from importlib_metadata>=4.11.4->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (3.23.0)
Requirement already satisfied: charset_normalizer<4,>=2 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (3.4.4)
Requirement already satisfied: idna<4,>=2.5 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (3.11)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2.5.0)
Requirement already satisfied: certifi>=2017.4.17 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from requests>=2.19->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2025.10.5)
Requirement already satisfied: cryptography>=2.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from SecretStorage>=3.2->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (46.0.3)
Requirement already satisfied: cffi>=2.0.0 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from cryptography>=2.0->SecretStorage>=3.2->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2.0.0)
Requirement already satisfied: pycparser in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from cffi>=2.0.0->cryptography>=2.0->SecretStorage>=3.2->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2.22)
Requirement already satisfied: zope.interface in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from datetime->ullyses>=4.1.0->hasp) (8.1)
Requirement already satisfied: more-itertools in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from jaraco.classes->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (10.8.0)
Requirement already satisfied: backports.tarfile in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from jaraco.context->keyring>=15.0->astroquery->stistools>=1.4.2->ullyses>=4.1.0->hasp) (1.2.0)
Requirement already satisfied: narwhals>=1.15.1 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from plotly->ullyses>=4.1.0->hasp) (2.11.0)
Requirement already satisfied: lxml>=4.6.4 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pysiaf->stistools>=1.4.2->ullyses>=4.1.0->hasp) (6.0.2)
Requirement already satisfied: openpyxl>=3.0.9 in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from pysiaf->stistools>=1.4.2->ullyses>=4.1.0->hasp) (3.1.5)
Requirement already satisfied: et-xmlfile in /home/runner/micromamba/envs/ci-env/lib/python3.11/site-packages (from openpyxl>=3.0.9->pysiaf->stistools>=1.4.2->ullyses>=4.1.0->hasp) (2.0.0)

3. Running the Co-add Script#

3.1 Retrieving the Data#

The program operates on the following COS and STIS files:

  • X1D - the one-dimensional extracted product spectra.

  • SX1 - the one-dimensional extracted spectra from combined or cosmic-ray rejected images. This file is produced only for STIS data.

Make sure that all of these files, for every spectrum that you wish to combine, are in the same directory. The script will combine only the files in this directory.

3.2 Running the Script#

Now that you have retrieved your data, you can run the co-add script. HASP (which does not combine data from multiple programs) and HSLA (which does) run the same script. The difference is that HSLA calls the program with the -x argument, thus instructing the code to perform cross-program co-adds.

Command-line Option

Value

--input_directory (-i)

The path to the directory that contains the data to be co-added (required)

--output_directory (-o)

The path to the directory that will contain the newly co-added products (required)

--clobber (-o)

If set, overwrite existing products

--cross_program (-x)

Create cross-program (HSLA) coadds (optional)

--threshold (-t)

The threshold for flux-based filtering (optional; default is -50)

--snrmax (-s)

The maximum SNR for flux-based filtering (optional; default is 20)

--grating_table (-g)

Name of custom grating priority table (optional)

--no_keyword_filtering (-k)

Disable keyword-based filtering (except for STIS PRISM data, which is always filtered) (optional)

Note: If you wish to exclude any data files from the co-add, simply remove them from the input directory before running the script.

To run the HASP version of the code, open your terminal, activate your micromamba environment, and enter:

swrapper -i <YOUR_DATA_DIR> -o <YOUR_PRODUCT_DIR>

The co-added spectra will be deposited in the output directory.

3.3 Understanding the HASP Output Files#

The HSLA script produces four sets of files for each target. First are the co-added spectra for each grating and visit:

hst_programID_instrument_targetname_grating_obset_cspec.fits, where obset is a six-digit string like O4A520

Second are the co-added spectra for each grating in the program:

hst_programID_instrument_targetname_grating_obset_cspec.fits, where obset is a four-digit string like O4A5

Third are the abutted spectra from multiple gratings for each visit:

hst_programID_instrument_targetname_allGratings_obset_cspec.fits

Fourth are the abutted spectra from multiple gratings for the entire program:

hst_programID_instrument_targetname_allGratings_cspec.fits

Here’s an example. These are the output files for a STIS GD71 dataset that is co-added in the HASP Coadd Tutorial notebook. Here, the programID is 7656, the instrument is STIS, and the targetname is gd71.

Set

Filename

Description

1

hst_7656_stis_gd71_sg140l_o4a520_cspec.fits

Co-adding all G140L observations for visit O4A520

2

hst_7656_stis_gd71_sg140l_o4a5_cspec.fits

Co-adding all G140L spectra for program 04A5

3

hst_7656_stis_gd71_sg140l-sg230l-g430l-g750l_o4a520_cspec.fits

Abutting multiple gratings for visit O4A520

4

hst_7656_stis_gd71_sg140l-sg230l-g430l-g750l_o4a5_cspec.fits

Abutting multiple gratings for all visits in program O4A5

HST file naming conventions use a combination of three letters and numbers to create a unique association between a PI’s proposal ID and program ID, meaning that o4a5 is essentially the program ID for our example. More information is available on the MAST HST file naming convention page.

For an overview of the output files from the HSLA version of the code, please see the notebook, Introduction to the HSLA Data Products and Tools.

About this Notebook#

Authors: Sierra Gomez (sigomez@stsci.edu) and Van Dixon (dixon@stsci.edu)

Updated on: 10/27/2025

This tutorial was generated to be in compliance with the STScI style guides. We would like to cite the Jupyter guide in particular.

Space Telescope Logo