Calculating the Hubble Constant with eBOSS#
Learning Goals#
By the end of this tutorial, you will:
Understand how to use
astroquery.mast
to download SDSS eBOSS and HST data from the MAST archive.Plot a sample of galaxies from eBOSS with a line of best fit to determine Hubble’s constant.
Create a color image of Abell 2199 from HST data.
Table of Contents#
Introduction
Imports
Accessing eBOSS Data from MAST
Querying eBOSS Data
Sampling eBOSS for Redshifted Galaxies
Downloading Products from eBOSS
Making the Hubble-Lemaître Diagram
Plotting eBOSS Data
Importing Abell 2199 Data
Comparing Calculated H0 to Other Models
Utilizing HST Data from Mast
Creating an Image of Abell 2199 Using HST
Plotting the HST Images
Colorizing the HST Image
End of Tutorial
Additional Resources
Citations
About this Notebook
Introduction#
The Hubble-Lemaître law is one of the most prominent topics of debate in modern cosmology. In 1927, Georges Lemaître published a paper in a Belgian journal proposing that the Universe was expanding, using data from Vesto Slipher at Lowell Observatory. Around the same time, Edwin Hubble was independently studying the relationship between galaxy distances and their radial velocities at Mount Wilson Observatory. Although Hubble was originally credited with the discovery, in 2018 the International Astronomical Union officially renamed “Hubble’s Law” to the “Hubble–Lemaître Law” to acknowledge Lemaître’s earlier contribution [1].
The Big Bang occurred approximately 14 billion years ago, leading to the expansion of the Universe. We can estimate the speed of this expansion by examining the redshifts of a sample of galaxies. These redshifts can be translated into radial velocities, and then using observed spectral flux, we can the determine the distances to these galaxies. By plotting radial velocities versus distances, we can apply a linear fit model to the data. This allows us to approximate the Hubble constant from the slope as described by Hubble’s Law [2]:
There are various models used to calculate H0, some based on observations of the Cosmic Microwave Background (CMB), and others on measurements of galaxies or supernovae. These models typically yield varying values of H0 ranging from approximately 67 km/s/Mpc to 74 km/s/Mpc. This discrepancy is known as the Hubble Tension [3].
In this notebook, we’ll construct a Hubble-Lemaître Diagram using data from the Sloan Digital Sky Survey’s (SDSS) Extended Baryon Oscillation Spectroscopic Survey (eBOSS). eBOSS gathered over 4 million spectra from stars, quasars, and galaxies. We’ll focus on a subset of galaxies, using their redshifts and spectral data to plot radial velocity against distance. By applying a linear fit to this relationship, we can estimate Hubble’s constant from the slope of the resulting line.
Imports#
The main packages and their use-cases in this tutorial are as follows:
numpy to handle array functions
matplotlib.pyplot for plotting data
astroquery.mast.Observations to access data from MAST
astropy.io.fits for accessing FITS files
astropy.table.vstack for vertically stacking tables
scipy.optimize.curve_fit for creating a linear fit
astropy.visualization.make_luptopn_rgb for creating an RGB image
astropy.wcs.WCS for world coordinate system transformations
reproject for stacking FITS images
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from astroquery.mast import Observations
import astropy.io.fits as fits
from astropy.table import vstack
from scipy.optimize import curve_fit
from astropy.visualization import make_lupton_rgb
from astropy.wcs import WCS
import reproject
If you’re not sure if you have the required versions of packages installed on your device, you can run the following cell:
with open("requirements.txt") as f:
print(f"Required packages for this notebook:\n{f.read()}")
Required packages for this notebook:
astropy >= 5.3
astroquery >= 0.4.9
matplotlib >= 3.9.1
numpy >= 1.26.4
scipy >= 1.15.3
reproject >= 0.14.0
To ensure these requirements are installed, you can run the following command in the terminal:
pip install -r requirements.txt
Accessing eBOSS Data from MAST#
The Mikulski Archive for Space Telescopes (MAST) hosts a large array of data from several telescope missions. In this tutorial, we will be specifically focusing on data from the Sloan Digital Sky Survey (SDSS) and the Hubble Space Telescope (HST).
The Extended Baryon Oscillation Spectroscopic Survey (eBOSS) was completed using the SDSS-2.5m telescope and BOSS spectrograph at the Apache Point Observatory in New Mexico. Using plug plates and a 1000 fiber-fed spectrograph, eBOSS was able to collect spectra from over 4 million objects including quasars, galaxies, and stars in the northern hemisphere.
Querying eBOSS Data#
You can query data from MAST using the website portal. You can also query MAST data in Python using the package astroquery.mast
!
We can query all of the eBOSS data using Observations.query_criteria
with provenance_name = 'eBOSS'
and obs_collection = 'SDSS'
. Since eBOSS has a large amount of data, we can display the first 10 results using the pagesize
parameter as well as the page
parameter.
We can also limit the number of observations by date. Using the t_min=[58118, 60675]
parameter (the modified Julian date of the exposure), we can filter data that has a modified Julian date from 58118 to 60676 (years 2018-2024).
This might take a few minutes depending on your internet connection.
eboss_data = Observations.query_criteria(
obs_collection="SDSS",
provenance_name="eBOSS",
t_min=[58118, 60675],
pagesize=5,
page=1,
)
# Show the astropy table
eboss_data
intentType | obs_collection | provenance_name | instrument_name | project | filters | wavelength_region | target_name | target_classification | obs_id | s_ra | s_dec | dataproduct_type | proposal_pi | calib_level | t_min | t_max | t_exptime | em_min | em_max | obs_title | t_obs_release | proposal_id | proposal_type | sequence_number | s_region | jpegURL | dataURL | dataRights | mtFlag | srcDen | obsid | objID |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str7 | str4 | str5 | str4 | str4 | str4 | str7 | str21 | str6 | str27 | float64 | float64 | str8 | str18 | int64 | float64 | float64 | float64 | float64 | float64 | str56 | float64 | str3 | str1 | int64 | str56 | str64 | str64 | str6 | bool | float64 | str9 | str9 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 8061-58253-266 | QSO | sdss_eboss_8061-58253-0266 | 247.6561799999999 | 53.52345 | spectrum | SDSS Collaboration | 3 | 58252.42982638889 | 58253.44824155093 | 2700.2 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 247.6561799999999 53.52345 0.0002777777777777778 | mast:SDSS/eboss/8061/58253/0266/spec-image-8061-58253-0266.png | mast:SDSS/eboss/8061/58253/0266/full/spec-8061-58253-0266.fits | PUBLIC | False | nan | 244271644 | 725056406 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 10938-58514-216 | QSO | sdss_eboss_10938-58514-0216 | 222.12283 | 32.679912 | spectrum | SDSS Collaboration | 3 | 58514.41091435185 | 58514.45541782407 | 3600.41 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 222.12283 32.679912 0.0002777777777777778 | mast:SDSS/eboss/10938/58514/0216/spec-image-10938-58514-0216.png | mast:SDSS/eboss/10938/58514/0216/full/spec-10938-58514-0216.fits | PUBLIC | False | nan | 244271652 | 725056425 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 8061-58253-504 | QSO | sdss_eboss_8061-58253-0504 | 245.7695699999999 | 54.336356 | spectrum | SDSS Collaboration | 3 | 58252.42982638889 | 58253.448242592596 | 2700.2 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 245.7695699999999 54.336356 0.0002777777777777778 | mast:SDSS/eboss/8061/58253/0504/spec-image-8061-58253-0504.png | mast:SDSS/eboss/8061/58253/0504/full/spec-8061-58253-0504.fits | PUBLIC | False | nan | 244271655 | 725056433 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 10938-58514-697 | GALAXY | sdss_eboss_10938-58514-0697 | 221.61738 | 34.345396 | spectrum | SDSS Collaboration | 3 | 58514.41091435185 | 58514.45541851852 | 3600.41 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 221.61738 34.345396 0.0002777777777777778 | mast:SDSS/eboss/10938/58514/0697/spec-image-10938-58514-0697.png | mast:SDSS/eboss/10938/58514/0697/full/spec-10938-58514-0697.fits | PUBLIC | False | nan | 244271661 | 725056449 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 8061-58253-287 | QSO | sdss_eboss_8061-58253-0287 | 247.53341 | 52.881373 | spectrum | SDSS Collaboration | 3 | 58252.42982638889 | 58253.44824155093 | 2700.2 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 247.53341 52.881373 0.0002777777777777778 | mast:SDSS/eboss/8061/58253/0287/spec-image-8061-58253-0287.png | mast:SDSS/eboss/8061/58253/0287/full/spec-8061-58253-0287.fits | PUBLIC | False | nan | 244271671 | 725056472 |
The table above provides some basic information for each object:
s_ra
ands_dec
: Right ascension and declination.instrument_name
:BOSS
indicates that the data were collected using the BOSS spectrograph.obs_id
: Observation ID associated with the object. This is based on the plate number, the modified Julian date of observation, and the fiber ID, so the observation ID will look something likesdss_eboss_{PLATE}-{MJD}-{FIBERID}
.target_classification
: Indicates the type of object (QSO
,STAR
, orGALAXY
).t_min
andt_max
: The modified Julian dates indicating the start and end times of the exposures.wavelength_region
: Indicates the region of the electromagnetic spectrum observed. This should beOPTICAL
, since eBOSS observed in the optical wavelength range.em_min
andem_max
: The minimum and maximum wavelengths observed by the survey. For eBOSS, this range is 360.0–1040.0 nanometers (optical).dataproduct_type
: Since eBOSS was a spectroscopic survey, this should bespectrum
.
Sampling eBOSS for Redshifted Galaxies#
In this tutorial, we will be examining a sample of 311 galaxies, with 32 of those being from the galaxy cluster Abell 2199. This sample was curated for this exercise by randomly selecting 500 galaxies from the LOFAR subprogram of eBOSS across a uniform range of redshifts, and then selecting the most linear portion of the data when plotted on a radial velocity vs. distance plot.
For the purpose of this tutorial, we will only focus on querying by observation ID. The list of observation IDs of the 311 galaxies is located in the .txt file all_galaxies.txt
. The galaxies from Abell 2199 are located in abell_2199.txt
.
# importing the galaxy IDs
obs_id = np.loadtxt("all_galaxies.txt", dtype=str)
# looping through the .txt file to collect query results
# (this might take a few minutes)
results_tables = []
for i in obs_id:
query_result = Observations.query_criteria(
obs_collection="SDSS", provenance_name="eBOSS", obs_id=i
)
results_tables.append(query_result)
# combine query results using vstack
combined_results = vstack(results_tables)
# show the first 10 results
combined_results[:10]
intentType | obs_collection | provenance_name | instrument_name | project | filters | wavelength_region | target_name | target_classification | obs_id | s_ra | s_dec | dataproduct_type | proposal_pi | calib_level | t_min | t_max | t_exptime | em_min | em_max | obs_title | t_obs_release | proposal_id | proposal_type | sequence_number | s_region | jpegURL | dataURL | dataRights | mtFlag | srcDen | obsid | objID |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str7 | str4 | str5 | str4 | str4 | str4 | str7 | str21 | str6 | str27 | float64 | float64 | str8 | str18 | int64 | float64 | float64 | float64 | float64 | float64 | str56 | float64 | str3 | str1 | int64 | str56 | str64 | str64 | str6 | bool | float64 | str9 | str9 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7563-56810-546 | GALAXY | sdss_eboss_7563-56810-0546 | 242.38543 | 55.191924 | spectrum | SDSS Collaboration | 3 | 56810.23339120371 | 56810.266540972225 | 2700.3 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 242.38543 55.191924 0.0002777777777777778 | mast:SDSS/eboss/7563/56810/0546/spec-image-7563-56810-0546.png | mast:SDSS/eboss/7563/56810/0546/full/spec-7563-56810-0546.fits | PUBLIC | False | nan | 247778078 | 731713673 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7562-56799-119 | GALAXY | sdss_eboss_7562-56799-0119 | 242.23545 | 54.39303 | spectrum | SDSS Collaboration | 3 | 56799.26600694445 | 56799.31052199074 | 3600.38 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 242.23545 54.39303 0.0002777777777777778 | mast:SDSS/eboss/7562/56799/0119/spec-image-7562-56799-0119.png | mast:SDSS/eboss/7562/56799/0119/full/spec-7562-56799-0119.fits | PUBLIC | False | nan | 246836643 | 729532212 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7563-56810-66 | GALAXY | sdss_eboss_7563-56810-0066 | 246.3541299999999 | 53.987946 | spectrum | SDSS Collaboration | 3 | 56810.23339120371 | 56810.266540509256 | 2700.3 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 246.3541299999999 53.987946 0.0002777777777777778 | mast:SDSS/eboss/7563/56810/0066/spec-image-7563-56810-0066.png | mast:SDSS/eboss/7563/56810/0066/full/spec-7563-56810-0066.fits | PUBLIC | False | nan | 247778139 | 731713984 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7564-56804-589 | GALAXY | sdss_eboss_7564-56804-0589 | 241.9422 | 54.987496 | spectrum | SDSS Collaboration | 3 | 56804.29349537037 | 56804.3494 | 4500.51 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 241.9422 54.987496 0.0002777777777777778 | mast:SDSS/eboss/7564/56804/0589/spec-image-7564-56804-0589.png | mast:SDSS/eboss/7564/56804/0589/full/spec-7564-56804-0589.fits | PUBLIC | False | nan | 244576784 | 725746454 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7562-56799-322 | GALAXY | sdss_eboss_7562-56799-0322 | 239.64237 | 53.270835 | spectrum | SDSS Collaboration | 3 | 56799.26600694445 | 56799.31052199074 | 3600.38 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 239.64237 53.270835 0.0002777777777777778 | mast:SDSS/eboss/7562/56799/0322/spec-image-7562-56799-0322.png | mast:SDSS/eboss/7562/56799/0322/full/spec-7562-56799-0322.fits | PUBLIC | False | nan | 246835989 | 729530281 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7562-56799-946 | GALAXY | sdss_eboss_7562-56799-0946 | 242.29276 | 55.442419 | spectrum | SDSS Collaboration | 3 | 56799.26600694445 | 56799.31052245371 | 3600.38 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 242.29276 55.442419 0.0002777777777777778 | mast:SDSS/eboss/7562/56799/0946/spec-image-7562-56799-0946.png | mast:SDSS/eboss/7562/56799/0946/full/spec-7562-56799-0946.fits | PUBLIC | False | nan | 246835581 | 729529394 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7565-56809-575 | GALAXY | sdss_eboss_7565-56809-0575 | 240.7521 | 55.295251 | spectrum | SDSS Collaboration | 3 | 56809.23818287037 | 56809.27134421296 | 2700.27 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 240.7521 55.295251 0.0002777777777777778 | mast:SDSS/eboss/7565/56809/0575/spec-image-7565-56809-0575.png | mast:SDSS/eboss/7565/56809/0575/full/spec-7565-56809-0575.fits | PUBLIC | False | nan | 246919581 | 729701420 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7564-56804-655 | GALAXY | sdss_eboss_7564-56804-0655 | 242.15617 | 54.257776 | spectrum | SDSS Collaboration | 3 | 56804.29349537037 | 56804.3494 | 4500.51 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 242.15617 54.257776 0.0002777777777777778 | mast:SDSS/eboss/7564/56804/0655/spec-image-7564-56804-0655.png | mast:SDSS/eboss/7564/56804/0655/full/spec-7564-56804-0655.fits | PUBLIC | False | nan | 244577089 | 725747202 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7563-56810-647 | GALAXY | sdss_eboss_7563-56810-0647 | 242.90702 | 54.704448 | spectrum | SDSS Collaboration | 3 | 56810.23339120371 | 56810.266540972225 | 2700.3 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 242.90702 54.704448 0.0002777777777777778 | mast:SDSS/eboss/7563/56810/0647/spec-image-7563-56810-0647.png | mast:SDSS/eboss/7563/56810/0647/full/spec-7563-56810-0647.fits | PUBLIC | False | nan | 247778318 | 731714416 |
science | SDSS | eBOSS | BOSS | SDSS | None | OPTICAL | eBOSS 7563-56810-740 | GALAXY | sdss_eboss_7563-56810-0740 | 243.28003 | 54.632292 | spectrum | SDSS Collaboration | 3 | 56810.23339120371 | 56810.266540972225 | 2700.3 | 360.0 | 1040.0 | Extended Baryon Oscillation Spectroscopic Survey (eBOSS) | 59554.0 | N/A | -- | -- | CIRCLE 243.28003 54.632292 0.0002777777777777778 | mast:SDSS/eboss/7563/56810/0740/spec-image-7563-56810-0740.png | mast:SDSS/eboss/7563/56810/0740/full/spec-7563-56810-0740.fits | PUBLIC | False | nan | 247780260 | 731720216 |
Downloading Products from eBOSS#
For each object, there are three available files: The preview .png image, the “full spectrum” file, and the “lite spectrum” file. The full spectrum is listed as Minimum Recommended Products
for the productGroupDescription
parameter.
For more information about eBOSS data products, you can visit the MAST Archive Manual as well as in the search results table.
This will take a few minutes to load.
# Obtaining the product list of all galaxies
products = Observations.get_product_list(combined_results)
# Display the available products
products
obsID | obs_collection | dataproduct_type | obs_id | description | type | dataURI | productType | productGroupDescription | productSubGroupDescription | productDocumentationURL | project | prvversion | proposal_id | productFilename | size | parent_obsid | dataRights | calib_level | filters |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str9 | str4 | str12 | str30 | str235 | str1 | str69 | str7 | str28 | str14 | str61 | str5 | str7 | str3 | str31 | int64 | str9 | str6 | int64 | str4 |
244093798 | SDSS | spectrum | sdss_eboss_10729-58248-0357 | Preview-Full | S | mast:SDSS/eboss/10729/58248/0357/spec-image-10729-58248-0357.png | PREVIEW | -- | -- | -- | eBOSS | DR17 | N/A | spec-image-10729-58248-0357.png | 33843 | 244093798 | PUBLIC | 3 | None |
244093798 | SDSS | spectrum | sdss_eboss_10729-58248-0357 | SDSS eBOSS lite spectrum file containing the combined spectrum and associated metadata but not the individual exposures. | S | mast:SDSS/eboss/10729/58248/0357/lite/spec-lite-10729-58248-0357.fits | SCIENCE | -- | SPECTRA | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | DR17 | N/A | spec-lite-10729-58248-0357.fits | 216000 | 244093798 | PUBLIC | 3 | None |
244093798 | SDSS | spectrum | sdss_eboss_10729-58248-0357 | SDSS eBOSS full spectrum file containing the combined spectrum, associated metadata, and the individual exposures. | S | mast:SDSS/eboss/10729/58248/0357/full/spec-10729-58248-0357.fits | SCIENCE | Minimum Recommended Products | SPECTRA | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | DR17 | N/A | spec-10729-58248-0357.fits | 864000 | 244093798 | PUBLIC | 3 | None |
244093916 | SDSS | spectrum | sdss_eboss_10729-58248-0657 | Preview-Full | S | mast:SDSS/eboss/10729/58248/0657/spec-image-10729-58248-0657.png | PREVIEW | -- | -- | -- | eBOSS | DR17 | N/A | spec-image-10729-58248-0657.png | 39087 | 244093916 | PUBLIC | 3 | None |
244093916 | SDSS | spectrum | sdss_eboss_10729-58248-0657 | SDSS eBOSS lite spectrum file containing the combined spectrum and associated metadata but not the individual exposures. | S | mast:SDSS/eboss/10729/58248/0657/lite/spec-lite-10729-58248-0657.fits | SCIENCE | -- | SPECTRA | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | DR17 | N/A | spec-lite-10729-58248-0657.fits | 216000 | 244093916 | PUBLIC | 3 | None |
244093916 | SDSS | spectrum | sdss_eboss_10729-58248-0657 | SDSS eBOSS full spectrum file containing the combined spectrum, associated metadata, and the individual exposures. | S | mast:SDSS/eboss/10729/58248/0657/full/spec-10729-58248-0657.fits | SCIENCE | Minimum Recommended Products | SPECTRA | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | DR17 | N/A | spec-10729-58248-0657.fits | 864000 | 244093916 | PUBLIC | 3 | None |
244094913 | SDSS | spectrum | sdss_eboss_10729-58248-0359 | Preview-Full | S | mast:SDSS/eboss/10729/58248/0359/spec-image-10729-58248-0359.png | PREVIEW | -- | -- | -- | eBOSS | DR17 | N/A | spec-image-10729-58248-0359.png | 34149 | 244094913 | PUBLIC | 3 | None |
244094913 | SDSS | spectrum | sdss_eboss_10729-58248-0359 | SDSS eBOSS lite spectrum file containing the combined spectrum and associated metadata but not the individual exposures. | S | mast:SDSS/eboss/10729/58248/0359/lite/spec-lite-10729-58248-0359.fits | SCIENCE | -- | SPECTRA | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | DR17 | N/A | spec-lite-10729-58248-0359.fits | 216000 | 244094913 | PUBLIC | 3 | None |
244094913 | SDSS | spectrum | sdss_eboss_10729-58248-0359 | SDSS eBOSS full spectrum file containing the combined spectrum, associated metadata, and the individual exposures. | S | mast:SDSS/eboss/10729/58248/0359/full/spec-10729-58248-0359.fits | SCIENCE | Minimum Recommended Products | SPECTRA | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | DR17 | N/A | spec-10729-58248-0359.fits | 864000 | 244094913 | PUBLIC | 3 | None |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248379571 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248380187 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248380410 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248380534 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248380590 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248380647 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248380843 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248381352 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248381483 | PUBLIC | 3 | -- |
252830431 | SDSS | measurements | sdss_eboss_spall | SDSS eBOSS summary catalog. This provides collated summary tables on the observations and data processing from eBOSS, including targeting information, spectroscopic classifications, and redshifts for every observation. | D | mast:SDSS/eboss/spAll-v5_13_2.fits | SCIENCE | -- | eBOSS Catalogs | https://outerspace.stsci.edu/display/SDSS/eBOSS+Data+Products | eBOSS | v5_13_2 | N/A | spAll-v5_13_2.fits | 15895373760 | 248382373 | PUBLIC | 3 | -- |
To utilize the data, we must download the FITS files. Any data products dowloaded from MAST will appear in a folder called mastDownload
.
We’ll be focusing on using the full spectrum datafile only, which is labeled “Minimum Recommended Products” as the product Group Description. To ensure we’re only downloading this file for each target, we’ll use the parameter mrp_only = True
.
This download should take around 45 seconds or so.
# Downloading the full spectra products
manifest = Observations.download_products(
products, mrp_only=True, verbose=False
)
We’ll send these FITS files to an array so that we can access the redshift and flux values.
# Sending the FITS files to an array
galaxy_array = []
for path in manifest["Local Path"]:
galaxy_array.append(fits.open(path))
# View available file extensions
galaxy_array[0].info()
Filename: ./mastDownload/SDSS/sdss_eboss_10729-58248-0357/spec-10729-58248-0357.fits
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 PrimaryHDU 134 ()
1 COADD 1 BinTableHDU 26 4567R x 8C [E, E, E, J, J, E, E, E]
2 SPALL 1 BinTableHDU 488 1R x 236C [27A, 14A, 4A, E, E, J, J, E, J, E, E, E, K, K, K, K, K, K, K, K, K, B, B, J, I, 5E, 5E, J, J, J, J, 7A, 7A, 16A, D, D, 6A, 21A, E, E, E, J, E, 24A, 10J, J, 10E, E, E, E, E, E, E, J, E, E, E, J, 5E, E, E, 10E, 10E, 10E, 5E, 5E, 5E, 5E, 5E, J, J, E, E, E, E, E, E, 16A, 9A, 12A, E, E, E, E, E, E, E, E, J, E, E, J, J, 6A, 21A, E, 35E, K, 19A, 19A, 19A, B, B, B, I, 3A, B, I, I, I, I, J, E, J, J, E, E, E, E, E, E, E, E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5J, 5J, 5J, 5E, 5J, 75E, 75E, 5E, 5E, 5E, 5J, 5E, D, D, D, D, D, D, D, D, D, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 5E, 40E, 40E, 5J, 5J, 5E, 5E, 5D, J, J, J, J, J, J, J, E]
3 SPZLINE 1 BinTableHDU 48 32R x 19C [J, J, J, 13A, D, E, E, E, E, E, E, E, E, E, E, J, J, E, E]
4 B1-00268372-00268371-00268370 1 BinTableHDU 189 2481R x 8C [E, E, E, J, E, E, E, E]
5 B1-00268373-00268371-00268370 1 BinTableHDU 189 2481R x 8C [E, E, E, J, E, E, E, E]
6 B1-00268374-00268371-00268370 1 BinTableHDU 189 2481R x 8C [E, E, E, J, E, E, E, E]
7 R1-00268372-00268371-00268370 1 BinTableHDU 189 3105R x 8C [E, E, E, J, E, E, E, E]
8 R1-00268373-00268371-00268370 1 BinTableHDU 189 3105R x 8C [E, E, E, J, E, E, E, E]
9 R1-00268374-00268371-00268370 1 BinTableHDU 189 3105R x 8C [E, E, E, J, E, E, E, E]
For this tutorial, we will focus on using the spectroscopic flux in the r-band provided by spALL. These are accessed through the second file extension.
The various file extensions are broken down on the SDSS website:
HDU 0: The primary header information.
HDU 1: The coadded observed spectrum.
HDU 2: Metadata from spALL.
HDU 3: Emission line fitting metadata from spZline.
HDU 4+: Individual red and blue spectra that make up the coadded spectrum.
The second file extension is broken down even further, available also on the SDSS website. We’ll be focusing on using SPECTROFLUX
. Since this provides us a five-element array for each band (u, g, r, i , z), we’ll use the third element for the r-band flux.
Making the Hubble-Lemaître Diagram#
# Setting up arrays to send all z-values, z-error, and flux to arrays
z_val = []
z_err = []
r_flux = []
# Looping through all the data and adding z-values, z-error, and flux to arrays
for galaxy in galaxy_array:
galaxy_z = galaxy[2].data["Z"]
zerr = galaxy[2].data["Z_ERR"]
spectroflux = galaxy[2].data["SPECTROFLUX"][:, 2]
z_val.append(galaxy_z)
z_err.append(zerr)
r_flux.append(spectroflux)
# Converting lists to arrays
z_val = np.array(z_val)
z_err = np.array(z_err)
r_flux = np.array(r_flux)
In order to determine the relative distance to each galaxy, we can use the inverse square law as we know flux is proportional to \(\frac{1}{d^2}\). Thus, distance is proportional to \(\frac{1}{\sqrt{flux}}\) [4].
# Finding the relative distance by taking 1/sqrt of the radiant flux
relative_distance = 1 / np.sqrt(r_flux)
# Converting the relative distance to kiloparsecs
new_relative_distance = relative_distance / 1e3 # kpc
# Stacking arrays to remove points with nan
plot_array = np.column_stack((z_val, new_relative_distance, z_err))
Due to the behavior of \(\frac{1}{\sqrt{flux}}\), we will create a mask to remove any ‘nan’ values.
# Selecting all distances that are not 'nan'
mask = ~np.isnan(plot_array[:, 1])
# Applying mask
new_plot_array = plot_array[mask]
Since Hubble’s constant is in units km/s/Mpc, we want to convert redshift to velocity. To do this, we can use the relativistic radial velocity equation [5]:
Using error propagation, the error in redshift becomes:
# Define speed of light constant (c) in km/s
c = 2.998e5 # km/s
# Calculating velocity from redshift
velocity = []
velocity_err = []
for i, j in zip(new_plot_array[:, 0], new_plot_array[:, 2]):
v = c * (((1 + i) ** 2 - 1) / ((1 + i) ** 2 + 1))
v_err = np.abs(((4 * c * (1 + i)) / ((1 + i) ** 2 + 1) ** 2)) * j
velocity.append(v)
velocity_err.append(v_err)
# Creating new array of distance, velocity, and error in velocity
distance_velocity_array = np.column_stack(
(new_plot_array[:, 1], velocity, velocity_err)
)
Plotting eBOSS Data#
We can examine the data by creating a scatter plot of the velocity versus the relative distance.
# Plotting eBOSS data
plt.figure(figsize=(8, 5))
plt.scatter(
distance_velocity_array[:, 0],
distance_velocity_array[:, 1],
s=1.5,
color="blue",
)
plt.title("Velocity vs. Relative Distance of eBOSS Data")
plt.xlabel("Relative Distance")
plt.ylabel("Radial Velocity (km/s)")
plt.grid(True)
plt.show()

Importing Abell 2199 Data#
In order to obtain the actualized distances for the sample, we can use the relative distance of the first galaxy from Abell 2199 and set it equal to 1. We’ll follow the same procedures as before by importing the abell_2199.txt
file and querying eBOSS for those 32 select galaxies.
# Loading the Abell 2199 dataset
obs_id2 = np.loadtxt("abell_2199.txt", dtype=str)
# Querying eBOSS for the 32 Abell 2199 galaxies, sending the data to an array
results_tables2 = []
for i in obs_id2:
query_result2 = Observations.query_criteria(
provenance_name="eBOSS", obs_id=i
)
results_tables2.append(query_result2)
# Stacking the data into one table
combined_results2 = vstack(results_tables2)
# Ensuring the length of the stacked table is 32
print(f"Length of Abell 2199 dataset = {len(combined_results2)}")
Length of Abell 2199 dataset = 32
We’ll gather and download the products again, and then send the FITS data to an array.
# Gathering and downloading full spectra files
products2 = Observations.get_product_list(combined_results2)
manifest2 = Observations.download_products(
products2, mrp_only=True, verbose=False
)
# Writing data to an array
abell_array = []
for path in manifest2["Local Path"]:
abell_array.append(fits.open(path))
# Checking the length of the array matches the dataset
print(f"Length of Abell 2199 array = {len(abell_array)}")
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_10729-58248-0357/spec-10729-58248-0357.fits with expected size 864000. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_10729-58248-0359/spec-10729-58248-0359.fits with expected size 864000. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_10729-58248-0657/spec-10729-58248-0657.fits with expected size 864000. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0747/spec-5190-56077-0747.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0749/spec-5190-56077-0749.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0753/spec-5190-56077-0753.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0756/spec-5190-56077-0756.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0757/spec-5190-56077-0757.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0758/spec-5190-56077-0758.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0759/spec-5190-56077-0759.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0761/spec-5190-56077-0761.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0762/spec-5190-56077-0762.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0790/spec-5190-56077-0790.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0793/spec-5190-56077-0793.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0795/spec-5190-56077-0795.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0797/spec-5190-56077-0797.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0798/spec-5190-56077-0798.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_5190-56077-0799/spec-5190-56077-0799.fits with expected size 875520. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0084/spec-6045-56072-0084.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0121/spec-6045-56072-0121.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0124/spec-6045-56072-0124.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0125/spec-6045-56072-0125.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0126/spec-6045-56072-0126.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0130/spec-6045-56072-0130.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0161/spec-6045-56072-0161.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0162/spec-6045-56072-0162.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0163/spec-6045-56072-0163.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0164/spec-6045-56072-0164.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0165/spec-6045-56072-0165.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0167/spec-6045-56072-0167.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0169/spec-6045-56072-0169.fits with expected size 1082880. [astroquery.query]
INFO: Found cached file ./mastDownload/SDSS/sdss_eboss_6045-56072-0206/spec-6045-56072-0206.fits with expected size 1082880. [astroquery.query]
Length of Abell 2199 array = 32
Now we can extract the redshift, error in redshift, and r-band flux values. Following the same processes as before, we can use the flux to find the relative distances.
# Sending redshift, error in redshift, and r-band magnitudes to arrays
z_val_abell = []
z_err_abell = []
r_flux_abell = []
for galaxy in abell_array:
galaxy_z = galaxy[2].data["Z"]
zerr = galaxy[2].data["Z_ERR"]
spectroflux = galaxy[2].data["SPECTROFLUX"][:, 2]
z_val_abell.append(galaxy_z)
z_err_abell.append(zerr)
r_flux_abell.append(spectroflux)
# Converting lists into arrays
z_val_abell = np.array(z_val_abell)
z_err_abell = np.array(z_err_abell)
r_flux_abell = np.array(r_flux_abell)
# Calculate relative distance
relative_distance_abell = 1 / np.sqrt(r_flux_abell)
new_relative_distance_abell = relative_distance_abell / 1e3 # kpc
# Filter out zeros
plot_array_abell = np.column_stack(
(z_val_abell, new_relative_distance_abell, z_err_abell)
)
mask2 = ~np.isnan(plot_array_abell[:, 1])
new_array_abell = plot_array_abell[mask2]
# Calculate velocity
velocity_abell = []
velocity_err_abell = []
for i, j in zip(new_array_abell[:, 0], new_array_abell[:, 2]):
v = c * (((1 + i) ** 2 - 1) / ((1 + i) ** 2 + 1))
v_err = np.abs(((4 * c * (1 + i)) / ((1 + i) ** 2 + 1) ** 2)) * j
velocity_abell.append(v)
velocity_err_abell.append(v_err)
# Creating new array of distance, velocity, and error in velocity
distance_velocity_array_abell = np.column_stack(
(new_array_abell[:, 1], velocity_abell, velocity_err_abell)
)
Now that we have filtered out both datasets, we can normalize the relative distances. To do this, we’ll set up a ratio such that the closest galaxy in the Abell 2199 cluster equals 1:
where \(d_{1}\) is the relative distance of the closest Abell 2199 galaxy, \(d_{relative}\) is the array of relative distances of the eBOSS galaxies, and \(d_{norm}\) is the array of normalized distances. To solve for the array of \(d_{norm}\), we’ll divide the array of relative distances by \(d_{1}\). [4]
Since we know the distance to Abell 2199 is 128 Mpc, we’ll multiply the normalized distances by 128 Mpc to obtain the actualized distances. [6].
# Sorting the Abell 2199 data to find closest galaxy
sorted_abell = np.argsort(distance_velocity_array_abell[:, 0])
sorted_abell_array = distance_velocity_array_abell[sorted_abell]
# Taking the first Abell 2199 galaxy and find the average, setting that to 1
d1_abell = sorted_abell_array[0][0]
# Normalize distances to d1_abell
norm_dist = distance_velocity_array[:, 0] / d1_abell
norm_dist_abell = distance_velocity_array_abell[:, 0] / d1_abell
# Distance to Abell 2199
distance = 128 # Mpc
Now we have normalized distances! We can multiply these by the distance to Abell 2199 and generate a plot with distances and radial velocities. We can use scipy.optimize.curve_fit
to perform a linear fit, and in return, we can obtain the value of the slope, i.e., Hubble’s constant!
# Defining linear fit function
def fit_func(x, m, b):
return m * x + b
# Doing linear fit using scipy.optimize.curve_fit
popt, covariance = curve_fit(
fit_func,
norm_dist * distance,
distance_velocity_array[:, 1],
sigma=distance_velocity_array[:, 2],
absolute_sigma=True,
)
m = popt[0] # slope (Hubble's constant!)
b = popt[1] # intercept
# Setting up an array of x-values to plot the line of best fit
x_array = np.linspace(0, 2000, 200000)
# Plotting the data as well as the line of best fit
plt.errorbar(
norm_dist * distance,
distance_velocity_array[:, 1],
yerr=distance_velocity_array[:, 2],
ms=1.5,
fmt="o",
label="eBOSS data",
zorder=1,
)
plt.scatter(
norm_dist_abell * distance,
distance_velocity_array_abell[:, 1],
s=5,
label="Abell 2199",
color="purple",
zorder=2,
)
plt.plot(
x_array,
fit_func(x_array, m, b),
label="linear fit",
color="orange",
zorder=3,
)
plt.ylabel("Radial Velocity (km/s)")
plt.xlabel("Actualized Distance (Mpc)")
plt.title(
f"Radial Velocity vs. Actualized Distance of eBOSS Galaxy Sample \n eBOSS - LOFAR \n $H_{0}$ = {m:.3f} km/s/Mpc \n r - band magnitude"
)
plt.legend(loc="lower right")
plt.grid()
plt.tight_layout()
plt.show()

