@@ -231,10 +231,10 @@ def cone_search(self, coordinates, radius, filename=None,
231
231
232
232
Parameters
233
233
----------
234
- radius : float
235
- radius in arcmin of the cone_search
236
234
coordinates : astropy.coordinate, mandatory
237
235
coordinates of the center in the cone search
236
+ radius : float or quantity
237
+ radius in arcmin (int, float) or quantity of the cone_search
238
238
filename : str, default None
239
239
Path and name of the file to store the results.
240
240
If the filename is defined, the file will be
@@ -257,7 +257,10 @@ def cone_search(self, coordinates, radius, filename=None,
257
257
astropy.table.Table with the result of the cone_search
258
258
"""
259
259
coord = self ._getCoordInput (coordinates )
260
- radius_in_grades = Angle (radius , units .arcmin ).deg
260
+ if type (radius ) == int or type (radius ) == float :
261
+ radius_in_grades = Angle (radius , units .arcmin ).deg
262
+ else :
263
+ radius_in_grades = radius .to (units .deg ).value
261
264
ra = coord .ra .deg
262
265
dec = coord .dec .deg
263
266
query = "select o.observation_id, " \
@@ -312,8 +315,8 @@ def cone_search_criteria(self, radius, target=None,
312
315
313
316
Parameters
314
317
----------
315
- radius : float
316
- radius in arcmin of the cone_search
318
+ radius : float or quantity
319
+ radius in arcmin (int, float) or quantity of the cone_search
317
320
target : str, mandatory if no coordinates is provided
318
321
name of the target, that will act as center in the cone search
319
322
coordinates : astropy.coordinate, mandatory if no target is provided
@@ -377,16 +380,16 @@ def cone_search_criteria(self, radius, target=None,
377
380
raise TypeError ("Please use only target or coordinates as"
378
381
"parameter." )
379
382
if target :
380
- try :
381
- ra , dec = self ._query_tap_target (target )
382
- except Exception :
383
- raise ValueError ('This target cannot be resolved' )
383
+ ra , dec = self ._query_tap_target (target )
384
384
else :
385
385
coord = self ._getCoordInput (coordinates )
386
386
ra = coord .ra .deg
387
387
dec = coord .dec .deg
388
388
389
- radius_in_grades = Angle (radius , units .arcmin ).deg
389
+ if type (radius ) == int or type (radius ) == float :
390
+ radius_in_grades = Angle (radius , units .arcmin ).deg
391
+ else :
392
+ radius_in_grades = radius .to (units .deg ).value
390
393
cone_query = "1=CONTAINS(POINT('ICRS', pos.ra, pos.dec)," \
391
394
"CIRCLE('ICRS', {0}, {1}, {2}))" .\
392
395
format (str (ra ), str (dec ), str (radius_in_grades ))
@@ -401,17 +404,20 @@ def cone_search_criteria(self, radius, target=None,
401
404
return table
402
405
403
406
def _query_tap_target (self , target ):
404
- params = {"TARGET_NAME" : target ,
405
- "RESOLVER_TYPE" : "SN" ,
406
- "FORMAT" : "json" }
407
- target_response = self ._request ('GET' ,
408
- self .target_url ,
409
- cache = True ,
410
- params = params )
411
- target_result = target_response .json ()['data' ][0 ]
412
- ra = target_result ['RA_DEGREES' ]
413
- dec = target_result ['DEC_DEGREES' ]
414
- return ra , dec
407
+ try :
408
+ params = {"TARGET_NAME" : target ,
409
+ "RESOLVER_TYPE" : "SN" ,
410
+ "FORMAT" : "json" }
411
+ target_response = self ._request ('GET' ,
412
+ self .target_url ,
413
+ cache = True ,
414
+ params = params )
415
+ target_result = target_response .json ()['data' ][0 ]
416
+ ra = target_result ['RA_DEGREES' ]
417
+ dec = target_result ['DEC_DEGREES' ]
418
+ return ra , dec
419
+ except KeyError as e :
420
+ raise ValueError ("This target cannot be resolved" )
415
421
416
422
def query_metadata (self , output_format = 'votable' , verbose = False ):
417
423
return
@@ -582,14 +588,14 @@ def query_criteria(self, calibration_level=None,
582
588
"JOIN ehst.position as pos on p.plane_id = pos.plane_id"
583
589
if parameters :
584
590
query += " where({})" .format (" AND " .join (parameters ))
585
- table = self .query_hst_tap (query = query , async_job = async_job ,
586
- output_file = output_file ,
587
- output_format = output_format ,
588
- verbose = verbose )
589
591
if verbose :
590
592
log .info (query )
591
593
if get_query :
592
594
return query
595
+ table = self .query_hst_tap (query = query , async_job = async_job ,
596
+ output_file = output_file ,
597
+ output_format = output_format ,
598
+ verbose = verbose )
593
599
return table
594
600
595
601
def __get_calibration_level (self , calibration_level ):
0 commit comments