nb8. Query using astroquery |
In a similar manner to the previous notebooks, it is also possible to run TAP queries using the astroquery Python package.
The very lastest version of astroquery is needed. This can be installed with:
pip3 install --upgrade --pre astroquery
from astroquery.alma import Alma
import numpy as np
import astropy
You can obtain keywords, description and units of the ALMA TAP service by calling:
Alma.help()
Most common ALMA query keywords are listed below. These keywords are part of the ALMA ObsCore model, an IVOA standard for metadata representation (3rd column). They were also present in original ALMA Web form and, for backwards compatibility can be accessed with their old names (2nd column). More elaborate queries on the ObsCore model are possible with `query_sia` or `query_tap` methods Description Original ALMA keyword ObsCore keyword ------------------------------------------------------------------------------------------------------- Position Source name (astropy Resolver) source_name_resolver SkyCoord.from_name Source name (ALMA) source_name_alma target_name RA Dec (Sexagesimal) ra_dec s_ra, s_dec Galactic (Degrees) galactic gal_longitude, gal_latitude Angular resolution (arcsec) spatial_resolution spatial_resolution Largest angular scale (arcsec) spatial_scale_max spatial_scale_max Field of view (arcsec) fov s_fov Energy Frequency (GHz) frequency frequency Bandwidth (GHz) bandwidth bandwidth Spectral resolution (KHz) spectral_resolution em_resolution Band band_list band_list Time Observation date start_date t_min Integration time (s) integration_time t_exptime Polarization Polarisation type (Single, Dual, Full) polarisation_type pol_states Observation Line sensitivity (10 km/s) (mJy/beam) line_sensitivity sensitivity_10kms Continuum sensitivity (mJy/beam) continuum_sensitivity cont_sensitivity_bandwidth Water vapour (mm) water_vapour pvw Project Project code project_code proposal_id Project title project_title obs_title PI name pi_name obs_creator_name Proposal authors proposal_authors proposal_authors Project abstract project_abstract proposal_abstract Publication count publication_count NA Science keyword science_keyword science_keyword Publication Bibcode bibcode bib_reference Title pub_title pub_title First author first_author first_author Authors authors authors Abstract pub_abstract pub_abstract Year publication_year pub_year Options Public data only public_data data_rights Science observations only science_observation science_observation Examples of queries: Alma.query('proposal_id':'2011.0.00131.S'} Alma.query({'band_list': ['5', '7']} Alma.query({'source_name_alma': 'GRB021004'}) Alma.query(payload=dict(project_code='2017.1.01355.L', source_name_alma='G008.67'))
This is equivalent to the queries we show in notebook 1.
coordinates = astropy.coordinates.SkyCoord.from_name("Cen A")
output = Alma.query_tap(f"SELECT * FROM ivoa.obscore WHERE INTERSECTS(CIRCLE('ICRS',{coordinates.ra.degree},{coordinates.dec.degree},0.16),s_region)=1").to_table().to_pandas()
output.head(5)
access_url | access_format | proposal_id | data_rights | gal_longitude | gal_latitude | obs_publisher_did | obs_collection | facility_name | instrument_name | ... | frequency | velocity_resolution | obs_creator_name | pub_title | first_author | qa2_passed | bib_reference | science_keyword | scientific_category | lastModified | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00008.SV | Public | 309.512363 | 19.416239 | ADS/JAO.ALMA#2011.0.00008.SV | ALMA | JAO | ALMA | ... | 238.261613 | 1183.847494 | observatory, ALMA | ALMA Observations of the Physical and Chemical... | Azeez, Jazeel H. Israel, F. P. McCoy, Mark | T | 2014A&A...562A..96I 2017AdAst2017E...6A 2017Ap... | Galactic centres/nuclei, Active Galactic Nucle... | Active galaxies | 2021-09-30T16:34:41.133 |
1 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00008.SV | Public | 309.512363 | 19.416239 | ADS/JAO.ALMA#2011.0.00008.SV | ALMA | JAO | ALMA | ... | 238.261613 | 1183.847494 | observatory, ALMA | ALMA Observations of the Physical and Chemical... | Azeez, Jazeel H. Israel, F. P. McCoy, Mark | T | 2014A&A...562A..96I 2017AdAst2017E...6A 2017Ap... | Galactic centres/nuclei, Active Galactic Nucle... | Active galaxies | 2021-09-30T16:34:41.133 |
2 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00008.SV | Public | 309.512363 | 19.416239 | ADS/JAO.ALMA#2011.0.00008.SV | ALMA | JAO | ALMA | ... | 238.261613 | 1183.847494 | observatory, ALMA | ALMA Observations of the Physical and Chemical... | Azeez, Jazeel H. Israel, F. P. McCoy, Mark | T | 2014A&A...562A..96I 2017AdAst2017E...6A 2017Ap... | Galactic centres/nuclei, Active Galactic Nucle... | Active galaxies | 2021-09-30T16:34:41.133 |
3 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00008.SV | Public | 309.512363 | 19.416239 | ADS/JAO.ALMA#2011.0.00008.SV | ALMA | JAO | ALMA | ... | 238.261613 | 1183.847494 | observatory, ALMA | ALMA Observations of the Physical and Chemical... | Azeez, Jazeel H. Israel, F. P. McCoy, Mark | T | 2014A&A...562A..96I 2017AdAst2017E...6A 2017Ap... | Galactic centres/nuclei, Active Galactic Nucle... | Active galaxies | 2021-09-30T16:34:41.133 |
4 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00010.S | Public | 309.515914 | 19.417224 | ADS/JAO.ALMA#2011.0.00010.S | ALMA | JAO | ALMA | ... | 219.025328 | 663.940713 | Ott, Juergen | ALMA Observations of the Physical and Chemical... | McCoy, Mark | T | 2017ApJ...851...76M | Active Galactic Nuclei (AGN)/Quasars (QSO), Me... | Active galaxies | 2021-09-30T16:34:41.133 |
5 rows × 63 columns
Print all the target names associated with these coordinates:
np.unique(output['target_name'])
array(['1322-427', '3FGL_J1325.4-4301', 'CenA', 'Cen_A', 'Centaurus A', 'Centaurus_A', 'Centaurus_a', 'J1325-430', 'J1325-4301', 'NGC_5128'], dtype=object)
As in notebook 1, querying by source name should use the name resolver, e.g. Example 8a. Only in very special occasions it can be useful to query for the source name that the PI has put into their proposal. Many sources have a large variety of different names.
output = Alma.query({'source_name_alma': 'CenA'}).to_pandas()
output.head(5)
access_url | access_format | proposal_id | data_rights | gal_longitude | gal_latitude | obs_publisher_did | obs_collection | facility_name | instrument_name | ... | frequency | velocity_resolution | obs_creator_name | pub_title | first_author | qa2_passed | bib_reference | science_keyword | scientific_category | lastModified | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00010.S | Public | 309.515914 | 19.417224 | ADS/JAO.ALMA#2011.0.00010.S | ALMA | JAO | ALMA | ... | 111.417365 | 322.835911 | Ott, Juergen | ALMA Observations of the Physical and Chemical... | McCoy, Mark | T | 2017ApJ...851...76M | Active Galactic Nuclei (AGN)/Quasars (QSO), Me... | Active galaxies | 2021-09-30T16:34:41.133 |
1 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00010.S | Public | 309.515914 | 19.417224 | ADS/JAO.ALMA#2011.0.00010.S | ALMA | JAO | ALMA | ... | 111.417365 | 322.835911 | Ott, Juergen | ALMA Observations of the Physical and Chemical... | McCoy, Mark | T | 2017ApJ...851...76M | Active Galactic Nuclei (AGN)/Quasars (QSO), Me... | Active galaxies | 2021-09-30T16:34:41.133 |
2 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00010.S | Public | 309.515914 | 19.417224 | ADS/JAO.ALMA#2011.0.00010.S | ALMA | JAO | ALMA | ... | 111.417365 | 322.835911 | Ott, Juergen | ALMA Observations of the Physical and Chemical... | McCoy, Mark | T | 2017ApJ...851...76M | Active Galactic Nuclei (AGN)/Quasars (QSO), Me... | Active galaxies | 2021-09-30T16:34:41.133 |
3 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00010.S | Public | 309.515914 | 19.417224 | ADS/JAO.ALMA#2011.0.00010.S | ALMA | JAO | ALMA | ... | 111.417365 | 322.835911 | Ott, Juergen | ALMA Observations of the Physical and Chemical... | McCoy, Mark | T | 2017ApJ...851...76M | Active Galactic Nuclei (AGN)/Quasars (QSO), Me... | Active galaxies | 2021-09-30T16:34:41.133 |
4 | http://almascience.org/aq?member_ous_id=uid://... | text/html | 2011.0.00010.S | Public | 309.515914 | 19.417224 | ADS/JAO.ALMA#2011.0.00010.S | ALMA | JAO | ALMA | ... | 92.655678 | 368.331902 | Ott, Juergen | ALMA Observations of the Physical and Chemical... | McCoy, Mark | T | 2017ApJ...851...76M | Active Galactic Nuclei (AGN)/Quasars (QSO), Me... | Active galaxies | 2021-09-30T16:34:41.133 |
5 rows × 63 columns
Similar to notebook 1, TAP can also be used for the queries through Astroquery. In SQL, the % is the special character for "any string", equivalent to * in the shell. Similarly, in SQL the _ is the special character for "any character", equivalent to ? in the shell.
output = Alma.query_tap(f"SELECT * FROM ivoa.obscore WHERE target_name like '%Cen%A%'").to_table().to_pandas()
The variations of the source name which include 'Cen' and 'A' are the following:
np.unique(output['target_name'])
array(['Cen A - Xray N5', 'CenA', 'CenA - CO knot S1', 'CenA - Xray N1', 'CenA - Xray N2', 'CenA - Xray N3', 'CenA - Xray N4', 'Cen_A', 'Centaurus A', 'Centaurus_A'], dtype=object)