Comparing Calculated H0 to Other Models#
Using data from eBOSS, we were able to calculate an H0 value of \(\approx\) 73.66 km/s/Mpc!
The European Space Agency calculated an H0 value of 67.40 ± 1.40 km/s/Mpc using Planck data. A recent calculation using Cepheid variables and SNe Ia from the SH0ES collaboration provided an H0 value of 73.04 ± 1.04 km/s/Mpc [3]. Astronomers continue to use both local distance indicators (e.g., Tip of the Red Giant Branch stars) and early-Universe probes like the CMB to constrain H0, but the Hubble Tension remains unresolved [7].
Due to relativistic effects, H0 values calculated from CMB observations (which probe the early Universe) tend to be lower than those calculated from nearby objects like Cepheid variables or Type Ia supernovae. Since our H0 value is based on galaxy observations from eBOSS, it’s reasonable that it falls on the higher end of the range, though this could also be influenced by uncertainties introduced by several assumptions:
We assume galaxies are point sources, using a single static distance for each.
We calculate distances using the inverse square law, but intrinsic galaxy brightness can vary significantly.
Utilizing HST Data from MAST#
The Hubble Space Telescope (HST) is a 2.4 meter serviceable telescope launched in 1990. It’s equipped with three cameras (ACS, WFC3/UVIS, and WFC3/IR). Using observations from HST, we can construct an image of Abell 2199!
While we won’t be covering this in the tutorial, we could use the constructed image from HST to determine the relative distance to Abell 2199 rather than using the one from NED. For example, we could use the apparent brightness of the cluster’s brightest galaxy, or analyze the relative physical sizes of its member galaxies [4].
For more information about HST, check out this overview from MAST!
Creating an Image of Abell 2199 Using HST#
To create an image of Abell 2199 using HST, we’ll query MAST using objectname = 'Abell 2199'
and specify HST using obs_collection = 'HST'
.
# Query HST using objectname
obs_hst = Observations.query_criteria(
objectname="Abell 2199",
# specifying Hubble data
obs_collection="HST",
# We want science observations and not calibration files
intentType="science",
# Calibrated reduced observations to display final image
provenance_name="CAL*",
)
# Display results
obs_hst
intentType | obs_collection | provenance_name | instrument_name | project | filters | wavelength_region | target_name | target_classification | obs_id | s_ra | s_dec | dataproduct_type | proposal_pi | calib_level | t_min | t_max | t_exptime | em_min | em_max | obs_title | t_obs_release | proposal_id | proposal_type | sequence_number | s_region | jpegURL | dataURL | dataRights | mtFlag | srcDen | obsid | objID | objID1 | distance |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str7 | str3 | str8 | str13 | str3 | str6 | str8 | str21 | str69 | str9 | float64 | float64 | str8 | str21 | int64 | float64 | float64 | float64 | float64 | float64 | str110 | float64 | str5 | str12 | int64 | str1098 | str34 | str35 | str6 | bool | float64 | str9 | str9 | str9 | float64 |
science | HST | CALNIC | NICMOS/NIC3 | HST | F160W | Infrared | NGC6166-WF4 | GALAXY;ELLIPTICAL;BCM | n4t204070 | 247.1793481664 | 39.55485355641 | image | Geisler, Douglas | 3 | 50990.66488426 | 50990.79190972 | 3583.872072 | 1408.3999999999999 | 1809.4 | The Metallicity Distribution of the Globular Cluster Systems of Giant Elliptical Galaxies | 51356.53231477 | 7265 | GO | -- | POLYGON -112.81429500000002 39.545485 -112.80873299999996 39.559266 -112.80873332280447 39.559266077458844 -112.80851899999999 39.559797 -112.82164528889807 39.56294585492904 -112.82701700000001 39.564234 -112.83257600000002 39.550452 -112.83257587496034 39.550451970020688 -112.83278999999999 39.549921 -112.83210196969837 39.54975607514 -112.83210199999996 39.549756 -112.81429500000002 39.545485 -112.81429500000002 39.545485 | mast:HST/product/n4t204070_mos.jpg | mast:HST/product/n4t204070_mos.fits | PUBLIC | False | nan | 24861478 | 109228114 | 109228114 | 73.05880201851693 |
science | HST | CALNIC | NICMOS/NIC2 | HST | F160W | Infrared | ABELL2199-SKYS | CALIBRATION;SKY BACKGROUND | n4hd21030 | 247.160006665 | 39.47067612935 | image | Tonry, John L. | 3 | 50799.99439224537 | 50800.001336608795 | 383.990005 | 1408.3999999999999 | 1809.4 | The SBF Hubble Diagram | 51165.55783555 | 7453 | GO | -- | POLYGON -112.83682999999996 39.469599 -112.83380699999998 39.47445 -112.840036 39.476763 -112.84305900000004 39.471911 -112.83682999999996 39.469599 -112.83682999999996 39.469599 POLYGON -112.83994899999999 39.464592 -112.836926 39.469444 -112.84315500000002 39.471756 -112.84617700000001 39.466904 -112.83994899999999 39.464592 -112.83994899999999 39.464592 | mast:HST/product/n4hd21030_mos.jpg | mast:HST/product/n4hd21030_mos.fits | PUBLIC | False | nan | 24854837 | 109244905 | 109244905 | 233.75097836993348 |
science | HST | CALWFPC | WFPC/PC | HST | F555W | Optical | NGC6166 | GALAXY;ELLIPTICAL;RADIO GALAXY; | w10a0k03t | 247.1602080555556 | 39.55083305555556 | image | Faber, Sandra M. | 2 | 48912.790486770835 | 48912.81016269676 | 1700.0 | 490.4 | 605.4 | CORES OF EARLY-TYPE GALAXIES | 49277.97034713 | 3912 | GO | -- | POLYGON 247.16026223 39.55848068 247.16854576 39.55107914 247.158936 39.54468522 247.15065221 39.55208608 247.16026223 39.55848068 | mast:HST/product/w10a0k03t_c0f.jpg | mast:HST/product/w10a0k03t_c0f.fits | PUBLIC | False | nan | 24734062 | 121579829 | 121579829 | 41.44383128973108 |
science | HST | CALNIC | NICMOS/NIC3 | HST | F160W | Infrared | ABELL2199-SKYS | CALIBRATION;SKY BACKGROUND | n4hd21040 | 247.1339505311 | 39.48167425652 | image | Tonry, John L. | 3 | 50799.99439305555 | 50800.02956019 | 383.990005 | 1408.3999999999999 | 1809.4 | The SBF Hubble Diagram | 51165.55482632 | 7453 | GO | -- | POLYGON -112.863315 39.469529 -112.85511399999996 39.482499 -112.85515305545294 39.48251371201912 -112.85199599999999 39.487506 -112.868742 39.493813 -112.87694099999999 39.480841 -112.87690210780677 39.480826359142355 -112.88005699999997 39.475834 -112.863315 39.469529 -112.863315 39.469529 | mast:HST/product/n4hd21040_mos.jpg | mast:HST/product/n4hd21040_mos.fits | PUBLIC | False | nan | 24854838 | 125025147 | 125025147 | 171.7010033904009 |
science | HST | CALSTIS | STIS/CCD | HST | MIRVIS | Optical | ANY | UNIDENTIFIED;PARALLEL FIELD | o4k1uq010 | 247.2330667592 | 39.4324369098 | image | Baum, Stefi A. | 3 | 50990.44631774306 | 50990.450299421296 | 300.0 | nan | nan | POMS Test Proposal: STIS non-scripted parallel proposal | 50990.74260405 | 7908 | GO/PAR | -- | POLYGON 247.22159539995113 39.42784078011958 247.22707603758766 39.441280962158395 247.24453811574787 39.437033032856746 247.23905747811133 39.42359285081793 247.22159539995113 39.42784078011958 | -- | mast:HST/product/o4k1uq010_sx2.fits | PUBLIC | False | nan | 24916064 | 361298289 | 361298289 | 425.4196862145258 |
science | HST | CALSTIS | STIS/CCD | HST | MIRVIS | Optical | ANY | UNIDENTIFIED;PARALLEL FIELD | o4k1w3010 | 247.2671136734 | 39.44580006266 | image | Baum, Stefi A. | 3 | 50990.66669961806 | 50990.67190813657 | 400.0 | nan | nan | POMS Test Proposal: STIS non-scripted parallel proposal | 50990.74288183 | 7908 | GO/PAR | -- | POLYGON 247.25563785375158 39.44120729811321 247.26112615216493 39.45464587159116 247.27858949034362 39.45039282058389 247.27310119193027 39.436954247105945 247.25563785375158 39.44120729811321 | -- | mast:HST/product/o4k1w3010_sx2.fits | PUBLIC | False | nan | 24916087 | 361298736 | 361298736 | 448.96962551989975 |
science | HST | CALSTIS | STIS/CCD | HST | MIRVIS | Optical | ANY | UNIDENTIFIED;PARALLEL FIELD | o4k1w1010 | 247.2411980164 | 39.45178911856 | image | Baum, Stefi A. | 3 | 50990.646676655095 | 50990.65188480324 | 400.0 | nan | nan | POMS Test Proposal: STIS non-scripted parallel proposal | 50990.74760404 | 7908 | GO/PAR | -- | POLYGON 247.2297229224898 39.44719380296406 247.23520668238115 39.460633596012656 247.25267310760765 39.456384427532456 247.24718934771633 39.44294463448386 247.2297229224898 39.44719380296406 | -- | mast:HST/product/o4k1w1010_sx2.fits | PUBLIC | False | nan | 24916085 | 361298749 | 361298749 | 383.40239361919663 |
science | HST | CALSTIS | STIS/CCD | HST | MIRVIS | Optical | HI-LATITUDE-FIELD | STAR | o5hjmmvbq | 247.1342541244 | 39.46526553535 | image | Baum, Stefi A. | 2 | 51383.33821987268 | 51383.3399559838 | 150.0 | nan | nan | POMS Test Proposal: STIS non-scripted parallel proposal continuation V | 51383.69723367 | 8406 | ENG/STIS/PAR | -- | POLYGON 247.1230456105921 39.46029046473415 247.12777066916982 39.473901168582714 247.14546263587928 39.470240599258126 247.14073757730156 39.45662989540956 247.1230456105921 39.46029046473415 | -- | mast:HST/product/o5hjmmvbq_flt.fits | PUBLIC | False | nan | 24458735 | 361414815 | 361414815 | 243.90550319973354 |
science | HST | CALACS | ACS/WFC | HST | F475W | OPTICAL | NGC-6166 | GALAXY;ELLIPTICAL | jbhr01010 | 247.1599125 | 39.54200555556 | image | Harris, William Edgar | 3 | 55773.28388880787 | 55773.415844641204 | 5370.0 | 390.0 | 550.0 | Supermassive Star Clusters in Supergiant Galaxies: Tracing the Enrichment of the Earliest Stellar Systems | 56139.54138886 | 12238 | GO | -- | POLYGON -112.86275602999987 39.518147039999995 -112.86271187025956 39.518206797457765 -112.86268716999994 39.518197600000128 -112.82622465999985 39.567498360000144 -112.82627228862017 39.567516100878137 -112.82625031999989 39.567545780000117 -112.85968168000004 39.579991389999996 -112.8597258711428 39.57993164789022 -112.85975055000009 39.579940830000083 -112.89619584000009 39.53062963 -112.89614819747909 39.530611909670405 -112.89617012999996 39.530582209999942 -112.86275602999987 39.518147039999995 -112.86275602999987 39.518147039999995 POLYGON -112.82970656000008 39.506421130000007 -112.82966139750027 39.506480366747262 -112.82963766999983 39.506471690000005 -112.79275050999998 39.554814740000154 -112.7927988487199 39.554832423044175 -112.79277614000011 39.554862160000091 -112.82519745000006 39.566715840000029 -112.82524264329537 39.566656620917342 -112.82526633999981 39.566665279999995 -112.86213722000011 39.51831200000003 -112.86208885359757 39.518294332653461 -112.86211152999992 39.518264570000127 -112.82970656000008 39.506421130000007 -112.82970656000008 39.506421130000007 | mast:HST/product/jbhr01010_drz.jpg | mast:HST/product/jbhr01010_drz.fits | PUBLIC | False | nan | 24834402 | 741033393 | 741033393 | 0.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
science | HST | CALWF3 | WFC3/UVIS | HST | F336W | OPTICAL | PS15AOT-SN2009EU-HOST | GALAXY;ELLIPTICAL | iey929010 | 247.1654514304 | 39.55075434279 | image | Kelsey, Lisa | 3 | 59933.10898993056 | 59933.12674452546 | 360.0 | 305.8 | 367.3 | Local Environments of Low-redshift Type Ia Supernova Siblings | 59933.48858801 | 17194 | SNAP | -- | POLYGON -112.81925200000011 39.522145629999855 -112.80732268999986 39.54258658000002 -112.80737951545382 39.542610020566 -112.80711494851404 39.543063207567947 -112.80689240000011 39.542972830000032 -112.79484269999986 39.563667969999919 -112.7948988548921 39.563690775328347 -112.79454513999994 39.564298070000078 -112.84659405999993 39.58541789 -112.85863210000019 39.564717380000012 -112.85857593339213 39.564694609384638 -112.85892909000003 39.564087120000067 -112.85884136466962 39.564051555105166 -112.87051424999994 39.544025700000113 -112.87045739161762 39.544002285837124 -112.8708110300001 39.543395389999866 -112.81925200000011 39.522145629999855 -112.81925200000011 39.522145629999855 | mast:HST/product/iey929010_drz.jpg | mast:HST/product/iey929010_drz.fits | PUBLIC | False | nan | 106457966 | 767238113 | 767238113 | 0.0 |
science | HST | CALACS | ACS/WFC | HST | F814W | OPTICAL | NGC6166 | GALAXY;ELLIPTICAL;LINER | j6jt05020 | 247.1443138604 | 39.56568924527 | image | Ford, Holland | 3 | 52764.767804282405 | 52764.77748040509 | 700.0 | 708.0 | 959.0 | Massive Black Holes in Early Type Galaxies | 53131.42950234 | 9293 | GTO/ACS | -- | POLYGON -112.81907106000008 39.563255929999912 -112.81404633000007 39.591601029999993 -112.88610806999993 39.603104409999894 -112.89110415000002 39.574756219999934 -112.81907106000008 39.563255929999912 -112.81907106000008 39.563255929999912 POLYGON -112.82436564000002 39.534789040000064 -112.81978306000008 39.562217240000045 -112.8907723199999 39.574315340000112 -112.89532763000001 39.546884369999972 -112.82436564000002 39.534789040000064 -112.82436564000002 39.534789040000064 | mast:HST/product/j6jt05021_drz.jpg | mast:HST/product/j6jt05021_drz.fits | PUBLIC | False | nan | 26091432 | 785134894 | 785134894 | 0.0 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F673N | OPTICAL | 3C338.0 | GALAXY;RADIO GALAXY; | u2s07801t | 247.1593798559 | 39.54271951924 | image | Sparks, William B. | 3 | 50048.450891898145 | 50048.45436412037 | 300.0 | 670.86 | 675.58 | Snapshots of 3CR Radio Galaxies | 50415.09186345 | 5957 | SNAP | -- | POLYGON 247.1588745068656 39.54384182979161 247.15046986829364 39.551449716293796 247.16032049263436 39.55793939381302 247.16872670919946 39.5503338532899 247.1588745068656 39.54384182979161 | mast:HST/product/u2s07801t_drw.jpg | mast:HST/product/u2s07801t_drw.fits | PUBLIC | False | nan | 24561898 | 788766846 | 788766846 | 39.4469579247626 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F673N | OPTICAL | 3C338.0 | GALAXY;RADIO GALAXY; | u2s07802t | 247.1593798559 | 39.54271951924 | image | Sparks, William B. | 3 | 50048.456447453704 | 50048.45991967592 | 300.0 | 670.86 | 675.58 | Snapshots of 3CR Radio Galaxies | 50415.09549769 | 5957 | SNAP | -- | POLYGON 247.1588745068656 39.54384182979161 247.15046986829364 39.551449716293796 247.16032049263436 39.55793939381302 247.16872670919946 39.5503338532899 247.1588745068656 39.54384182979161 | mast:HST/product/u2s07802t_drw.jpg | mast:HST/product/u2s07802t_drw.fits | PUBLIC | False | nan | 24561899 | 788771094 | 788771094 | 39.4469579247626 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F606W | OPTICAL | ANY | UNIDENTIFIED;PARALLEL FIELD | u4k2m601r | 247.2639535316 | 39.51530930574 | image | Casertano, Stefano | 3 | 50990.44738506944 | 50990.453172106485 | 500.0 | 510.89 | 661.13 | POMS Test Proposal: WFII parallel archive proposal | 50990.63297444 | 7909 | GO/PAR | -- | POLYGON 247.26529584017683 39.51484093361801 247.27765482259042 39.51184985808498 247.27379760950498 39.502314521624314 247.26144081752278 39.50530203906747 247.26529584017683 39.51484093361801 | mast:HST/product/u4k2m601r_drw.jpg | mast:HST/product/u4k2m601r_drw.fits | PUBLIC | False | nan | 24602332 | 789739298 | 789739298 | 349.30898244486366 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F606W | OPTICAL | HIGH | EXT-MEDIUM | u4k2lz02r | 247.2980470745 | 39.52866341629 | image | Casertano, Stefano | 3 | 50990.67377395833 | 50990.67956099537 | 500.0 | 510.89 | 661.13 | POMS Test Proposal: WFII parallel archive proposal | 50990.74797447 | 7909 | GO/PAR | -- | POLYGON 247.2993894074153 39.52819464989219 247.31174929014978 39.525199948201404 247.30788663478177 39.51566574427916 247.2955289412657 39.51865688704364 247.2993894074153 39.52819464989219 | mast:HST/product/u4k2lz02r_drw.jpg | mast:HST/product/u4k2lz02r_drw.fits | PUBLIC | False | nan | 24602316 | 789745750 | 789745750 | 428.30333475443496 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F606W | OPTICAL | ANY | UNIDENTIFIED;PARALLEL FIELD | u4k2m602r | 247.2632660938 | 39.51547482218 | image | Casertano, Stefano | 3 | 50990.45849618055 | 50990.466598032406 | 700.0 | 510.89 | 661.13 | POMS Test Proposal: WFII parallel archive proposal | 50990.63315963 | 7909 | GO/PAR | -- | POLYGON 247.2646084101698 39.51500645775736 247.27696745093658 39.512015453275325 247.27311032077844 39.502480094631046 247.26075347050354 39.505467541033354 247.2646084101698 39.51500645775736 | mast:HST/product/u4k2m602r_drw.jpg | mast:HST/product/u4k2m602r_drw.fits | PUBLIC | False | nan | 24602333 | 789745772 | 789745772 | 347.3089749576426 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F300W | UV | HIGH | EXT-MEDIUM | u4k2ly04r | 247.2714155412 | 39.53482491055 | image | Casertano, Stefano | 3 | 50990.59599618056 | 50990.61219988426 | 1400.0 | 254.97 | 328.99 | POMS Test Proposal: WFII parallel archive proposal | 50990.74858789 | 7909 | GO/PAR | -- | POLYGON 247.27276176864666 39.53435065873066 247.28511525876343 39.53136396134659 247.28125839985375 39.521834221792595 247.2689065892541 39.52481973537812 247.27276176864666 39.53435065873066 | mast:HST/product/u4k2ly04r_drw.jpg | mast:HST/product/u4k2ly04r_drw.fits | PUBLIC | False | nan | 24602313 | 789756114 | 789756114 | 351.64648648762767 |
science | HST | CALWFPC2 | WFPC2/PC | HST | F555W | OPTICAL | NGC6166-CENTER | GALAXY;ELLIPTICAL;BCM | u4t20301r | 247.1604779253 | 39.54909217001 | image | Geisler, Douglas | 3 | 51383.33765628472 | 51383.35270258102 | 1300.0 | 472.26000000000005 | 595.1 | The Metallicity Distribution of the Globular Cluster Systems of Giant Elliptical Galaxies | 51749.69840271 | 7265 | GO | -- | POLYGON 247.16184361753605 39.54867518305677 247.17436379619448 39.546100335007374 247.17104405360607 39.53644599006302 247.15852636186068 39.53901759053526 247.16184361753605 39.54867518305677 | mast:HST/product/u4t20301r_drw.jpg | mast:HST/product/u4t20301r_drw.fits | PUBLIC | False | nan | 24604264 | 789805403 | 789805403 | 40.95574336166708 |
science | HST | CALSTIS | STIS/CCD | HST | G750L | OPTICAL | ANY | UNIDENTIFIED;PARALLEL FIELD | o4k1v9piq | 247.2405111522 | 39.45195450143 | spectrum | Baum, Stefi A. | 2 | 50990.598378125 | 50990.612544791664 | 1224.0 | 524.0 | 1027.0 | POMS Test Proposal: STIS non-scripted parallel proposal | 50990.74354161 | 7908 | GO/PAR | -- | POLYGON 247.22903608175014 39.447359110323134 247.23451970633545 39.46079893945676 247.2519862199474 39.45654988591336 247.2465025953621 39.44311005677974 247.22903608175014 39.447359110323134 | -- | mast:HST/product/o4k1v9piq_flt.fits | PUBLIC | False | nan | 24442445 | 794180714 | 794180714 | 381.6948436989644 |
Similar to eBOSS, we’ll retrieve and download the products for Abell 2199, specifically the fully calibrated combined images using productGroupDescription = 'Minimum Recommended Products'
and productSubGroupDescription = 'DRZ'
.
# Get products from query
products_hst = Observations.get_product_list(obs_hst)
# Select specific products
products_hst = Observations.filter_products(
products_hst,
# Specify science files
productType="SCIENCE",
# Recommended products,
productGroupDescription="Minimum Recommended Products",
# DRZ files -> calibrated combined images
productSubGroupDescription="DRZ",
)
# Display product list
products_hst
obsID | obs_collection | dataproduct_type | obs_id | description | type | dataURI | productType | productGroupDescription | productSubGroupDescription | productDocumentationURL | project | prvversion | proposal_id | productFilename | size | parent_obsid | dataRights | calib_level | filters |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
str9 | str3 | str8 | str37 | str67 | str1 | str97 | str9 | str28 | str11 | str1 | str8 | str20 | str5 | str52 | int64 | str9 | str6 | int64 | str9 |
24801640 | HST | image | ibhr01020 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/ibhr01020_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALWF3 | 3.7.2 (Apr-15-2024) | 12238 | ibhr01020_drz.fits | 217932480 | 24801640 | PUBLIC | 3 | F475W |
24801653 | HST | image | ibhr13030 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/ibhr13030_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALWF3 | 3.7.2 (Apr-15-2024) | 12238 | ibhr13030_drz.fits | 217638720 | 24801653 | PUBLIC | 3 | F814W |
24801654 | HST | image | ibhr13040 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/ibhr13040_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALWF3 | 3.7.2 (Apr-15-2024) | 12238 | ibhr13040_drz.fits | 217638720 | 24801654 | PUBLIC | 3 | F814W |
24834402 | HST | image | jbhr01010 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/jbhr01010_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALACS | DrizzlePac 3.9.1 | 12238 | jbhr01010_drz.fits | 215023680 | 24834402 | PUBLIC | 3 | F475W |
24834415 | HST | image | jbhr13010 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/jbhr13010_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALACS | DrizzlePac 3.9.1 | 12238 | jbhr13010_drz.fits | 214859520 | 24834415 | PUBLIC | 3 | F814W |
24834416 | HST | image | jbhr13020 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/jbhr13020_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALACS | DrizzlePac 3.9.1 | 12238 | jbhr13020_drz.fits | 214859520 | 24834416 | PUBLIC | 3 | F814W |
24834423 | HST | image | jbhv02010 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/jbhv02010_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALACS | DrizzlePac 3.9.1 | 12220 | jbhv02010_drz.fits | 23569920 | 24834423 | PUBLIC | 3 | F140LP |
26091389 | HST | image | j6jt05010 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/j6jt05011_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALACS | DrizzlePac 3.9.1 | 9293 | j6jt05011_drz.fits | 214456320 | 26091389 | PUBLIC | 3 | FR656N |
26091432 | HST | image | j6jt05020 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/j6jt05021_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALACS | DrizzlePac 3.9.1 | 9293 | j6jt05021_drz.fits | 214352640 | 26091432 | PUBLIC | 3 | F814W |
106457965 | HST | image | iey929020 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/iey929020_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALWF3 | 3.7.2 (Apr-15-2024) | 17194 | iey929020_drz.fits | 220492800 | 106457965 | PUBLIC | 3 | F625W |
106457966 | HST | image | iey929010 | DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STIS | D | mast:HST/product/iey929010_drz.fits | SCIENCE | Minimum Recommended Products | DRZ | -- | CALWF3 | 3.7.2 (Apr-15-2024) | 17194 | iey929010_drz.fits | 220492800 | 106457966 | PUBLIC | 3 | F336W |
# Download products into same directory
Observations.download_products(products_hst, flat=True)
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibhr01020_drz.fits to ./ibhr01020_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibhr13030_drz.fits to ./ibhr13030_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibhr13040_drz.fits to ./ibhr13040_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/iey929010_drz.fits to ./iey929010_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/iey929020_drz.fits to ./iey929020_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/j6jt05011_drz.fits to ./j6jt05011_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/j6jt05021_drz.fits to ./j6jt05021_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbhr01010_drz.fits to ./jbhr01010_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbhr13010_drz.fits to ./jbhr13010_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbhr13020_drz.fits to ./jbhr13020_drz.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbhv02010_drz.fits to ./jbhv02010_drz.fits ...
[Done]
Local Path | Status | Message | URL |
---|---|---|---|
str20 | str8 | object | object |
./ibhr01020_drz.fits | COMPLETE | None | None |
./ibhr13030_drz.fits | COMPLETE | None | None |
./ibhr13040_drz.fits | COMPLETE | None | None |
./iey929010_drz.fits | COMPLETE | None | None |
./iey929020_drz.fits | COMPLETE | None | None |
./j6jt05011_drz.fits | COMPLETE | None | None |
./j6jt05021_drz.fits | COMPLETE | None | None |
./jbhr01010_drz.fits | COMPLETE | None | None |
./jbhr13010_drz.fits | COMPLETE | None | None |
./jbhr13020_drz.fits | COMPLETE | None | None |
./jbhv02010_drz.fits | COMPLETE | None | None |
Each FITS file has a corresponding filter in the table above under the filter
column. To create a color image, we’ll choose three images that overlap coordinates and have different filters.
The following images were picked based on if they overlapped in the AstroView of the MAST Portal.
# Opening three different filters
img1 = fits.open("j6jt05011_drz.fits")
img1_wcs = WCS(img1[1].header)
img2 = fits.open("j6jt05021_drz.fits")
img2_wcs = WCS(img2[1].header)
img3 = fits.open("iey929020_drz.fits")
img3_wcs = WCS(img3[1].header)
Plotting the HST Images#
We’ll now set up a subplot of the three images we chose. The first two images were taken as a pair of images (hence the small whitespace in the center). You can see the overlap in all three images where there’s a fairly consistent cluster of five galaxy sources. While the shapes of these galaxies aren’t very clear in these images, they’ll become more distinct when we create the color image!
# Set up figure
fig = plt.figure(figsize=(15, 8))
# First image
ax1 = fig.add_subplot(1, 3, 1, projection=img1_wcs)
ax1.imshow(img1[1].data, cmap="Greys_r", vmin=0, vmax=2.5, origin="lower")
ax1.set_title(f"{img1[0].header['INSTRUME']}/{img1[0].header['FILTER1']}")
ax1.set_ylabel("Declination")
ax1.set_xlabel("Right Ascension")
# Second image
ax2 = fig.add_subplot(1, 3, 2, projection=img2_wcs)
ax2.imshow(img2[1].data, cmap="Greys_r", vmin=0, vmax=2.5, origin="lower")
ax2.set_title(f"{img2[0].header['INSTRUME']}/{img2[0].header['FILTER1']}")
ax2.set_ylabel("Declination")
ax2.set_xlabel("Right Ascension")
# Third image
ax3 = fig.add_subplot(1, 3, 3, projection=img3_wcs)
ax3.imshow(img3[1].data, cmap="Greys_r", vmin=0, vmax=2.5, origin="lower")
ax3.set_title(f"{img3[0].header['INSTRUME']}/{img3[0].header['FILTER']}")
ax3.set_ylabel("Declination")
ax3.set_xlabel("Right Ascension")
plt.tight_layout()
plt.show()

