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 calibation data acquired with the HIRES instrument; 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, 2021)

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_hires where koaid like '%20040824%' "
job = koa.launch_job_async(sql)
r = job.get_results()
print(r)
print(job)
INFO: Query finished. [astroquery.utils.tap.core]
        koaid                                filehand                      
---------------------- ----------------------------------------------------
HI.20040824.08204.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08204.fits
HI.20040824.08544.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08544.fits
HI.20040824.08591.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08591.fits
HI.20040824.08638.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08638.fits
HI.20040824.08685.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08685.fits
HI.20040824.08732.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08732.fits
HI.20040824.08779.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08779.fits
HI.20040824.08826.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08826.fits
HI.20040824.08873.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08873.fits
HI.20040824.08919.fits /koadata1/HIRES/20040824/lev0/HI.20040824.08919.fits
                   ...                                                  ...
HI.20040824.54756.fits /koadata1/HIRES/20040824/lev0/HI.20040824.54756.fits
HI.20040824.54803.fits /koadata1/HIRES/20040824/lev0/HI.20040824.54803.fits
HI.20040824.54849.fits /koadata1/HIRES/20040824/lev0/HI.20040824.54849.fits
HI.20040824.54896.fits /koadata1/HIRES/20040824/lev0/HI.20040824.54896.fits
HI.20040824.54944.fits /koadata1/HIRES/20040824/lev0/HI.20040824.54944.fits
HI.20040824.54990.fits /koadata1/HIRES/20040824/lev0/HI.20040824.54990.fits
HI.20040824.55037.fits /koadata1/HIRES/20040824/lev0/HI.20040824.55037.fits
HI.20040824.55084.fits /koadata1/HIRES/20040824/lev0/HI.20040824.55084.fits
HI.20040824.55131.fits /koadata1/HIRES/20040824/lev0/HI.20040824.55131.fits
HI.20040824.55177.fits /koadata1/HIRES/20040824/lev0/HI.20040824.55177.fits
HI.20040824.55224.fits /koadata1/HIRES/20040824/lev0/HI.20040824.55224.fits
Length = 105 rows
<Table length=105>
  name   dtype 
-------- ------
   koaid object
filehand object
Jobid: tap_str17mlm
Phase: COMPLETED
Owner: None
Output file: async_20210304091637.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 20040824

In [4]:
sql = "select * from koa_hires where koaid like '%20040824%'"
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]
 el  elaptime equinox eramode ...      z        spt_ind      ofname    
---- -------- ------- ------- ... ------------ --------- --------------
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2300.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2301.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2302.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2303.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2304.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2305.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2306.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2307.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2308.fits
45.0        1     0.0 B, G, R ... 0.7068576891 203233131 hires2309.fits
 ...      ...     ...     ... ...          ...       ...            ...
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2394.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2395.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2396.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2397.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2398.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2399.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2400.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2401.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2402.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2403.fits
0.01        1  2000.0 B, G, R ... 0.0001813223 200021201 hires2404.fits
Length = 105 rows
<Table length=105>
   name     dtype  n_bad
