|
| 1 | +--- |
| 2 | +jupytext: |
| 3 | + text_representation: |
| 4 | + extension: .md |
| 5 | + format_name: myst |
| 6 | + format_version: 0.13 |
| 7 | + jupytext_version: 1.18.1 |
| 8 | +kernelspec: |
| 9 | + name: python3 |
| 10 | + display_name: python3 |
| 11 | + language: python |
| 12 | +--- |
| 13 | + |
| 14 | +# Plot Spitzer IRS Spectra |
| 15 | + |
| 16 | +## Learning Goals |
| 17 | + |
| 18 | +By the end of this tutorial, you will be able to : |
| 19 | + |
| 20 | +- Discover which spectroscopy catalogs are available through IRSA’s Simple Spectral Access (SSA) service |
| 21 | +- Use Irsa.query_ssa() to search for spectra at specific sky positions |
| 22 | +- Retrieve and visualize infrared spectra from the IRSA archive |
| 23 | +- Adapt the workflow shown here to your own science use cases |
| 24 | + |
| 25 | +## Introduction |
| 26 | + |
| 27 | +In this tutorial we use a published sample of debris disk host stars to demonstrate how to search for and retrieve infrared spectra using IRSA’s SSA service. |
| 28 | +The targets are drawn from the catalog of debris disks compiled by Mittal et al. (2015, ApJ, 798, 87), which identifies stars exhibiting infrared excesses indicative of circumstellar dust. |
| 29 | +Debris disks trace the remnants of planet formation and are valuable probes of disk evolution, dust composition, and dynamical interactions with planets. |
| 30 | + |
| 31 | +Infrared spectroscopy is particularly powerful for studying debris disks because many of the diagnostic features of dust grains—such as silicate emission bands—appear at mid‑infrared wavelengths. |
| 32 | +The Spitzer Infrared Spectrograph (IRS) provides sensitive, low‑ and moderate‑resolution spectra in this regime, enabling measurements of dust temperature, composition, and structure. |
| 33 | +Querying the IRSA archive for Spitzer IRS observations allows us to connect published debris‑disk samples with archival spectroscopy and explore these systems in greater physical detail. |
| 34 | + |
| 35 | +### Instructions |
| 36 | + |
| 37 | +Feel free to adapt this notebook to your own targets and science goals. |
| 38 | +The functions and overall structure shown here are intended to be reusable for searching IRSA for spectra of interest using SSA. |
| 39 | + |
| 40 | +### Input |
| 41 | + |
| 42 | +- A list of sky positions (RA, Dec) |
| 43 | + |
| 44 | +### Output |
| 45 | + |
| 46 | +- Tables describing available spectra |
| 47 | +Optional plots of flux versus wavelength |
| 48 | + |
| 49 | +## Imports |
| 50 | + |
| 51 | +```{code-cell} ipython3 |
| 52 | +# Uncomment the next line to install dependencies if needed. |
| 53 | +# !pip install numpy matplotlib astropy "astroquery>=0.4.10" |
| 54 | +``` |
| 55 | + |
| 56 | +```{code-cell} ipython3 |
| 57 | +import numpy as np |
| 58 | +import matplotlib.pyplot as plt |
| 59 | +
|
| 60 | +from astropy.coordinates import SkyCoord |
| 61 | +import astropy.units as u |
| 62 | +from astropy.table import Table |
| 63 | +
|
| 64 | +from astroquery.vizier import Vizier |
| 65 | +from astroquery.ipac.irsa import Irsa |
| 66 | +
|
| 67 | +import warnings |
| 68 | +# suppress warnings about cache |
| 69 | +warnings.filterwarnings( |
| 70 | + "ignore", |
| 71 | + message="XDG_CACHE_HOME is set", |
| 72 | + category=UserWarning, |
| 73 | +) |
| 74 | +``` |
| 75 | + |
| 76 | +## 1. Exploring SSA catalogs available at IRSA |
| 77 | +Before querying for spectra, it is often useful to see which spectral collections are available through SSA. |
| 78 | +IRSA hosts spectra from multiple missions and instruments, each grouped into collections. |
| 79 | + |
| 80 | +```{code-cell} ipython3 |
| 81 | +Irsa.list_collections(servicetype='ssa') |
| 82 | +``` |
| 83 | + |
| 84 | +Each entry corresponds to a distinct spectral data collection (for example, Spitzer IRS enhanced products). |
| 85 | +You can use these collection names with `query_ssa(collection=...)` to control which archive holdings are searched. |
| 86 | +Users interested in other instruments or wavelength ranges are encouraged to explore this list and substitute a different collection name below. |
| 87 | + |
| 88 | ++++ |
| 89 | + |
| 90 | +## 2. Define the targets |
| 91 | + |
| 92 | +We begin by loading a published catalog of debris disk host stars from VizieR. |
| 93 | + |
| 94 | +```{code-cell} ipython3 |
| 95 | +vizier = Vizier() |
| 96 | +vizier.ROW_LIMIT = 150 # Override the default limit of 50 |
| 97 | +# VizieR catalog identifier for Mittal et al. (2015) |
| 98 | +mittal = "J/ApJ/798/87" |
| 99 | +
|
| 100 | +debris_disks = vizier.get_catalogs(mittal) |
| 101 | +``` |
| 102 | + |
| 103 | +### 2.1 Explore the target catalog |
| 104 | + |
| 105 | +Let’s inspect the contents of the returned catalog and identify the columns we need. |
| 106 | + |
| 107 | +```{code-cell} ipython3 |
| 108 | +debris_disks |
| 109 | +``` |
| 110 | + |
| 111 | +```{code-cell} ipython3 |
| 112 | +#we really want the first table, not the refs table |
| 113 | +debris_disks = debris_disks[0] |
| 114 | +debris_disks |
| 115 | +``` |
| 116 | + |
| 117 | +```{code-cell} ipython3 |
| 118 | +debris_disks.colnames |
| 119 | +``` |
| 120 | + |
| 121 | +## 3. Find IRSA spectroscopy |
| 122 | + |
| 123 | +Lets see if any of these debris disks have spectra in the IRSA archive |
| 124 | + |
| 125 | +```{code-cell} ipython3 |
| 126 | +# IRSA queries require sky coordinates, |
| 127 | +# so we convert the RA and Dec columns into a vectorized SkyCoord object. |
| 128 | +coords = SkyCoord(ra=debris_disks["_RA"], |
| 129 | + dec=debris_disks["_DE"], |
| 130 | + unit=u.deg, |
| 131 | + frame='icrs') |
| 132 | +
|
| 133 | +# Just to make this tutorial run faster, we will limit the number of debris disks |
| 134 | +coords = coords[0:10] |
| 135 | +``` |
| 136 | + |
| 137 | +The function below queries IRSA’s SSA service for Spitzer IRS enhanced spectra near each target position. |
| 138 | +It optionally plots the retrieved spectra and includes inline comments explaining each step. |
| 139 | + |
| 140 | +We provide this as a function so it can be easily lifted from this tutorial and used in your own work. |
| 141 | + |
| 142 | +```{code-cell} ipython3 |
| 143 | +def query_and_plot_spectra(positions, *, plot=True, verbose=True): |
| 144 | + """ |
| 145 | + Query IRSA for Spitzer IRS spectra near each target position using SSA. |
| 146 | +
|
| 147 | +
|
| 148 | + Parameters |
| 149 | + ---------- |
| 150 | + positions : astropy.coordinates.SkyCoord |
| 151 | + Vectorized SkyCoord object containing target positions. |
| 152 | + plot : bool, optional |
| 153 | + If True, generate plots of flux versus wavelength. |
| 154 | + verbose : bool, optional |
| 155 | + If True, print status messages about query results. |
| 156 | + """ |
| 157 | + # for each set of coordinates |
| 158 | + for i, sc in enumerate(positions): |
| 159 | + # Retrieve the target name from the debris disk catalog |
| 160 | + target_name = debris_disks["Name"][i] |
| 161 | +
|
| 162 | + # Query the IRSA SSA service around this position |
| 163 | + result = Irsa.query_ssa(pos=sc, |
| 164 | + radius=5*u.arcsec, |
| 165 | + collection='spitzer_irsenh') |
| 166 | +
|
| 167 | + # Handle cases with no available spectra |
| 168 | + if result is None or len(result) == 0: |
| 169 | + if verbose: |
| 170 | + print(f"No IRS spectra available for target {target_name}") |
| 171 | + continue |
| 172 | +
|
| 173 | + # Let the user know we have a winner |
| 174 | + if verbose: |
| 175 | + print(f"Found {len(result)} spectrum(s) for {target_name}") |
| 176 | +
|
| 177 | + # Loop through each spectrum returned for the object |
| 178 | + for j, row in enumerate(result): |
| 179 | +
|
| 180 | + # Each SSA row includes an access URL pointing to the spectrum |
| 181 | + spectrum_url = row['access_url'] |
| 182 | +
|
| 183 | + # Read the spectrum into an Astropy Table |
| 184 | + single_spec = Table.read(spectrum_url, format="ipac") |
| 185 | +
|
| 186 | + # If plotting is enabled, plot the spectrum. |
| 187 | + if plot: |
| 188 | + plt.figure() |
| 189 | + if len(result) > 1: |
| 190 | + label = row['ObsID'] if 'ObsID' in row.colnames else f"Spectrum {j+1}" |
| 191 | + plt.plot(single_spec['wavelength'], single_spec['flux_density'], label=label) |
| 192 | + else: |
| 193 | + plt.plot(single_spec['wavelength'], single_spec['flux_density']) |
| 194 | +
|
| 195 | + plt.xlabel("Wavelength (μm))") |
| 196 | + plt.ylabel("Flux ") |
| 197 | + plt.title(f"Spitzer IRS Spectrum for {target_name}") |
| 198 | +
|
| 199 | + # If more than one spectrum was found, add a legend |
| 200 | + if len(result) > 1: |
| 201 | + plt.legend() |
| 202 | +
|
| 203 | + plt.tight_layout() |
| 204 | + plt.show() |
| 205 | +``` |
| 206 | + |
| 207 | +```{code-cell} ipython3 |
| 208 | +query_and_plot_spectra(coords) |
| 209 | +``` |
| 210 | + |
| 211 | +## Acknowledgements |
| 212 | + |
| 213 | +- [IPAC-IRSA](https://irsa.ipac.caltech.edu/) |
| 214 | + |
| 215 | +## About this notebook |
| 216 | + |
| 217 | +**Authors:** IPAC Science Platform Team, including Troy Raen, Brigitta Sipőcz, Jessica Krick, Andreas Faisst, Vandana Desai |
| 218 | + |
| 219 | +**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or problems. |
| 220 | + |
| 221 | +**Updated:** 2026-01-13 |
| 222 | + |
| 223 | +**Runtime:** As of the date above, this notebook takes about 3 minutes to run to completion on a machine with 8GB RAM and 2 CPU. |
| 224 | +This runtime is heavily dependent on archive servers which means runtime will vary for users. |
| 225 | + |
| 226 | +**AI:** AI-based tools were used to assist in drafting and refining this tutorial, with all content reviewed and validated by the authors. |
0 commit comments