The NASA Exoplanet Science Institute (NExScI) (visit https://nexsci.caltech.edu) has developed a Python-based server to implement an API that complies with the Virtual Observatory (VO) Table Access Protocol(TAP) version 1.1 (September 2019) (http://ivoa.net/documents/TAP/20190927/index.html), a standard recommended by the International Virtual Observatory alliance (IVOA) (http://ivoa.net).
The TAP API enables a rich variety of searches against tabular data, includung cone, box or all-sky searches, temporal searches, combinations of spatial searches and temporal searches, searches against instrumental attributes and program attributes.
This tutorial supports demonstrates how to use the TAP+ client to perform synchronous TAP-based queries for public raw science and calibration data acquired with the DEep Imaging Multi-Object Spectrograph (DEIMOS) these data are hosted at the Keck Observatory Archive (KOA; https://koa.ipac.caltech.edu).
TAP+ was developed at the ESAC Space Data Centre (ESDC: http://www.cosmos.esa.int/web/esdc/) and can be installed from PyPI as part of the astroquery package:
$ pip install --upgrade astroquery
The tutorial requires Python 3.6 (or above), plus the table read and write functions from Astropy. We have tested with Astropy 4.0.1, but any version should work. We recommend using the Ananconda Python distribution.
import numpy as np
from astroquery.utils.tap.core import TapPlus
koa = TapPlus(url="https://koa.ipac.caltech.edu/TAP")
sql = "select koaid, filehand from koa_deimos where koaid like '%20150901%' "
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='KoaTapDate1.tbl', \
output_format='ipac')
job = koa.launch_job(sql, dump_to_file=True, output_file='KoaTapDate2.vot', \
output_format='votable')
job = koa.launch_job(sql, dump_to_file=True, output_file='KoaTapDate3.csv', \
output_format='csv')
job = koa.launch_job(sql, dump_to_file=True, output_file='KoaTapDate4.tsv', \
output_format='tsv')
sql = "select * from koa_deimos where koaid like '%20150901%'"
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='table_ascii.tbl', \
output_format='ipac')
sql = "select koaid, filehand from koa_deimos \
where koaid like '%20150901%' "
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='columns.tbl', \
output_format='ipac')
sql = "select top 5 koaid, filehand, frameno from koa_deimos where koaid like '%20150901%'"
job = koa.launch_job(sql, dump_to_file=True, output_file='KoaTapTestFiniteRecors.tbl', output_format='ipac')
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='top20.tbl', \
output_format='ipac')
sql="select koaid, filehand from koa_deimos \
where (utdatetime >= to_date('2015-09-01 00:00:00', \
'yyyy-mm-dd HH24:MI:SS') and \
utdatetime <= to_date('2015-09-30 23:59:59', 'yyyy-mm-dd HH24:MI:SS'))"
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='date_range.tbl', \
output_format='ipac')
sql= ("select koaid, filehand, progid, ha, az, detector, gratenam \
from koa_deimos where (progid = 'U024') ")
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='progID.tbl', \
output_format='ipac')
sql=("select koaid, filehand, ra, dec from koa_deimos where \
contains(point('icrs', ra, dec), \
circle('icrs', 23.4, 30.60,1.0)) = 1")
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='Spatial_cone.txt', \
output_format='ipac')
sql=("select koaid, filehand, ra, dec from koa_deimos where \
contains(point('icrs', ra, dec), \
box('icrs',23.4, 30.60,1.0,120)) = 1")
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='SpatBox.txt', output_format='ipac')
sql=("select koaid, filehand, ra, dec from koa_deimos where \
contains(point('icrs', ra, dec), \
polygon('icrs',209.80225,53.34894,209.80225,55.34894,211.80225,54.34894)) = 1")
job = koa.launch_job(sql)
r = job.get_results()
print(r)
job = koa.launch_job(sql, dump_to_file=True, output_file='SpatPoly.txt', \
output_format='ipac')
sql=("select count(*) from koa_deimos where \
(utdatetime >= to_date('2009-01-01 00:00:00', 'yyyy-mm-dd HH24:MI:SS') and \
utdatetime <= to_date('2009-01-31 23:59:59', 'yyyy-mm-dd HH24:MI:SS'))" )
job = koa.launch_job(sql)
r = job.get_results()
print(r)
sql="select count(*) as total from koa_deimos"
job = koa.launch_job(sql)
r = job.get_results()
print(r)
Visit KOA at https://koa.ipac.caltech.edu.
The Keck Observatory Archive (KOA) is a collaboration between the NASA Exoplanet Science Institute (NExScI) and the W. M. Keck Observatory (WMKO). NExScI is sponsored by NASA's Exoplanet Exploration Program, and operated by the California Institute of Technology in coordination with the Jet Propulsion Laboratory (JPL).
Need help? Submit your questions to the KOA Help Desk at https://koa.ipac.caltech.edu/cgi-bin/Helpdesk/nph-genTicketForm?projname=KOA