@@ -298,7 +298,7 @@ def query_tap(self, query, *, maxrec=None):
298
298
True , True , True , False )
299
299
)
300
300
def query_region (self , position = None , catalog = None , radius = None , * ,
301
- spatial = 'cone' , width = None , polygon = None ,
301
+ spatial = 'cone' , width = None , polygon = None , add_offset = False ,
302
302
get_query_payload = False , columns = None , cache = False ,
303
303
verbose = False , maxrec = None ,
304
304
** kwargs ):
@@ -335,6 +335,10 @@ def query_region(self, position=None, catalog=None, radius=None, *,
335
335
outlining the polygon to search in. It can also be a list of
336
336
`astropy.coordinates` object or strings that can be parsed by
337
337
`astropy.coordinates.ICRS`.
338
+ add_offset: bool
339
+ If True and spatial=='cone', add a search_offset column that
340
+ indicates the separation (in arcmin) between the requested
341
+ coordinate and the entry coordinates in the catalog. Default is False.
338
342
get_query_payload : bool, optional
339
343
If `True` then returns the generated ADQL query as str.
340
344
Defaults to `False`.
@@ -399,9 +403,10 @@ def query_region(self, position=None, catalog=None, radius=None, *,
399
403
radius = coordinates .Angle (radius )
400
404
where = (" WHERE CONTAINS(POINT('ICRS',ra,dec),CIRCLE("
401
405
f"'ICRS',{ ra } ,{ dec } ,{ radius .to (u .deg ).value } ))=1" )
402
- # add search_offset_ for the case of cone
403
- columns += (",DISTANCE(POINT('ICRS',ra,dec), "
404
- f"POINT('ICRS',{ ra } ,{ dec } )) as search_offset_" )
406
+ # add search_offset for the case of cone
407
+ if add_offset :
408
+ columns += (",DISTANCE(POINT('ICRS',ra,dec), "
409
+ f"POINT('ICRS',{ ra } ,{ dec } )) as search_offset" )
405
410
elif spatial .lower () == 'box' :
406
411
if isinstance (width , str ):
407
412
width = coordinates .Angle (width )
@@ -423,8 +428,8 @@ def query_region(self, position=None, catalog=None, radius=None, *,
423
428
self ._catalog_name = catalog
424
429
425
430
table = response .to_table ()
426
- if 'search_offset_' in table . colnames :
427
- table ['search_offset_ ' ].unit = u .arcmin
431
+ if add_offset :
432
+ table ['search_offset ' ].unit = u .arcmin
428
433
if len (table ) == 0 :
429
434
warnings .warn (
430
435
NoResultsWarning ("No matching rows were found in the query." )
0 commit comments