Skip to content

Commit e58ae49

Browse files
authored
Merge pull request #3200 from bsipocz/ENH_irsa_collection_kwarg
ENH: IRSA: adding servicetype to list_collections
2 parents 1e8c4dd + 90a44d5 commit e58ae49

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ gaia
2121

2222
- Update DR4 retrieval_type names and include the new one EPOCH_ASTROMETRY_BRIGHT [#3207]
2323

24+
ipac.irsa
25+
^^^^^^^^^
26+
27+
- Adding the "servicetype" kwarg to ``list_collections`` to be able to list SIA
28+
and SSA collections separately. [#3200]
29+
2430
ipac.nexsci.nasa_exoplanet_archive
2531
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2632

astroquery/ipac/irsa/core.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,39 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None,
116116

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

119-
def list_collections(self):
119+
def list_collections(self, servicetype=None):
120120
"""
121121
Return information of available IRSA SIAv2 collections to be used in ``query_sia`` queries.
122122
123+
Parameters
124+
----------
125+
servicetype : str or None
126+
Service type to list collections for. Returns all collections when not provided.
127+
Currently supported service types are: 'SIA', 'SSA'.
128+
123129
Returns
124130
-------
125131
collections : A `~astropy.table.Table` object.
126132
A table listing all the possible collections for IRSA SIA queries.
127133
"""
128-
query = "SELECT DISTINCT collection from caom.observation ORDER by collection"
134+
135+
if not servicetype:
136+
query = "SELECT DISTINCT collection from caom.observation ORDER by collection"
137+
else:
138+
servicetype = servicetype.upper()
139+
if servicetype == 'SIA':
140+
query = ("SELECT DISTINCT o.collection FROM caom.observation o "
141+
"JOIN caom.plane p ON o.obsid = p.obsid "
142+
"WHERE (p.dataproducttype = 'image' OR p.dataproducttype = 'cube') "
143+
"order by collection")
144+
elif servicetype == 'SSA':
145+
query = ("SELECT DISTINCT o.collection FROM caom.observation o "
146+
"JOIN caom.plane p ON o.obsid = p.obsid "
147+
"WHERE (p.dataproducttype = 'spectrum' OR p.dataproducttype = 'cube') "
148+
"order by collection")
149+
else:
150+
raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'")
151+
129152
collections = self.query_tap(query=query)
130153
return collections.to_table()
131154

astroquery/ipac/irsa/tests/test_irsa_remote.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,18 @@ def test_list_catalogs(self):
6767
# (at the time of writing there are 933 tables in the list).
6868
assert len(catalogs) > 900
6969

70-
def test_list_collections(self):
71-
collections = Irsa.list_collections()
70+
@pytest.mark.parametrize('servicetype', (None, 'sia', 'ssa'))
71+
def test_list_collections(self, servicetype):
72+
collections = Irsa.list_collections(servicetype=servicetype)
7273
# Number of available collections may change over time, test only for significant drop.
73-
# (at the time of writing there are 110 collections in the list).
74-
assert len(collections) > 100
75-
assert 'spitzer_seip' in collections['collection']
76-
assert 'wise_allwise' in collections['collection']
74+
# (at the time of writing there are 104 SIA and 35 SSA collections in the list).
75+
if servicetype == 'ssa':
76+
assert len(collections) > 30
77+
assert 'sofia_exes' in collections['collection']
78+
else:
79+
assert len(collections) > 100
80+
assert 'spitzer_seip' in collections['collection']
81+
assert 'wise_allwise' in collections['collection']
7782

7883
def test_tap(self):
7984
query = "SELECT TOP 5 ra,dec FROM cosmos2015"

docs/ipac/irsa/irsa.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.tabl
234234

235235
To list available collections for SIA queries, the
236236
`~astroquery.ipac.irsa.IrsaClass.list_collections` method is provided, and
237-
will return a `~astropy.table.Table`:
237+
will return a `~astropy.table.Table`. You can use the ``servicetype``
238+
argument to filter for image or spectral collections using ``'SIA'`` or
239+
``'SSA'`` respectively:
238240

239241
.. doctest-remote-data::
240242

241243
>>> from astroquery.ipac.irsa import Irsa
242-
>>> Irsa.list_collections()
243-
<Table length=124>
244+
>>> Irsa.list_collections(servicetype='SIA')
245+
<Table length=104>
244246
collection
245247
object
246248
---------------------

0 commit comments

Comments
 (0)