@@ -326,7 +326,8 @@ def query_object_async(self, object_name, catalog=None, radius=None,
326326 def query_region_async (self , coordinates , radius = None , inner_radius = None ,
327327 width = None , height = None , catalog = None ,
328328 get_query_payload = False , cache = True ,
329- return_type = 'votable' , column_filters = {}):
329+ return_type = 'votable' , column_filters = {},
330+ frame = 'fk5' ):
330331 """
331332 Serves the same purpose as `query_region` but only
332333 returns the HTTP response rather than the parsed result.
@@ -357,35 +358,52 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
357358 column_filters: dict, optional
358359 Constraints on columns of the result. The dictionary contains
359360 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.
360365
361366 Returns
362367 -------
363368 response : `requests.Response`
364369 The response of the HTTP request.
365370
366371 """
372+ if frame not in ('galactic' , 'fk5' , 'icrs' ):
373+ raise ValueError ("Only the 'galactic', 'icrs', and 'fk5' frames are supported by VizieR" )
367374 catalog = VizierClass ._schema_catalog .validate (catalog )
368375 center = {}
369376 columns = []
370377
371378 # Process coordinates
372379 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 )
374381
375- if not c .isscalar :
382+ if not target .isscalar :
376383 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 )]
383395 columns += ["_q" ] # Always request reference to input table
384396 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 )
389407 elif isinstance (coordinates , tbl .Table ):
390408 if (("_RAJ2000" in coordinates .keys ()) and ("_DEJ2000" in
391409 coordinates .keys ())):
0 commit comments