Skip to content
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

ENH: query_sia and query_ssa to return QTable #3252

Merged
merged 4 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ New Tools and Services
API changes
-----------


esa.euclid
^^^^^^^^^^^^

- New module to access the ESA Euclid Archive. [#3216]

- Tests remove temp directories. [#3226]

ipac.irsa
^^^^^^^^^

- ``query_sia`` now returns the results as an astropy QTable. [#3252]

mast
^^^^

Expand Down
22 changes: 12 additions & 10 deletions astroquery/ipac/irsa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@

Returns
-------
Results in `pyvo.dal.SIAResults` format.
result.to_table() in Astropy table format
Results in `~astropy.table.QTable` format.

"""
return self.sia.search(
results = self.sia.search(

Check warning on line 108 in astroquery/ipac/irsa/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/ipac/irsa/core.py#L108

Added line #L108 was not covered by tests
pos=pos,
band=band,
time=time,
Expand All @@ -126,6 +126,8 @@
maxrec=maxrec,
**kwargs)

return results.to_qtable()

Check warning on line 129 in astroquery/ipac/irsa/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/ipac/irsa/core.py#L129

Added line #L129 was not covered by tests

query_sia.__doc__ = query_sia.__doc__.replace('_SIA2_PARAMETERS', SIA2_PARAMETERS_DESC)

def query_ssa(self, *, pos=None, radius=None, band=None, time=None, collection=None):
Expand All @@ -151,17 +153,17 @@

Returns
-------
Results in `pyvo.dal.SSAResults` format.
result.to_table() in Astropy table format
Results in `~astropy.table.QTable` format.
"""

if radius is None:
diameter = None
else:
diameter = 2 * radius

return self.ssa.search(pos=pos, diameter=diameter, band=band, time=time,
format='all', collection=collection)
results = self.ssa.search(pos=pos, diameter=diameter, band=band, time=time,

Check warning on line 164 in astroquery/ipac/irsa/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/ipac/irsa/core.py#L164

Added line #L164 was not covered by tests
format='all', collection=collection)
return results.to_qtable()

Check warning on line 166 in astroquery/ipac/irsa/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/ipac/irsa/core.py#L166

Added line #L166 was not covered by tests

def list_collections(self, servicetype=None):
"""
Expand Down Expand Up @@ -302,10 +304,10 @@
Parameters
----------
full : bool
If True returns the full schema VOTable. If False returns a dictionary of the table names and
their description.
If True returns the full schema as a `~astropy.table.Table`.
If False returns a dictionary of the table names and their description.
"""
tap_tables = Irsa.query_tap("SELECT * FROM TAP_SCHEMA.tables")
tap_tables = Irsa.query_tap("SELECT * FROM TAP_SCHEMA.tables").to_table()

Check warning on line 310 in astroquery/ipac/irsa/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/ipac/irsa/core.py#L310

Added line #L310 was not covered by tests

if full:
return tap_tables
Expand Down
2 changes: 1 addition & 1 deletion astroquery/ipac/irsa/tests/test_irsa_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ def test_ssa(self):
coord = SkyCoord.from_name("Eta Carina")
result = Irsa.query_ssa(pos=coord)
assert len(result) > 260
collections = set(result.to_table()['dataid_collection'])
collections = set(result['dataid_collection'])
assert {'champ', 'iso_sws', 'sofia_forcast', 'sofia_great', 'spitzer_sha'}.issubset(collections)
10 changes: 5 additions & 5 deletions docs/ipac/irsa/irsa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Simple image access queries

`~astroquery.ipac.irsa.IrsaClass.query_sia` provides a way to access IRSA's Simple
Image Access VO service. In the following example we are looking for Spitzer
Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.table.Table`.
Enhanced Imaging products in the centre of the COSMOS field as a `~astropy.table.QTable`.

.. doctest-remote-data::

Expand All @@ -280,7 +280,7 @@ Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.tabl
>>> from astropy import units as u
>>>
>>> coord = SkyCoord('150.01d 2.2d', frame='icrs')
>>> spitzer_images = Irsa.query_sia(pos=(coord, 1 * u.arcmin), collection='spitzer_seip').to_table()
>>> spitzer_images = Irsa.query_sia(pos=(coord, 1 * u.arcmin), collection='spitzer_seip')

To list available collections for SIA queries, the
`~astroquery.ipac.irsa.IrsaClass.list_collections` method is provided, and
Expand Down Expand Up @@ -342,7 +342,7 @@ Now plot the cutout.
from astropy.wcs import WCS
import matplotlib.pyplot as plt
coord = SkyCoord('150.01d 2.2d', frame='icrs')
spitzer_images = Irsa.query_sia(pos=(coord, 1 * u.arcmin), collection='spitzer_seip').to_table()
spitzer_images = Irsa.query_sia(pos=(coord, 1 * u.arcmin), collection='spitzer_seip')
science_image = spitzer_images[spitzer_images['dataproduct_subtype'] == 'science'][0]
with fits.open(science_image['access_url'], use_fsspec=True) as hdul:
cutout = Cutout2D(hdul[0].section, position=coord, size=2 *
Expand All @@ -356,7 +356,7 @@ Simple spectral access queries

`~astroquery.ipac.irsa.IrsaClass.query_ssa` provides a way to access IRSA's Simple
Spectral Access VO service. In the following example we are looking for Spitzer
Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.table.Table`.
Enhanced Imaging products in the centre of the COSMOS field as a `~astropy.table.QTable`.

.. doctest-remote-data::

Expand All @@ -365,7 +365,7 @@ Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.tabl
>>> from astropy import units as u
>>>
>>> coord = pos = SkyCoord.from_name('Arp 220')
>>> arp220_spectra = Irsa.query_ssa(pos=coord).to_table()
>>> arp220_spectra = Irsa.query_ssa(pos=coord)

Without specifying the collection, the query returns results from multiple
collections. For example this target has spectra from SOFIA as well as from
Expand Down
Loading