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]:

\[ v_{rad} = H_{0}d \]

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
Table masked=True length=5
intentTypeobs_collectionprovenance_nameinstrument_nameprojectfilterswavelength_regiontarget_nametarget_classificationobs_ids_ras_decdataproduct_typeproposal_picalib_levelt_mint_maxt_exptimeem_minem_maxobs_titlet_obs_releaseproposal_idproposal_typesequence_numbers_regionjpegURLdataURLdataRightsmtFlagsrcDenobsidobjID
str7str4str5str4str4str4str7str21str6str27float64float64str8str18int64float64float64float64float64float64str56float64str3str1int64str56str64str64str6boolfloat64str9str9
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 8061-58253-266QSOsdss_eboss_8061-58253-0266247.656179999999953.52345spectrumSDSS Collaboration358252.4298263888958253.448241550932700.2360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 247.6561799999999 53.52345 0.0002777777777777778mast:SDSS/eboss/8061/58253/0266/spec-image-8061-58253-0266.pngmast:SDSS/eboss/8061/58253/0266/full/spec-8061-58253-0266.fitsPUBLICFalsenan244271644725056406
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 10938-58514-216QSOsdss_eboss_10938-58514-0216222.1228332.679912spectrumSDSS Collaboration358514.4109143518558514.455417824073600.41360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 222.12283 32.679912 0.0002777777777777778mast:SDSS/eboss/10938/58514/0216/spec-image-10938-58514-0216.pngmast:SDSS/eboss/10938/58514/0216/full/spec-10938-58514-0216.fitsPUBLICFalsenan244271652725056425
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 8061-58253-504QSOsdss_eboss_8061-58253-0504245.769569999999954.336356spectrumSDSS Collaboration358252.4298263888958253.4482425925962700.2360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 245.7695699999999 54.336356 0.0002777777777777778mast:SDSS/eboss/8061/58253/0504/spec-image-8061-58253-0504.pngmast:SDSS/eboss/8061/58253/0504/full/spec-8061-58253-0504.fitsPUBLICFalsenan244271655725056433
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 10938-58514-697GALAXYsdss_eboss_10938-58514-0697221.6173834.345396spectrumSDSS Collaboration358514.4109143518558514.455418518523600.41360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 221.61738 34.345396 0.0002777777777777778mast:SDSS/eboss/10938/58514/0697/spec-image-10938-58514-0697.pngmast:SDSS/eboss/10938/58514/0697/full/spec-10938-58514-0697.fitsPUBLICFalsenan244271661725056449
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 8061-58253-287QSOsdss_eboss_8061-58253-0287247.5334152.881373spectrumSDSS Collaboration358252.4298263888958253.448241550932700.2360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 247.53341 52.881373 0.0002777777777777778mast:SDSS/eboss/8061/58253/0287/spec-image-8061-58253-0287.pngmast:SDSS/eboss/8061/58253/0287/full/spec-8061-58253-0287.fitsPUBLICFalsenan244271671725056472

