astropy / astroquery

Functions and classes to access online data resources. Maintainers: @keflavich and @bsipocz and @ceb8
http://astroquery.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
706 stars 399 forks source link

Simple Gaia query trouble #2651

Closed dan-adi closed 1 year ago

dan-adi commented 1 year ago

Hi, I am learning to use Gaia-astroquery. I've tried a simple query but it doesn't work. My attempt:

from astroquery.gaia import Gaia

query = Gaia.launch_job_async("SELECT ra,dec \
FROM gaiadr3.gaia_source \
WHERE source_id = 'M101'")

table = query.get_results()
print(table)

The error I'm getting:

HTTPError: Error 500:
null

How do I query for a single object?

eerovaher commented 1 year ago

The way you wrote your query does work, but only if you know what is the source id of the object you are interested in. You can often look up source ids (and more) from e.g. Simbad. But M101 is a galaxy and the Gaia catalog contains only point sources, so the closest to what you might have in mind would be something like

>>> from astropy.coordinates import SkyCoord
>>> from astroquery.gaia import Gaia
>>> query_results = Gaia.cone_search_async(SkyCoord.from_name("M101"), radius="0.1 deg", columns=["ra", "dec"])
dan-adi commented 1 year ago

table = query.get_results()

I understand, thank you very much.