---------- ------- -----
        el float64     0
  elaptime   int32     0
   equinox float64     0
   eramode  object     0
  erasecnt   int32     0
  erasline  object     0
  exm0dovf   int32     0
  exm0dsum   int32     0
  exm0fwmp   int32     0
  exm0lovf   int32     0
  exm0lsum   int32     0
  exm0midp   int32     0
   exm0mod  object     0
  exm0ssum   int32     0
   exm0sta  object     0
  exm0targ   int32     0
  exm0tovf   int32     0
  exposure   int32   105
   exptime float64     0
    extend  object     0
   fil1cal  object     0
   fil1con  object     0
  fil1name  object     0
   fil1pos   int32     0
   fil1raw   int32     0
   fil2cal  object     0
   fil2con  object     0
  fil2name  object     0
   fil2pos   int32     0
   fil2raw   int32     0
  flushmod  object     0
     frame  object     0
   frameno   int32     0
  guidfwhm float64    56
  guidtime  object     0
        ha  object     0
   hatclos  object     0
    hatcon  object     0
   hatopen  object     0
  im01md01 float64     0
  im01md02 float64     0
  im01md03 float64     0
  im01md04 float64   105
  im01md05 float64   105
  im01md06 float64   105
  im01mn01 float64     0
  im01mn02 float64     0
  im01mn03 float64     0
  im01mn04 float64   105
  im01mn05 float64   105
  im01mn06 float64   105
  im01sd01 float64     0
  im01sd02 float64     0
  im01sd03 float64     0
  im01sd04 float64   105
  im01sd05 float64   105
  im01sd06 float64   105
  koaimtyp  object     0
    imtype  object     0
  instrume  object     0
  inststat   int32     0
    iodcon  object     0
     iodin  object     0
    iodout  object     0
  irot2ang float64     0
  irot2cal  object     0
   irotcal  object     0
   irotcon  object     0
  irotcvop  object     0
    irotin  object     0
   irotout  object     0
  keepprep  object     0
  lampcat1  object     0
  lampcat2  object     0
  lampdeut  object     0
   lamplsr  object     0
  lampname  object     0
  lampqtz2  object     0
   lfilcal  object     0
   lfilcon  object     0
  lfilname  object     0
   lfilpos   int32     0
   lfilraw   int32     0
    lights  object     0
   lmirrin  object     0
  lmirrout  object     0
   lselcal  object     0
   lselcon  object     0
  lselname  object     0
   lselraw   int32     0
       mjd float64     0
   mosmode  object     0
     naxis   int32     0
   npixsat   int32     0
   nsubint   int32     0
   numamps   int32   105
   nvidinp   int32     0
        oa  object     0
    object  object     0
  observer  object     0
    obsnum   int32   105
   obstype  object     0
    outdir  object     0
   outfile  object     0
  ovrflush   int32     0
      pane  object     0
     pane1  object     0
    pane10  object     0
    pane11  object     0
    pane12  object     0
    pane13  object     0
    pane14  object     0
    pane15  object     0
    pane16  object     0
     pane2  object     0
     pane3  object     0
     pane4  object     0
     pane5  object     0
     pane6  object     0
     pane7  object     0
     pane8  object     0
     pane9  object     0
  panefits  object     0
  panelist  object     0
  panerror  object     0
    parang float64     0
  pexpelap   int32     0
  pexptime   int32     0
  pmt0mpow  object     0
   pmt0ovl  object     0
  pmt0tpow  object     0
  postline   int32     0
   postpix   int32     0
    precol   int32     0
  preflush   int32     0
   preline   int32     0
    prerow   int32     0
    progid  object     0
  proginst  object     0
    progpi  object     0
  progtitl  object     0
  prop0sta  object     0
  pt01md01 float64     0
  pt01md02 float64     0
     koaid  object     0
  propint1   int32     0
  propint2   int32     0
  propint3   int32     0
   propint   int32     0
    abfreq   int32     0
   acpower  object     0
   airmass float64     0
  airpress float64     0
   amplist  object     0
   ampmode  object     0
  amppsize  object     0
   antiblm  object     0
  arcfocus float64    95
    arcres float64    95
  autoshut  object     0
        az float64     0
  bccvclos  object     0
  bccvopen  object     0
   binning  object     0
    bitpix   int32     0
    bscale float64     0
     bzero float64     0
  c1cvclos  object     0
  c1cvopen  object     0
  c2cvclos  object     0
  c2cvopen  object     0
  cacvclos  object     0
  cacvopen  object     0
    cafcal  object     0
    cafcon  object     0
   cafname  object     0
   cafocus float64     0
    cafraw   int32     0
    camcon  object     0
   catcur1 float64     0
   catcur2 float64     0
     caton  object     0
   ccdgain  object     0
   ccdgn01 float64     0
   ccdgn02 float64     0
   ccdgn03 float64     0
   ccdgn04 float64   105
   ccdgn05 float64   105
   ccdgn06 float64   105
  ccdpsize  object     0
   ccdrn01 float64     0
   ccdrn02 float64     0
   ccdrn03 float64     0
   ccdrn04 float64   105
   ccdrn05 float64   105
   ccdrn06 float64   105
  ccdspeed  object     0
    ccdsum  object     0
  checksum  object     0
    cofcal  object     0
    cofcon  object     0
   cofname  object     0
   cofocus float64     0
    cofraw   int32     0
  collblue  object     0
  collbrak  object     0
   collcon  object     0
   collred  object     0
  coolflow  object     0
  darkclos  object     0
  darkopen  object     0
  darktime float64     0
   datasum  object     0
   date_ut  object     0
  date_beg  object     0
  date_end  object     0
  date_obs  object     0
  datlevel   int32     0
   dcsstat  object     0
       dec float64     0
   deckcal  object     0
   deckcon  object     0
   deckloc float64     0
  deckname  object     0
   deckraw   int32     0
  detcnfid   int32     0
  detector  object     0
  detlsize  object     0
  dispscal float64     0
  domestat  object     0
      door  object     0
  dqa_date  object     0
  dqa_vers  object     0
   dwrn2lv float64     0
   echangl float64     0
    echcal  object     0
    echcon  object     0
   echname  object     0
    echpix float64     0
    echraw   int32     0
  ecovclos  object     0
  ecovopen  object     0
  pt01md03 float64     0
  pt01md04 float64   105
  pt01md05 float64   105
  pt01md06 float64   105
  pt01mn01 float64     0
  pt01mn02 float64     0
  pt01mn03 float64     0
  pt01mn04 float64   105
  pt01mn05 float64   105
  pt01mn06 float64   105
  pt01sd01 float64     0
  pt01sd02 float64     0
  pt01sd03 float64     0
  pt01sd04 float64   105
  pt01sd05 float64   105
  pt01sd06 float64   105
   pwrblok float64   105
  pwrblok1 float64     0
  pwrblok2 float64     0
  pwrblok3 float64     0
        ra float64     0
  rccvclos  object     0
  rccvopen  object     0
    relhum float64     0
   resn2lv float64     0
    roqual  object     0
   rotdest float64     0
   rotmode  object     0
   rotposn float64     0
   rowshft   int32     0
  semester  object     0
  shbloptm float64     0
  shclocnt   int32     0
  shlatclo float64     0
  shopncnt   int32     0
  sig2nois float64     0
    simple  object     0
     skypa float64     0
   slitcal  object     0
   slitcon  object     0
   slitlen float64     0
  slitname  object     0
   slitraw   int32     0
   slitwid float64     0
  slitwidt float64     0
  spatscal float64     0
   specres float64     0
        st  object     0
    subexp  object     0
  targname  object     0
  telescop  object     0
  telfocus float64     0
  tempcool float64     0
   tempdet float64     0
  tempdet1 float64     0
  tempdet2 float64     0
  tempdet3 float64     0
    tempin float64     0
  tempiod1 float64     0
  tempiod2 float64     0
  templamp float64     0
   tempout float64     0
   tempset float64     0
    temptv float64     0
     ttime   int32     0
    tvacal  object     0
    tvacon  object     0
   tvaname  object     0
    tvaraw   int32     0
   tvf1cal  object     0
   tvf1con  object     0
  tvf1name  object     0
   tvf1pos   int32     0
   tvf1raw   int32     0
   tvf2cal  object     0
   tvf2con  object     0
  tvf2name  object     0
   tvf2pos   int32     0
   tvf2raw   int32     0
    tvfcal  object     0
    tvfcon  object     0
   tvfname  object     0
   tvfocus float64     0
    tvfraw   int32     0
      tvon  object     0
     upson  object     0
        ut  object     0
  utb15ven  object     0
  utb30ven  object     0
   utbm15v float64     0
   utbp15v float64     0
   utbp30v float64     0
    utbp5v float64     0
   utbtemp float64     0
    ut_end  object     0
  vidinact   int32     0
  vidinbeg   int32     0
  vidinend   int32     0
   vidoff1   int32     0
   vidoff2   int32     0
   vidoff3   int32     0
   vidoff4   int32     0
   vidoff5   int32     0
   vidoff6   int32     0
  waveblue float64     0
  wavecntr float64     0
   wavered float64     0
    window  object     0
  wxdomhum float64     0
  wxdomtmp float64     0
    wxdwpt float64     0
  wxouthum float64     0
  wxouttmp float64     0
   wxpress float64     0
    wxtime  object     0
   wxwndir float64     0
   wxwndsp float64     0
  xcovclos  object     0
  xcovopen  object     0
    xdangl float64     0
     xdcal  object     0
     xdcon  object     0
  xddeltad float64     0
  xdispers  object     0
    xdname  object     0
     xdpix float64     0
     xdraw   int32     0
  xdsigmai float64     0
     xflip   int32   105
     yflip   int32   105
       cra  object     0
      cdec  object     0
      ha_d float64     0