The table above provides some basic information for each object:

  • s_ra and s_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 like sdss_eboss_{PLATE}-{MJD}-{FIBERID}.

  • target_classification: Indicates the type of object (QSO, STAR, or GALAXY).

  • t_min and t_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 be OPTICAL, since eBOSS observed in the optical wavelength range.

  • em_min and em_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 be spectrum.

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]
Table length=10
intentTypeobs_collectionprovenance_nameinstrument_nameprojectfilterswavelength_regiontarget_nametarget_classificationobs_ids_ras_decdataproduct_typeproposal_picalib_levelt_mint_maxt_exptimeem_minem_maxobs_titlet_obs_releaseproposal_idproposal_typesequence_numbers_regionjpegURLdataURLdataRightsmtFlagsrcDenobsidobjID
str7str4str5str4str4str4str7str21str6str27float64float64str8str18int64float64float64float64float64float64str56float64str3str1int64str56str64str64str6boolfloat64str9str9
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7563-56810-546GALAXYsdss_eboss_7563-56810-0546242.3854355.191924spectrumSDSS Collaboration356810.2333912037156810.2665409722252700.3360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 242.38543 55.191924 0.0002777777777777778mast:SDSS/eboss/7563/56810/0546/spec-image-7563-56810-0546.pngmast:SDSS/eboss/7563/56810/0546/full/spec-7563-56810-0546.fitsPUBLICFalsenan247778078731713673
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7562-56799-119GALAXYsdss_eboss_7562-56799-0119242.2354554.39303spectrumSDSS Collaboration356799.2660069444556799.310521990743600.38360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 242.23545 54.39303 0.0002777777777777778mast:SDSS/eboss/7562/56799/0119/spec-image-7562-56799-0119.pngmast:SDSS/eboss/7562/56799/0119/full/spec-7562-56799-0119.fitsPUBLICFalsenan246836643729532212
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7563-56810-66GALAXYsdss_eboss_7563-56810-0066246.354129999999953.987946spectrumSDSS Collaboration356810.2333912037156810.2665405092562700.3360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 246.3541299999999 53.987946 0.0002777777777777778mast:SDSS/eboss/7563/56810/0066/spec-image-7563-56810-0066.pngmast:SDSS/eboss/7563/56810/0066/full/spec-7563-56810-0066.fitsPUBLICFalsenan247778139731713984
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7564-56804-589GALAXYsdss_eboss_7564-56804-0589241.942254.987496spectrumSDSS Collaboration356804.2934953703756804.34944500.51360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 241.9422 54.987496 0.0002777777777777778mast:SDSS/eboss/7564/56804/0589/spec-image-7564-56804-0589.pngmast:SDSS/eboss/7564/56804/0589/full/spec-7564-56804-0589.fitsPUBLICFalsenan244576784725746454
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7562-56799-322GALAXYsdss_eboss_7562-56799-0322239.6423753.270835spectrumSDSS Collaboration356799.2660069444556799.310521990743600.38360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 239.64237 53.270835 0.0002777777777777778mast:SDSS/eboss/7562/56799/0322/spec-image-7562-56799-0322.pngmast:SDSS/eboss/7562/56799/0322/full/spec-7562-56799-0322.fitsPUBLICFalsenan246835989729530281
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7562-56799-946GALAXYsdss_eboss_7562-56799-0946242.2927655.442419spectrumSDSS Collaboration356799.2660069444556799.310522453713600.38360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 242.29276 55.442419 0.0002777777777777778mast:SDSS/eboss/7562/56799/0946/spec-image-7562-56799-0946.pngmast:SDSS/eboss/7562/56799/0946/full/spec-7562-56799-0946.fitsPUBLICFalsenan246835581729529394
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7565-56809-575GALAXYsdss_eboss_7565-56809-0575240.752155.295251spectrumSDSS Collaboration356809.2381828703756809.271344212962700.27360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 240.7521 55.295251 0.0002777777777777778mast:SDSS/eboss/7565/56809/0575/spec-image-7565-56809-0575.pngmast:SDSS/eboss/7565/56809/0575/full/spec-7565-56809-0575.fitsPUBLICFalsenan246919581729701420
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7564-56804-655GALAXYsdss_eboss_7564-56804-0655242.1561754.257776spectrumSDSS Collaboration356804.2934953703756804.34944500.51360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 242.15617 54.257776 0.0002777777777777778mast:SDSS/eboss/7564/56804/0655/spec-image-7564-56804-0655.pngmast:SDSS/eboss/7564/56804/0655/full/spec-7564-56804-0655.fitsPUBLICFalsenan244577089725747202
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7563-56810-647GALAXYsdss_eboss_7563-56810-0647242.9070254.704448spectrumSDSS Collaboration356810.2333912037156810.2665409722252700.3360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 242.90702 54.704448 0.0002777777777777778mast:SDSS/eboss/7563/56810/0647/spec-image-7563-56810-0647.pngmast:SDSS/eboss/7563/56810/0647/full/spec-7563-56810-0647.fitsPUBLICFalsenan247778318731714416
scienceSDSSeBOSSBOSSSDSSNoneOPTICALeBOSS 7563-56810-740GALAXYsdss_eboss_7563-56810-0740243.2800354.632292spectrumSDSS Collaboration356810.2333912037156810.2665409722252700.3360.01040.0Extended Baryon Oscillation Spectroscopic Survey (eBOSS)59554.0N/A----CIRCLE 243.28003 54.632292 0.0002777777777777778mast:SDSS/eboss/7563/56810/0740/spec-image-7563-56810-0740.pngmast:SDSS/eboss/7563/56810/0740/full/spec-7563-56810-0740.fitsPUBLICFalsenan247780260731720216

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
Table masked=True length=2170
obsIDobs_collectiondataproduct_typeobs_iddescriptiontypedataURIproductTypeproductGroupDescriptionproductSubGroupDescriptionproductDocumentationURLprojectprvversionproposal_idproductFilenamesizeparent_obsiddataRightscalib_levelfilters
str9str4str12str30str235str1str69str7str28str14str61str5str7str3str31int64str9str6int64str4
244093798SDSSspectrumsdss_eboss_10729-58248-0357Preview-FullSmast:SDSS/eboss/10729/58248/0357/spec-image-10729-58248-0357.pngPREVIEW------eBOSSDR17N/Aspec-image-10729-58248-0357.png33843244093798PUBLIC3None
244093798SDSSspectrumsdss_eboss_10729-58248-0357SDSS eBOSS lite spectrum file containing the combined spectrum and associated metadata but not the individual exposures.Smast:SDSS/eboss/10729/58248/0357/lite/spec-lite-10729-58248-0357.fitsSCIENCE--SPECTRAhttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSDR17N/Aspec-lite-10729-58248-0357.fits216000244093798PUBLIC3None
244093798SDSSspectrumsdss_eboss_10729-58248-0357SDSS eBOSS full spectrum file containing the combined spectrum, associated metadata, and the individual exposures.Smast:SDSS/eboss/10729/58248/0357/full/spec-10729-58248-0357.fitsSCIENCEMinimum Recommended ProductsSPECTRAhttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSDR17N/Aspec-10729-58248-0357.fits864000244093798PUBLIC3None
244093916SDSSspectrumsdss_eboss_10729-58248-0657Preview-FullSmast:SDSS/eboss/10729/58248/0657/spec-image-10729-58248-0657.pngPREVIEW------eBOSSDR17N/Aspec-image-10729-58248-0657.png39087244093916PUBLIC3None
244093916SDSSspectrumsdss_eboss_10729-58248-0657SDSS eBOSS lite spectrum file containing the combined spectrum and associated metadata but not the individual exposures.Smast:SDSS/eboss/10729/58248/0657/lite/spec-lite-10729-58248-0657.fitsSCIENCE--SPECTRAhttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSDR17N/Aspec-lite-10729-58248-0657.fits216000244093916PUBLIC3None
244093916SDSSspectrumsdss_eboss_10729-58248-0657SDSS eBOSS full spectrum file containing the combined spectrum, associated metadata, and the individual exposures.Smast:SDSS/eboss/10729/58248/0657/full/spec-10729-58248-0657.fitsSCIENCEMinimum Recommended ProductsSPECTRAhttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSDR17N/Aspec-10729-58248-0657.fits864000244093916PUBLIC3None
244094913SDSSspectrumsdss_eboss_10729-58248-0359Preview-FullSmast:SDSS/eboss/10729/58248/0359/spec-image-10729-58248-0359.pngPREVIEW------eBOSSDR17N/Aspec-image-10729-58248-0359.png34149244094913PUBLIC3None
244094913SDSSspectrumsdss_eboss_10729-58248-0359SDSS eBOSS lite spectrum file containing the combined spectrum and associated metadata but not the individual exposures.Smast:SDSS/eboss/10729/58248/0359/lite/spec-lite-10729-58248-0359.fitsSCIENCE--SPECTRAhttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSDR17N/Aspec-lite-10729-58248-0359.fits216000244094913PUBLIC3None
244094913SDSSspectrumsdss_eboss_10729-58248-0359SDSS eBOSS full spectrum file containing the combined spectrum, associated metadata, and the individual exposures.Smast:SDSS/eboss/10729/58248/0359/full/spec-10729-58248-0359.fitsSCIENCEMinimum Recommended ProductsSPECTRAhttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSDR17N/Aspec-10729-58248-0359.fits864000244094913PUBLIC3None
............................................................
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248379571PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248380187PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248380410PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248380534PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248380590PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248380647PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248380843PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248381352PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248381483PUBLIC3--
252830431SDSSmeasurementssdss_eboss_spallSDSS 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.Dmast:SDSS/eboss/spAll-v5_13_2.fitsSCIENCE--eBOSS Catalogshttps://outerspace.stsci.edu/display/SDSS/eBOSS+Data+ProductseBOSSv5_13_2N/AspAll-v5_13_2.fits15895373760248382373PUBLIC3--

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]:

