@@ -379,7 +379,7 @@ def get_columns(self, table_name, *, only_names=True, verbose=False):
379
379
else :
380
380
return columns
381
381
382
- def query_observations (self , coordinate , radius , * , n_obs = 10 ):
382
+ def query_observations (self , coordinate , radius , * , n_obs = 10 , ** kwargs ):
383
383
"""
384
384
Get the observation IDs from a given region
385
385
@@ -391,6 +391,8 @@ def query_observations(self, coordinate, radius, *, n_obs=10):
391
391
the radius of the region
392
392
n_obs : int, optional
393
393
the number of observations
394
+ kwargs : dict
395
+ passed to `query_hsa_tap`
394
396
395
397
Returns
396
398
-------
@@ -405,7 +407,40 @@ def query_observations(self, coordinate, radius, *, n_obs=10):
405
407
f"where contains("
406
408
f"point('ICRS', hsa.v_active_observation.ra, hsa.v_active_observation.dec), "
407
409
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 )
409
444
410
445
411
446
HSA = HSAClass ()
0 commit comments