-
Notifications
You must be signed in to change notification settings - Fork 4
MAINT: switch pyvo obscore query with astroquery #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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'` -- | ||
|
||
# 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. | ||
|
@@ -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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, that's great news! |
||
|
There was a problem hiding this comment.
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.