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, including 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 PyVO client to perform asynchronous TAP-based queries for public raw science and calibation data acquired with the Long Wavelength Spectrometer (LWS) or Near Infrared Camera (NIRC); these data are hosted at the Keck Observatory Archive (KOA; https://koa.ipac.caltech.edu).
This tutorial uses PyVO version 1.1.1, and can be installed from PyPI:
$ pip install --upgrade PyVO
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.
The number of records returned here may differ from those returned here because new data are released daily.
print("from pyvo.dal import tap")
print("koa = tap.TAPService(\"https://koa.ipac.caltech.edu/TAP\")")
print("import time")
print("import sys")
print("import os")
print("import time")
print("import warnings")
print(" ")
print('─' * 10)
print(" ")
from pyvo.dal import tap
koa = tap.TAPService("https://koa.ipac.caltech.edu/TAP")
import time
import sys
import os
import time
import warnings
from pyvo.dal import tap koa = tap.TAPService("https://koa.ipac.caltech.edu/TAP") import time import sys import os import time import warnings ──────────
Uncomment the instrument below for either LWS or NIRC
# Uncomment below for LWS
instrument = 'LWS'
# Uncomment for NIRC
#instrument = 'NIRC'
if (instrument == 'LWS'):
instr = 'lws'
koatable = 'koa_lws'
outdir = './outputLW_async/'
koaid_date = '19981203'
startdate = '1998-12-03 00:00:00'
enddate = '1998-12-27 23:59:59'
date = '1998-12-03'
program = 'A078LS'
circle_pos = '68.98 16.51 1.0'
box_pos = '68.98 16.51 0.5 0.5'
polygon_pos = '67.98,15.51,67.98,17.51,70.98,22.03'
if (instrument == 'NIRC'):
instr = 'nirc'
koatable = 'koa_nirc'
outdir = './outputN1_async/'
koaid_date = '19950316'
startdate = '1995-03-16 00:00:00'
enddate = '1995-04-01 23:59:59'
date = '1995-03-16'
program = 'U41N'
circle_pos = '162.07 12.63 1.0'
box_pos = '162.07 12.63 0.5 0.5'
polygon_pos = '161.07,11.63,161.07,13.63,164.07,12.63'
print("try:")
print("\tos.mkdir('" + outdir + "')")
print("except:")
print("\tprint (\" " + instrument + " Directory exists already\", flush=True)")
print(" ")
print('─' * 10)
print(" ")
try:
os.mkdir(outdir)
except:
print(instrument + " Directory exists already", flush=True)
try: os.mkdir('./outputLW_async/') except: print (" LWS Directory exists already", flush=True) ──────────
# write results to VOTable format
print("sql = \"select koaid, filehand from "+ koatable + " where koaid like '%" + koaid_date + "%'\"")
print("results= koa.run_async(sql)")
print("print(results)")
print("table=results.to_table()")
print("table.write ('" + outdir + instr + "_table_ipacascii.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%'"
results = koa.run_async(sql)
print(results)
table=results.to_table()
table.write (outdir + instr + "_table_ipacascii.vot",format='votable',overwrite=True)
sql = "select koaid, filehand from koa_lws where koaid like '%19981203%'" results= koa.run_async(sql) print(results) table=results.to_table() table.write ('./outputLW_async/lws_table_ipacascii.vot',format='votable',overwrite=True) ────────── <Table length=63> koaid filehand object object ---------------------- --------------------------------------------------- LW.19981203.08419.fits /koadata31/LWS/19981203/lev0/LW.19981203.08419.fits LW.19981203.55485.fits /koadata31/LWS/19981203/lev0/LW.19981203.55485.fits LW.19981203.59695.fits /koadata31/LWS/19981203/lev0/LW.19981203.59695.fits LW.19981203.55023.fits /koadata31/LWS/19981203/lev0/LW.19981203.55023.fits LW.19981203.57381.fits /koadata31/LWS/19981203/lev0/LW.19981203.57381.fits LW.19981203.55703.fits /koadata31/LWS/19981203/lev0/LW.19981203.55703.fits LW.19981203.56388.fits /koadata31/LWS/19981203/lev0/LW.19981203.56388.fits LW.19981203.56623.fits /koadata31/LWS/19981203/lev0/LW.19981203.56623.fits LW.19981203.56888.fits /koadata31/LWS/19981203/lev0/LW.19981203.56888.fits LW.19981203.57719.fits /koadata31/LWS/19981203/lev0/LW.19981203.57719.fits ... ... LW.19981203.23814.fits /koadata31/LWS/19981203/lev0/LW.19981203.23814.fits LW.19981203.23960.fits /koadata31/LWS/19981203/lev0/LW.19981203.23960.fits LW.19981203.24201.fits /koadata31/LWS/19981203/lev0/LW.19981203.24201.fits LW.19981203.39808.fits /koadata31/LWS/19981203/lev0/LW.19981203.39808.fits LW.19981203.37619.fits /koadata31/LWS/19981203/lev0/LW.19981203.37619.fits LW.19981203.39910.fits /koadata31/LWS/19981203/lev0/LW.19981203.39910.fits LW.19981203.44693.fits /koadata31/LWS/19981203/lev0/LW.19981203.44693.fits LW.19981203.47031.fits /koadata31/LWS/19981203/lev0/LW.19981203.47031.fits LW.19981203.49426.fits /koadata31/LWS/19981203/lev0/LW.19981203.49426.fits LW.19981203.49988.fits /koadata31/LWS/19981203/lev0/LW.19981203.49988.fits
# write results to an IPAC ASCII table
print("sql = \"select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%'\"")
print("results = koa.run_async(sql)")
print("print(results)")
print("table=results.to_table()")
print("table.write ('" + outdir + instr + "_table_ipacascii.tbl',format='ascii.ipac',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%' "
results = koa.run_async(sql)
print(results)
table=results.to_table()
table.write (outdir + instr + "_table_ipacascii.tbl",format='ascii.ipac',overwrite=True)
sql = "select koaid, filehand from koa_lws where koaid like '%19981203%'" results = koa.run_async(sql) print(results) table=results.to_table() table.write ('./outputLW_async/lws_table_ipacascii.tbl',format='ascii.ipac',overwrite=True) ────────── <Table length=63> koaid filehand object object ---------------------- --------------------------------------------------- LW.19981203.08419.fits /koadata31/LWS/19981203/lev0/LW.19981203.08419.fits LW.19981203.55485.fits /koadata31/LWS/19981203/lev0/LW.19981203.55485.fits LW.19981203.59695.fits /koadata31/LWS/19981203/lev0/LW.19981203.59695.fits LW.19981203.55023.fits /koadata31/LWS/19981203/lev0/LW.19981203.55023.fits LW.19981203.57381.fits /koadata31/LWS/19981203/lev0/LW.19981203.57381.fits LW.19981203.55703.fits /koadata31/LWS/19981203/lev0/LW.19981203.55703.fits LW.19981203.56388.fits /koadata31/LWS/19981203/lev0/LW.19981203.56388.fits LW.19981203.56623.fits /koadata31/LWS/19981203/lev0/LW.19981203.56623.fits LW.19981203.56888.fits /koadata31/LWS/19981203/lev0/LW.19981203.56888.fits LW.19981203.57719.fits /koadata31/LWS/19981203/lev0/LW.19981203.57719.fits ... ... LW.19981203.23814.fits /koadata31/LWS/19981203/lev0/LW.19981203.23814.fits LW.19981203.23960.fits /koadata31/LWS/19981203/lev0/LW.19981203.23960.fits LW.19981203.24201.fits /koadata31/LWS/19981203/lev0/LW.19981203.24201.fits LW.19981203.39808.fits /koadata31/LWS/19981203/lev0/LW.19981203.39808.fits LW.19981203.37619.fits /koadata31/LWS/19981203/lev0/LW.19981203.37619.fits LW.19981203.39910.fits /koadata31/LWS/19981203/lev0/LW.19981203.39910.fits LW.19981203.44693.fits /koadata31/LWS/19981203/lev0/LW.19981203.44693.fits LW.19981203.47031.fits /koadata31/LWS/19981203/lev0/LW.19981203.47031.fits LW.19981203.49426.fits /koadata31/LWS/19981203/lev0/LW.19981203.49426.fits LW.19981203.49988.fits /koadata31/LWS/19981203/lev0/LW.19981203.49988.fits
# write results to CSV file
print("sql = \"select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%'\"")
print("results = koa.run_async(sql)")
print("print (results)")
print("table=results.to_table()")
print("table.write ('"+ outdir + instr + "_table_csv.csv',format='csv', overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%' "
results = koa.run_async(sql)
print(results)
table=results.to_table()
table.write (outdir + instr + "_table_csv.csv",format='csv', overwrite=True)
sql = "select koaid, filehand from koa_lws where koaid like '%19981203%'" results = koa.run_async(sql) print (results) table=results.to_table() table.write ('./outputLW_async/lws_table_csv.csv',format='csv', overwrite=True) ────────── <Table length=63> koaid filehand object object ---------------------- --------------------------------------------------- LW.19981203.08419.fits /koadata31/LWS/19981203/lev0/LW.19981203.08419.fits LW.19981203.55485.fits /koadata31/LWS/19981203/lev0/LW.19981203.55485.fits LW.19981203.59695.fits /koadata31/LWS/19981203/lev0/LW.19981203.59695.fits LW.19981203.55023.fits /koadata31/LWS/19981203/lev0/LW.19981203.55023.fits LW.19981203.57381.fits /koadata31/LWS/19981203/lev0/LW.19981203.57381.fits LW.19981203.55703.fits /koadata31/LWS/19981203/lev0/LW.19981203.55703.fits LW.19981203.56388.fits /koadata31/LWS/19981203/lev0/LW.19981203.56388.fits LW.19981203.56623.fits /koadata31/LWS/19981203/lev0/LW.19981203.56623.fits LW.19981203.56888.fits /koadata31/LWS/19981203/lev0/LW.19981203.56888.fits LW.19981203.57719.fits /koadata31/LWS/19981203/lev0/LW.19981203.57719.fits ... ... LW.19981203.23814.fits /koadata31/LWS/19981203/lev0/LW.19981203.23814.fits LW.19981203.23960.fits /koadata31/LWS/19981203/lev0/LW.19981203.23960.fits LW.19981203.24201.fits /koadata31/LWS/19981203/lev0/LW.19981203.24201.fits LW.19981203.39808.fits /koadata31/LWS/19981203/lev0/LW.19981203.39808.fits LW.19981203.37619.fits /koadata31/LWS/19981203/lev0/LW.19981203.37619.fits LW.19981203.39910.fits /koadata31/LWS/19981203/lev0/LW.19981203.39910.fits LW.19981203.44693.fits /koadata31/LWS/19981203/lev0/LW.19981203.44693.fits LW.19981203.47031.fits /koadata31/LWS/19981203/lev0/LW.19981203.47031.fits LW.19981203.49426.fits /koadata31/LWS/19981203/lev0/LW.19981203.49426.fits LW.19981203.49988.fits /koadata31/LWS/19981203/lev0/LW.19981203.49988.fits
print("sql = \"select * from " + koatable + " where koaid like '%" + koaid_date + "%' \"")
print("results = koa.run_async(sql)")
print("print (results)")
print("table_selectall=results.to_table()")
print("table_selectall.write ('" + outdir + instr + "_table_selectall.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select * from " + koatable + " where koaid like '%" + koaid_date + "%' "
results = koa.run_async(sql)
print (results)
table_selectall=results.to_table()
table_selectall.write (outdir + instr + "_table_selectall.vot",format='votable',overwrite=True)
sql = "select * from koa_lws where koaid like '%19981203%' " results = koa.run_async(sql) print (results) table_selectall=results.to_table() table_selectall.write ('./outputLW_async/lws_table_selectall.vot',format='votable',overwrite=True) ────────── <Table length=63> koaid ofname propint ... z spt_ind object object int32 ... float64 int32 ---------------------- -------------- ------- ... ------------------ --------- LW.19981203.08419.fits lws0001.fits 18 ... 0.94128377839366 231320231 LW.19981203.55485.fits irc0080.fits 18 ... 0.22971800335177 220221323 LW.19981203.59695.fits irc0102.fits 18 ... 0.229531147144593 220221323 LW.19981203.55023.fits irc0078.fits 18 ... 0.22971800335177 220221323 LW.19981203.57381.fits irc0090.fits 18 ... 0.229701016773622 220221323 LW.19981203.55703.fits irc0082.fits 18 ... 0.22971800335177 220221323 LW.19981203.56388.fits irc0084.fits 18 ... 0.229701016773622 220221323 LW.19981203.56623.fits irc0086.fits 18 ... 0.229701016773622 220221323 LW.19981203.56888.fits irc0088.fits 18 ... 0.229701016773622 220221323 LW.19981203.57719.fits irc0092.fits 18 ... 0.229701016773622 220221323 ... ... ... ... ... ... LW.19981203.23814.fits lws0025.fits 18 ... 0.470673134104844 200111131 LW.19981203.23960.fits lws0028.fits 18 ... 0.470719330980502 200111131 LW.19981203.24201.fits lws0031.fits 18 ... 0.470719330980502 200111131 LW.19981203.39808.fits lws0047.fits 18 ... 0.28417398445677 230301121 LW.19981203.37619.fits lws0043.fits 18 ... 0.284157250672583 230301121 LW.19981203.39910.fits lws0048.fits 18 ... 0.28417398445677 230301121 LW.19981203.44693.fits vycma0056.fits 18 ... -0.434735114462566 110110112 LW.19981203.47031.fits vycma0061.fits 18 ... -0.434703678780342 110110112 LW.19981203.49426.fits vycma0063.fits 18 ... -0.434703678780342 110110112 LW.19981203.49988.fits vycma0067.fits 18 ... -0.434703678780342 110110112
print("sql = \"select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%'\"")
print("results = koa.run_async(sql)")
print("print(results)")
print("table = results.to_table()")
print("table.write('" + outdir + instr + "_select_columns.tbl',format='ascii.ipac',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select koaid, filehand from " + koatable + " where koaid like '%" + koaid_date + "%'"
results = koa.run_async(sql)
print(results)
table = results.to_table()
table.write(outdir + instr + "_select_columns.tbl",format='ascii.ipac',overwrite=True)
sql = "select koaid, filehand from koa_lws where koaid like '%19981203%'" results = koa.run_async(sql) print(results) table = results.to_table() table.write('./outputLW_async/lws_select_columns.tbl',format='ascii.ipac',overwrite=True) ────────── <Table length=63> koaid filehand object object ---------------------- --------------------------------------------------- LW.19981203.08419.fits /koadata31/LWS/19981203/lev0/LW.19981203.08419.fits LW.19981203.55485.fits /koadata31/LWS/19981203/lev0/LW.19981203.55485.fits LW.19981203.59695.fits /koadata31/LWS/19981203/lev0/LW.19981203.59695.fits LW.19981203.55023.fits /koadata31/LWS/19981203/lev0/LW.19981203.55023.fits LW.19981203.57381.fits /koadata31/LWS/19981203/lev0/LW.19981203.57381.fits LW.19981203.55703.fits /koadata31/LWS/19981203/lev0/LW.19981203.55703.fits LW.19981203.56388.fits /koadata31/LWS/19981203/lev0/LW.19981203.56388.fits LW.19981203.56623.fits /koadata31/LWS/19981203/lev0/LW.19981203.56623.fits LW.19981203.56888.fits /koadata31/LWS/19981203/lev0/LW.19981203.56888.fits LW.19981203.57719.fits /koadata31/LWS/19981203/lev0/LW.19981203.57719.fits ... ... LW.19981203.23814.fits /koadata31/LWS/19981203/lev0/LW.19981203.23814.fits LW.19981203.23960.fits /koadata31/LWS/19981203/lev0/LW.19981203.23960.fits LW.19981203.24201.fits /koadata31/LWS/19981203/lev0/LW.19981203.24201.fits LW.19981203.39808.fits /koadata31/LWS/19981203/lev0/LW.19981203.39808.fits LW.19981203.37619.fits /koadata31/LWS/19981203/lev0/LW.19981203.37619.fits LW.19981203.39910.fits /koadata31/LWS/19981203/lev0/LW.19981203.39910.fits LW.19981203.44693.fits /koadata31/LWS/19981203/lev0/LW.19981203.44693.fits LW.19981203.47031.fits /koadata31/LWS/19981203/lev0/LW.19981203.47031.fits LW.19981203.49426.fits /koadata31/LWS/19981203/lev0/LW.19981203.49426.fits LW.19981203.49988.fits /koadata31/LWS/19981203/lev0/LW.19981203.49988.fits
print("sql = \"select koaid, filehand, frameno from " + koatable + " where koaid like '%" + koaid_date + "%'\"")
print("results = koa.run_async(sql, maxrec=20)")
print("print (results)")
print("table = results.to_table()")
print("table.write('" + outdir + instr + "_select_maxrec.tbl',format='ascii.ipac',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select koaid, filehand, frameno from " + koatable + " where koaid like '%" + koaid_date + "%'"
results = koa.run_async(sql, maxrec=20)
print (results)
table = results.to_table()
table.write(outdir + instr + "_select_maxrec.tbl",format='ascii.ipac',overwrite=True)
sql = "select koaid, filehand, frameno from koa_lws where koaid like '%19981203%'" results = koa.run_async(sql, maxrec=20) print (results) table = results.to_table() table.write('./outputLW_async/lws_select_maxrec.tbl',format='ascii.ipac',overwrite=True) ────────── <Table length=20> koaid ... frameno object ... int32 ---------------------- ... ------- LW.19981203.08419.fits ... 1 LW.19981203.55485.fits ... 80 LW.19981203.59695.fits ... 102 LW.19981203.55023.fits ... 78 LW.19981203.57381.fits ... 90 LW.19981203.55703.fits ... 82 LW.19981203.56388.fits ... 84 LW.19981203.56623.fits ... 86 LW.19981203.56888.fits ... 88 LW.19981203.57719.fits ... 92 LW.19981203.59336.fits ... 98 LW.19981203.58397.fits ... 94 LW.19981203.58630.fits ... 95 LW.19981203.59572.fits ... 101 LW.19981203.59487.fits ... 100 LW.19981203.20446.fits ... 14 LW.19981203.13742.fits ... 2 LW.19981203.19367.fits ... 9 LW.19981203.19491.fits ... 10 LW.19981203.20423.fits ... 13
print("sql = \"select koaid, filehand from "+ koatable + " where (utdatetime >= to_date('" + startdate + "', 'yyyy-mm-dd HH24:MI:SS') and utdatetime <= to_date('" + enddate + "', 'yyyy-mm-dd HH24:MI:SS'))\"")
print("results = koa.run_async(sql)")
print("print (results)")
print("table_daterange=results.to_table()")
print("table.write ('" + outdir + instr + "_table_daterange.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql = "select koaid, filehand from " + koatable + " where (utdatetime >= to_date('" + startdate + "', 'yyyy-mm-dd HH24:MI:SS') and utdatetime <= to_date('" + enddate + "', 'yyyy-mm-dd HH24:MI:SS'))"
results = koa.run_async(sql)
print (results)
table_daterange=results.to_table()
table.write (outdir + instr + "_table_daterange.vot",format='votable',overwrite=True)
sql = "select koaid, filehand from koa_lws where (utdatetime >= to_date('1998-12-03 00:00:00', 'yyyy-mm-dd HH24:MI:SS') and utdatetime <= to_date('1998-12-27 23:59:59', 'yyyy-mm-dd HH24:MI:SS'))" results = koa.run_async(sql) print (results) table_daterange=results.to_table() table.write ('./outputLW_async/lws_table_daterange.vot',format='votable',overwrite=True) ────────── <Table length=229> koaid filehand object object ---------------------- --------------------------------------------------- LW.19981227.32380.fits /koadata31/LWS/19981227/lev0/LW.19981227.32380.fits LW.19981227.47503.fits /koadata31/LWS/19981227/lev0/LW.19981227.47503.fits LW.19981227.47636.fits /koadata31/LWS/19981227/lev0/LW.19981227.47636.fits LW.19981227.47724.fits /koadata31/LWS/19981227/lev0/LW.19981227.47724.fits LW.19981227.47904.fits /koadata31/LWS/19981227/lev0/LW.19981227.47904.fits LW.19981227.47993.fits /koadata31/LWS/19981227/lev0/LW.19981227.47993.fits LW.19981227.48087.fits /koadata31/LWS/19981227/lev0/LW.19981227.48087.fits LW.19981227.48197.fits /koadata31/LWS/19981227/lev0/LW.19981227.48197.fits LW.19981227.48319.fits /koadata31/LWS/19981227/lev0/LW.19981227.48319.fits LW.19981227.49207.fits /koadata31/LWS/19981227/lev0/LW.19981227.49207.fits ... ... LW.19981205.16579.fits /koadata31/LWS/19981205/lev0/LW.19981205.16579.fits LW.19981205.17364.fits /koadata31/LWS/19981205/lev0/LW.19981205.17364.fits LW.19981205.16650.fits /koadata31/LWS/19981205/lev0/LW.19981205.16650.fits LW.19981205.16687.fits /koadata31/LWS/19981205/lev0/LW.19981205.16687.fits LW.19981205.16724.fits /koadata31/LWS/19981205/lev0/LW.19981205.16724.fits LW.19981205.17438.fits /koadata31/LWS/19981205/lev0/LW.19981205.17438.fits LW.19981205.17401.fits /koadata31/LWS/19981205/lev0/LW.19981205.17401.fits LW.19981205.17478.fits /koadata31/LWS/19981205/lev0/LW.19981205.17478.fits LW.19981205.17513.fits /koadata31/LWS/19981205/lev0/LW.19981205.17513.fits LW.19981205.17605.fits /koadata31/LWS/19981205/lev0/LW.19981205.17605.fits
print("sql= (\"select koaid, filehand, progid from " + koatable + " where (progid = '" + program + "')\")")
print("results = koa.run_async(sql)")
print("print(results)")
print("table_progid=results.to_table()")
print("table.write ('"+ outdir +instr + "_progid.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql= ("select koaid, filehand, progid from " + koatable + " where (progid = '" + program + "')")
results = koa.run_async(sql)
print(results)
table_progid=results.to_table()
table.write (outdir + instr + "_progid.vot",format='votable',overwrite=True)
sql= ("select koaid, filehand, progid from koa_lws where (progid = 'A078LS')") results = koa.run_async(sql) print(results) table_progid=results.to_table() table.write ('./outputLW_async/lws_progid.vot',format='votable',overwrite=True) ────────── <Table length=338> koaid ... progid object ... object ---------------------- ... ------ LW.20050219.22427.fits ... A078LS LW.20050219.22529.fits ... A078LS LW.20050219.23025.fits ... A078LS LW.20050219.23128.fits ... A078LS LW.20050219.23332.fits ... A078LS LW.20050219.23433.fits ... A078LS LW.20050219.23865.fits ... A078LS LW.20050219.24609.fits ... A078LS LW.20050219.24710.fits ... A078LS LW.20050219.24926.fits ... A078LS ... ... ... LW.20050220.43116.fits ... A078LS LW.20050220.43477.fits ... A078LS LW.20050220.45889.fits ... A078LS LW.20050220.49828.fits ... A078LS LW.20050220.50336.fits ... A078LS LW.20050220.50700.fits ... A078LS LW.20050220.51124.fits ... A078LS LW.20050220.51861.fits ... A078LS LW.20050220.52308.fits ... A078LS LW.20050220.53887.fits ... A078LS
print("sql=(\"select koaid, filehand, ra, dec from " + koatable + " where contains(point('J2000', ra, dec), circle('J2000', " + circle_pos + ")) = 1\")")
print("results = koa.run_async(sql)")
print("print(results)")
print("table_spatial_1=results.to_table()")
print("table.write ('" + outdir + instr + "_table_spatial_circle.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql=("select koaid, filehand, ra, dec from " + koatable + " where contains(point('J2000', ra, dec), circle('J2000', " + circle_pos + ")) = 1")
results = koa.run_async(sql)
print(results)
table_spatial_1=results.to_table()
table.write (outdir + instr + "_table_spatial_circle.vot",format='votable',overwrite=True)
sql=("select koaid, filehand, ra, dec from koa_lws where contains(point('J2000', ra, dec), circle('J2000', 68.98 16.51 1.0)) = 1") results = koa.run_async(sql) print(results) table_spatial_1=results.to_table() table.write ('./outputLW_async/lws_table_spatial_circle.vot',format='votable',overwrite=True) ────────── <Table length=518> koaid ... dec object ... float64 ---------------------- ... -------- LW.20050219.26119.fits ... 16.508 LW.20050219.26167.fits ... 16.509 LW.20050219.26268.fits ... 16.508 LW.20050219.26436.fits ... 16.508 LW.20050219.26018.fits ... 16.51 LW.20050219.26334.fits ... 16.509 LW.20050220.22673.fits ... 16.51 LW.20050220.29357.fits ... 16.51 LW.20050220.29528.fits ... 16.509 LW.20050220.22843.fits ... 16.508 ... ... ... LW.19990902.50388.fits ... 16.508 LW.19990902.50306.fits ... 16.508 LW.19990902.50775.fits ... 16.509 LW.19990902.54480.fits ... 16.509 LW.19990902.54570.fits ... 16.509 LW.19990902.54954.fits ... 16.509 LW.19990902.56523.fits ... 16.509 LW.19991122.42812.fits ... 16.50648 LW.19991122.42980.fits ... 16.50648 LW.19991122.47190.fits ... 16.51249
print("sql=(\"select koaid, filehand, ra, dec from " + koatable + " where contains(point('J2000', ra, dec), box('J2000', " + box_pos + ")) = 1\")")
print("results = koa.run_async(sql)")
print("print(results)")
print("table_spatial_1=results.to_table()")
print("table.write ('" + outdir + instr + "_table_spatial_box.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql=("select koaid, filehand, ra, dec from " + koatable + " where contains(point('J2000', ra, dec), box('J2000', " + box_pos + ")) = 1")
results = koa.run_async(sql)
print(results)
table_spatial_1=results.to_table()
table.write (outdir + instr + "_table_spatial_box.vot",format='votable',overwrite=True)
sql=("select koaid, filehand, ra, dec from koa_lws where contains(point('J2000', ra, dec), box('J2000', 68.98 16.51 0.5 0.5)) = 1") results = koa.run_async(sql) print(results) table_spatial_1=results.to_table() table.write ('./outputLW_async/lws_table_spatial_box.vot',format='votable',overwrite=True) ────────── <Table length=518> koaid ... dec object ... float64 ---------------------- ... -------- LW.20050219.26119.fits ... 16.508 LW.20050219.26167.fits ... 16.509 LW.20050219.26268.fits ... 16.508 LW.20050219.26436.fits ... 16.508 LW.20050219.26018.fits ... 16.51 LW.20050219.26334.fits ... 16.509 LW.20050220.22673.fits ... 16.51 LW.20050220.29357.fits ... 16.51 LW.20050220.29528.fits ... 16.509 LW.20050220.22843.fits ... 16.508 ... ... ... LW.19990902.50388.fits ... 16.508 LW.19990902.50306.fits ... 16.508 LW.19990902.50775.fits ... 16.509 LW.19990902.54480.fits ... 16.509 LW.19990902.54570.fits ... 16.509 LW.19990902.54954.fits ... 16.509 LW.19990902.56523.fits ... 16.509 LW.19991122.42812.fits ... 16.50648 LW.19991122.42980.fits ... 16.50648 LW.19991122.47190.fits ... 16.51249
print("sql=(\"select koaid, filehand, ra, dec from " + koatable + " where contains(point('icrs', ra, dec), polygon('J2000', " + polygon_pos + ")) = 1\")")
print("results = koa.run_async(sql)")
print("print(results)")
print("table_spatial_1=results.to_table()")
print("table.write ('" + outdir + instr + "_table_spatial_polygon.vot',format='votable',overwrite=True)")
print(" ")
print('─' * 10)
print(" ")
sql=("select koaid, filehand, ra, dec from " + koatable + " where contains(point('icrs', ra, dec), polygon('J2000', " + polygon_pos + ")) = 1")
results = koa.run_async(sql)
print(results)
table_spatial_1=results.to_table()
table.write (outdir + instr + "_table_spatial_polygon.vot",format='votable',overwrite=True)
sql=("select koaid, filehand, ra, dec from koa_lws where contains(point('icrs', ra, dec), polygon('J2000', 67.98,15.51,67.98,17.51,70.98,22.03)) = 1") results = koa.run_async(sql) print(results) table_spatial_1=results.to_table() table.write ('./outputLW_async/lws_table_spatial_polygon.vot',format='votable',overwrite=True) ────────── <Table length=41> koaid ... dec object ... float64 ---------------------- ... -------- LW.20021113.44213.fits ... 17.86405 LW.20021113.44828.fits ... 17.86406 LW.20030220.22189.fits ... 17.525 LW.20030220.23158.fits ... 17.525 LW.20010312.19037.fits ... 17.528 LW.19990823.52297.fits ... 17.528 LW.19990823.52460.fits ... 17.528 LW.19990823.53149.fits ... 17.528 LW.19990823.53945.fits ... 17.528 LW.19990823.54734.fits ... 17.528 ... ... ... LW.19991028.50744.fits ... 17.52735 LW.19991123.44243.fits ... 17.862 LW.19991123.44614.fits ... 17.862 LW.19991122.40111.fits ... 17.53 LW.19991122.41310.fits ... 17.527 LW.19991122.38915.fits ... 17.528 LW.19991122.39504.fits ... 17.53 LW.19991122.40493.fits ... 17.527 LW.19991122.40932.fits ... 17.527 LW.19991122.41699.fits ... 17.527
print("sql=(\"select count(*) as count from " + koatable + " where date_obs=to_date('" + date + " ', 'YYYY-MM-DD')\")")
print("results = koa.run_async(sql)")
print("print(results)")
print(" ")
print('─' * 10)
print(" ")
sql=("select count(*) as count from " + koatable + " where date_obs=to_date('" + date + "', 'YYYY-MM-DD')")
results = koa.run_async(sql)
print(results)
sql=("select count(*) as count from koa_lws where date_obs=to_date('1998-12-03 ', 'YYYY-MM-DD')") results = koa.run_async(sql) print(results) ────────── <Table length=1> count int32 ----- 63
print("sql=\"select count(*) as total from " + koatable + "\"")
print("results = koa.run_async(sql)")
print("print(results)")
print(" ")
print('─' * 10)
print(" ")
sql="select count(*) as total from " + koatable
results = koa.run_async(sql)
print(results)
sql="select count(*) as total from koa_lws" results = koa.run_async(sql) print(results) ────────── <Table length=1> total int32 ----- 23737
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