Skip to content

Commit b816a7c

Browse files
authored
Bug fixes
Corrected the use of the 'B' prefix for galactic coordinates; now accepting only a limited set of strings for frame; other minor fixes.
1 parent d0e74fd commit b816a7c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

astroquery/vizier/core.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,9 @@ def query_object_async(self, object_name, catalog=None, radius=None,
325325

326326
def query_region_async(self, coordinates, radius=None, inner_radius=None,
327327
width=None, height=None, catalog=None,
328-
get_query_payload=False, frame='fk5', cache=True,
329-
return_type='votable', column_filters={}):
328+
get_query_payload=False, cache=True,
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.
@@ -354,19 +355,22 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
354355
catalog : str or list, optional
355356
The catalog(s) which must be searched for this identifier.
356357
If not specified, all matching catalogs will be searched.
357-
frame : str, optional
358-
The frame to use for the request: can be 'galactic' or 'fk5'.
359-
It influences the orientation of box requests.
360358
column_filters: dict, optional
361359
Constraints on columns of the result. The dictionary contains
362360
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.
363365
364366
Returns
365367
-------
366368
response : `requests.Response`
367369
The response of the HTTP request.
368370
369371
"""
372+
if frame not in ('galactic', 'fk5', 'icrs'):
373+
raise ValueError("Only the 'galactic', 'icrs', and 'fk5' frames are supported by VizieR")
370374
catalog = VizierClass._schema_catalog.validate(catalog)
371375
center = {}
372376
columns = []
@@ -379,14 +383,12 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
379383
center["-c"] = []
380384
for pos in c:
381385
if frame == 'galactic':
382-
glon_deg = pos.l.to_string(unit="deg", decimal=True,
383-
precision=8)
384-
glat_deg = pos.b.to_string(unit="deg", decimal=True,
385-
precision=8, alwayssign=True)
386-
center["-c"] += ["B{}{}".format(glon_deg, glat_deg)]
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)]
387390
else:
388-
ra_deg = pos.ra.to_string(unit="deg", decimal=True,
389-
precision=8)
391+
ra_deg = pos.ra.to_string(unit="deg", decimal=True, precision=8)
390392
dec_deg = pos.dec.to_string(unit="deg", decimal=True,
391393
precision=8, alwayssign=True)
392394
center["-c"] += ["{}{}".format(ra_deg, dec_deg)]
@@ -395,12 +397,12 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
395397
if frame == 'galactic':
396398
glon = c.l.to_string(unit='deg', decimal=True, precision=8)
397399
glat = c.b.to_string(unit="deg", decimal=True, precision=8,
398-
alwayssign=True)
400+
alwayssign=True)
399401
center["-c"] = "G{glon}{glat}".format(glon=glon, glat=glat)
400402
else:
401403
ra = c.ra.to_string(unit='deg', decimal=True, precision=8)
402404
dec = c.dec.to_string(unit="deg", decimal=True, precision=8,
403-
alwayssign=True)
405+
alwayssign=True)
404406
center["-c"] = "{ra}{dec}".format(ra=ra, dec=dec)
405407
elif isinstance(coordinates, tbl.Table):
406408
if (("_RAJ2000" in coordinates.keys()) and ("_DEJ2000" in

0 commit comments

Comments
 (0)