Skip to content

Commit f3970e1

Browse files
jkrickbsipocz
authored andcommitted
Adding SSA tutorial
1 parent 0744811 commit f3970e1

1 file changed

Lines changed: 223 additions & 0 deletions

File tree

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
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 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. IRSA hosts spectra from multiple missions and instruments, each grouped into collections.
78+
79+
```{code-cell} ipython3
80+
Irsa.list_collections()
81+
```
82+
83+
Each entry corresponds to a distinct spectral data collection (for example, Spitzer IRS enhanced products). You can use these collection names with query_ssa(collection=...) to control which archive holdings are searched. Users interested in other instruments or wavelength ranges are encouraged to explore this list and substitute a different collection name below.
84+
85+
+++
86+
87+
## 2. Define the targets
88+
89+
We begin by loading a published catalog of debris disk host stars from VizieR.
90+
91+
```{code-cell} ipython3
92+
vizier = Vizier() # this instantiates Vizier with its default parameters
93+
vizier.ROW_LIMIT = 150
94+
# VizieR catalog identifier for Mittal et al. (2015)
95+
mittal = "J/ApJ/798/87"
96+
97+
debris_disks = vizier.get_catalogs(mittal)
98+
```
99+
100+
### 2.1 Explore the target catalog
101+
102+
Let’s inspect the contents of the returned catalog and identify the columns we need.
103+
104+
```{code-cell} ipython3
105+
debris_disks
106+
```
107+
108+
```{code-cell} ipython3
109+
#we really want the first table, not the refs table
110+
debris_disks = debris_disks[0]
111+
debris_disks
112+
```
113+
114+
```{code-cell} ipython3
115+
debris_disks.colnames
116+
```
117+
118+
## 3. Find IRSA spectroscopy
119+
120+
Lets see if any of these debris disks have spectra in the IRSA archive
121+
122+
```{code-cell} ipython3
123+
# IRSA queries require sky coordinates,
124+
# so we convert the RA and Dec columns into a vectorized SkyCoord object.
125+
coords = SkyCoord(ra=debris_disks["_RA"],
126+
dec=debris_disks["_DE"],
127+
unit=u.deg,
128+
frame='icrs')
129+
130+
# Just to make this tutorial run faster, we will limit the number of debris disks
131+
coords = coords[0:10]
132+
```
133+
134+
The function below queries IRSA’s SSA service for Spitzer IRS enhanced spectra near each target position. It optionally plots the retrieved spectra and includes inline comments explaining each step.
135+
136+
We provide this as a function so it can be easily lifted from this tutorial and used in your own work.
137+
138+
```{code-cell} ipython3
139+
def query_and_plot_spectra(positions, *, plot=True, verbose = True):
140+
"""
141+
Query IRSA for Spitzer IRS spectra near each target position using SSA.
142+
143+
144+
Parameters
145+
----------
146+
positions : astropy.coordinates.SkyCoord
147+
Vectorized SkyCoord object containing target positions.
148+
plot : bool, optional
149+
If True, generate plots of flux versus wavelength.
150+
verbose : bool, optional
151+
If True, print status messages about query results.
152+
"""
153+
#for each set of coordinates
154+
for i, sc in enumerate(positions):
155+
# Retrieve the target name from the debris disk catalog
156+
target_name = debris_disks["Name"][i]
157+
158+
# Query the IRSA SSA service around this position
159+
result = Irsa.query_ssa(pos=sc,
160+
radius=5*u.arcsec,
161+
collection='spitzer_irsenh')
162+
163+
# Handle cases with no available spectra
164+
if result is None or len(result) == 0:
165+
if verbose:
166+
print(f"No IRS spectra available for target {target_name}")
167+
continue
168+
169+
# Let the user know we have a winner
170+
if verbose:
171+
print(f"Found {len(result)} spectrum(s) for {target_name}")
172+
173+
# Loop through each spectrum returned for the object
174+
for j, row in enumerate(result):
175+
176+
# Each SSA row includes an access URL pointing to the spectrum
177+
spectrum_url = row['access_url']
178+
179+
# Read the spectrum into an Astropy Table
180+
single_spec = Table.read(spectrum_url, format="ipac")
181+
182+
# If plotting is enabled, plot the spectrum.
183+
if plot:
184+
plt.figure()
185+
if len(result) > 1:
186+
label = row['ObsID'] if 'ObsID' in row.colnames else f"Spectrum {j+1}"
187+
plt.plot(single_spec['wavelength'], single_spec['flux_density'], label=label)
188+
else:
189+
plt.plot(single_spec['wavelength'], single_spec['flux_density'])
190+
191+
plt.xlabel("Wavelength (μm))")
192+
plt.ylabel("Flux ")
193+
plt.title(f"Spitzer IRS Spectrum for {target_name}")
194+
195+
# If more than one spectrum was found, add a legend
196+
if len(result) > 1:
197+
plt.legend()
198+
199+
plt.tight_layout()
200+
plt.show()
201+
```
202+
203+
```{code-cell} ipython3
204+
query_and_plot_spectra(coords)
205+
```
206+
207+
## Acknowledgements
208+
209+
- [IPAC-IRSA](https://irsa.ipac.caltech.edu/)
210+
211+
## About this notebook
212+
213+
**Authors:** IPAC Science Platform Team, including Troy Raen, Brigitta Sipőcz, Jessica Krick, Andreas Faisst, Vandana Desai
214+
215+
**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions
216+
or problems.
217+
218+
**Updated:** 2026-01-13
219+
220+
**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. This runtime is
221+
heavily dependent on archive servers which means runtime will vary for users".)
222+
223+
**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

Comments
 (0)