\[ v = c \frac{(1+z)^2-1}{(1+z)^2+1} \]

Using error propagation, the error in redshift becomes:

\[ v_{err} = z_{err}|\frac{4c(1+z)}{((1+z)^2+1)^2}| \]
# 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()
../../../_images/45cef68c2268ce7f09c742184624c084e5252c75e04d613908317c968828df03.png

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:

\[ \frac{d_{1}}{d_{relative}} = \frac{1}{d_{norm}} \]

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()
../../../_images/0a1b6a295c65fa4e45cb1b74d3195054c13893e5a0bde01f2666989aae908691.png

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
Table masked=True length=77
intentTypeobs_collectionprovenance_nameinstrument_nameprojectfilterswavelength_regiontarget_nametarget_classificationobs_ids_ras_decdataproduct_typeproposal_picalib_levelt_mint_maxt_exptimeem_minem_maxobs_titlet_obs_releaseproposal_idproposal_typesequence_numbers_regionjpegURLdataURLdataRightsmtFlagsrcDenobsidobjIDobjID1distance
str7str3str8str13str3str6str8str21str69str9float64float64str8str21int64float64float64float64float64float64str110float64str5str12int64str1098str34str35str6boolfloat64str9str9str9float64
scienceHSTCALNICNICMOS/NIC3HSTF160WInfraredNGC6166-WF4GALAXY;ELLIPTICAL;BCMn4t204070247.179348166439.55485355641imageGeisler, Douglas350990.6648842650990.791909723583.8720721408.39999999999991809.4The Metallicity Distribution of the Globular Cluster Systems of Giant Elliptical Galaxies51356.532314777265GO--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.545485mast:HST/product/n4t204070_mos.jpgmast:HST/product/n4t204070_mos.fitsPUBLICFalsenan2486147810922811410922811473.05880201851693
scienceHSTCALNICNICMOS/NIC2HSTF160WInfraredABELL2199-SKYSCALIBRATION;SKY BACKGROUNDn4hd21030247.16000666539.47067612935imageTonry, John L.350799.9943922453750800.001336608795383.9900051408.39999999999991809.4The SBF Hubble Diagram51165.557835557453GO--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.464592mast:HST/product/n4hd21030_mos.jpgmast:HST/product/n4hd21030_mos.fitsPUBLICFalsenan24854837109244905109244905233.75097836993348
scienceHSTCALWFPCWFPC/PCHSTF555WOpticalNGC6166GALAXY;ELLIPTICAL;RADIO GALAXY;w10a0k03t247.160208055555639.55083305555556imageFaber, Sandra M.248912.79048677083548912.810162696761700.0490.4605.4CORES OF EARLY-TYPE GALAXIES49277.970347133912GO--POLYGON 247.16026223 39.55848068 247.16854576 39.55107914 247.158936 39.54468522 247.15065221 39.55208608 247.16026223 39.55848068mast:HST/product/w10a0k03t_c0f.jpgmast:HST/product/w10a0k03t_c0f.fitsPUBLICFalsenan2473406212157982912157982941.44383128973108
scienceHSTCALNICNICMOS/NIC3HSTF160WInfraredABELL2199-SKYSCALIBRATION;SKY BACKGROUNDn4hd21040247.133950531139.48167425652imageTonry, John L.350799.9943930555550800.02956019383.9900051408.39999999999991809.4The SBF Hubble Diagram51165.554826327453GO--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.469529mast:HST/product/n4hd21040_mos.jpgmast:HST/product/n4hd21040_mos.fitsPUBLICFalsenan24854838125025147125025147171.7010033904009
scienceHSTCALSTISSTIS/CCDHSTMIRVISOpticalANYUNIDENTIFIED;PARALLEL FIELDo4k1uq010247.233066759239.4324369098imageBaum, Stefi A.350990.4463177430650990.450299421296300.0nannanPOMS Test Proposal: STIS non-scripted parallel proposal50990.742604057908GO/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.fitsPUBLICFalsenan24916064361298289361298289425.4196862145258
scienceHSTCALSTISSTIS/CCDHSTMIRVISOpticalANYUNIDENTIFIED;PARALLEL FIELDo4k1w3010247.267113673439.44580006266imageBaum, Stefi A.350990.6666996180650990.67190813657400.0nannanPOMS Test Proposal: STIS non-scripted parallel proposal50990.742881837908GO/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.fitsPUBLICFalsenan24916087361298736361298736448.96962551989975
scienceHSTCALSTISSTIS/CCDHSTMIRVISOpticalANYUNIDENTIFIED;PARALLEL FIELDo4k1w1010247.241198016439.45178911856imageBaum, Stefi A.350990.64667665509550990.65188480324400.0nannanPOMS Test Proposal: STIS non-scripted parallel proposal50990.747604047908GO/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.fitsPUBLICFalsenan24916085361298749361298749383.40239361919663
scienceHSTCALSTISSTIS/CCDHSTMIRVISOpticalHI-LATITUDE-FIELDSTARo5hjmmvbq247.134254124439.46526553535imageBaum, Stefi A.251383.3382198726851383.3399559838150.0nannanPOMS Test Proposal: STIS non-scripted parallel proposal continuation V51383.697233678406ENG/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.fitsPUBLICFalsenan24458735361414815361414815243.90550319973354
scienceHSTCALACSACS/WFCHSTF475WOPTICALNGC-6166GALAXY;ELLIPTICALjbhr01010247.159912539.54200555556imageHarris, William Edgar355773.2838888078755773.4158446412045370.0390.0550.0Supermassive Star Clusters in Supergiant Galaxies: Tracing the Enrichment of the Earliest Stellar Systems56139.5413888612238GO--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.506421130000007mast:HST/product/jbhr01010_drz.jpgmast:HST/product/jbhr01010_drz.fitsPUBLICFalsenan248344027410333937410333930.0
.........................................................................................................
scienceHSTCALWF3WFC3/UVISHSTF336WOPTICALPS15AOT-SN2009EU-HOSTGALAXY;ELLIPTICALiey929010247.165451430439.55075434279imageKelsey, Lisa359933.1089899305659933.12674452546360.0305.8367.3Local Environments of Low-redshift Type Ia Supernova Siblings59933.4885880117194SNAP--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.522145629999855mast:HST/product/iey929010_drz.jpgmast:HST/product/iey929010_drz.fitsPUBLICFalsenan1064579667672381137672381130.0
scienceHSTCALACSACS/WFCHSTF814WOPTICALNGC6166GALAXY;ELLIPTICAL;LINERj6jt05020247.144313860439.56568924527imageFord, Holland352764.76780428240552764.77748040509700.0708.0959.0Massive Black Holes in Early Type Galaxies53131.429502349293GTO/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.534789040000064mast:HST/product/j6jt05021_drz.jpgmast:HST/product/j6jt05021_drz.fitsPUBLICFalsenan260914327851348947851348940.0
scienceHSTCALWFPC2WFPC2/PCHSTF673NOPTICAL3C338.0GALAXY;RADIO GALAXY;u2s07801t247.159379855939.54271951924imageSparks, William B.350048.45089189814550048.45436412037300.0670.86675.58Snapshots of 3CR Radio Galaxies50415.091863455957SNAP--POLYGON 247.1588745068656 39.54384182979161 247.15046986829364 39.551449716293796 247.16032049263436 39.55793939381302 247.16872670919946 39.5503338532899 247.1588745068656 39.54384182979161mast:HST/product/u2s07801t_drw.jpgmast:HST/product/u2s07801t_drw.fitsPUBLICFalsenan2456189878876684678876684639.4469579247626
scienceHSTCALWFPC2WFPC2/PCHSTF673NOPTICAL3C338.0GALAXY;RADIO GALAXY;u2s07802t247.159379855939.54271951924imageSparks, William B.350048.45644745370450048.45991967592300.0670.86675.58Snapshots of 3CR Radio Galaxies50415.095497695957SNAP--POLYGON 247.1588745068656 39.54384182979161 247.15046986829364 39.551449716293796 247.16032049263436 39.55793939381302 247.16872670919946 39.5503338532899 247.1588745068656 39.54384182979161mast:HST/product/u2s07802t_drw.jpgmast:HST/product/u2s07802t_drw.fitsPUBLICFalsenan2456189978877109478877109439.4469579247626
scienceHSTCALWFPC2WFPC2/PCHSTF606WOPTICALANYUNIDENTIFIED;PARALLEL FIELDu4k2m601r247.263953531639.51530930574imageCasertano, Stefano350990.4473850694450990.453172106485500.0510.89661.13POMS Test Proposal: WFII parallel archive proposal50990.632974447909GO/PAR--POLYGON 247.26529584017683 39.51484093361801 247.27765482259042 39.51184985808498 247.27379760950498 39.502314521624314 247.26144081752278 39.50530203906747 247.26529584017683 39.51484093361801mast:HST/product/u4k2m601r_drw.jpgmast:HST/product/u4k2m601r_drw.fitsPUBLICFalsenan24602332789739298789739298349.30898244486366
scienceHSTCALWFPC2WFPC2/PCHSTF606WOPTICALHIGHEXT-MEDIUMu4k2lz02r247.298047074539.52866341629imageCasertano, Stefano350990.6737739583350990.67956099537500.0510.89661.13POMS Test Proposal: WFII parallel archive proposal50990.747974477909GO/PAR--POLYGON 247.2993894074153 39.52819464989219 247.31174929014978 39.525199948201404 247.30788663478177 39.51566574427916 247.2955289412657 39.51865688704364 247.2993894074153 39.52819464989219mast:HST/product/u4k2lz02r_drw.jpgmast:HST/product/u4k2lz02r_drw.fitsPUBLICFalsenan24602316789745750789745750428.30333475443496
scienceHSTCALWFPC2WFPC2/PCHSTF606WOPTICALANYUNIDENTIFIED;PARALLEL FIELDu4k2m602r247.263266093839.51547482218imageCasertano, Stefano350990.4584961805550990.466598032406700.0510.89661.13POMS Test Proposal: WFII parallel archive proposal50990.633159637909GO/PAR--POLYGON 247.2646084101698 39.51500645775736 247.27696745093658 39.512015453275325 247.27311032077844 39.502480094631046 247.26075347050354 39.505467541033354 247.2646084101698 39.51500645775736mast:HST/product/u4k2m602r_drw.jpgmast:HST/product/u4k2m602r_drw.fitsPUBLICFalsenan24602333789745772789745772347.3089749576426
scienceHSTCALWFPC2WFPC2/PCHSTF300WUVHIGHEXT-MEDIUMu4k2ly04r247.271415541239.53482491055imageCasertano, Stefano350990.5959961805650990.612199884261400.0254.97328.99POMS Test Proposal: WFII parallel archive proposal50990.748587897909GO/PAR--POLYGON 247.27276176864666 39.53435065873066 247.28511525876343 39.53136396134659 247.28125839985375 39.521834221792595 247.2689065892541 39.52481973537812 247.27276176864666 39.53435065873066mast:HST/product/u4k2ly04r_drw.jpgmast:HST/product/u4k2ly04r_drw.fitsPUBLICFalsenan24602313789756114789756114351.64648648762767
scienceHSTCALWFPC2WFPC2/PCHSTF555WOPTICALNGC6166-CENTERGALAXY;ELLIPTICAL;BCMu4t20301r247.160477925339.54909217001imageGeisler, Douglas351383.3376562847251383.352702581021300.0472.26000000000005595.1The Metallicity Distribution of the Globular Cluster Systems of Giant Elliptical Galaxies51749.698402717265GO--POLYGON 247.16184361753605 39.54867518305677 247.17436379619448 39.546100335007374 247.17104405360607 39.53644599006302 247.15852636186068 39.53901759053526 247.16184361753605 39.54867518305677mast:HST/product/u4t20301r_drw.jpgmast:HST/product/u4t20301r_drw.fitsPUBLICFalsenan2460426478980540378980540340.95574336166708
scienceHSTCALSTISSTIS/CCDHSTG750LOPTICALANYUNIDENTIFIED;PARALLEL FIELDo4k1v9piq247.240511152239.45195450143spectrumBaum, Stefi A.250990.59837812550990.6125447916641224.0524.01027.0POMS Test Proposal: STIS non-scripted parallel proposal50990.743541617908GO/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.fitsPUBLICFalsenan24442445794180714794180714381.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
Table masked=True length=11
obsIDobs_collectiondataproduct_typeobs_iddescriptiontypedataURIproductTypeproductGroupDescriptionproductSubGroupDescriptionproductDocumentationURLprojectprvversionproposal_idproductFilenamesizeparent_obsiddataRightscalib_levelfilters
str9str3str8str37str67str1str97str9str28str11str1str8str20str5str52int64str9str6int64str9
24801640HSTimageibhr01020DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/ibhr01020_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALWF33.7.2 (Apr-15-2024)12238ibhr01020_drz.fits21793248024801640PUBLIC3F475W
24801653HSTimageibhr13030DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/ibhr13030_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALWF33.7.2 (Apr-15-2024)12238ibhr13030_drz.fits21763872024801653PUBLIC3F814W
24801654HSTimageibhr13040DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/ibhr13040_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALWF33.7.2 (Apr-15-2024)12238ibhr13040_drz.fits21763872024801654PUBLIC3F814W
24834402HSTimagejbhr01010DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/jbhr01010_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALACSDrizzlePac 3.9.112238jbhr01010_drz.fits21502368024834402PUBLIC3F475W
24834415HSTimagejbhr13010DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/jbhr13010_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALACSDrizzlePac 3.9.112238jbhr13010_drz.fits21485952024834415PUBLIC3F814W
24834416HSTimagejbhr13020DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/jbhr13020_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALACSDrizzlePac 3.9.112238jbhr13020_drz.fits21485952024834416PUBLIC3F814W
24834423HSTimagejbhv02010DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/jbhv02010_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALACSDrizzlePac 3.9.112220jbhv02010_drz.fits2356992024834423PUBLIC3F140LP
26091389HSTimagej6jt05010DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/j6jt05011_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALACSDrizzlePac 3.9.19293j6jt05011_drz.fits21445632026091389PUBLIC3FR656N
26091432HSTimagej6jt05020DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/j6jt05021_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALACSDrizzlePac 3.9.19293j6jt05021_drz.fits21435264026091432PUBLIC3F814W
106457965HSTimageiey929020DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/iey929020_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALWF33.7.2 (Apr-15-2024)17194iey929020_drz.fits220492800106457965PUBLIC3F625W
106457966HSTimageiey929010DADS DRZ file - Calibrated combined image ACS/WFC3/WFPC2/STISDmast:HST/product/iey929010_drz.fitsSCIENCEMinimum Recommended ProductsDRZ--CALWF33.7.2 (Apr-15-2024)17194iey929010_drz.fits220492800106457966PUBLIC3F336W
# 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]
Table length=11
Local PathStatusMessageURL
str20str8objectobject
./ibhr01020_drz.fitsCOMPLETENoneNone
./ibhr13030_drz.fitsCOMPLETENoneNone
./ibhr13040_drz.fitsCOMPLETENoneNone
./iey929010_drz.fitsCOMPLETENoneNone
./iey929020_drz.fitsCOMPLETENoneNone
./j6jt05011_drz.fitsCOMPLETENoneNone
./j6jt05021_drz.fitsCOMPLETENoneNone
./jbhr01010_drz.fitsCOMPLETENoneNone
./jbhr13010_drz.fitsCOMPLETENoneNone
./jbhr13020_drz.fitsCOMPLETENoneNone
./jbhv02010_drz.fitsCOMPLETENoneNone

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()
../../../_images/2c4b994a251287565ea2a85accc5bac5e3b3ae426f1eace5f68928dbbdbf0bd7.png

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()
../../../_images/f1925ace2a0e81aacbee0dbc1e89f3265a166ea0feb4c99ddba84709d2ce791c.png

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


Top of Page Space Telescope Logo