Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.3.8 (unreleased)
------------------

- GAIA: Default URL switched to DR2 and made configurable [#1112]
- TAP: Add tool to check for phase of background job [#1073]
- splatalogue: Move to https. Old HTTP post requests were broken [#1066,#1076]
- heasarc: Add additional functionality and expand query capabilities [#1047]
Expand Down
8 changes: 7 additions & 1 deletion astroquery/gaia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ class Conf(_config.ConfigNamespace):
"""
Configuration parameters for `astroquery.gaia`.
"""
pass

MAIN_GAIA_TABLE = _config.ConfigItem("gaiadr2.gaia_source",
"GAIA source data table")
MAIN_GAIA_TABLE_RA = _config.ConfigItem("ra",
"Name of RA parameter in table")
MAIN_GAIA_TABLE_DEC = _config.ConfigItem("dec",
"Name of Dec parameter in table")


conf = Conf()
Expand Down
85 changes: 38 additions & 47 deletions astroquery/gaia/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
from astropy import units
from astropy.units import Quantity

__all__ = ['Gaia', 'GaiaClass']
from . import conf

MAIN_GAIA_TABLE = "gaiadr1.gaia_source"
MAIN_GAIA_TABLE_RA = "ra"
MAIN_GAIA_TABLE_DEC = "dec"
__all__ = ['Gaia', 'GaiaClass']


class GaiaClass(object):

"""
Proxy class to default TapPlus object (pointing to Gaia Archive)
"""
MAIN_GAIA_TABLE = conf.MAIN_GAIA_TABLE
MAIN_GAIA_TABLE_RA = conf.MAIN_GAIA_TABLE_RA
MAIN_GAIA_TABLE_DEC = conf.MAIN_GAIA_TABLE_DEC

def __init__(self, tap_plus_handler=None):
if tap_plus_handler is None:
Expand Down Expand Up @@ -79,9 +80,8 @@ def load_table(self, table, verbose=False):
return self.__gaiatap.load_table(table, verbose)

def launch_job(self, query, name=None, output_file=None,
output_format="votable", verbose=False,
dump_to_file=False, upload_resource=None,
upload_table_name=None):
output_format="votable", verbose=False, dump_to_file=False,
upload_resource=None, upload_table_name=None):
"""Launches a synchronous job
TAP & TAP+

Expand All @@ -107,14 +107,13 @@ def launch_job(self, query, name=None, output_file=None,
-------
A Job object
"""
return self.__gaiatap.launch_job(query,
name=name,
output_file=output_file,
output_format=output_format,
verbose=verbose,
dump_to_file=dump_to_file,
upload_resource=upload_resource,
upload_table_name=upload_table_name)
return self.__gaiatap.launch_job(query, name=name,
output_file=output_file,
output_format=output_format,
verbose=verbose,
dump_to_file=dump_to_file,
upload_resource=upload_resource,
upload_table_name=upload_table_name)

def launch_job_async(self, query, name=None, output_file=None,
output_format="votable", verbose=False,
Expand Down Expand Up @@ -246,12 +245,12 @@ def __query_object(self, coordinate, radius=None, width=None, height=None,
heightQuantity = self.__getQuantityInput(height, "height")
widthDeg = widthQuantity.to(units.deg)
heightDeg = heightQuantity.to(units.deg)
query = "SELECT DISTANCE(POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","\
+ str(MAIN_GAIA_TABLE_DEC)+"), \
query = "SELECT DISTANCE(POINT('ICRS',"+str(self.MAIN_GAIA_TABLE_RA)+","\
+ str(self.MAIN_GAIA_TABLE_DEC)+"), \
POINT('ICRS',"+str(ra)+","+str(dec)+")) AS dist, * \
FROM "+str(MAIN_GAIA_TABLE)+" WHERE CONTAINS(\
POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","\
+ str(MAIN_GAIA_TABLE_DEC)+"),\
FROM "+str(self.MAIN_GAIA_TABLE)+" WHERE CONTAINS(\
POINT('ICRS',"+str(self.MAIN_GAIA_TABLE_RA)+","\
+ str(self.MAIN_GAIA_TABLE_DEC)+"),\
BOX('ICRS',"+str(ra)+","+str(dec)+", "+str(widthDeg.value)+", "\
+ str(heightDeg.value)+"))=1 \
ORDER BY dist ASC"
Expand Down Expand Up @@ -283,12 +282,8 @@ def query_object(self, coordinate, radius=None, width=None, height=None,
-------
The job results (astropy.table).
"""
return self.__query_object(coordinate,
radius,
width,
height,
async_job=False,
verbose=verbose)
return self.__query_object(coordinate, radius, width, height,
async_job=False, verbose=verbose)

def query_object_async(self, coordinate, radius=None, width=None,
height=None, verbose=False):
Expand All @@ -314,12 +309,8 @@ def query_object_async(self, coordinate, radius=None, width=None,
-------
The job results (astropy.table).
"""
return self.__query_object(coordinate,
radius,
width,
height,
async_job=True,
verbose=verbose)
return self.__query_object(coordinate, radius, width, height,
async_job=True, verbose=verbose)

def __cone_search(self, coordinate, radius, async_job=False,
background=False,
Expand Down Expand Up @@ -360,26 +351,26 @@ def __cone_search(self, coordinate, radius, async_job=False,
if radius is not None:
radiusQuantity = self.__getQuantityInput(radius, "radius")
radiusDeg = commons.radius_to_unit(radiusQuantity, unit='deg')
query = "SELECT DISTANCE(POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","\
+ str(MAIN_GAIA_TABLE_DEC)+"), \
query = "SELECT DISTANCE(POINT('ICRS',"+str(self.MAIN_GAIA_TABLE_RA)+","\
+ str(self.MAIN_GAIA_TABLE_DEC)+"), \
POINT('ICRS',"+str(ra)+","+str(dec)+")) AS dist, * \
FROM "+str(MAIN_GAIA_TABLE)+" WHERE CONTAINS(\
POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","+str(MAIN_GAIA_TABLE_DEC)+"),\
FROM "+str(self.MAIN_GAIA_TABLE)+" WHERE CONTAINS(\
POINT('ICRS',"+str(self.MAIN_GAIA_TABLE_RA)+","+str(self.MAIN_GAIA_TABLE_DEC)+"),\
CIRCLE('ICRS',"+str(ra)+","+str(dec)+", "+str(radiusDeg)+"))=1 \
ORDER BY dist ASC"
if async_job:
return self.__gaiatap.launch_job_async(query=query,
output_file=output_file,
output_format=output_format,
verbose=verbose,
dump_to_file=dump_to_file,
background=background)
output_file=output_file,
output_format=output_format,
verbose=verbose,
dump_to_file=dump_to_file,
background=background)
else:
return self.__gaiatap.launch_job(query=query,
output_file=output_file,
output_format=output_format,
verbose=verbose,
dump_to_file=dump_to_file)
output_file=output_file,
output_format=output_format,
verbose=verbose,
dump_to_file=dump_to_file)

def cone_search(self, coordinate, radius=None, output_file=None,
output_format="votable", verbose=False,
Expand Down Expand Up @@ -417,8 +408,8 @@ def cone_search(self, coordinate, radius=None, output_file=None,
dump_to_file=dump_to_file)

def cone_search_async(self, coordinate, radius=None, background=False,
output_file=None, output_format="votable", verbose=False,
dump_to_file=False):
output_file=None, output_format="votable",
verbose=False, dump_to_file=False):
"""Cone search sorted by distance (async)
TAP & TAP+

Expand Down