Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions tutorials/spherex/spherex_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jupytext:
format_version: 0.13
jupytext_version: 1.17.2
kernelspec:
name: python3
display_name: Python 3 (ipykernel)
language: python
name: python3
---

# Introduction to SPHEREx Spectral Images
Expand Down Expand Up @@ -58,7 +58,7 @@ from astropy.table import Table
from astropy import units as u
from astropy.coordinates import SkyCoord

import pyvo
from astroquery.ipac.irsa import Irsa
from pyvo.dal.adhoc import DatalinkResults

from firefly_client import FireflyClient
Expand All @@ -73,31 +73,31 @@ Define some coordinates of interest.
```{code-cell} ipython3
ra_deg = 304.693508808
dec_deg = 42.4436872991

coord = SkyCoord(ra_deg, dec_deg, unit='deg')
search_radius = 1 * u.arcsec
```

Query IRSA for a list of Spectral Image MEFs that overlap this position.
Query IRSA for a list of Spectral Image MEFs that overlap this position. We use the [IRSA module in astroquery](https://astroquery.readthedocs.io/en/latest/ipac/irsa/irsa.html) and the Simple Image Access API.

```{code-cell} ipython3
# Define the TAP service URL for IRSA
tap_url = "https://irsa.ipac.caltech.edu/TAP"
+++

# Connect to the TAP service
service = pyvo.dal.TAPService(tap_url)
```{tip}
The IRSA SIA collections can be listed using using the ``list_collections`` method, we can filter on the ones containing "spherex" in the collection name:

# Define your ADQL query
query = "SELECT * FROM spherex.obscore WHERE CONTAINS(POINT('ICRS',"+str(ra_deg)+","+str(dec_deg)+"), s_region)=1"
Irsa.list_collections(filter='spherex')
```

# Submit the asynchronous query
job = service.submit_job(query)
+++

# Run the job (starts the query execution on the server)
job.run()
There are currently three collections available:

# Wait for the job to complete (polling)
job.wait(phases=["COMPLETED", "ERROR", "ABORTED"], timeout=300)
* `'spherex_qr'` -- the Quick Release Observations, for more information see [SPHEREx archive documentation at IRSA]().
* `'spherex_qr_cal'` -- the Quick Release Calibration products.
* `'spherex_qr_deep'` --
Comment on lines +95 to +97
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessworking here, @vandesai1 please provide guidence here.


# Capture the results
results = job.fetch_result()
```{code-cell} ipython3
results = Irsa.query_sia(pos=(coord, search_radius), collection='spherex_qr')
```

Each row of the results of your query represents a different spectral image.
Expand All @@ -112,10 +112,10 @@ len(results)
The query results provide a lot of metadata about each spectral image. These columns have standard names as defined by the IVOA. Let's list them:

```{code-cell} ipython3
list(results.fieldnames)
results.colnames
```

The 'access_url' column is particularly important because it tells you how to access the data. Let's look at the 'access_url' value for the first row:
The `'access_url'` column is particularly important because it tells you how to access the data. Let's look at the `'access_url'` value for the first row:

```{code-cell} ipython3
results['access_url'][0]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is draft as this line currently returns an incomplete HTTPS url rather than a datalink.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to have been fixed, at least in the sense that it is now returning a full url instead of a relative path.

>>> results = Irsa.query_sia(pos=(coord, search_radius), collection='spherex_qr')
>>> results['access_url'][0]
'https://irsa.ipac.caltech.edu/ibe/data/spherex/qr/level2/2025W20_2D/l2b-v12-2025-176/6/level2_2025W20_2D_0444_1D6_spx_l2b-v12-2025-176.fits'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's great news!

Expand Down
Loading