Using the nexsciTAP Server with the TAP+ Client to Access Data From KOA In Asynchronous Mode

The nexsciTAP server

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 OSIRIS integral field spectrograp; these data are hosted at the Keck Observatory Archive (KOA; https://koa.ipac.caltech.edu).

Requirements

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.

A note on output records

The number of records returned here may differ from those returned here because new data are released daily.

Version 1.0 (March, 2020)

In [1]:
import numpy as np
from astroquery.utils.tap.core import TapPlus
koa = TapPlus(url="https://koa.ipac.caltech.edu/TAP")
Created TAP+ (v1.2.1) - Connection:
	Host: koa.ipac.caltech.edu
	Use HTTPS: True
	Port: 443
	SSL Port: 443

Search by date

In [2]:
sql = "select koaid, filehand from koa_osiris where koaid like '%20150529%' "
job = koa.launch_job_async(sql)
r = job.get_results()
print(r)
print(job)
INFO: Query finished. [astroquery.utils.tap.core]
        koaid                                 filehand                       
---------------------- ------------------------------------------------------
OI.20150529.41901.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.41901.fits
OI.20150529.42096.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.42096.fits
OI.20150529.42327.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.42327.fits
OI.20150529.46047.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.46047.fits
OS.20150529.01240.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01240.fits
OS.20150529.01400.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01400.fits
OS.20150529.01554.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01554.fits
OS.20150529.01606.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01606.fits
OS.20150529.01737.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01737.fits
OS.20150529.01820.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01820.fits
                   ...                                                    ...
OS.20150529.54818.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.54818.fits
OS.20150529.54981.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.54981.fits
OS.20150529.55131.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55131.fits
OS.20150529.55209.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55209.fits
OS.20150529.55541.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55541.fits
OS.20150529.55592.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55592.fits
OS.20150529.55667.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55667.fits
OS.20150529.55735.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55735.fits
OS.20150529.83374.fits /koadata23/OSIRIS/20150530/lev0/OS.20150529.83374.fits
OS.20150529.83590.fits /koadata23/OSIRIS/20150530/lev0/OS.20150529.83590.fits
OS.20150529.83772.fits /koadata23/OSIRIS/20150530/lev0/OS.20150529.83772.fits
Length = 123 rows
<Table length=123>
  name   dtype 
-------- ------
   koaid object
filehand object
Jobid: tap_tq9ak_i7
Phase: COMPLETED
Owner: None
Output file: async_20210303123918.vot
Results: None

Write the output to the IPAC ASCII, VOtable CSV and TSV formats

In [3]:
job = koa.launch_job_async(sql, dump_to_file=True, output_file='KoaTapDate.tbl', \
                           output_format='ipac')
job = koa.launch_job_async(sql, dump_to_file=True, output_file='KoaTapDate2.vot', 
                           output_format='votable') 
job = koa.launch_job_async(sql, dump_to_file=True, output_file='KoaTapDate3.csv', \
                           output_format='csv')
job = koa.launch_job_async(sql, dump_to_file=True, output_file='KoaTapDate4.tsv', \
                           output_format='tsv')

Select all keywords for data acquired on UT Date

In [4]:
sql = "select * from koa_osiris where koaid like '%20150529%'"
job = koa.launch_job_async(sql)
r = job.get_results()
print(r)
print(job)

job = koa.launch_job_async(sql, dump_to_file=True, output_file='AllFields.tbl', \
                           output_format='ipac')
INFO: Query finished. [astroquery.utils.tap.core]
        koaid          propint        ofname        ...     z      spt_ind 
---------------------- ------- -------------------- ... --------- ---------
OI.20150529.41901.fits      18 i150529_a024016.fits ...  0.026658 202000111
OI.20150529.42096.fits      18 i150529_a024017.fits ...  0.026658 202000111
OI.20150529.42327.fits      18 i150529_a024018.fits ...  0.026749 202000111
OI.20150529.46047.fits      18 i150529_a026019.fits ...  0.026722 202000111
OS.20150529.01240.fits      18 s150529_a001002.fits ... -0.001497 132000000
OS.20150529.01400.fits      18 s150529_a001003.fits ... -0.001497 132000000
OS.20150529.01554.fits      18 s150529_a001004.fits ... -0.001497 132000000
OS.20150529.01606.fits      18 s150529_a001005.fits ... -0.001497 132000000
OS.20150529.01737.fits      18 s150529_a001006.fits ... -0.001497 132000000
OS.20150529.01820.fits      18 s150529_a001007.fits ... -0.001497 132000000
                   ...     ...                  ... ...       ...       ...
OS.20150529.54818.fits      18 s150529_s032002.fits ...   0.07067 202001131
OS.20150529.54981.fits      18 s150529_s033001.fits ...  0.070675 202001131
OS.20150529.55131.fits      18 s150529_s034001.fits ...  0.070675 202001131
OS.20150529.55209.fits      18 s150529_s034002.fits ...  0.070665 202001131
OS.20150529.55541.fits      18 s150529_s035001.fits ... -0.102996 130033020
OS.20150529.55592.fits      18 s150529_s035002.fits ... -0.102986 130033020
OS.20150529.55667.fits      18 s150529_s036001.fits ... -0.103003 130033020
OS.20150529.55735.fits      18 s150529_s036002.fits ... -0.102989 130033020
OS.20150529.83374.fits      30 s150529_a001001.fits ...       0.0 200020010
OS.20150529.83590.fits      30 s150529_a001002.fits ...       0.0 200020010
OS.20150529.83772.fits      30 s150529_a001003.fits ...       0.0 200020010
Length = 123 rows
<Table length=123>
    name     dtype  n_bad
----------- ------- -----
      koaid  object     0
    propint   int32     0
     ofname  object     0
filesize_mb float64   123
   date_obs  object     0
       cdec  object     0
   elaptime float64     0
    equinox float64     0
    frameno   int32     0
   instrume  object     0
   koaimtyp  object     0
     progid  object     0
   proginst  object     0
     progpi  object     0
   progtitl  object     0
        cra  object     0
   semester  object     0
   targname  object     0
         ut  object     0
        utc  object     0
     crval1 float64   119
     crval2 float64   119
     crpix1 float64   119
     crpix2 float64   119
     ctype1  object     0
     ctype2  object     0
   wat0_001  object     0
   wat1_001  object     0
   wat2_001  object     0
     wcsdim   int32   119
     ltm1_1 float64   119
     ltm2_2 float64   119
     cdelt1 float64   119
     cdelt2 float64   119
     crota2 float64   119
   radecsys  object     0
    airmass float64     0
   aoaoamed   int32     0
    aodelay   int32     0
   aodmstat  object     0
   aodrdten float64     0
    aodrena float64     0
   aodtstat  object     0
   aofclbct  object     0
   aofclbfo float64     0
   aofclgct  object     0
   aofclgfo float64     0
   aofcngct  object     0
   aofcngfo float64     0
   aofcsalt   int32     0
      aofmx float64     0
      aofmy float64     0
   aofomode  object     0
   aolbfwhm float64     0
   aolpmove  object     0
   aoopsmod   int32     0
    aotsdar  object     0
      aotsx float64     0
      aotsy float64     0
      aotsz float64     0
   aottmode  object     0
     aowfc0 float64     0
    axestat  object     0
         az float64     0
     badpix  object     0
     bitpix float64     0
    calocal float64     0
    celocal float64     0
     coadds   int32     0
      ctmp1 float64     0
      ctmp2 float64     0
      ctmp3 float64     0
      ctmp4 float64     0
      ctmp5 float64     0
      ctmp6 float64     0
      ctmp7 float64     0
      ctmp8 float64     0
   ctmploc1  object     0
   ctmploc2  object     0
   ctmploc3  object     0
   ctmploc4  object     0
   ctmploc5  object     0
   ctmploc6  object     0
   ctmploc7  object     0
   ctmploc8  object     0
   currinst  object     0
   datafile  object     0
    dataset  object     0
    dcoords  object     0
    dcsstat  object     0
       ddec float64     0
     decoff float64     0
   dlstoff1 float64     0
   dlstoff2 float64     0
     dmgain float64     0
     dmmrfn  object     0
   domeposn float64     0
   domestat  object     0
   dpwname1  object     0
   dpwname2  object     0
   dpwname3  object     0
   dpwname4  object     0
   dpwname5  object     0
   dpwname6  object     0
   dpwname7  object     0
   dpwstat1   int32     0
   dpwstat2   int32     0
   dpwstat3   int32     0
   dpwstat4   int32     0
   dpwstat5   int32     0
   dpwstat6   int32     0
   dpwstat7   int32     0
   dpwstat8   int32     0
        dra float64     0
      dtclp  object     0
     dtgain float64     0
      dtmp1 float64     0
      dtmp2 float64     0
      dtmp3 float64     0
      dtmp4 float64     0
      dtmp5 float64     0
      dtmp6 float64     0
      dtmp7 float64     0
      dtmp8 float64     0
   dtmploc1  object     0
   dtmploc2  object     0
   dtmploc3  object     0
   dtmploc4  object     0
   dtmploc5  object     0
   dtmploc6  object     0
   dtmploc7  object     0
   dtmploc8  object     0
   dtotoff1 float64     0
   dtotoff2 float64     0
     dtrack  object     0
         el float64     0
   epwname1  object     0
   epwname2  object     0
   epwname3  object     0
   epwname4  object     0
   epwname5  object     0
   epwname6  object     0
   epwname7  object     0
   epwname8  object     0
   epwstat1   int32     0
   epwstat2   int32     0
   epwstat3   int32     0
   epwstat4   int32     0
   epwstat5   int32     0
   epwstat6   int32     0
   epwstat7   int32     0
   epwstat8   int32     0
     extend  object     0
   focalstn  object     0
   framenum   int32     0
       gain float64     0
   guidwave float64     0
         ha float64     0
    icurtmp float64     0
    if1mech  object     0
    if1name  object     0
     if1raw   int32     0
    if1stat  object     0
   if1swtch   int32     0
    if2mech  object     0
    if2name  object     0
     if2raw   int32     0
    if2stat  object     0
   if2swtch   int32     0
    ifilter  object     0
     iframe   int32     0
    iframes   int32     0
    ihtract   int32     0
    ihtrout float64     0
   imagmode  object     0
   instangl float64     0
   instflip  object     0
      instr  object     0
      issky   int32     0
      itime float64     0
    itrgtmp float64     0
    lgrmswf float64     0
   lsamppwr float64   123
     lsprop  object     0
        lst  object     0
    mjd_obs float64     0
      naxis   int32     0
     naxis1   int32     0
     naxis2   int32     0
   noisefil  object     0
   numreads   int32     0
   obamname  object     0
   obfmdren float64     0
    obfmxim float64     0
    obfmxpu float64     0
    obfmyim float64     0
    obfmypu float64     0
   obfsname  object     0
   obimname  object     0
     object  object     0
   objpttrn  object     0
   oblbname  object     0
       obrt float64     0
   obsdname  object     0
   observer  object     0
   obsfname  object     0
      obsfx float64     0
      obsfy float64     0
      obsfz float64     0
       obsi float64     0
   obsnname  object     0
    obstype  object     0
   obswname  object     0
    obswsta  object     0
   obtsname  object     0
      obtsx float64     0
      obtsy float64     0
      obtsz float64     0
   obwcname  object     0
       obwf float64     0
   obwfstst  object     0
   obwlname  object     0
   obwnname  object     0
   obwpname  object     0
     parang float64     0
    pa_imag float64     0
    pa_spec float64     0
    pcifile  object     0
     poname  object     0
    poname1  object     0
    poname2  object     0
    poname3  object     0
     poxpos float64     0
    poxpos1 float64     0
    poxpos2 float64     0
    poxpos3 float64     0
     poypos float64     0
    poypos1 float64     0
    poypos2 float64     0
    poypos3 float64     0
   pressure float64     0
      raoff float64     0
    rditime float64     0
   readtime float64     0
   rotcalan float64     0
    rotdest float64     0
    rotmode  object     0
   rotpdest float64     0
    rotposn float64     0
   rotpposn float64     0
   rotrefan float64     0
   sampmode   int32     0
   saturate   int32     0
    scurtmp float64     0
   secfocus float64     0
   secthetx float64     0
   secthety float64     0
     setnum   int32     0
    sfilter  object     0
     sframe   int32     0
    sframes   int32     0
    sfwmech  object     0
    sfwname  object     0
     sfwraw float64     0
    sfwstat  object     0
   sfwswtch   int32     0
    shtract   int32     0
    shtrout float64     0
   shtrrang   int32     0
     simple  object     0
   skypttrn  object     0
    slmmech  object     0
    slmname  object     0
     slmraw   int32     0
    slmstat  object     0
   slmswtch   int32     0
    ss1mech  object     0
    ss1name  object     0
     ss1raw   int32     0
    ss1stat  object     0
   ss1swtch   int32     0
    ss2mech  object     0
    ss2name  object     0
     ss2raw   int32     0
    ss2stat  object     0
   ss2swtch   int32     0
     sscale float64     0
    strgtmp float64     0
   targwave float64     0
   telescop  object     0
   telfocus float64     0
    timfile  object     0
   tubetemp float64     0
      utclp  object     0
     utgain float64     0
   wcdmstat  object     0
   wcdtstat  object     0
   wcutstat  object     0
      wfdar  object     0
       wfdm  object     0
       wftt  object     0
   wscnorfn  object     0
     wsfrrt   int32     0
     wssmgn   int32     0
    wssmprg   int32     0
    wssmrep   int32     0
   datlevel   int32     0
   dqa_date  object     0
   dqa_vers  object     0
         oa  object     0
   waveblue float64    35
   wavecntr float64    35
    wavered float64    35
   wxdomhum float64     3
   wxdomtmp float64     3
     wxdwpt float64     3
   wxouthum float64     3
   wxouttmp float64     3
    wxpress float64     3
     wxtime  object     0
    wxwndir float64   123
    wxwndsp float64   123
    npixsat   int32     0
     nonlin   int32     0
    nlinear   int32     0
     filter  object     0
      scale float64     0
         ra float64     0
        dec float64     0
 utdatetime  object     0
 l0_ingtime  object     0
   filehand  object     0
      semid  object     0
          x float64     0
          y float64     0
          z float64     0
    spt_ind   int32     0
Jobid: tap_8k2om7_3
Phase: COMPLETED
Owner: None
Output file: async_20210303123953.vot
Results: None

Select columns acquired on UT Date

In [5]:
sql = "select koaid, filehand  from koa_osiris \
    where koaid like '%20150529%' "
job = koa.launch_job_async(sql, dump_to_file=True, output_file='columns.tbl', output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid                                 filehand                       
---------------------- ------------------------------------------------------
OI.20150529.41901.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.41901.fits
OI.20150529.42096.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.42096.fits
OI.20150529.42327.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.42327.fits
OI.20150529.46047.fits /koadata23/OSIRIS/20150529/lev0/OI.20150529.46047.fits
OS.20150529.01240.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01240.fits
OS.20150529.01400.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01400.fits
OS.20150529.01554.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01554.fits
OS.20150529.01606.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01606.fits
OS.20150529.01737.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01737.fits
OS.20150529.01820.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.01820.fits
                   ...                                                    ...
OS.20150529.54818.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.54818.fits
OS.20150529.54981.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.54981.fits
OS.20150529.55131.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55131.fits
OS.20150529.55209.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55209.fits
OS.20150529.55541.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55541.fits
OS.20150529.55592.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55592.fits
OS.20150529.55667.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55667.fits
OS.20150529.55735.fits /koadata23/OSIRIS/20150529/lev0/OS.20150529.55735.fits
OS.20150529.83374.fits /koadata23/OSIRIS/20150530/lev0/OS.20150529.83374.fits
OS.20150529.83590.fits /koadata23/OSIRIS/20150530/lev0/OS.20150529.83590.fits
OS.20150529.83772.fits /koadata23/OSIRIS/20150530/lev0/OS.20150529.83772.fits
Length = 123 rows



<Table length=123>
  name   dtype
-------- -----
   koaid str22
filehand str54
Jobid: tap_ea1tiiyo
Phase: COMPLETED

Owner: None
Output file: columns.tbl
Results: None

Select a maximum number of records

In [6]:
sql="select top 20 koaid, filehand, frameno from koa_osiris \
    where koaid like '%20150529%'"

job = koa.launch_job_async(sql, dump_to_file=True, output_file='top20.tbl', output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid          ... frameno
---------------------- ... -------
OI.20150529.41901.fits ...      16
OI.20150529.42096.fits ...      17
OI.20150529.42327.fits ...      18
OI.20150529.46047.fits ...      19
OS.20150529.01240.fits ...       2
OS.20150529.23625.fits ...       1
OS.20150529.23777.fits ...       1
OS.20150529.45616.fits ...       1
OS.20150529.45783.fits ...       2
OS.20150529.46315.fits ...       1
OS.20150529.46963.fits ...       2
OS.20150529.47668.fits ...       1
OS.20150529.48307.fits ...       2
OS.20150529.48950.fits ...       3
OS.20150529.49599.fits ...       4
OS.20150529.50306.fits ...       1
OS.20150529.50959.fits ...       2
OS.20150529.51607.fits ...       3
OS.20150529.52975.fits ...       2
OS.20150529.53621.fits ...       3



<Table length=20>
  name   dtype
-------- -----
   koaid str22
filehand str54
 frameno int64
Jobid: tap_i35utdom
Phase: COMPLETED

Owner: None
Output file: top20.tbl
Results: None

Select columns and search by date range

In [7]:
sql="select koaid, filehand from koa_osiris \
     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_async(sql, dump_to_file=True, output_file='DateRange.tbl', output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid                                 filehand                       
---------------------- ------------------------------------------------------
OS.20150902.75160.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.75160.fits
OS.20150902.75197.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.75197.fits
OS.20150902.75229.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.75229.fits
OS.20150902.75262.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.75262.fits
OS.20150902.77319.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.77319.fits
OS.20150902.77352.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.77352.fits
OS.20150902.69966.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.69966.fits
OS.20150902.69999.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.69999.fits
OS.20150902.70033.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.70033.fits
OS.20150902.75295.fits /koadata23/OSIRIS/20150903/lev0/OS.20150902.75295.fits
                   ...                                                    ...
OS.20150913.79206.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.79206.fits
OS.20150913.79234.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.79234.fits
OS.20150913.79264.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.79264.fits
OS.20150913.79297.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.79297.fits
OS.20150913.72749.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.72749.fits
OS.20150913.72777.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.72777.fits
OS.20150913.75913.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.75913.fits
OS.20150913.75943.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.75943.fits
OS.20150913.75971.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.75971.fits
OS.20150913.76000.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.76000.fits
OS.20150913.76028.fits /koadata23/OSIRIS/20150914/lev0/OS.20150913.76028.fits
Length = 20086 rows



<Table length=20086>
  name   dtype
-------- -----
   koaid str22
filehand str54
Jobid: tap_bekfzmui
Phase: COMPLETED

Owner: None
Output file: DateRange.tbl
Results: None

Search by program ID

In [8]:
sql= ("select koaid, filehand, progid, ha, az \
    from koa_osiris where (progid = 'N021') ")



job = koa.launch_job_async(sql, dump_to_file=True, output_file='ProgramID.tbl', output_format='ipac')

r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid          ...     az   
                       ...  degrees 
---------------------- ... ---------
OI.20190529.09103.fits ... 229.99966
OI.20190529.09810.fits ... 229.99967
OI.20190529.10083.fits ... 229.99967
OI.20190529.10304.fits ... 229.99967
OI.20190529.10373.fits ... 229.99967
OI.20190529.10484.fits ... 229.99967
OI.20190529.10526.fits ... 229.99967
OI.20190529.10568.fits ... 229.99967
OI.20190529.10609.fits ... 229.99968
OI.20190529.10650.fits ... 229.99968
                   ... ...       ...
OI.20190531.51610.fits ... 218.49028
OI.20190531.51700.fits ... 218.75805
OI.20190531.51772.fits ... 218.97391
OI.20190531.51842.fits ... 219.18109
OI.20190531.52132.fits ... 218.77133
OI.20190531.52204.fits ... 219.00335
OI.20190531.52276.fits ... 219.23572
OI.20190531.52361.fits ...  219.5109
OI.20190531.52434.fits ...  219.7435
OI.20190531.52514.fits ...  219.9956
Length = 549 rows



<Table length=549>
  name    dtype    unit 
-------- ------- -------
   koaid   str22        
filehand   str54        
  progid    str4        
      ha float64        
      az float64 degrees
Jobid: tap_tdry_qfu
Phase: COMPLETED

Owner: None
Output file: ProgramID.tbl
Results: None
In [9]:
sql=("select koaid, filehand, ra, dec from koa_osiris where \
    contains(point('icrs', ra, dec), \
    circle('icrs', 270.4 -27.2 1.0)) = 1")

job = koa.launch_job_async(sql, dump_to_file=True, output_file='ConeSearch.tbl', output_format='ipac')

r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid          ...    dec   
---------------------- ... ---------
OI.20190421.48934.fits ...   -27.547
OI.20190421.49094.fits ...   -27.547
OI.20190421.49287.fits ...   -27.547
OI.20190421.49344.fits ...   -27.547
OI.20190421.49394.fits ...   -27.547
OI.20190421.49442.fits ...   -27.547
OI.20190421.49493.fits ...   -27.547
OI.20190421.49560.fits ... -27.54716
OI.20190421.49610.fits ... -27.54716
OI.20190421.49659.fits ... -27.54716
                   ... ...       ...
OI.20190513.43152.fits ... -27.54727
OI.20190513.43202.fits ... -27.54727
OI.20190513.43252.fits ... -27.54727
OI.20190513.43301.fits ... -27.54727
OI.20190513.43350.fits ... -27.54727
OS.20160813.24913.fits ... -26.52847
OS.20160813.24983.fits ... -26.52819
OS.20160813.25147.fits ... -26.52847
OS.20160813.25218.fits ... -26.52819
OS.20160813.25335.fits ... -26.52847
OS.20160813.25407.fits ... -26.52819
Length = 122 rows



<Table length=122>
  name    dtype 
-------- -------
   koaid   str22
filehand   str54
      ra float64
     dec float64
Jobid: tap_5rw7ka65
Phase: COMPLETED

Owner: None
Output file: ConeSearch.tbl
Results: None
In [10]:
sql=("select koaid, filehand, ra, dec from koa_osiris where \
     contains(point('icrs', ra, dec), \
     box('icrs',23.4, 30.60,1.0,120)) = 1")

job = koa.launch_job_async(sql, dump_to_file=True, output_file='Spat_Box.tbl', \
                           output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid          ...    dec   
---------------------- ... ---------
OI.20051012.12061.fits ...  89.96783
OI.20051012.12087.fits ...  89.96783
OI.20051012.12111.fits ...  89.96783
OI.20051012.12135.fits ...  89.96783
OI.20051012.12160.fits ...  89.96783
OI.20051012.12957.fits ...  89.96783
OI.20051012.13651.fits ...  89.96783
OI.20051012.13676.fits ...  89.96783
OI.20051012.13692.fits ...  89.96783
OI.20051012.13717.fits ...  89.96783
                   ... ...       ...
OS.20210114.24130.fits ... -13.08002
OS.20210114.24190.fits ... -13.08002
OS.20210114.24245.fits ... -13.08002
OS.20210114.24299.fits ... -13.08002
OS.20210114.24357.fits ... -13.08002
OS.20210114.24411.fits ... -13.08002
OS.20210114.24464.fits ... -13.08002
OS.20210114.24523.fits ... -13.08002
OS.20210114.24578.fits ... -13.08002
OS.20210114.24632.fits ... -13.08002
OS.20210114.24690.fits ... -13.08002
Length = 2645 rows



<Table length=2645>
  name    dtype 
-------- -------
   koaid   str22
filehand   str54
      ra float64
     dec float64
Jobid: tap_tpbuql3i
Phase: COMPLETED

Owner: None
Output file: Spat_Box.tbl
Results: None
In [11]:
sql=("select koaid, filehand, ra, dec from koa_osiris  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_async(sql, dump_to_file=True, output_file='Spat_Poly.tbl', \
                           output_format='ipac')
r = job.get_results()
print(r)
        koaid          ...   dec   
---------------------- ... --------
OS.20160416.49503.fits ... 54.41594
OS.20160416.49605.fits ... 54.41594
OS.20160416.49631.fits ... 54.41594
OS.20160416.49658.fits ... 54.41594
OS.20160416.49683.fits ... 54.41594
OS.20160416.49709.fits ... 54.41594
OS.20160416.49744.fits ... 54.41594
OS.20160416.49769.fits ... 54.41594
OS.20160416.49796.fits ... 54.41594
OS.20160416.49826.fits ... 54.41594
                   ... ...      ...
OS.20170509.43779.fits ... 54.23825
OS.20170509.43806.fits ... 54.23825
OS.20170509.43836.fits ... 54.23825
OS.20170509.43864.fits ... 54.23825
OS.20170509.43890.fits ... 54.23784
OS.20170509.43920.fits ... 54.23784
OS.20170509.43948.fits ... 54.23825
OS.20170509.43974.fits ... 54.23825
OS.20170509.44001.fits ... 54.23825
OS.20170509.44027.fits ... 54.23825
OS.20170509.44083.fits ... 54.23825
Length = 215 rows

Count number of records in date range

In [15]:
sql=("select count(*) from koa_osiris 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_async(sql, dump_to_file=True, output_file='Count_daterange.tbl', \
                           output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
count(*)
--------
     306



<Table length=1>
  name   dtype
-------- -----
count(*) int64
Jobid: tap_x6nwo8rb
Phase: COMPLETED

Owner: None
Output file: Count_daterange.tbl
Results: None

Count total number of records in table

In [16]:
sql="select count(*) as total from koa_osiris"

job = koa.launch_job_async(sql, dump_to_file=True, output_file='Count_table.tbl', \
                           output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
total 
------
239106



<Table length=1>
 name dtype
----- -----
total int64
Jobid: tap_wddph_nb
Phase: COMPLETED

Owner: None
Output file: Count_table.tbl
Results: None

Note that in asynchronous mode, TAP+ returns all records.


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=KO

In [ ]: