
Installing the Hubble Advanced Spectral Products Script#
This Notebook is designed to walk you through downloading, installing, and using the Hubble Advanced Spectral Products (HASP) co-add script.#
Learning Goals:#
By the end of this tutorial, you will:
Download
condaand create acondaenvironmentDownload and install the 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 conda
- 1.1 Installing conda
- 1.2 Creating a conda Environment
2. Downloading and Installing the HASP Script
- 3.1 Running the Script
0. Introduction#
The Hubble Advanced Spectral Products (HASP) code is a script that co-adds spectra of the same target within programs. This software is able to co-add data taken with the spectrographs onboard the Hubble Space Telescope (HST); the Space Telescope Imaging Spectrograph (STIS) and the Cosmic Origins Spectrograph (COS). The Hubble Spectroscopic Legacy Archive (HSLA) uses this script to co-add these instruments’ data from the MAST archive to create high-quality spectra with a broad wavelength coverate (whenever possible from the ultraviolet to the near-infrared) that is publicly available for the scientific community. These custom co-addition notebooks will instruct users on how to produce their own co-adds in cases where the MAST archive data needs special processing or is rejected by the default filters used in the co-add script.
The script first co-adds the observations for each grating for a given program, then it combines all gratings for the observation set. Finally, it co-adds the spectra of each observation set in the program to produce a fully co-added spectra for each target in a program.
This notebook focuses primarily on the installation of the co-add code, and provides a quick overview on its usage. To see an example of downloading COS and STIS datasets, running the script, and analyzing the output, please check out our notebook CoaddTutorial.ipynb.
1. Downloading and Installing conda#
1.1 Installing conda#
Conda is a package, dependency, and environment manager that runs on Windows, Mac, and Linux. Conda allows us to easily install Python packages and create isolated conda environments, each with their own packages and dependencies. By switching between conda environments, we avoid conflicts between different versions of packages.
We will create a conda environment to install the packages needed for the HASP script. We can first check if you have conda already installed by running the command in the terminal:
!conda --version
conda 25.9.1
Running the command should print out the version of conda that you have installed (e.g. conda 23.7.2). If the command returns a statement saying that the package is unknown, then you do not have conda installed on your machine. You will need to download one of the conda distributions.
There are a few different distributions of conda that you can install, depending on your preferences. Anaconda is one distribution that carries a lot of pre-installed packages, some of which you won’t use. Miniconda is another distribution of conda that contains only the minimum packages. Finally, the Mamba disctribution of conda is similar to Miniconda, but uses different parallelization and cache algorithms to increase speed and optimize memory.
Once you have installed one of these clients, try running the above cell again to confirm that conda is installed.
1.2 Creating a Conda Environment#
Once you’ve installed conda, we can create a conda environment. We will download all of the packages needed to run the HASP script in a new environment that we will create, called hasp-env. We will use this environment for all of the tutorial notebooks.
The first step is to add the conda-forge channel to the list of avaible conda channels. Channels are where conda packages are stored and downloaded from, and conda-forge allows us to download additional packages for the code that the default conda channel may not have available. We can add this channel by running the following command in the terminal:
!conda config --add channels conda-forge
Warning: 'conda-forge' already in 'channels' list, moving to the top
We can now create the conda environment, hasp-env. Note that this can take several minutes to run:
!yes | conda create --name hasp-env python=3.11 notebook jupyterlab numpy astropy astroquery matplotlib
CI detected...
2 channel Terms of Service accepted
WARNING: A conda environment already exists at '/usr/share/miniconda/envs/hasp-env'
Remove existing environment?
This will remove ALL directories contained within this specified prefix directory, including any other conda environments.
(y/[n])?
Channels:
- conda-forge
- defaults
Platform: linux-64
Collecting package metadata (repodata.json): -
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
done
Solving environment: -
\
|
/
-
\
done
## Package Plan ##
environment location: /usr/share/miniconda/envs/hasp-env
added / updated specs:
- astropy
- astroquery
- jupyterlab
- matplotlib
- notebook
- numpy
- python=3.11
The following NEW packages will be INSTALLED:
_libgcc_mutex conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-2_gnu
aiobotocore conda-forge/noarch::aiobotocore-2.25.2-pyhcf101f3_0
aiohappyeyeballs conda-forge/noarch::aiohappyeyeballs-2.6.1-pyhd8ed1ab_0
aiohttp conda-forge/linux-64::aiohttp-3.13.2-py311h0281608_0
aioitertools conda-forge/noarch::aioitertools-0.12.0-pyhd8ed1ab_1
aiosignal conda-forge/noarch::aiosignal-1.4.0-pyhd8ed1ab_0
alsa-lib conda-forge/linux-64::alsa-lib-1.2.14-hb9d3cd8_0
anyio conda-forge/noarch::anyio-4.11.0-pyhcf101f3_0
argon2-cffi conda-forge/noarch::argon2-cffi-25.1.0-pyhd8ed1ab_0
argon2-cffi-bindi~ conda-forge/linux-64::argon2-cffi-bindings-25.1.0-py311h49ec1c0_2
arrow conda-forge/noarch::arrow-1.4.0-pyhcf101f3_0
astropy conda-forge/noarch::astropy-7.1.1-pyhd8ed1ab_0
astropy-base conda-forge/linux-64::astropy-base-7.1.1-py311h52c8da0_0
astropy-iers-data conda-forge/noarch::astropy-iers-data-0.2025.11.10.0.38.31-pyhd8ed1ab_0
astroquery conda-forge/noarch::astroquery-0.4.11-pyhd8ed1ab_0
asttokens conda-forge/noarch::asttokens-3.0.1-pyhd8ed1ab_0
async-lru conda-forge/noarch::async-lru-2.0.5-pyh29332c3_0
attrs conda-forge/noarch::attrs-25.4.0-pyh71513ae_0
aws-c-auth conda-forge/linux-64::aws-c-auth-0.9.1-h7ca4310_7
aws-c-cal conda-forge/linux-64::aws-c-cal-0.9.10-h346e085_1
aws-c-common conda-forge/linux-64::aws-c-common-0.12.5-hb03c661_1
aws-c-compression conda-forge/linux-64::aws-c-compression-0.3.1-h7e655bb_8
aws-c-event-stream conda-forge/linux-64::aws-c-event-stream-0.5.6-h3cb25bf_6
aws-c-http conda-forge/linux-64::aws-c-http-0.10.7-hc5c8343_4
aws-c-io conda-forge/linux-64::aws-c-io-0.23.3-ha76f1cc_3
aws-c-mqtt conda-forge/linux-64::aws-c-mqtt-0.13.3-h3a25ec9_10
aws-c-s3 conda-forge/linux-64::aws-c-s3-0.10.1-hcb69869_2
aws-c-sdkutils conda-forge/linux-64::aws-c-sdkutils-0.2.4-h7e655bb_3
aws-checksums conda-forge/linux-64::aws-checksums-0.2.7-h7e655bb_4
aws-crt-cpp conda-forge/linux-64::aws-crt-cpp-0.35.2-h2ceb62e_4
aws-sdk-cpp conda-forge/linux-64::aws-sdk-cpp-1.11.606-hd6e39bc_7
azure-core-cpp conda-forge/linux-64::azure-core-cpp-1.16.1-h3a458e0_0
azure-identity-cpp conda-forge/linux-64::azure-identity-cpp-1.13.2-h3a5f585_1
azure-storage-blo~ conda-forge/linux-64::azure-storage-blobs-cpp-12.15.0-h2a74896_1
azure-storage-com~ conda-forge/linux-64::azure-storage-common-cpp-12.11.0-h3d7a050_1
azure-storage-fil~ conda-forge/linux-64::azure-storage-files-datalake-cpp-12.13.0-hf38f1be_1
babel conda-forge/noarch::babel-2.17.0-pyhd8ed1ab_0
backports conda-forge/noarch::backports-1.0-pyhd8ed1ab_5
backports.tarfile conda-forge/noarch::backports.tarfile-1.2.0-pyhd8ed1ab_1
beautifulsoup4 conda-forge/noarch::beautifulsoup4-4.14.2-pyha770c72_0
bleach conda-forge/noarch::bleach-6.2.0-pyh29332c3_4
bleach-with-css conda-forge/noarch::bleach-with-css-6.2.0-h82add2a_4
botocore conda-forge/noarch::botocore-1.40.70-pyhd8ed1ab_0
bottleneck conda-forge/linux-64::bottleneck-1.6.0-np2py311h50facf7_3
bqplot conda-forge/noarch::bqplot-0.12.45-pyhe01879c_0
brotli conda-forge/linux-64::brotli-1.2.0-h41a2e66_0
brotli-bin conda-forge/linux-64::brotli-bin-1.2.0-hf2c8021_0
brotli-python conda-forge/linux-64::brotli-python-1.2.0-py311h7c6b74e_0
bzip2 conda-forge/linux-64::bzip2-1.0.8-hda65f42_8
c-ares conda-forge/linux-64::c-ares-1.34.5-hb9d3cd8_0
ca-certificates conda-forge/noarch::ca-certificates-2025.11.12-hbd8a1cb_0
cached-property conda-forge/noarch::cached-property-1.5.2-hd8ed1ab_1
cached_property conda-forge/noarch::cached_property-1.5.2-pyha770c72_1
cairo conda-forge/linux-64::cairo-1.18.4-h3394656_0
certifi conda-forge/noarch::certifi-2025.11.12-pyhd8ed1ab_0
cffi conda-forge/linux-64::cffi-2.0.0-py311h03d9500_1
charset-normalizer conda-forge/noarch::charset-normalizer-3.4.4-pyhd8ed1ab_0
click conda-forge/noarch::click-8.3.1-pyh707e725_0
cloudpickle conda-forge/noarch::cloudpickle-3.1.2-pyhd8ed1ab_0
comm conda-forge/noarch::comm-0.2.3-pyhe01879c_0
contourpy conda-forge/linux-64::contourpy-1.3.3-py311hdf67eae_3
cryptography conda-forge/linux-64::cryptography-46.0.3-py311h8488d03_0
cycler conda-forge/noarch::cycler-0.12.1-pyhd8ed1ab_1
cyrus-sasl conda-forge/linux-64::cyrus-sasl-2.1.28-hd9c7081_0
dask-core conda-forge/noarch::dask-core-2025.11.0-pyhcf101f3_0
dbus conda-forge/linux-64::dbus-1.16.2-h3c4dab8_0
debugpy conda-forge/linux-64::debugpy-1.8.17-py311hc665b79_0
decorator conda-forge/noarch::decorator-5.2.1-pyhd8ed1ab_0
defusedxml conda-forge/noarch::defusedxml-0.7.1-pyhd8ed1ab_0
double-conversion conda-forge/linux-64::double-conversion-3.3.1-h5888daf_0
exceptiongroup conda-forge/noarch::exceptiongroup-1.3.0-pyhd8ed1ab_0
executing conda-forge/noarch::executing-2.2.1-pyhd8ed1ab_0
font-ttf-dejavu-s~ conda-forge/noarch::font-ttf-dejavu-sans-mono-2.37-hab24e00_0
font-ttf-inconsol~ conda-forge/noarch::font-ttf-inconsolata-3.000-h77eed37_0
font-ttf-source-c~ conda-forge/noarch::font-ttf-source-code-pro-2.038-h77eed37_0
font-ttf-ubuntu conda-forge/noarch::font-ttf-ubuntu-0.83-h77eed37_3
fontconfig conda-forge/linux-64::fontconfig-2.15.0-h7e30c49_1
fonts-conda-ecosy~ conda-forge/noarch::fonts-conda-ecosystem-1-0
fonts-conda-forge conda-forge/noarch::fonts-conda-forge-1-hc364b38_1
fonttools conda-forge/linux-64::fonttools-4.60.1-py311h3778330_0
fqdn conda-forge/noarch::fqdn-1.5.1-pyhd8ed1ab_1
freetype conda-forge/linux-64::freetype-2.14.1-ha770c72_0
frozenlist conda-forge/linux-64::frozenlist-1.7.0-py311h52bc045_0
fsspec conda-forge/noarch::fsspec-2025.10.0-pyhd8ed1ab_0
gast conda-forge/noarch::gast-0.4.0-pyh9f0ad1d_0
gflags conda-forge/linux-64::gflags-2.2.2-h5888daf_1005
glog conda-forge/linux-64::glog-0.7.1-hbabe93e_0
graphite2 conda-forge/linux-64::graphite2-1.3.14-hecca717_2
h11 conda-forge/noarch::h11-0.16.0-pyhd8ed1ab_0
h2 conda-forge/noarch::h2-4.3.0-pyhcf101f3_0
h5py conda-forge/linux-64::h5py-3.15.1-nompi_py311h0b2f468_100
harfbuzz conda-forge/linux-64::harfbuzz-12.2.0-h15599e2_0
hdf5 conda-forge/linux-64::hdf5-1.14.6-nompi_h6e4c0c1_103
hpack conda-forge/noarch::hpack-4.1.0-pyhd8ed1ab_0
html5lib conda-forge/noarch::html5lib-1.1-pyhd8ed1ab_2
httpcore conda-forge/noarch::httpcore-1.0.9-pyh29332c3_0
httpx conda-forge/noarch::httpx-0.28.1-pyhd8ed1ab_0
hyperframe conda-forge/noarch::hyperframe-6.1.0-pyhd8ed1ab_0
icu conda-forge/linux-64::icu-75.1-he02047a_0
idna conda-forge/noarch::idna-3.11-pyhd8ed1ab_0
importlib-metadata conda-forge/noarch::importlib-metadata-8.7.0-pyhe01879c_1
importlib_resourc~ conda-forge/noarch::importlib_resources-6.5.2-pyhd8ed1ab_0
ipydatagrid conda-forge/noarch::ipydatagrid-1.4.0-pyhcf101f3_2
ipykernel conda-forge/noarch::ipykernel-7.1.0-pyha191276_0
ipython conda-forge/noarch::ipython-9.7.0-pyh53cf698_0
ipython_pygments_~ conda-forge/noarch::ipython_pygments_lexers-1.1.1-pyhd8ed1ab_0
ipywidgets conda-forge/noarch::ipywidgets-8.1.8-pyhd8ed1ab_0
isoduration conda-forge/noarch::isoduration-20.11.0-pyhd8ed1ab_1
jaraco.classes conda-forge/noarch::jaraco.classes-3.4.0-pyhd8ed1ab_2
jaraco.context conda-forge/noarch::jaraco.context-6.0.1-pyhd8ed1ab_0
jaraco.functools conda-forge/noarch::jaraco.functools-4.3.0-pyhd8ed1ab_0
jedi conda-forge/noarch::jedi-0.19.2-pyhd8ed1ab_1
jeepney conda-forge/noarch::jeepney-0.9.0-pyhd8ed1ab_0
jinja2 conda-forge/noarch::jinja2-3.1.6-pyhd8ed1ab_0
jmespath conda-forge/noarch::jmespath-1.0.1-pyhd8ed1ab_1
jplephem conda-forge/noarch::jplephem-2.23-pyha4b2019_0
json5 conda-forge/noarch::json5-0.12.1-pyhd8ed1ab_0
jsonpointer conda-forge/linux-64::jsonpointer-3.0.0-py311h38be061_2
jsonschema conda-forge/noarch::jsonschema-4.25.1-pyhe01879c_0
jsonschema-specif~ conda-forge/noarch::jsonschema-specifications-2025.9.1-pyhcf101f3_0
jsonschema-with-f~ conda-forge/noarch::jsonschema-with-format-nongpl-4.25.1-he01879c_0
jupyter-lsp conda-forge/noarch::jupyter-lsp-2.3.0-pyhcf101f3_0
jupyter_client conda-forge/noarch::jupyter_client-8.6.3-pyhd8ed1ab_1
jupyter_core conda-forge/noarch::jupyter_core-5.9.1-pyhc90fa1f_0
jupyter_events conda-forge/noarch::jupyter_events-0.12.0-pyh29332c3_0
jupyter_server conda-forge/noarch::jupyter_server-2.17.0-pyhcf101f3_0
jupyter_server_te~ conda-forge/noarch::jupyter_server_terminals-0.5.3-pyhd8ed1ab_1
jupyterlab conda-forge/noarch::jupyterlab-4.5.0-pyhd8ed1ab_0
jupyterlab_pygmen~ conda-forge/noarch::jupyterlab_pygments-0.3.0-pyhd8ed1ab_2
jupyterlab_server conda-forge/noarch::jupyterlab_server-2.28.0-pyhcf101f3_0
jupyterlab_widgets conda-forge/noarch::jupyterlab_widgets-3.0.16-pyhcf101f3_1
keyring conda-forge/noarch::keyring-25.7.0-pyha804496_0
keyutils conda-forge/linux-64::keyutils-1.6.3-hb9d3cd8_0
kiwisolver conda-forge/linux-64::kiwisolver-1.4.9-py311h724c32c_2
krb5 conda-forge/linux-64::krb5-1.21.3-h659f571_0
lark conda-forge/noarch::lark-1.3.1-pyhd8ed1ab_0
lcms2 conda-forge/linux-64::lcms2-2.17-h717163a_0
ld_impl_linux-64 conda-forge/linux-64::ld_impl_linux-64-2.45-h1aa0949_0
lerc conda-forge/linux-64::lerc-4.0.0-h0aef613_1
libabseil conda-forge/linux-64::libabseil-20250512.1-cxx17_hba17884_0
libaec conda-forge/linux-64::libaec-1.1.4-h3f801dc_0
libarrow conda-forge/linux-64::libarrow-22.0.0-h773bc41_4_cpu
libarrow-acero conda-forge/linux-64::libarrow-acero-22.0.0-h635bf11_4_cpu
libarrow-compute conda-forge/linux-64::libarrow-compute-22.0.0-h8c2c5c3_4_cpu
libarrow-dataset conda-forge/linux-64::libarrow-dataset-22.0.0-h635bf11_4_cpu
libarrow-substrait conda-forge/linux-64::libarrow-substrait-22.0.0-h3f74fd7_4_cpu
libblas conda-forge/linux-64::libblas-3.11.0-1_h4a7cf45_openblas
libbrotlicommon conda-forge/linux-64::libbrotlicommon-1.2.0-h09219d5_0
libbrotlidec conda-forge/linux-64::libbrotlidec-1.2.0-hd53d788_0
libbrotlienc conda-forge/linux-64::libbrotlienc-1.2.0-h02bd7ab_0
libcblas conda-forge/linux-64::libcblas-3.11.0-1_h0358290_openblas
libclang-cpp21.1 conda-forge/linux-64::libclang-cpp21.1-21.1.6-default_h99862b1_0
libclang13 conda-forge/linux-64::libclang13-21.1.6-default_h746c552_0
libcrc32c conda-forge/linux-64::libcrc32c-1.1.2-h9c3ff4c_0
libcups conda-forge/linux-64::libcups-2.3.3-hb8b1518_5
libcurl conda-forge/linux-64::libcurl-8.17.0-h4e3cde8_0
libdeflate conda-forge/linux-64::libdeflate-1.25-h17f619e_0
libdrm conda-forge/linux-64::libdrm-2.4.125-hb03c661_1
libedit conda-forge/linux-64::libedit-3.1.20250104-pl5321h7949ede_0
libegl conda-forge/linux-64::libegl-1.7.0-ha4b6fd6_2
libev conda-forge/linux-64::libev-4.33-hd590300_2
libevent conda-forge/linux-64::libevent-2.1.12-hf998b51_1
libexpat conda-forge/linux-64::libexpat-2.7.3-hecca717_0
libffi conda-forge/linux-64::libffi-3.5.2-h9ec8514_0
libfreetype conda-forge/linux-64::libfreetype-2.14.1-ha770c72_0
libfreetype6 conda-forge/linux-64::libfreetype6-2.14.1-h73754d4_0
libgcc conda-forge/linux-64::libgcc-15.2.0-h767d61c_7
libgcc-ng conda-forge/linux-64::libgcc-ng-15.2.0-h69a702a_7
libgfortran conda-forge/linux-64::libgfortran-15.2.0-h69a702a_7
libgfortran5 conda-forge/linux-64::libgfortran5-15.2.0-hcd61629_7
libgl conda-forge/linux-64::libgl-1.7.0-ha4b6fd6_2
libglib conda-forge/linux-64::libglib-2.86.1-h32235b2_2
libglvnd conda-forge/linux-64::libglvnd-1.7.0-ha4b6fd6_2
libglx conda-forge/linux-64::libglx-1.7.0-ha4b6fd6_2
libgomp conda-forge/linux-64::libgomp-15.2.0-h767d61c_7
libgoogle-cloud conda-forge/linux-64::libgoogle-cloud-2.39.0-hdb79228_0
libgoogle-cloud-s~ conda-forge/linux-64::libgoogle-cloud-storage-2.39.0-hdbdcf42_0
libgrpc conda-forge/linux-64::libgrpc-1.73.1-h3288cfb_1
libiconv conda-forge/linux-64::libiconv-1.18-h3b78370_2
libjpeg-turbo conda-forge/linux-64::libjpeg-turbo-3.1.2-hb03c661_0
liblapack conda-forge/linux-64::liblapack-3.11.0-1_h47877c9_openblas
libllvm21 conda-forge/linux-64::libllvm21-21.1.6-hf7376ad_0
liblzma conda-forge/linux-64::liblzma-5.8.1-hb9d3cd8_2
libnghttp2 conda-forge/linux-64::libnghttp2-1.67.0-had1ee68_0
libnsl conda-forge/linux-64::libnsl-2.0.1-hb9d3cd8_1
libntlm conda-forge/linux-64::libntlm-1.8-hb9d3cd8_0
libopenblas conda-forge/linux-64::libopenblas-0.3.30-pthreads_h94d23a6_4
libopengl conda-forge/linux-64::libopengl-1.7.0-ha4b6fd6_2
libopentelemetry-~ conda-forge/linux-64::libopentelemetry-cpp-1.21.0-hb9b0907_1
libopentelemetry-~ conda-forge/linux-64::libopentelemetry-cpp-headers-1.21.0-ha770c72_1
libparquet conda-forge/linux-64::libparquet-22.0.0-h7376487_4_cpu
libpciaccess conda-forge/linux-64::libpciaccess-0.18-hb9d3cd8_0
libpng conda-forge/linux-64::libpng-1.6.50-h421ea60_1
libpq conda-forge/linux-64::libpq-18.1-h5c52fec_1
libprotobuf conda-forge/linux-64::libprotobuf-6.31.1-h49aed37_2
libre2-11 conda-forge/linux-64::libre2-11-2025.11.05-h7b12aa8_0
libsodium conda-forge/linux-64::libsodium-1.0.20-h4ab18f5_0
libsqlite conda-forge/linux-64::libsqlite-3.51.0-hee844dc_0
libssh2 conda-forge/linux-64::libssh2-1.11.1-hcf80075_0
libstdcxx conda-forge/linux-64::libstdcxx-15.2.0-h8f9b012_7
libstdcxx-ng conda-forge/linux-64::libstdcxx-ng-15.2.0-h4852527_7
libthrift conda-forge/linux-64::libthrift-0.22.0-h454ac66_1
libtiff conda-forge/linux-64::libtiff-4.7.1-h9d88235_1
libutf8proc conda-forge/linux-64::libutf8proc-2.11.1-hfe17d71_0
libuuid conda-forge/linux-64::libuuid-2.41.2-he9a06e4_0
libvulkan-loader conda-forge/linux-64::libvulkan-loader-1.4.328.1-h5279c79_0
libwebp-base conda-forge/linux-64::libwebp-base-1.6.0-hd42ef1d_0
libxcb conda-forge/linux-64::libxcb-1.17.0-h8a09558_0
libxcrypt conda-forge/linux-64::libxcrypt-4.4.36-hd590300_1
libxkbcommon conda-forge/linux-64::libxkbcommon-1.13.0-hca5e8e5_0
libxml2 conda-forge/linux-64::libxml2-2.15.1-h26afc86_0
libxml2-16 conda-forge/linux-64::libxml2-16-2.15.1-ha9997c6_0
libxslt conda-forge/linux-64::libxslt-1.1.43-h711ed8c_1
libzlib conda-forge/linux-64::libzlib-1.3.1-hb9d3cd8_2
locket conda-forge/noarch::locket-1.0.0-pyhd8ed1ab_0
lz4-c conda-forge/linux-64::lz4-c-1.10.0-h5888daf_1
markupsafe conda-forge/linux-64::markupsafe-3.0.3-py311h3778330_0
matplotlib conda-forge/linux-64::matplotlib-3.10.8-py311h38be061_0
matplotlib-base conda-forge/linux-64::matplotlib-base-3.10.8-py311h0f3be63_0
matplotlib-inline conda-forge/noarch::matplotlib-inline-0.2.1-pyhd8ed1ab_0
mistune conda-forge/noarch::mistune-3.1.4-pyhcf101f3_0
more-itertools conda-forge/noarch::more-itertools-10.8.0-pyhd8ed1ab_0
mpmath conda-forge/noarch::mpmath-1.3.0-pyhd8ed1ab_1
multidict conda-forge/linux-64::multidict-6.6.3-py311h2dc5d0c_0
munkres conda-forge/noarch::munkres-1.1.4-pyhd8ed1ab_1
nbclient conda-forge/noarch::nbclient-0.10.2-pyhd8ed1ab_0
nbconvert-core conda-forge/noarch::nbconvert-core-7.16.6-pyhcf101f3_1
nbformat conda-forge/noarch::nbformat-5.10.4-pyhd8ed1ab_1
ncurses conda-forge/linux-64::ncurses-6.5-h2d0b736_3
nest-asyncio conda-forge/noarch::nest-asyncio-1.6.0-pyhd8ed1ab_1
nlohmann_json conda-forge/linux-64::nlohmann_json-3.12.0-h54a6638_1
notebook conda-forge/noarch::notebook-7.5.0-pyhcf101f3_0
notebook-shim conda-forge/noarch::notebook-shim-0.2.4-pyhd8ed1ab_1
numpy conda-forge/linux-64::numpy-2.3.5-py311h2e04523_0
openjpeg conda-forge/linux-64::openjpeg-2.5.4-h55fea9a_0
openldap conda-forge/linux-64::openldap-2.6.10-he970967_0
openssl conda-forge/linux-64::openssl-3.6.0-h26f9b46_0
orc conda-forge/linux-64::orc-2.2.1-hd747db4_0
overrides conda-forge/noarch::overrides-7.7.0-pyhd8ed1ab_1
packaging conda-forge/noarch::packaging-25.0-pyh29332c3_1
pandas conda-forge/linux-64::pandas-2.3.3-py311hed34c8f_1
pandocfilters conda-forge/noarch::pandocfilters-1.5.0-pyhd8ed1ab_0
parso conda-forge/noarch::parso-0.8.5-pyhcf101f3_0
partd conda-forge/noarch::partd-1.4.2-pyhd8ed1ab_0
pcre2 conda-forge/linux-64::pcre2-10.46-h1321c63_0
pexpect conda-forge/noarch::pexpect-4.9.0-pyhd8ed1ab_1
pillow conda-forge/linux-64::pillow-12.0.0-py311h07c5bb8_0
pip conda-forge/noarch::pip-25.3-pyh8b19718_0
pixman conda-forge/linux-64::pixman-0.46.4-h54a6638_1
platformdirs conda-forge/noarch::platformdirs-4.5.0-pyhcf101f3_0
prometheus-cpp conda-forge/linux-64::prometheus-cpp-1.3.0-ha5d0236_0
prometheus_client conda-forge/noarch::prometheus_client-0.23.1-pyhd8ed1ab_0
prompt-toolkit conda-forge/noarch::prompt-toolkit-3.0.52-pyha770c72_0
propcache conda-forge/linux-64::propcache-0.3.1-py311h2dc5d0c_0
psutil conda-forge/linux-64::psutil-7.1.3-py311haee01d2_0
pthread-stubs conda-forge/linux-64::pthread-stubs-0.4-hb9d3cd8_1002
ptyprocess conda-forge/noarch::ptyprocess-0.7.0-pyhd8ed1ab_1
pure_eval conda-forge/noarch::pure_eval-0.2.3-pyhd8ed1ab_1
py2vega conda-forge/noarch::py2vega-0.6.1-pyhd8ed1ab_0
pyarrow conda-forge/linux-64::pyarrow-22.0.0-py311h38be061_0
pyarrow-core conda-forge/linux-64::pyarrow-core-22.0.0-py311h342b5a4_0_cpu
pycparser conda-forge/noarch::pycparser-2.22-pyh29332c3_1
pyerfa conda-forge/linux-64::pyerfa-2.0.1.5-py310h32771cd_2
pygments conda-forge/noarch::pygments-2.19.2-pyhd8ed1ab_0
pyparsing conda-forge/noarch::pyparsing-3.2.5-pyhcf101f3_0
pyside6 conda-forge/linux-64::pyside6-6.9.3-py311he4c1a5a_1
pysocks conda-forge/noarch::pysocks-1.7.1-pyha55dd90_7
python conda-forge/linux-64::python-3.11.14-hd63d673_2_cpython
python-dateutil conda-forge/noarch::python-dateutil-2.9.0.post0-pyhe01879c_2
python-fastjsonsc~ conda-forge/noarch::python-fastjsonschema-2.21.2-pyhe01879c_0
python-json-logger conda-forge/noarch::python-json-logger-2.0.7-pyhd8ed1ab_0
python-tzdata conda-forge/noarch::python-tzdata-2025.2-pyhd8ed1ab_0
python_abi conda-forge/noarch::python_abi-3.11-8_cp311
pytz conda-forge/noarch::pytz-2025.2-pyhd8ed1ab_0
pyvo conda-forge/noarch::pyvo-1.8-pyhd8ed1ab_0
pyyaml conda-forge/linux-64::pyyaml-6.0.3-py311h3778330_0
pyzmq conda-forge/linux-64::pyzmq-27.1.0-py311h2315fbb_0
qhull conda-forge/linux-64::qhull-2020.2-h434a139_5
qt6-main conda-forge/linux-64::qt6-main-6.9.3-h5c1c036_1
re2 conda-forge/linux-64::re2-2025.11.05-h5301d42_0
readline conda-forge/linux-64::readline-8.2-h8c095d6_2
referencing conda-forge/noarch::referencing-0.37.0-pyhcf101f3_0
requests conda-forge/noarch::requests-2.32.5-pyhd8ed1ab_0
rfc3339-validator conda-forge/noarch::rfc3339-validator-0.1.4-pyhd8ed1ab_1
rfc3986-validator conda-forge/noarch::rfc3986-validator-0.1.1-pyh9f0ad1d_0
rfc3987-syntax conda-forge/noarch::rfc3987-syntax-1.1.0-pyhe01879c_1
rpds-py conda-forge/linux-64::rpds-py-0.29.0-py311h902ca64_0
s2n conda-forge/linux-64::s2n-1.6.0-h8399546_1
s3fs conda-forge/noarch::s3fs-2025.10.0-pyhd8ed1ab_0
scipy conda-forge/linux-64::scipy-1.16.3-py311h1e13796_1
secretstorage conda-forge/linux-64::secretstorage-3.4.1-py311h38be061_0
send2trash conda-forge/noarch::send2trash-1.8.3-pyh0d859eb_1
setuptools conda-forge/noarch::setuptools-80.9.0-pyhff2d567_0
six conda-forge/noarch::six-1.17.0-pyhe01879c_1
snappy conda-forge/linux-64::snappy-1.2.2-h03e3b7b_1
sniffio conda-forge/noarch::sniffio-1.3.1-pyhd8ed1ab_2
sortedcontainers conda-forge/noarch::sortedcontainers-2.4.0-pyhd8ed1ab_1
soupsieve conda-forge/noarch::soupsieve-2.8-pyhd8ed1ab_0
stack_data conda-forge/noarch::stack_data-0.6.3-pyhd8ed1ab_1
terminado conda-forge/noarch::terminado-0.18.1-pyh0d859eb_0
tinycss2 conda-forge/noarch::tinycss2-1.4.0-pyhd8ed1ab_0
tk conda-forge/linux-64::tk-8.6.13-noxft_ha0e22de_103
tomli conda-forge/noarch::tomli-2.3.0-pyhcf101f3_0
toolz conda-forge/noarch::toolz-1.1.0-pyhd8ed1ab_1
tornado conda-forge/linux-64::tornado-6.5.2-py311h49ec1c0_2
traitlets conda-forge/noarch::traitlets-5.14.3-pyhd8ed1ab_1
traittypes conda-forge/noarch::traittypes-0.2.3-pyh332efcf_0
typing-extensions conda-forge/noarch::typing-extensions-4.15.0-h396c80c_0
typing_extensions conda-forge/noarch::typing_extensions-4.15.0-pyhcf101f3_0
typing_utils conda-forge/noarch::typing_utils-0.1.0-pyhd8ed1ab_1
tzdata conda-forge/noarch::tzdata-2025b-h78e105d_0
uncompresspy conda-forge/noarch::uncompresspy-0.4.1-pyhd8ed1ab_0
unicodedata2 conda-forge/linux-64::unicodedata2-17.0.0-py311h49ec1c0_1
uri-template conda-forge/noarch::uri-template-1.3.0-pyhd8ed1ab_1
urllib3 conda-forge/noarch::urllib3-2.5.0-pyhd8ed1ab_0
wayland conda-forge/linux-64::wayland-1.24.0-hd6090a7_1
wcwidth conda-forge/noarch::wcwidth-0.2.14-pyhd8ed1ab_0
webcolors conda-forge/noarch::webcolors-25.10.0-pyhd8ed1ab_0
webencodings conda-forge/noarch::webencodings-0.5.1-pyhd8ed1ab_3
websocket-client conda-forge/noarch::websocket-client-1.9.0-pyhd8ed1ab_0
wheel conda-forge/noarch::wheel-0.45.1-pyhd8ed1ab_1
widgetsnbextension conda-forge/noarch::widgetsnbextension-4.0.15-pyhd8ed1ab_0
wrapt conda-forge/linux-64::wrapt-1.17.3-py311h49ec1c0_1
xcb-util conda-forge/linux-64::xcb-util-0.4.1-h4f16b4b_2
xcb-util-cursor conda-forge/linux-64::xcb-util-cursor-0.1.6-hb03c661_0
xcb-util-image conda-forge/linux-64::xcb-util-image-0.4.0-hb711507_2
xcb-util-keysyms conda-forge/linux-64::xcb-util-keysyms-0.4.1-hb711507_0
xcb-util-renderut~ conda-forge/linux-64::xcb-util-renderutil-0.3.10-hb711507_0
xcb-util-wm conda-forge/linux-64::xcb-util-wm-0.4.2-hb711507_0
xkeyboard-config conda-forge/linux-64::xkeyboard-config-2.46-hb03c661_0
xorg-libice conda-forge/linux-64::xorg-libice-1.1.2-hb9d3cd8_0
xorg-libsm conda-forge/linux-64::xorg-libsm-1.2.6-he73a12e_0
xorg-libx11 conda-forge/linux-64::xorg-libx11-1.8.12-h4f16b4b_0
xorg-libxau conda-forge/linux-64::xorg-libxau-1.0.12-hb03c661_1
xorg-libxcomposite conda-forge/linux-64::xorg-libxcomposite-0.4.6-hb9d3cd8_2
xorg-libxcursor conda-forge/linux-64::xorg-libxcursor-1.2.3-hb9d3cd8_0
xorg-libxdamage conda-forge/linux-64::xorg-libxdamage-1.1.6-hb9d3cd8_0
xorg-libxdmcp conda-forge/linux-64::xorg-libxdmcp-1.1.5-hb03c661_1
xorg-libxext conda-forge/linux-64::xorg-libxext-1.3.6-hb9d3cd8_0
xorg-libxfixes conda-forge/linux-64::xorg-libxfixes-6.0.2-hb03c661_0
xorg-libxi conda-forge/linux-64::xorg-libxi-1.8.2-hb9d3cd8_0
xorg-libxrandr conda-forge/linux-64::xorg-libxrandr-1.5.4-hb9d3cd8_0
xorg-libxrender conda-forge/linux-64::xorg-libxrender-0.9.12-hb9d3cd8_0
xorg-libxtst conda-forge/linux-64::xorg-libxtst-1.2.5-hb9d3cd8_3
xorg-libxxf86vm conda-forge/linux-64::xorg-libxxf86vm-1.1.6-hb9d3cd8_0
yaml conda-forge/linux-64::yaml-0.2.5-h280c20c_3
yarl conda-forge/linux-64::yarl-1.22.0-py311h3778330_0
zeromq conda-forge/linux-64::zeromq-4.3.5-h387f397_9
zipp conda-forge/noarch::zipp-3.23.0-pyhd8ed1ab_0
zlib conda-forge/linux-64::zlib-1.3.1-hb9d3cd8_2
zlib-ng conda-forge/linux-64::zlib-ng-2.2.5-hde8ca8f_0
zstandard conda-forge/linux-64::zstandard-0.25.0-py311haee01d2_1
zstd conda-forge/linux-64::zstd-1.5.7-hb8e6e7a_2
Proceed ([y]/n)?
Downloading and Extracting Packages:
Preparing transaction: /
-
\
|
/
-
\
|
/
-
done
Verifying transaction: |
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
done
Executing transaction: |
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
-
\
|
/
done
#
# To activate this environment, use
#
# $ conda activate hasp-env
#
# To deactivate an active environment, use
#
# $ conda deactivate
yes: standard output: Broken pipe
We also downloaded some additional packages that we will need outside of the HASP script to analyze the data. Once we activate the conda environment, as seen below, we can download the HASP script and run it. Note that you should run this in a terminal rather than in the cell below. Depending on your shell and operating system settings, you may need to restart your Jupyter notebook application in order for your environment to be fully activated in your notebook.
!conda activate hasp-env
CondaError: Run 'conda init' before 'conda activate'
Now that we created and activated a conda environment, we can now begin to download the HASP code.
2. Downloading and Installing the HASP Script#
We will download the HASP wrapper script from the HASP Github repository. Downloading this script will create a hasp directory, which will contain all of the required code.
You will only have to run one of the two options below, depending on your computer and Git settings.
Option A, using pip:#
pip install clones the reposoitory and install 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
Option B, using git clone:#
While git clone still 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
After you’ve downloaded the code using Options A or B, run the command below in your terminal to download the script’s dependencies:#
pip install ./hasp
This will install additional dependencies using the pyproject.toml file.
To run the wrapper, We only need to download the following COS and/or 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 only produced with STIS data.
Make sure that all of these files, for every spectra you wish to abut, are in the same directory. The script will only co-add the files within this directory.
3. Running the Co-add Script#
3.1 Running the Script#
Now that we have the wrapper installed, we can now run the co-add script.
Command-line Option |
Value |
|---|---|
|
The path to the directory that contains the data to be co-added (required) |
|
The path to the directory that will contain the newly co-added products** (required) |
|
The threshold for flux-based filtering (optional) |
|
The maximum SNR for flux-based filtering (optional) |
|
Disable keyword based filtering (except for STIS PRISM data, which is always filtered) (optional) |
**Note: If you wish to exclude certain data files from the co-add, you can just remove them from your input directory before you run the script.
To finally run the script, open your terminal, activate your conda environment, and run:
swrapper -i <YOUR_DATA_DIR> -o <YOUR_PRODUCT_DIR>
You should now have created the co-added spectra for your desired program.
3.2 Understanding the Output Files#
The script produces multiple different files with abutted spectra. Currently, the script outputs abutted products for a single program. It first creates co-added spectra for each grating of a single observation set:
hst_programID_instrument_targetname_grating_obset_cspec.fits
It then co-adds the spectra of all gratings for a single observation set:
hst_programID_instrument_targetname_allGratings_obset_cspec.fits
Finally, it co-adds all abutted observation sets’ spectra to create a final co-added product for a single target:
hst_programID_instrument_targetname_allGratings_cspec.fits
An example of this will be below. These filenames are the output files for a STIS GD71 dataset that is co-added in the CoaddTutorial.ipynb notebook example. Here, the programID is 7656, the instrument is STIS, and the targetname is gd71.
Step |
Filename |
Description |
|---|---|---|
1 |
|
Co-adding all |
2 |
|
Co-adding all observations taken at every grating for the observation set, |
3 |
|
Co-adding all GD71 observations at each grating for this program, |
Note: HST file naming conventions use a combination of three letters and/or numbers to have a unique association between a PI’s proposal ID and program ID, meaning that o4a5 at the end of hst_7656_stis_gd71_g140l-g230l-g430l-g750l_o4a5_cspec.fits is essentially the program ID for our example. Check out more information on the MAST HST file naming convention page
About this Notebook#
Author: Sierra Gomez (sigomez@stsci.edu)
Updated on: 12/04/2023
This tutorial was generated to be in compliance with the STScI style guides and would like to cite the Jupyter guide in particular.