Skip to content

Commit 1ffae3e

Browse files
committed
ENH: adding filter kwarg for list_collections and list_catalogs
1 parent fb76dd6 commit 1ffae3e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

astroquery/ipac/irsa/core.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def query_ssa(self, *, pos=None, radius=None, band=None, time=None, collection=N
165165
format='all', collection=collection)
166166
return results.to_table()
167167

168-
def list_collections(self, servicetype=None):
168+
def list_collections(self, *, servicetype=None, filter=None):
169169
"""
170170
Return information of available IRSA SIAv2 collections to be used in ``query_sia`` queries.
171171
@@ -174,6 +174,8 @@ def list_collections(self, servicetype=None):
174174
servicetype : str or None
175175
Service type to list collections for. Returns all collections when not provided.
176176
Currently supported service types are: 'SIA', 'SSA'.
177+
filter : str or None
178+
If specified we only return collections with names containing the filter string.
177179
178180
Returns
179181
-------
@@ -198,8 +200,12 @@ def list_collections(self, servicetype=None):
198200
else:
199201
raise ValueError("if specified, servicetype should be 'SIA' or 'SSA'")
200202

201-
collections = self.query_tap(query=query)
202-
return collections.to_table()
203+
collections = self.query_tap(query=query).to_table()
204+
205+
if filter:
206+
mask = [filter in collection for collection in collections['collection']]
207+
collections = collections[mask]
208+
return collections
203209

204210
@deprecated_renamed_argument(("selcols", "cache", "verbose"), ("columns", None, None), since="0.4.7")
205211
def query_region(self, coordinates=None, *, catalog=None, spatial='Cone',
@@ -297,7 +303,7 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone',
297303
return response.to_table()
298304

299305
@deprecated_renamed_argument("cache", None, since="0.4.7")
300-
def list_catalogs(self, full=False, cache=False):
306+
def list_catalogs(self, *, full=False, filter=None, cache=False):
301307
"""
302308
Return information of available IRSA catalogs.
303309
@@ -306,9 +312,15 @@ def list_catalogs(self, full=False, cache=False):
306312
full : bool
307313
If True returns the full schema as a `~astropy.table.Table`.
308314
If False returns a dictionary of the table names and their description.
315+
filter : str or None
316+
If specified we only return catalogs with names containing the filter string.
309317
"""
310318
tap_tables = Irsa.query_tap("SELECT * FROM TAP_SCHEMA.tables").to_table()
311319

320+
if filter:
321+
mask = [filter in name for name in tap_tables['table_name']]
322+
tap_tables = tap_tables[mask]
323+
312324
if full:
313325
return tap_tables
314326
else:

0 commit comments

Comments
 (0)