Skip to content

Commit 5606fd9

Browse files
authored
Merge pull request #3334 from bsipocz/ENH_irsa_no_metadata_tables
ENH: do not include image metadata tables in catalog list
2 parents a4770a9 + e3eca6e commit 5606fd9

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ imcce
5757
- Changing RuntimeError to NoResultsWarning when an empty result is
5858
returned. [#3307]
5959

60+
ipac.irsa
61+
^^^^^^^^^
62+
63+
- Fix ``list_catalogs`` to not include image metadata tables, only
64+
catalogs. The ``include_metadata_tables`` keyword argument allows opting
65+
in to return all TAP tables, including non-spatial and metadata ones,
66+
too. [#3334]
67+
6068
SIMBAD
6169
^^^^^^
6270

astroquery/ipac/irsa/core.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone',
304304
return response.to_table()
305305

306306
@deprecated_renamed_argument("cache", None, since="0.4.7")
307-
def list_catalogs(self, *, full=False, filter=None, cache=False):
307+
def list_catalogs(self, *, full=False, filter=None, include_metadata_tables=False, cache=False):
308308
"""
309309
Return information of available IRSA catalogs.
310310
@@ -316,8 +316,19 @@ def list_catalogs(self, *, full=False, filter=None, cache=False):
316316
filter : str or None
317317
If specified we only return catalogs when their catalog_name
318318
contains the filter string.
319+
include_metadata_tables : bool
320+
If True returns not just the catalogs but all table holdings including the image metadata tables.
321+
These are not suitable for spatial queries with e.g. ``query_region``.
319322
"""
320-
tap_tables = self.query_tap("SELECT * FROM TAP_SCHEMA.tables").to_table()
323+
324+
if include_metadata_tables:
325+
more_filtering = ""
326+
else:
327+
# Filter out non-spatial catalogs and metadata tables with
328+
# irsa_pos=y and irsa_dbms=21
329+
more_filtering = "WHERE irsa_dbms=21 AND irsa_pos='y'"
330+
331+
tap_tables = self.query_tap(f"SELECT * FROM TAP_SCHEMA.tables {more_filtering}").to_table()
321332

322333
if filter:
323334
mask = [filter in name for name in tap_tables['table_name']]

astroquery/ipac/irsa/tests/test_irsa_remote.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,26 @@ def test_list_columns(self):
7272
def test_list_catalogs(self):
7373
catalogs = Irsa.list_catalogs()
7474
# Number of available catalogs may change over time, test only for significant drop.
75-
# (at the time of writing there are 933 tables in the list).
76-
assert len(catalogs) > 900
75+
# (at the time of writing there are 521 catalogs in the list).
76+
assert len(catalogs) > 520
7777
assert isinstance(catalogs, dict)
7878

79+
catalogs_full = Irsa.list_catalogs(full=True)
80+
assert isinstance(catalogs_full, Table)
81+
7982
def test_list_catalogs_filter(self):
80-
spitzer_catalogs = Irsa.list_catalogs(filter='spitzer')
83+
allwise_catalogs = Irsa.list_catalogs(filter='allwise')
84+
85+
assert len(allwise_catalogs) == 4
86+
87+
def test_list_catalogs_metadata(self):
88+
catalogs = Irsa.list_catalogs(filter='wise')
89+
all_tables = Irsa.list_catalogs(filter='wise', include_metadata_tables=True)
90+
91+
assert len(catalogs) < len(all_tables)
8192

82-
assert len(spitzer_catalogs) == 142
93+
assert 'wise.wise_allwise_p3am_cdd' not in catalogs
94+
assert 'wise.wise_allwise_p3am_cdd' in all_tables
8395

8496
@pytest.mark.parametrize('servicetype', (None, 'sia', 'ssa'))
8597
def test_list_collections(self, servicetype):

docs/ipac/irsa/irsa.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,15 @@ available about the columns in a `~astropy.table.Table`.
234234
.. doctest-remote-data::
235235

236236
>>> from astroquery.ipac.irsa import Irsa
237-
>>> Irsa.list_columns(catalog="allwise_p3as_psd")
238-
{'designation': 'WISE source designation',
237+
>>> Irsa.list_columns(catalog="allwise_p3as_psd") # doctest: +IGNORE_OUTPUT
238+
{...
239+
'designation': 'WISE source designation',
239240
'ra': 'right ascension (J2000)',
240241
'dec': 'declination (J2000)',
241242
'sigra': 'uncertainty in RA',
242243
'sigdec': 'uncertainty in DEC',
243244
...
244-
'htm20': 'HTM20 spatial index key'}
245+
}
245246

246247

247248
Async queries
@@ -410,8 +411,9 @@ Spitzer.
410411

411412
>>> from astropy.table import unique
412413
>>> unique(arp220_spectra, keys='dataid_collection')['dataid_collection']
413-
<MaskedColumn name='dataid_collection' dtype='object' description='IVOA Identifier of collection' length=4>
414+
<MaskedColumn name='dataid_collection' dtype='object' description='IVOA Identifier of collection' length=5>
414415
goals
416+
herschel_herus
415417
sofia_fifils
416418
spitzer_irsenh
417419
spitzer_sha
@@ -425,7 +427,7 @@ will return a `~astropy.table.Table`.
425427

426428
>>> from astroquery.ipac.irsa import Irsa
427429
>>> Irsa.list_collections(servicetype='SSA')
428-
<Table length=35>
430+
<Table length=37>
429431
collection
430432
object
431433
------------------------
@@ -447,6 +449,7 @@ will return a `~astropy.table.Table`.
447449
irts
448450
iso_sws
449451
sofia_exes
452+
sofia_exes_enh
450453
sofia_fifils
451454
sofia_flitecam
452455
sofia_forcast
@@ -464,6 +467,7 @@ will return a `~astropy.table.Table`.
464467
spitzer_sha
465468
spitzer_sings
466469
spitzer_ssgss
470+
swas
467471

468472

469473
Other Configurations

0 commit comments

Comments
 (0)