utdatetime  object     0
  filehand  object     0
     semid  object     0
         x float64     0
         y float64     0
         z float64     0
   spt_ind   int32     0
    ofname  object     0
Jobid: tap_ujpa4i_4
Phase: COMPLETED
Owner: None
Output file: async_20210304091711.vot
Results: None

Select columns acquired on UT Date 20040824 and order by signal-to-noise (sig2nois)

In [5]:
sql = "select koaid, filehand, sig2nois from koa_hires \
    where koaid like '%20040824%'order by sig2nois"
job = koa.launch_job_async(sql, dump_to_file=True, output_file='orderbysig2nois.tbl', output_format='ipac')
r = job.get_results()
print(r)
print('\n\n')
print(job)
        koaid          ... sig2nois
---------------------- ... --------
HI.20040824.09677.fits ...      2.0
HI.20040824.09724.fits ...      2.0
HI.20040824.54001.fits ...      2.0
HI.20040824.53947.fits ...      2.0
HI.20040824.45942.fits ...      2.0
HI.20040824.44695.fits ...      2.0
HI.20040824.44395.fits ...      2.0
HI.20040824.44343.fits ...      2.0
HI.20040824.43054.fits ...      2.0
HI.20040824.41806.fits ...      2.0
                   ... ...      ...
