Skip to content

Commit 717d351

Browse files
authored
Allow a frame specification in query_region_async
The original `query_region_async` in the `VizierClass` always uses fk5 coordinates. This is OK for circular query, but limits box queries to boxes oriented along the equatorial axes. This change adds a parameter to `query_region_async` to allow the user to specify galactic coordinates: as a consequence, the returned queries will adopt boxes oriented along the galactic axes, as indicated in the ASU specification (and as tested).
1 parent ba0f0ed commit 717d351

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

astroquery/vizier/core.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ 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, cache=True,
328+
get_query_payload=False, frame='fk5', cache=True,
329329
return_type='votable', column_filters={}):
330330
"""
331331
Serves the same purpose as `query_region` but only
@@ -354,6 +354,9 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
354354
catalog : str or list, optional
355355
The catalog(s) which must be searched for this identifier.
356356
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.
357360
column_filters: dict, optional
358361
Constraints on columns of the result. The dictionary contains
359362
the column name as keys, and the constraints as values.
@@ -370,22 +373,35 @@ def query_region_async(self, coordinates, radius=None, inner_radius=None,
370373

371374
# Process coordinates
372375
if isinstance(coordinates, (commons.CoordClasses,) + six.string_types):
373-
c = commons.parse_coordinates(coordinates).transform_to('fk5')
376+
c = commons.parse_coordinates(coordinates).transform_to(frame)
374377

375378
if not c.isscalar:
376379
center["-c"] = []
377380
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+
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,
381385
precision=8, alwayssign=True)
382-
center["-c"] += ["{}{}".format(ra_deg, dec_deg)]
386+
center["-c"] += ["B{}{}".format(glon_deg, glat_deg)]
387+
else:
388+
ra_deg = pos.ra.to_string(unit="deg", decimal=True,
389+
precision=8)
390+
dec_deg = pos.dec.to_string(unit="deg", decimal=True,
391+
precision=8, alwayssign=True)
392+
center["-c"] += ["{}{}".format(ra_deg, dec_deg)]
383393
columns += ["_q"] # Always request reference to input table
384394
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)
395+
if frame == 'galactic':
396+
glon = c.l.to_string(unit='deg', decimal=True, precision=8)
397+
glat = c.b.to_string(unit="deg", decimal=True, precision=8,
398+
alwayssign=True)
399+
center["-c"] = "G{glon}{glat}".format(glon=glon, glat=glat)
400+
else:
401+
ra = c.ra.to_string(unit='deg', decimal=True, precision=8)
402+
dec = c.dec.to_string(unit="deg", decimal=True, precision=8,
403+
alwayssign=True)
404+
center["-c"] = "{ra}{dec}".format(ra=ra, dec=dec)
389405
elif isinstance(coordinates, tbl.Table):
390406
if (("_RAJ2000" in coordinates.keys()) and ("_DEJ2000" in
391407
coordinates.keys())):

0 commit comments

Comments
 (0)