Colorizing the HST Image of Abell 2199#
In order to create a color image of Abell 2199, we can assign red, green, and blue to each image, then combine the three images. We must choose the image with the largest pixel dimensions, and then project the other images onto it.
# Checking the shape of each image to determine which ones will be mapped onto the other
print(f"Shape of image 1: {img1[1].data.shape}")
print(f"Shape of image 2: {img2[1].data.shape}")
print(f"Shape of image 3: {img3[1].data.shape}")
Shape of image 1: (4239, 4213)
Shape of image 2: (4238, 4212)
Shape of image 3: (4446, 4130)
The third image appears to have the largest dimensions, so we’ll project the first and second images onto the third using reproject
. We’ll assign the first image to red, the second to blue, and the third to green.
# image 1 -> red
r, _ = reproject.reproject_interp(img1[1], img3[1].header)
# image 2 -> green
g, _ = reproject.reproject_interp(img2[1], img3[1].header)
# image 3 -> blue
b, _ = reproject.reproject_interp(img3[1], img3[1].header)
Using a ratio of red, blue, and green, we can now make a colorized image using make_lupton_rgb
!
image_hst = make_lupton_rgb(r * 3.8, g * 0.2, b * 0.65, Q=4, stretch=0.75)
/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/astropy/visualization/basic_rgb.py:153: RuntimeWarning: invalid value encountered in cast
return image_rgb.astype(output_dtype)
# Plotting the colorized image
plt.figure(figsize=(5, 5))
# Ensuring the coordinates are set to the WCS of the third image
ax = plt.subplot(projection=img3_wcs)
ax.imshow(image_hst)
# Zoom in
ax.set_xlim(1400, 2100)
ax.set_ylim(2200, 2900)
ax.set_xlabel("Right Ascension")
ax.set_ylabel("Declination")
ax.set_title("Colorized Image of Abell 2199")
ax.legend()
plt.tight_layout()
plt.show()
/tmp/ipykernel_2138/2518464466.py:15: UserWarning: No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
ax.legend()
/tmp/ipykernel_2138/2518464466.py:16: UserWarning: Tight layout not applied. The left and right margins cannot be made large enough to accommodate all Axes decorations.
plt.tight_layout()

End of Tutorial#
Congratulations, you’ve reached the end of this notebook! You’ve learned how to use astroquery.MAST
to calculate Hubble’s constant from eBOSS data and make a colorized image from HST data!
Additional Resources#
Additional resources are linked below:
Citations#
If you use data from MAST for published research, please see the following links for information on which citations to include in your paper:
About this Notebook#
Author(s): Natalie Haugen (nhaugen@terpmail.umd.edu) and Julie Imig (jimig@stsci.edu)
Keyword(s): Tutorial, eBOSS, HST, SDSS, galaxies
First published: July 2025
Last updated: July 2025