HI.20040824.09058.fits ...     11.0
HI.20040824.09011.fits ...     11.0
HI.20040824.08965.fits ...     11.0
HI.20040824.08873.fits ...     11.0
HI.20040824.09105.fits ...     11.0
HI.20040824.08779.fits ...     11.0
HI.20040824.08732.fits ...     11.0
HI.20040824.08826.fits ...     11.0
HI.20040824.08591.fits ...     11.0
HI.20040824.08204.fits ...     11.0
HI.20040824.08685.fits ...     15.0
Length = 105 rows



<Table length=105>
  name    dtype 
-------- -------
   koaid   str22
filehand   str52
sig2nois float64
Jobid: tap_xwnj24yx
Phase: COMPLETED

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

Select a maximum number of records

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

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
---------------------- ... -------
HI.20040824.08732.fits ...    2305
HI.20040824.08965.fits ...    2310
HI.20040824.09910.fits ...    2321
HI.20040824.10096.fits ...    2325
HI.20040824.10189.fits ...    2327
HI.20040824.16108.fits ...    2334
HI.20040824.16433.fits ...    2339
HI.20040824.16480.fits ...    2340
HI.20040824.16526.fits ...    2341
HI.20040824.17057.fits ...    2350
HI.20040824.18573.fits ...    2352
HI.20040824.29673.fits ...    2362
HI.20040824.30924.fits ...    2363
HI.20040824.36514.fits ...    2369
HI.20040824.44695.fits ...    2379
HI.20040824.54207.fits ...    2385
HI.20040824.54301.fits ...    2387
HI.20040824.54347.fits ...    2388
HI.20040824.54488.fits ...    2391
HI.20040824.54896.fits ...    2397



<Table length=20>
  name   dtype
-------- -----
   koaid str22
filehand str52
 frameno int64
