Skip to content

Commit 73afabf

Browse files
authored
Merge pull request #2969 from esdc-esac-esa-int/ESA_gaia_update_documentation
GAIA: Astroquery documentation: general update [ci skip]
2 parents 5f4e92b + 122ff83 commit 73afabf

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

docs/gaia/gaia.rst

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TAP provides two operation modes:
4343
Gaia TAP+ server provides two access modes:
4444

4545
* Public: this is the standard TAP access. A user can execute ADQL queries and
46-
upload tables to be used in a query 'on-the-fly' (these tables will be removed
46+
upload votables to be used in a query 'on-the-fly' (these tables will be removed
4747
once the query is executed). The results are available to any other user and
4848
they will remain in the server for a limited time.
4949

@@ -76,8 +76,13 @@ Examples
7676

7777
This query searches for all the objects contained in an arbitrary rectangular projection of the sky.
7878

79+
WARNING: This method implements the ADQL BOX function that is deprecated in the latest version of the standard
80+
(ADQL 2.1, see: https://ivoa.net/documents/ADQL/20231107/PR-ADQL-2.1-20231107.html#tth_sEc4.2.9).
81+
7982
It is possible to choose which data release to query, by default the Gaia DR3 catalogue is used. For example::
8083

84+
.. doctest-remote-data::
85+
8186
>>> from astroquery.gaia import Gaia
8287
>>> Gaia.MAIN_GAIA_TABLE = "gaiadr2.gaia_source" # Select Data Release 2
8388
>>> Gaia.MAIN_GAIA_TABLE = "gaiadr3.gaia_source" # Reselect Data Release 3, default
@@ -199,7 +204,7 @@ To load only table names metadata (TAP+ capability):
199204
INFO: Retrieving tables... [astroquery.utils.tap.core]
200205
INFO: Parsing tables... [astroquery.utils.tap.core]
201206
INFO: Done. [astroquery.utils.tap.core]
202-
>>> for table in (tables):
207+
>>> for table in tables:
203208
... print(table.get_qualified_name())
204209
external.external.apassdr9
205210
external.external.catwise2020
@@ -361,11 +366,10 @@ Note: you can inspect the status of the job by typing:
361366
1.5. Synchronous query on an 'on-the-fly' uploaded table
362367
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
363368

364-
A table can be uploaded to the server in order to be used in a query.
369+
A votable can be uploaded to the server in order to be used in a query.
365370

366371
You have to provide the local path to the file you want to upload. In the following example,
367-
the file 'my_table.xml' is located to the relative location where your python program is
368-
running. See note below.
372+
the file 'my_table.xml' is located to the relative location where your python program is running. See note below.
369373

370374
.. doctest-skip::
371375

@@ -563,7 +567,8 @@ Your schema name will be automatically added to the provided table name::
563567
Job '1539932326689O' created to upload table 'table_test_from_url'.
564568

565569
Now, you can query your table as follows (a full qualified table name must be provided,
566-
i.e.: *user_<your_login_name>.<table_name>*)::
570+
i.e.: *user_<your_login_name>.<table_name>*. Note that if the <table_name> contains capital letters, it must be
571+
surrounded by quotation marks, i.e.: *user_<your_login_name>."<table_name>"*)::
567572

568573
>>> full_qualified_table_name = 'user_<your_login_name>.table_test_from_url'
569574
>>> query = 'select * from ' + full_qualified_table_name
@@ -590,7 +595,8 @@ Your schema name will be automatically added to the provided table name.
590595
Uploaded table 'table_test_from_file'.
591596
592597
Now, you can query your table as follows (a full qualified table name must be provided,
593-
i.e.: *user_<your_login_name>.<table_name>*)::
598+
i.e.: *user_<your_login_name>.<table_name>*. Note that if the <table_name> contains capital letters, it must be
599+
surrounded by quotation marks, i.e.: *user_<your_login_name>."<table_name>"*)::
594600

595601
>>> full_qualified_table_name = 'user_<your_login_name>.table_test_from_file'
596602
>>> query = 'select * from ' + full_qualified_table_name
@@ -617,7 +623,8 @@ Your schema name will be automatically added to the provided table name.
617623
618624
619625
Now, you can query your table as follows (a full qualified table name must be provided,
620-
i.e.: *user_<your_login_name>.<table_name>*)::
626+
i.e.: *user_<your_login_name>.<table_name>*. Note that if the <table_name> contains capital letters, it must be
627+
surrounded by quotation marks, i.e.: *user_<your_login_name>."<table_name>"*)::
621628

622629
>>> full_qualified_table_name = 'user_<your_login_name>.table_test_from_astropy'
623630
>>> query = 'select * from ' + full_qualified_table_name
@@ -636,13 +643,14 @@ table named: user_<your_login_name>.'t'<job_id>::
636643
>>> from astroquery.gaia import Gaia
637644
>>> Gaia.login()
638645
>>> j1 = Gaia.launch_job_async("select top 10 * from gaiadr3.gaia_source")
639-
>>> job = Gaia.upload_table_from_job(j1)
646+
>>> Gaia.upload_table_from_job(job=j1)
640647
Created table 't1539932994481O' from job: '1539932994481O'.
641648

642649
Now, you can query your table as follows (a full qualified table name must be provided,
643-
i.e.: *user_<your_login_name>.t<job_id>*)::
650+
i.e.: *user_<your_login_name>."t<job_id>"*. Note that the previous table name must be
651+
surrounded by quotation marks since it contains capital letters.)::
644652

645-
>>> full_qualified_table_name = 'user_<your_login_name>.t1539932994481O'
653+
>>> full_qualified_table_name = 'user_<your_login_name>."t1710251325268O"'
646654
>>> query = 'select * from ' + full_qualified_table_name
647655
>>> job = Gaia.launch_job(query=query)
648656
>>> results = job.get_results()
@@ -750,12 +758,11 @@ The following example uploads a table and then, the table is used in a cross mat
750758

751759
Once you have your cross match finished, you can obtain the results::
752760

761+
753762
>>> xmatch_table = 'user_<your_login_name>.' + xmatch_table_name
754-
>>> query = ('SELECT c."dist"*3600 as dist, a.*, b.* FROM gaiadr3.gaia_source AS a, '
755-
... 'full_qualified_table_name+' AS b, '
756-
... 'xmatch_table+' AS c '
757-
... 'WHERE (c.gaia_source_source_id = a.source_id AND '
758-
... 'c.my_sources_my_sources_oid = b.my_sources_oid)'
763+
>>> query = (f"SELECT c.separation*3600 AS separation_arcsec, a.*, b.* FROM gaiadr3.gaia_source AS a, "
764+
... f"{full_qualified_table_name} AS b, {xmatch_table} AS c WHERE c.gaia_source_source_id = a.source_id AND "
765+
... f"c.my_sources_my_sources_oid = b.my_sources_oid")
759766
>>> job = Gaia.launch_job(query=query)
760767
>>> results = job.get_results()
761768

@@ -855,16 +862,20 @@ The following example shows how to retrieve the DataLink products associated wit
855862
>>> data_release = 'Gaia DR3' # Options are: 'Gaia DR3' (default), 'Gaia DR2'
856863
>>> datalink = Gaia.load_data(ids=[2263166706630078848, 2263178457660566784, 2268372099615724288],
857864
... data_release=data_release, retrieval_type=retrieval_type, data_structure=data_structure)
858-
>>> datalink.keys()
859-
dict_keys(['MCMC_GSPPHOT_COMBINED.xml', 'EPOCH_PHOTOMETRY_COMBINED.xml', 'RVS_COMBINED.xml', 'MCMC_MSC_COMBINED.xml', 'XP_SAMPLED_COMBINED.xml', 'XP_CONTINUOUS_COMBINED.xml'])
860865

866+
The DataLink products are stored inside a Python Dictionary. Each of its elements (keys) contains a one-element list that can be extracted as follows:
867+
.. code-block:: python
868+
869+
>>> dl_keys = [inp for inp in datalink.keys()]
870+
>>> dl_keys.sort()
871+
>>> print(f'The following Datalink products have been downloaded:')
872+
>>> for dl_key in dl_keys:
873+
... print(f' * {dl_key}')
861874
862875
.. Note::
863876

864-
It is not possible to search for and retrieve the DataLink products
865-
associated to more than 5000 sources in one and the same call.
866-
However, it is possible to overcome this limit programmatically using a
867-
sequential download, as explained in this tutorial_.
877+
It is not possible to search for and retrieve the DataLink products associated to more than 5000 sources in one and the same call.
878+
However, it is possible to overcome this limit programmatically using a sequential download, as explained in this tutorial_.
868879

869880
.. _tutorial: https://www.cosmos.esa.int/web/gaia-users/archive/datalink-products#datalink_jntb_get_above_lim
870881
.. _DataLink: https://www.ivoa.net/documents/DataLink/

0 commit comments

Comments
 (0)