nb4. Query by scientific category |
The relevant columns in the ALMA TAP service are:
The scientific categories of observations are:
Note: these categories are stable in time and valid for all ALMA Cycles and may thus slighly differ from the categories in the ALMA Observing Tool which can change from Cycle to Cycle.
import numpy as np
from astropy.table import Table
import pyvo
import sys
import matplotlib.pyplot as plt
import pandas as pd
import sklearn.cluster
service = pyvo.dal.TAPService("https://almascience.eso.org/tap") # for the EU ALMA TAP service
# service = pyvo.dal.TAPService("https://almascience.nao.ac.jp/tap") # for the EA ALMA TAP service
# service = pyvo.dal.TAPService("https://almascience.nrao.edu/tap") # for the NA ALMA TAP service
def query_scientific_category(service, scientific_category):
"""Query for all science observations of a given scientific category. To reduce the memory
requirements, rather than using *, it is often useful to select the columns of interest.
service pyvo TAPService instance
scientific_category one of the categories shown at the top of this notebook
returns pandas table
"""
query = f"""
SELECT target_name, science_keyword, s_ra, s_dec, band_list
FROM ivoa.obscore
WHERE scientific_category = '{scientific_category}'
AND science_observation = 'T'
GROUP BY target_name, science_keyword, s_ra, s_dec, band_list
"""
return service.search(query).to_table().to_pandas()
def query_science_keyword(service, science_keyword):
"""ALMA has a long list of scientific keywords in the Observing Tool from whch PIs need to select
one or two in their proposals. This query returns all science observations for a given science
keyword (or part of it).
service pyvo TAPService instance
science_keyword one of the science keywords of ALMA or a substring
returns pandas table
"""
query = f"""
SELECT s_ra, s_dec, target_name, band_list, t_exptime
FROM ivoa.obscore
WHERE science_observation = 'T'
AND science_keyword like '%{science_keyword}%'
GROUP BY s_ra, s_dec, target_name, band_list, t_exptime
"""
return service.search(query).to_table().to_pandas()
def query_science_keyword_datatype(service, science_keyword, datatype):
"""This function shows how to combine several constraints. Here the science keyword as well
as the datatype and science_observations
service pyvo TAPService instance
science_keyword one of the science keywords of ALMA or a substring
datatype "image" or "cube"
returns pandas table
"""
query = f"""
SELECT s_ra, s_dec, target_name, band_list, t_exptime
FROM ivoa.obscore
WHERE science_keyword like '%{science_keyword}%'
AND science_observation = 'T'
AND dataproduct_type = '{datatype}'
GROUP BY s_ra, s_dec, target_name, band_list, t_exptime
"""
return service.search(query).to_table().to_pandas()
These queries only return science observations, not calibrator observations.
output_agn = query_scientific_category(service, 'Active galaxies')
print(f"There are {len(np.unique(output_agn['target_name']))} unique target names within the list of {len(output_agn)} results.")
There are 9865 unique target names within the list of 12844 results.
Showing the first 30 unique target names:
np.set_printoptions(threshold=sys.maxsize)
np.array(np.unique(output_agn['target_name']))[0:30]
array(['0-10000', '0-10510', '0-12043', '0-12407', '0-13299', '0-13375', '0-1426', '0-1437', '0-16822', '0-17244', '0-17749', '0-18038', '0-18180', '0-19883', '0-22825', '0-2318', '0-23382', '0-23626', '0-24625', '0-24636', '0-26339', '0-34302', '0-34622', '0-34897', '0-3662', '0-3753', '0-3973', '0-4356', '0-4503', '0-4936'], dtype=object)
In which bands have the AGN (as determined by the science category) been observed?
plt.rcParams["figure.figsize"] = (10,5)
output_agn['band_list'].hist(bins = 16)
<AxesSubplot:>
Where have they been observed?
plt.rcParams["figure.figsize"] = (20,15)
output_agn.plot(x='s_ra',y='s_dec', linestyle='', ms=7, marker='o', alpha=0.03, label='AGN (science category) observed with ALMA')
plt.xlabel('RA')
plt.ylabel('Dec')
Text(0, 0.5, 'Dec')
Within this science category there are several combinations of science keywords. We split each combination of science keywords up and then plot the pie chart.
flattened_science_keywords = [item.strip() for sublist in [keyword.split(',') for keyword in output_agn['science_keyword']] for item in sublist]
pd.DataFrame({'science_keyword':flattened_science_keywords})['science_keyword'].value_counts().plot.pie()
pd.DataFrame({'science_keyword':flattened_science_keywords})['science_keyword'].value_counts()
Starburst galaxies 7643 Sub-mm Galaxies (SMG) 5877 Active Galactic Nuclei (AGN)/Quasars (QSO) 1993 Starbursts 1707 star formation 1707 Galaxy structure & evolution 1368 High-z Active Galactic Nuclei (AGN) 993 jets 961 Outflows 961 feedback 961 Galactic centres/nuclei 852 Surveys of galaxies 349 Luminous and Ultra-Luminous Infra-Red Galaxies (LIRG & ULIRG) 321 Giant Molecular Clouds (GMC) properties 294 Merging and interacting galaxies 293 Galaxy groups and clusters 199 Spiral galaxies 169 Gravitational lenses 112 Galaxy Clusters 87 Galaxy chemistry 69 Dwarf/metal-poor galaxies 47 Early-type galaxies 46 Gamma Ray Bursts (GRB) 20 Damped Lyman Alpha (DLA) systems 4 Cosmic Microwave Background (CMB)/Sunyaev-Zel'dovich Effect (SZE) 2 Name: science_keyword, dtype: int64
Show the list of all Science Keywords in the the ALMA database:
query = f"""SELECT DISTINCT(science_keyword) from ivoa.obscore"""
flattened_science_keywords = sorted(list(set([item.strip() for sublist in [keyword.split(',') for keyword in service.search(query).to_table().to_pandas()['(science_keyword)']] for item in sublist])))
print(*flattened_science_keywords, sep="\n")
Active Galactic Nuclei (AGN)/Quasars (QSO) Astrochemistry Asymptotic Giant Branch (AGB) stars Black holes Brown dwarfs Cataclysmic stars Cosmic Microwave Background (CMB)/Sunyaev-Zel'dovich Effect (SZE) Damped Lyman Alpha (DLA) systems Debris disks Disks around high-mass stars Disks around low-mass stars Dwarf/metal-poor galaxies Early-type galaxies Evolved stars - Chemistry Evolved stars - Shaping/physical structure Evolved stars: Shaping/physical structure Exo-planets Exoplanets Galactic centres/nuclei Galaxy Clusters Galaxy chemistry Galaxy groups and clusters Galaxy structure & evolution Galaxy structure &evolution Gamma Ray Bursts (GRB) Giant Molecular Clouds (GMC) properties Gravitational lenses HII regions High-mass star formation High-z Active Galactic Nuclei (AGN) Hypergiants Infra-Red Dark Clouds (IRDC) Inter-Stellar Medium (ISM)/Molecular clouds Intermediate-mass star formation Low-mass star formation Luminous Blue Variables (LBV) Luminous and Ultra-Luminous Infra-Red Galaxies (LIRG & ULIRG) Lyman Alpha Emitters/Blobs (LAE/LAB) Lyman Break Galaxies (LBG) Magellanic Clouds Main sequence stars Merging and interacting galaxies Outflows Photon-Dominated Regions (PDR)/X-Ray Dominated Regions (XDR) Post-AGB stars Pre-stellar cores Pulsars and neutron stars Solar system - Asteroids Solar system - Comets Solar system - Planetary atmospheres Solar system - Planetary surfaces Solar system - Trans-Neptunian Objects (TNOs) Spiral galaxies Starburst galaxies Starbursts Sub-mm Galaxies (SMG) Supernovae (SN) ejecta Surveys of galaxies The Sun Transients White dwarfs feedback jets jets and ionized winds star formation
First, we investigate this question using the corresponding scientific keyword.
output_smgs_scikey = query_science_keyword(service, 'Sub-mm Galaxies (SMG)')
print(f"There are {len(output_smgs_scikey)} observations with keyword 'Sub-mm Galaxies (SMG)'.")
There are 10649 observations with keyword 'Sub-mm Galaxies (SMG)'.
Similarly, we can look for sub-millimeter Galaxies in the proposal abstract texts. For example with
query = """
SELECT s_ra, s_dec, target_name, t_exptime
FROM ivoa.obscore
WHERE proposal_abstract like '%SMG%'
OR proposal_abstract like '%ub-mm galax%'
AND science_observation = 'T'
GROUP BY s_ra, s_dec, target_name, t_exptime
"""
output_smgs_abstract = service.search(query).to_table().to_pandas()
print(f"There are {len(output_smgs_abstract)} observations where the proposal abstract mentions strings related to SMGs.")
There are 6035 observations where the proposal abstract mentions strings related to SMGs.
We can now plot the position of these sub-mm galaxies observations:
plt.rcParams["figure.figsize"] = (20,15)
ax = output_smgs_scikey.plot(x='s_ra',y='s_dec', linestyle='', ms=5, marker='o', label='ALMA observed SMGs', alpha=0.02)
output_smgs_abstract.plot(x='s_ra',y='s_dec', linestyle='', ms=5, marker='o', label='ALMA observed SMGs', alpha=0.02, ax=ax)
<AxesSubplot:xlabel='s_ra'>