Jobid: tap_43ldmfzj
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_hires \
     where (utdatetime >= to_date('2009-01-01 00:00:00', \
    'yyyy-mm-dd HH24:MI:SS') and \
     utdatetime <= to_date('2009-01-05 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                      
---------------------- ----------------------------------------------------
HI.20090101.09133.fits /koadata4/HIRES/20090101/lev0/HI.20090101.09133.fits
HI.20090101.09658.fits /koadata4/HIRES/20090101/lev0/HI.20090101.09658.fits
HI.20090101.09784.fits /koadata4/HIRES/20090101/lev0/HI.20090101.09784.fits
HI.20090104.02004.fits /koadata4/HIRES/20090104/lev0/HI.20090104.02004.fits
HI.20090104.02222.fits /koadata4/HIRES/20090104/lev0/HI.20090104.02222.fits
HI.20090104.02477.fits /koadata4/HIRES/20090104/lev0/HI.20090104.02477.fits
HI.20090105.04559.fits /koadata4/HIRES/20090105/lev0/HI.20090105.04559.fits
HI.20090105.05148.fits /koadata4/HIRES/20090105/lev0/HI.20090105.05148.fits
HI.20090105.06188.fits /koadata4/HIRES/20090105/lev0/HI.20090105.06188.fits
HI.20090105.08445.fits /koadata4/HIRES/20090105/lev0/HI.20090105.08445.fits
                   ...                                                  ...
HI.20090105.10541.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10541.fits
HI.20090105.10587.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10587.fits
HI.20090105.10632.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10632.fits
HI.20090105.10678.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10678.fits
HI.20090105.10724.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10724.fits
HI.20090105.10770.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10770.fits
HI.20090105.10816.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10816.fits
HI.20090105.10862.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10862.fits
HI.20090105.10908.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10908.fits
HI.20090105.10954.fits /koadata4/HIRES/20090105/lev0/HI.20090105.10954.fits
HI.20090105.11000.fits /koadata4/HIRES/20090105/lev0/HI.20090105.11000.fits
Length = 61 rows



<Table length=61>
  name   dtype
-------- -----
   koaid str22
filehand str52
Jobid: tap_72kdjmrg
Phase: COMPLETED

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

Search by program ID

In [8]:
sql= ("select koaid, filehand, progid, iodin, koaimtyp \
      from koa_hires where (progid = 'C307') ")

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          ... koaimtyp
---------------------- ... --------
HI.20180331.02525.fits ...    focus
HI.20180331.03342.fits ...    focus
HI.20180331.03598.fits ...    focus
HI.20180331.03786.fits ...    focus
HI.20180331.03943.fits ...    focus
HI.20180331.04060.fits ...    focus
HI.20180331.04218.fits ...    focus
HI.20180331.04338.fits ...    focus
HI.20180331.04502.fits ...  arclamp
HI.20180331.04578.fits ...  arclamp
                   ... ...      ...
HI.20180801.44904.fits ...   object
HI.20180801.45058.fits ...   object
HI.20180801.45222.fits ...   object
HI.20180801.45356.fits ...   object
HI.20180801.45644.fits ...   object
HI.20180801.45867.fits ...   object
HI.20180801.45945.fits ...   object
HI.20180801.46157.fits ... flatlamp
HI.20180801.46246.fits ... flatlamp
HI.20180801.46399.fits ...  arclamp
HI.20180801.46463.fits ...  arclamp
Length = 538 rows



<Table length=538>
  name   dtype
-------- -----
   koaid str22
filehand str53
  progid  str4
   iodin  str1
koaimtyp  str8
Jobid: tap_7w5xkkqa
Phase: COMPLETED

Owner: None
Output file: ProgramID.tbl
Results: None
In [9]:
sql=("select koaid, filehand, ra, dec from koa_hires where \
    contains(point('icrs', ra, dec), \
    circle('icrs',262.0,17.0,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   
---------------------- ... --------
HI.19980718.34975.fits ... 16.82711
HI.19980912.26279.fits ... 16.82489
HI.19980913.27523.fits ... 16.82269
HI.19980914.23928.fits ... 16.82186
HI.19980914.24204.fits ... 16.82186
HI.19980914.29108.fits ... 16.82222
HI.19980915.26653.fits ...  16.8225
HI.19980916.25837.fits ... 16.82369
HI.19980918.24196.fits ... 16.82519
HI.19990421.49245.fits ...  17.5081
                   ... ...      ...
HI.20040824.18573.fits ... 17.50994
HI.20040824.18925.fits ... 17.50994
HI.20040825.18800.fits ... 17.51019
HI.20041002.18948.fits ... 17.50994
HI.20041002.19291.fits ... 17.50994
HI.20041002.19935.fits ... 17.50994
HI.20041002.20579.fits ... 17.50994
HI.20050301.49856.fits ... 16.82503
HI.20160126.56113.fits ...  16.8245
HI.20160714.38961.fits ... 16.82319
HI.20180702.37596.fits ... 16.82131
Length = 42 rows



<Table length=42>
  name    dtype 
-------- -------
   koaid   str22
filehand   str53
      ra float64
     dec float64
Jobid: tap_mylxgwxn
Phase: COMPLETED

Owner: None
Output file: ConeSearch.tbl
Results: None
In [10]:
sql=("select koaid, filehand, ra, dec from koa_hires where \
     contains(point('icrs', ra, dec), \
     box('icrs',262.0,17.0,2.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   
---------------------- ... ---------
HI.19941214.78458.fits ...  29.92281
HI.19950716.29399.fits ... -37.29384
HI.19950716.29658.fits ... -37.29384
HI.19950716.29859.fits ... -37.29384
HI.19950716.30097.fits ... -37.29384
HI.19951129.15228.fits ...      25.0
HI.19951129.15327.fits ...      25.0
HI.19960523.16106.fits ...   5.33211
HI.19960523.16363.fits ...   5.33211
HI.19960523.16460.fits ...   5.33211
                   ... ...       ...
HI.20190614.36586.fits ...  34.27092
HI.20190614.36658.fits ...  34.27092
HI.20190616.31037.fits ...  67.30686
HI.20190715.29454.fits ...  60.05008
HI.20190715.29515.fits ...  60.05008
HI.20190715.29575.fits ...  60.05008
HI.20190715.29654.fits ...  67.30667
HI.20190715.29719.fits ...  67.30667
HI.20190715.29786.fits ...  67.30667
HI.20190715.29853.fits ...  67.30667
HI.20190715.29924.fits ...  67.30667
Length = 1031 rows



<Table length=1031>
  name    dtype 
-------- -------
   koaid   str22
filehand   str53
      ra float64
     dec float64
Jobid: tap_dtf0agii
Phase: COMPLETED

Owner: None
Output file: Spat_Box.tbl
Results: None
In [11]:
sql=("select koaid, filehand, ra, dec from koa_hires 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   
---------------------- ... --------
HI.20040114.51275.fits ... 54.35381
HI.20040114.53552.fits ... 54.35381
HI.20040114.55829.fits ... 54.35381
HI.20040114.58182.fits ... 54.35383
HI.20060420.33559.fits ... 54.35292
HI.20060420.35412.fits ... 54.35292
HI.20060420.37265.fits ... 54.35292
HI.20060420.39117.fits ... 54.35292
HI.20060420.41232.fits ... 54.31703
HI.20060420.43085.fits ... 54.31703
                   ... ...      ...
HI.20110903.19681.fits ... 54.27442
HI.20110905.19585.fits ... 54.27675
HI.20110909.17581.fits ... 54.27289
HI.20110909.18064.fits ... 54.27289
HI.20110909.18415.fits ... 54.27289
HI.20110909.19067.fits ... 54.27289
HI.20110909.19719.fits ... 54.27289
HI.20110920.17641.fits ... 54.27347
HI.20110923.18047.fits ... 54.27414
HI.20110923.18126.fits ... 54.27414
HI.20110923.18478.fits ... 54.27414
Length = 28 rows

Count number of records in date range

In [12]:
sql=("select count(*) from koa_hires where \
    (utdatetime >= to_date('2009-01-01 00:00:00', 'yyyy-mm-dd HH24:MI:SS') and \
     utdatetime <= to_date('2009-01-05 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(*)
--------
      61



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

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

Count total number of records in table

In [13]:
sql="select count(*) as total from koa_hires"

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 
------
414960



<Table length=1>
 name dtype
----- -----
total int64
Jobid: tap_rwxeih3v
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 [ ]: