@@ -326,7 +326,8 @@ def query_object_async(self, object_name, catalog=None, radius=None,
326
326
def query_region_async (self , coordinates , radius = None , inner_radius = None ,
327
327
width = None , height = None , catalog = None ,
328
328
get_query_payload = False , cache = True ,
329
- return_type = 'votable' , column_filters = {}):
329
+ return_type = 'votable' , column_filters = {},
330
+ frame = 'fk5' ):
330
331
"""
331
332
Serves the same purpose as `query_region` but only
332
333
returns the HTTP response rather than the parsed result.
@@ -357,35 +358,52 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
357
358
column_filters: dict, optional
358
359
Constraints on columns of the result. The dictionary contains
359
360
the column name as keys, and the constraints as values.
361
+ frame : str, optional
362
+ The frame to use for the request. It should be 'fk5', 'icrs',
363
+ or 'galactic'. This choice influences the the orientation of
364
+ box requests.
360
365
361
366
Returns
362
367
-------
363
368
response : `requests.Response`
364
369
The response of the HTTP request.
365
370
366
371
"""
372
+ if frame not in ('galactic' , 'fk5' , 'icrs' ):
373
+ raise ValueError ("Only the 'galactic', 'icrs', and 'fk5' frames are supported by VizieR" )
367
374
catalog = VizierClass ._schema_catalog .validate (catalog )
368
375
center = {}
369
376
columns = []
370
377
371
378
# Process coordinates
372
379
if isinstance (coordinates , (commons .CoordClasses ,) + six .string_types ):
373
- c = commons .parse_coordinates (coordinates ).transform_to ('fk5' )
380
+ target = commons .parse_coordinates (coordinates ).transform_to (frame )
374
381
375
- if not c .isscalar :
382
+ if not target .isscalar :
376
383
center ["-c" ] = []
377
- for pos in c :
378
- ra_deg = pos .ra .to_string (unit = "deg" , decimal = True ,
379
- precision = 8 )
380
- dec_deg = pos .dec .to_string (unit = "deg" , decimal = True ,
381
- precision = 8 , alwayssign = True )
382
- center ["-c" ] += ["{}{}" .format (ra_deg , dec_deg )]
384
+ for pos in target :
385
+ if frame == 'galactic' :
386
+ glon_deg = pos .l .to_string (unit = "deg" , decimal = True , precision = 8 )
387
+ glat_deg = pos .b .to_string (unit = "deg" , decimal = True , precision = 8 ,
388
+ alwayssign = True )
389
+ center ["-c" ] += ["G{}{}" .format (glon_deg , glat_deg )]
390
+ else :
391
+ ra_deg = pos .ra .to_string (unit = "deg" , decimal = True , precision = 8 )
392
+ dec_deg = pos .dec .to_string (unit = "deg" , decimal = True ,
393
+ precision = 8 , alwayssign = True )
394
+ center ["-c" ] += ["{}{}" .format (ra_deg , dec_deg )]
383
395
columns += ["_q" ] # Always request reference to input table
384
396
else :
385
- ra = c .ra .to_string (unit = 'deg' , decimal = True , precision = 8 )
386
- dec = c .dec .to_string (unit = "deg" , decimal = True , precision = 8 ,
387
- alwayssign = True )
388
- center ["-c" ] = "{ra}{dec}" .format (ra = ra , dec = dec )
397
+ if frame == 'galactic' :
398
+ glon = target .l .to_string (unit = 'deg' , decimal = True , precision = 8 )
399
+ glat = target .b .to_string (unit = "deg" , decimal = True , precision = 8 ,
400
+ alwayssign = True )
401
+ center ["-c" ] = "G{glon}{glat}" .format (glon = glon , glat = glat )
402
+ else :
403
+ ra = target .ra .to_string (unit = 'deg' , decimal = True , precision = 8 )
404
+ dec = target .dec .to_string (unit = "deg" , decimal = True , precision = 8 ,
405
+ alwayssign = True )
406
+ center ["-c" ] = "{ra}{dec}" .format (ra = ra , dec = dec )
389
407
elif isinstance (coordinates , tbl .Table ):
390
408
if (("_RAJ2000" in coordinates .keys ()) and ("_DEJ2000" in
391
409
coordinates .keys ())):
0 commit comments