Skip to content

Commit 7bca604

Browse files
committed
add query_regions
1 parent 9143453 commit 7bca604

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

astroquery/esa/hsa/core.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def get_columns(self, table_name, *, only_names=True, verbose=False):
379379
else:
380380
return columns
381381

382-
def query_observations(self, coordinate, radius, *, n_obs=10):
382+
def query_observations(self, coordinate, radius, *, n_obs=10, **kwargs):
383383
"""
384384
Get the observation IDs from a given region
385385
@@ -391,6 +391,8 @@ def query_observations(self, coordinate, radius, *, n_obs=10):
391391
the radius of the region
392392
n_obs : int, optional
393393
the number of observations
394+
kwargs : dict
395+
passed to `query_hsa_tap`
394396
395397
Returns
396398
-------
@@ -405,7 +407,40 @@ def query_observations(self, coordinate, radius, *, n_obs=10):
405407
f"where contains("
406408
f"point('ICRS', hsa.v_active_observation.ra, hsa.v_active_observation.dec), "
407409
f"circle('ICRS', {coord.ra.degree},{coord.dec.degree},{r.to(u.deg).value}))=1")
408-
return self.query_hsa_tap(query)
410+
return self.query_hsa_tap(query, **kwargs)
411+
412+
413+
def query_region(self, coordinate, radius, *, n_obs=10, columns='*', **kwargs):
414+
"""
415+
Get the observation metadata from a given region
416+
417+
Parameters
418+
----------
419+
coordinate : string / `astropy.coordinates`
420+
the identifier or coordinates around which to query
421+
radius : int / `~astropy.units.Quantity`
422+
the radius of the region
423+
n_obs : int, optional
424+
the number of observations
425+
columns : str, optional
426+
the columns to retrieve from the data table
427+
kwargs : dict
428+
passed to `query_hsa_tap`
429+
430+
Returns
431+
-------
432+
A table object with the list of observations in the region
433+
"""
434+
r = radius
435+
if not isinstance(radius, u.Quantity):
436+
r = radius*u.deg
437+
coord = commons.parse_coordinates(coordinate).icrs
438+
439+
query = (f"select top {n_obs} {columns} from hsa.v_active_observation "
440+
f"where contains("
441+
f"point('ICRS', hsa.v_active_observation.ra, hsa.v_active_observation.dec), "
442+
f"circle('ICRS', {coord.ra.degree},{coord.dec.degree},{r.to(u.deg).value}))=1")
443+
return self.query_hsa_tap(query, **kwargs)
409444

410445

411446
HSA = HSAClass()

0 commit comments

Comments
 (0)