5
$\begingroup$

I've been trying to find this out for a while now, but I'm making zero progress. I really struggle to find good documentation for the query language, and even in the astroquery library I can't find out how to do it. I've worked with a lot of APIs before, but this seems rather arcane to me. I've tried using the search on Gaia's own site, but the query language there is even more confusing. And nowhere on this site can I find anything about what I'm trying to do.

Any help is appreciated.

$\endgroup$

1 Answer 1

7
$\begingroup$

I faced this issue recently, and the solution I came up with was to write a custom query using the ADQL documentation and then use astroquery to process the query.

import astroquery.gaia

num_stars = 10

query = f"""SELECT TOP {num_stars} dr3.ra, dr3.dec, dr3.phot_g_mean_mag, dr3.distance_gspphot
FROM gaiadr3.gaia_source as dr3
ORDER BY dr3.distance_gspphot ASC
"""

job = astroquery.gaia.Gaia.launch_job(query)

table = job.get_results()

print(table)

which outputs

        ra                dec         phot_g_mean_mag distance_gspphot
       deg                deg               mag              pc       
------------------ ------------------ --------------- ----------------
217.39232147200883 -62.67607511676666        8.984749           1.3011
269.44850252543836  4.739420051112412       8.1939745           1.8275
165.83095967577933 35.948653032660104        6.551172           2.5453
 282.4587890175222 -23.83709744872712        9.126414           2.9762
 53.22829341517546 -9.458168216292322        3.465752           3.2179
 346.5039166796005  -35.8471642082214       6.5220323           3.2877
176.93768799004127 0.7991199702364985           9.601           3.3731
 316.7484792940004  38.76386244649797        4.766713           3.4904
  316.753662752556  38.75607277205679       5.4506445           3.4947
 280.6830708352289 59.638357907754816        7.854393            3.522
<Table length=10>
      name        dtype  unit                          description                          
---------------- ------- ---- --------------------------------------------------------------
              ra float64  deg                                                Right ascension
             dec float64  deg                                                    Declination
 phot_g_mean_mag float32  mag                                          G-band mean magnitude
distance_gspphot float32   pc Distance from GSP-Phot Aeneas best library using BP/RP spectra
```
$\endgroup$
6
  • $\begingroup$ Thanks, that's great. I guess I'll have to try to familiarize myself with how to get all the rows output to a single file as well, but given the correct query I suspect that will be easier to find out. $\endgroup$
    – Outis Nemo
    Commented Mar 20, 2023 at 23:44
  • 1
    $\begingroup$ For writing to a file, one option is to use the write() method of the resulting astropy.table.Table instance $\endgroup$
    – Roy Smart
    Commented Mar 20, 2023 at 23:48
  • $\begingroup$ Thanks a lot. I find that pretty easily in the docs too. I think I'm understanding the query language a bit better now, it's not that different from database query languages. I'm wondering one thing, though: I just added a WHERE clause to set a minimum distance, which is working as expected, and I reach the very end of the list by doing so, giving me no stars beyond ~36,000 parsec (~120,000 light-years); is that correct? Given that this is roughly the width of the Milky Way, and that I doubt any individual stars outside our own galaxy are included, I guess that sounds right to me. $\endgroup$
    – Outis Nemo
    Commented Mar 21, 2023 at 0:08
  • 1
    $\begingroup$ I think that's correct. Section 5.5 of this paper says that they assume all the sources are single stars in the Milky Way. $\endgroup$
    – Roy Smart
    Commented Mar 21, 2023 at 0:18
  • 1
    $\begingroup$ I didn't know this, but apparently bright stars are excluded from Gaia archive since they saturate the detector cosmos.esa.int/web/gaia-users/archive/faq#accordion-kzsv_-7 $\endgroup$
    – Roy Smart
    Commented Mar 23, 2023 at 1:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .