From ffd0c771964341ecea784d0b9a2999ce9c5e1b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 12 Dec 2024 20:49:51 -0800 Subject: [PATCH 1/4] ENH: adding servicetype kwarg to list_collection --- astroquery/ipac/irsa/core.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/astroquery/ipac/irsa/core.py b/astroquery/ipac/irsa/core.py index 8be1dda897..d24bbe5673 100644 --- a/astroquery/ipac/irsa/core.py +++ b/astroquery/ipac/irsa/core.py @@ -116,16 +116,29 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None, query_sia.__doc__ = query_sia.__doc__.replace('_SIA2_PARAMETERS', SIA2_PARAMETERS_DESC) - def list_collections(self): + def list_collections(self, servicetype='sia'): """ Return information of available IRSA SIAv2 collections to be used in ``query_sia`` queries. + Parameters + ---------- + servicetype : str or None + Service type to list collections for. + Currently supported ones are: 'SIA'. + Returns ------- collections : A `~astropy.table.Table` object. A table listing all the possible collections for IRSA SIA queries. """ - query = "SELECT DISTINCT collection from caom.observation ORDER by collection" + + servicetype = servicetype.upper() + + if servicetype == 'SIA': + query = "SELECT DISTINCT collection from caom.observation ORDER by collection" + else: + raise ValueError("servicetype should be 'sia'") + collections = self.query_tap(query=query) return collections.to_table() From b76d131068da58ce1887f216aa03ca728f8faaf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 31 Jan 2025 14:09:04 -0800 Subject: [PATCH 2/4] ENH: adding cached SIA and SSA collection queries --- astroquery/ipac/irsa/core.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/astroquery/ipac/irsa/core.py b/astroquery/ipac/irsa/core.py index d24bbe5673..a8eabb3ebb 100644 --- a/astroquery/ipac/irsa/core.py +++ b/astroquery/ipac/irsa/core.py @@ -116,15 +116,15 @@ def query_sia(self, *, pos=None, band=None, time=None, pol=None, query_sia.__doc__ = query_sia.__doc__.replace('_SIA2_PARAMETERS', SIA2_PARAMETERS_DESC) - def list_collections(self, servicetype='sia'): + def list_collections(self, servicetype=None): """ Return information of available IRSA SIAv2 collections to be used in ``query_sia`` queries. Parameters ---------- servicetype : str or None - Service type to list collections for. - Currently supported ones are: 'SIA'. + Service type to list collections for. Returns all collections when not provided. + Currently supported service types are: 'SIA', 'SSA'. Returns ------- @@ -134,10 +134,20 @@ def list_collections(self, servicetype='sia'): servicetype = servicetype.upper() - if servicetype == 'SIA': + if not servicetype: query = "SELECT DISTINCT collection from caom.observation ORDER by collection" + elif servicetype == 'SIA': + query = ("SELECT DISTINCT o.collection FROM caom.observation o " + "JOIN caom.plane p ON o.obsid = p.obsid " + "WHERE (p.dataproducttype = 'image' OR p.dataproducttype = 'cube') " + "order by collection") + elif servicetype == 'SSA': + query = ("SELECT DISTINCT o.collection FROM caom.observation o " + "JOIN caom.plane p ON o.obsid = p.obsid " + "WHERE (p.dataproducttype = 'spectrum' OR p.dataproducttype = 'cube') " + "order by collection") else: - raise ValueError("servicetype should be 'sia'") + raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'") collections = self.query_tap(query=query) return collections.to_table() From c9fd76a787d92e7a5252181b6b7f37740cd9a640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 12:25:55 -0800 Subject: [PATCH 3/4] TST: adding test for list_collections() servicetype --- astroquery/ipac/irsa/core.py | 26 +++++++++---------- .../ipac/irsa/tests/test_irsa_remote.py | 17 +++++++----- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/astroquery/ipac/irsa/core.py b/astroquery/ipac/irsa/core.py index a8eabb3ebb..1adf93437c 100644 --- a/astroquery/ipac/irsa/core.py +++ b/astroquery/ipac/irsa/core.py @@ -132,22 +132,22 @@ def list_collections(self, servicetype=None): A table listing all the possible collections for IRSA SIA queries. """ - servicetype = servicetype.upper() - if not servicetype: query = "SELECT DISTINCT collection from caom.observation ORDER by collection" - elif servicetype == 'SIA': - query = ("SELECT DISTINCT o.collection FROM caom.observation o " - "JOIN caom.plane p ON o.obsid = p.obsid " - "WHERE (p.dataproducttype = 'image' OR p.dataproducttype = 'cube') " - "order by collection") - elif servicetype == 'SSA': - query = ("SELECT DISTINCT o.collection FROM caom.observation o " - "JOIN caom.plane p ON o.obsid = p.obsid " - "WHERE (p.dataproducttype = 'spectrum' OR p.dataproducttype = 'cube') " - "order by collection") else: - raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'") + servicetype = servicetype.upper() + if servicetype == 'SIA': + query = ("SELECT DISTINCT o.collection FROM caom.observation o " + "JOIN caom.plane p ON o.obsid = p.obsid " + "WHERE (p.dataproducttype = 'image' OR p.dataproducttype = 'cube') " + "order by collection") + elif servicetype == 'SSA': + query = ("SELECT DISTINCT o.collection FROM caom.observation o " + "JOIN caom.plane p ON o.obsid = p.obsid " + "WHERE (p.dataproducttype = 'spectrum' OR p.dataproducttype = 'cube') " + "order by collection") + else: + raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'") collections = self.query_tap(query=query) return collections.to_table() diff --git a/astroquery/ipac/irsa/tests/test_irsa_remote.py b/astroquery/ipac/irsa/tests/test_irsa_remote.py index 1bba85fe91..47b345113e 100644 --- a/astroquery/ipac/irsa/tests/test_irsa_remote.py +++ b/astroquery/ipac/irsa/tests/test_irsa_remote.py @@ -67,13 +67,18 @@ def test_list_catalogs(self): # (at the time of writing there are 933 tables in the list). assert len(catalogs) > 900 - def test_list_collections(self): - collections = Irsa.list_collections() + @pytest.mark.parametrize('servicetype', (None, 'sia', 'ssa')) + def test_list_collections(self, servicetype): + collections = Irsa.list_collections(servicetype=servicetype) # Number of available collections may change over time, test only for significant drop. - # (at the time of writing there are 110 collections in the list). - assert len(collections) > 100 - assert 'spitzer_seip' in collections['collection'] - assert 'wise_allwise' in collections['collection'] + # (at the time of writing there are 104 SIA and 35 SSA collections in the list). + if servicetype == 'ssa': + assert len(collections) > 30 + assert 'sofia_exes' in collections['collection'] + else: + assert len(collections) > 100 + assert 'spitzer_seip' in collections['collection'] + assert 'wise_allwise' in collections['collection'] def test_tap(self): query = "SELECT TOP 5 ra,dec FROM cosmos2015" From a2e9b04295a41e8e746a1cfc507fe3d082afb645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 3 Feb 2025 14:28:49 -0800 Subject: [PATCH 4/4] DOC: adding docs and changelog --- CHANGES.rst | 6 ++++++ docs/ipac/irsa/irsa.rst | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 78a4d92caa..58e3e303e8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,12 @@ simbad Service fixes and enhancements ------------------------------ +ipac.irsa +^^^^^^^^^ + +- Adding the "servicetype" kwarg to list_collections to be able to list SIA + and SSA collections separately. [#3200] + ipac.nexsci.nasa_exoplanet_archive ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/ipac/irsa/irsa.rst b/docs/ipac/irsa/irsa.rst index 70259d931d..b6b103ffc6 100644 --- a/docs/ipac/irsa/irsa.rst +++ b/docs/ipac/irsa/irsa.rst @@ -234,13 +234,15 @@ Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.tabl To list available collections for SIA queries, the `~astroquery.ipac.irsa.IrsaClass.list_collections` method is provided, and -will return a `~astropy.table.Table`: +will return a `~astropy.table.Table`. You can use the ``servicetype`` +argument to filter for image or spectral collections using ``'SIA'`` or +``'SSA'`` respectively: .. doctest-remote-data:: >>> from astroquery.ipac.irsa import Irsa - >>> Irsa.list_collections() - + >>> Irsa.list_collections(servicetype='SIA') +
collection object ---------------------