@@ -426,39 +426,18 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
426426 raise TypeError ("Coordinates must be one of: string, astropy "
427427 "coordinates, or table containing coordinates!" )
428428
429- # decide whether box or radius
430429 if radius is not None :
431- # is radius a disk or an annulus?
432430 if inner_radius is None :
433- radius = coord .Angle (radius )
434- unit , value = _parse_angle (radius )
435- key = "-c.r" + unit
436- center [key ] = value
431+ _ , unit_str , o_radius = _parse_angle (radius )
432+ center ["-c.r" + unit_str ] = str (o_radius )
437433 else :
438- i_radius = coord .Angle (inner_radius )
439- o_radius = coord .Angle (radius )
440- if i_radius .unit != o_radius .unit :
441- o_radius = o_radius .to (i_radius .unit )
442- i_unit , i_value = _parse_angle (i_radius )
443- o_unit , o_value = _parse_angle (o_radius )
444- key = "-c.r" + i_unit
445- center [key ] = "," .join ([str (i_value ), str (o_value )])
434+ unit , unit_str , i_radius = _parse_angle (inner_radius )
435+ o_radius = coord .Angle (radius ).to_value (unit )
436+ center ["-c.r" + unit_str ] = f"{ i_radius } ,{ o_radius } "
446437 elif width is not None :
447- # is box a rectangle or square?
448- if height is None :
449- width = coord .Angle (width )
450- unit , value = _parse_angle (width )
451- key = "-c.b" + unit
452- center [key ] = "x" .join ([str (value )] * 2 )
453- else :
454- w_box = coord .Angle (width )
455- h_box = coord .Angle (height )
456- if w_box .unit != h_box .unit :
457- h_box = h_box .to (w_box .unit )
458- w_unit , w_value = _parse_angle (w_box )
459- h_unit , h_value = _parse_angle (h_box )
460- key = "-c.b" + w_unit
461- center [key ] = "x" .join ([str (w_value ), str (h_value )])
438+ unit , unit_str , w_box = _parse_angle (width )
439+ h_box = w_box if height is None else coord .Angle (height ).to_value (unit )
440+ center ["-c.b" + unit_str ] = f"{ w_box } x{ h_box } "
462441 else :
463442 raise Exception (
464443 "At least one of radius, width/height must be specified" )
@@ -806,17 +785,15 @@ def _parse_angle(angle):
806785
807786 Returns
808787 -------
809- (unit, value) : tuple
810- formatted for Vizier.
788+ (unit, unit_str, value) : tuple
811789 """
812790 angle = coord .Angle (angle )
813- if angle .unit == u .arcsec :
814- unit , value = 's' , angle .value
815- elif angle .unit == u .arcmin :
816- unit , value = 'm' , angle .value
791+ if angle .unit is u .arcsec :
792+ return u . arcsec , "s" , angle .value
793+ elif angle .unit is u .arcmin :
794+ return u . arcmin , "m" , angle .value
817795 else :
818- unit , value = 'd' , angle .to (u .deg ).value
819- return unit , value
796+ return u .deg , "d" , angle .to_value (u .deg )
820797
821798
822799class VizierKeyword (list ):
0 commit comments