aboutsummaryrefslogtreecommitdiff
path: root/vo/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /vo/src
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'vo/src')
-rw-r--r--vo/src/.gdb_history15
-rw-r--r--vo/src/OLD/datascope.cl152
-rw-r--r--vo/src/OLD/fchart.cl136
-rw-r--r--vo/src/OLD/sloanspec.cl413
-rw-r--r--vo/src/OLD/vizier.cl65
-rw-r--r--vo/src/mkpkg26
-rw-r--r--vo/src/registry.cl269
-rw-r--r--vo/src/skybot.cl129
8 files changed, 1205 insertions, 0 deletions
diff --git a/vo/src/.gdb_history b/vo/src/.gdb_history
new file mode 100644
index 00000000..6b2d98ea
--- /dev/null
+++ b/vo/src/.gdb_history
@@ -0,0 +1,15 @@
+run
+where
+quit
+run
+where
+quit
+b xerror_
+b zpanic_
+run
+p vo
+quit
+b zpanic_
+b xerror_
+c
+quit
diff --git a/vo/src/OLD/datascope.cl b/vo/src/OLD/datascope.cl
new file mode 100644
index 00000000..6eb1cdec
--- /dev/null
+++ b/vo/src/OLD/datascope.cl
@@ -0,0 +1,152 @@
+#{ DATASCOPE -- Toy DataScope task that returns a table of data services
+# and the number of results that can be expected for each given either an
+# input image or object name. For image input, the WCS footprint is computed
+# and used as the search parameters; For an object name the coordinates are
+# resolved and the search radius specified by the user is used.
+#
+# Example: Query a specific set of services, finding how many hits would
+# be returned against the dev$wpix test image
+#
+# cl> datascope dev$wpix service="GSC2.2,USNO-B1,DSS2"
+# #Num ShortName Count IVO Identifier
+# #--- --------- ----- --------------
+# 1 GSC2.2 50 ivo://archive.stsci.edu/gsc/gsc2.2
+# 2 USNO-B1 344 ivo://fs.usno/cat/usnob
+# 3 DSS2 1 ivo://archive.stsci.edu/dss/dss2
+#
+# REQUIRES: NVO package and VO-CL builtin functions.
+#
+# M. Fitzpatrick, Aug 2006
+
+
+procedure datascope (what)
+
+string what { prompt = "Object Name or Image" }
+string service = "cone" { prompt = "Service Type or list" }
+string bandpass = "optical" { prompt = "Bandpass of search" }
+real sr = 0.25 { prompt = "search radius" }
+
+bool filter = yes { prompt = "Filter results?" }
+bool verbose = yes { prompt = "Verbose output?" }
+int status = 0 { prompt = "Service status code" }
+
+begin
+ string url, tname, stype, this, bpass
+ string sname, ivorn, regResults, junk, svctyp
+ string zresp, eresp
+ real ra, dec, size
+ bool verb, filt
+ int dal, index, count, lnum
+
+ this = what
+ bpass = bandpass
+ verb = verbose
+ stype = service
+ filt = filter
+
+ if (stype == "catalog") {
+ stype = "cone"
+ } else if (stype == "image") {
+ stype = "siap"
+ }
+ ;
+
+ if (imaccess (this)) {
+ iferr { wcsinfo (this) } then {
+ error (0, "Cannot determine image coords for `"//this//"'")
+ } else {
+ ra = wcsinfo.midx
+ dec = wcsinfo.midy
+ size = max (wcsinfo.width, wcsinfo.height) / 60.0
+ }
+
+ } else {
+ # Assume it's an object name, resolve to coords.
+ sesame (this)
+ if (sesame.status < 0)
+ error (0, "Cannot resolve object `"//this//"'")
+ ra = sesame.ra
+ dec = sesame.dec
+ size = sr
+ }
+
+ # Initialize
+ zresp = ""
+ eresp = ""
+
+ # Now do a Registry query for the given service type and bandpass.
+ regResults = mktemp ("tmp$reg")
+ if (stype == "all") {
+ s1 = mktemp ("tmp$reg")
+ print (stype) | translit ("STDIN",",","\n",del-, > s1)
+ list = s1
+ i = 1
+
+ # Convert the list of specific services to a table we use below to
+ # query each.
+ while (fscan (list, s2) != EOF) {
+ printf ("%4d %s\n", i,
+ regResolver (s2,"","ShortName,ServiceType,Identifier"),
+ >> regResults)
+ i = i + 1
+ }
+ delete (s1, verify-)
+
+ } else {
+ registry ("", svc=stype, bandpass=bpass, verb-, header-,
+ >& regResults)
+ }
+
+
+ if (verbose) {
+ count (regResults) | scan (i)
+ printf ("#\n")
+ printf ("# Search Terms: RA=%H Dec=%h SR=%.3f\n", ra, dec, size)
+ printf ("# Service Type: %s\n", stype)
+ printf ("# Total Querys: %d\n", i)
+ printf ("#\n#\n")
+ printf ("#Num ShortName Count IVO Identifier\n")
+ printf ("#--- --------- ----- --------------\n")
+ }
+
+ # Loop over the registry and query by service type.
+ list = regResults
+ lnum = 1
+ while (fscan (list, index, sname, svctyp, ivorn) != EOF) {
+
+ count = 0
+ if (substr (svctyp,1,4) == "CONE")
+ count = dalRecordCount (\
+ dalConeSvc(\
+ regResolver(ivorn,"cone"), ra, dec, size))
+ else if (substr (svctyp,1,4) == "SIAP")
+ count = dalRecordCount (\
+ dalSiapSvc(\
+ regResolver(ivorn,"siap"), ra, dec, size, size))
+
+ if (count == 0)
+ zresp = zresp // sname // ","
+ if (!filter) {
+ printf ("%4d %-14.14s ", lnum, sname)
+ if (count < 0) {
+ printf (" ERROR %s\n", ivorn)
+ eresp = eresp // sname // ","
+ } else
+ printf ("%6d %s\n", count, ivorn)
+ lnum = lnum + 1
+ } else if (filter && count > 0) {
+ printf ("%4d %-14.14s %6d %s\n", lnum,sname,count,ivorn)
+ lnum = lnum + 1
+ } else if (count < 0)
+ eresp = eresp // sname // ","
+ }
+
+ if (verbose) {
+ printf ("#\n")
+ printf ("# Zero Values: ") ; prettystr(zresp,start=15,comment+)
+ printf ("# Err Returns: ") ; prettystr(eresp,start=15,comment+)
+ }
+
+ # Clean up.
+ delete (regResults, verify-)
+end
diff --git a/vo/src/OLD/fchart.cl b/vo/src/OLD/fchart.cl
new file mode 100644
index 00000000..d438c5db
--- /dev/null
+++ b/vo/src/OLD/fchart.cl
@@ -0,0 +1,136 @@
+# CHART -- Toy finder chart program using an object name, a user-supplied
+# image, or a position spec to display a point on the sky and an overlay
+# of known NED objects.
+
+procedure chart (object)
+
+string object { prompt = "Object to plot" }
+string image = "" { prompt = "Image name" }
+real ra = INDEF { prompt = "RA of position" }
+real dec = INDEF { prompt = "Dec of position" }
+string inwcs = "icrs" { prompt = "Input coord system" }
+real size = 0.2 { prompt = "Size (degrees)" }
+string fields = "G_Lens,Xray,Radio,QSO" { prompt = "Objects to mark" }
+bool grid = yes { prompt = "Overlay coordinate grid?" }
+
+begin
+ real lra, ldec, lsz
+ int count, siap, col
+ string imname, pos, fstr, obj, img, isys
+ bool do_grid
+
+ reset stdimage = imt1024 # Set the environment
+ reset imclobber = yes
+ reset clobber = yes
+
+ obj = object # get a local variable of the param value
+ lsz = size
+ fstr = fields
+ lra = ra
+ ldec = dec
+ img = image
+ isys = inwcs
+ do_grid = grid
+
+ # Get the starting position. Use an image if specified, the check
+ # for an ra/dec pos, and finally a user-supplied object name.
+ if (imaccess (img, verbose=no)) {
+ iferr { wcsinfo (img) } then {
+ error (0, "Cannot determine image coords for `"//img//"'")
+ } else {
+ lra = wcsinfo.midx
+ ldec = wcsinfo.midy
+ lsz = max (wcsinfo.width, wcsinfo.height) / 60.0
+ }
+ imname = img
+
+ } else if (ra != INDEF && dec != INDEF) {
+ # No image specified, use the parameters (assume it's in hours).
+ lra = ra * 15.
+ ldec = dec
+ lsz = size # size in degrees
+ imname = mktemp ("chart") // ".fits" # create temp filenames
+
+ } else {
+ # Sample Test Objects:
+ # abell2235 # has QSOs
+ # abell1689 # has G_Lens
+ # abell2255 # has lotsa Galaxies
+
+ # Resolve the Abell number to coordinates.
+ sesame (obj)
+ lra = sesame.ra
+ ldec = sesame.dec
+ lsz = size
+ imname = mktemp ("chart") // ".fits" # create temp filenames
+ }
+
+ # Convert alternate input coordinate system values.
+ if (isys != "icrs") {
+ print (lra // " " // ldec) | \
+ skyctran ("STDIN", "STDOUT", isys, "icrs", transform+,
+ olngu="deg", olatu="deg", olngf="%f", olatf="%f") | \
+ fields ("STDIN","1,2",lines="9") | scan (x, y)
+ if (verb) {
+ print ("#")
+ print ("# Input coords: ("//lra//","//ldec//") ("//isys//")")
+ print ("# Output coords: ("//x//","//y//") (ICRS)")
+ print ("#")
+ }
+ lra = x
+ ldec = y
+ }
+ pos = mktemp ("chart")
+
+
+ # Get an image of the field if the user didn't supply one.
+ if (obj != "" || (ra != INDEF && dec != INDEF)) {
+
+ dss ("", ra=ra, dec=dec)
+ imname = dss.imname
+ }
+
+ # Display the image. We're using DSS so we need to specify an image
+ # extension, other SIAP services
+ display (imname, 1, fill+, >& "dev$null")
+
+ # Get NED sources
+ #vocatalog (regResolver("NED","cone"), lra, ldec, lsz, output="ned.txt")
+ s1 = "http://nedwww.ipac.caltech.edu/cgi-bin/nph-NEDobjsearch?search_type=Near+Position+Search&of=xml_main&"
+ vocatalog (s1, lra, ldec, lsz, output="ned.txt")
+
+ # Select the RA,Dec from the output NED table.
+ fields ("ned.txt","3,4", >& "pos_all")
+
+ # Expand the list of object types we want to mark.
+ print (fstr) | translit ("STDIN",",","\n",del-, > "fields")
+
+ # Mark the Galaxies on the display.
+ match (" G ","ned.txt") | fields("STDIN","3,4", >& "pos_all")
+ wcsctran ("pos_all", "c1", imname, verb-,
+ inwcs="world",outwcs="logical",units="n n")
+ tvmark (frame=1,coords="c1",mark="plus", color=206, txsize=3)
+
+ # Mark the rest of the requested objects on the display.
+ list = "fields"
+ while (fscan (list, s1) != EOF) {
+ match (s1,"ned.txt") | fields("STDIN","3,4,5", >& "pos_w")
+ wcsctran ("pos_w","pos_l", imname, "world","logical",
+ verb-, units="n n") | \
+ tvmark (frame=1, coords="pos_l",mark="plus",color=204,txsize=3,lab+)
+ }
+
+ if (do_grid)
+ wcslab (imname, 1, use-, fill+, overplot+, append+,
+ labout-, dev="imdy")
+
+ # Clean up.
+ if (access (pos)) delete (pos, verify-, >& "dev$null")
+ if (access (imname)) delete (imname, verify-, >& "dev$null")
+
+ # Update params.
+ object = ""
+ image = ""
+ ra = INDEF
+ dec = INDEF
+end
diff --git a/vo/src/OLD/sloanspec.cl b/vo/src/OLD/sloanspec.cl
new file mode 100644
index 00000000..c6f24aed
--- /dev/null
+++ b/vo/src/OLD/sloanspec.cl
@@ -0,0 +1,413 @@
+#{ SLOANSPEC -- Query the SDSS Spectral Data (DR4) given an image footprint,
+# object name, or equatorial position and search size.
+
+procedure sloanspec (what)
+
+string what { prompt = "Image or Object name" }
+
+real ra = INDEF { prompt = "RA of Field (hours)" }
+real dec = INDEF { prompt = "Dec of Field (degrees)" }
+real sr = 0.25 { prompt = "Search size (degrees)" }
+
+int maxrecords = 100 { prompt = "Max records to return" }
+bool display = no { prompt = "Display result?" }
+bool interactive = yes { prompt = "Interactive mode?" }
+bool autosave = yes { prompt = "Auto-save downloaded data?" }
+bool verbose = yes { prompt = "Verbose output?" }
+bool ned = no { prompt = "Overlay NED objects?" }
+bool grid = no { prompt = "Overlay coord grid?" }
+bool download = no { prompt = "Automatically download data?" }
+
+string spectype = "all" { prompt = "Spectra type (qso|galaxy|all)",
+ enum="qso|galaxy|all" }
+real zlow = INDEF { prompt = "Low redshift filter" }
+real zhigh = INDEF { prompt = "High redshift filter" }
+
+real size = 15.0 { prompt = "Size of marker (pixels)" }
+int color = 207 { prompt = "Marker color" }
+int status = 0 { prompt = "Service status code" }
+
+string *llist
+
+begin
+ string this, img, obj, stab, ttab, mtab, coords, tvcoords, filter
+ string name, class, oclass, ch, cmd, tnames, imlist, sv_img, stype
+ bool verb, disp, do_grid, interact, saving, do_ned, found, getdata
+ int maxrec, mkcolor, n, wcs, siap, count
+ real szmark, d0, d1, xp, yp, z, x1, x2, y1, y2
+ real lra, ldec, lsr, sra, sdec, sz, sx, sy
+ real llx, lly, urx, ury, cx, cy, bsz, z1, z2
+ string sname, sid, sclass, mission
+
+
+ lra = ra
+ ldec = dec
+ this = ""
+ if (isindef(lra) && isindef(ldec))
+ this = what
+
+ lsr = sr
+ disp = display
+ maxrec = maxrecords
+ szmark = size
+ mkcolor = color
+ verb = verbose
+ interact = interactive
+ do_grid = grid
+ do_ned = ned
+ saving = autosave
+ stype = spectype
+ z1 = zlow
+ z2 = zhigh
+ getdata = download
+ sv_img = ""
+
+ # Set the environment.
+ set clobber = yes
+ set imclobber = yes
+
+
+ if (imaccess (this)) {
+ img = this
+ obj = ""
+ iferr { wcsinfo (this) } then {
+ error (0, "Cannot determine image coords for `"//this//"'")
+ } else {
+ ra = wcsinfo.midx
+ dec = wcsinfo.midy
+ size = max (wcsinfo.width, wcsinfo.height) / 60.0
+ }
+
+ } else {
+ # Assume it's an object name, resolve to coords.
+ sesame (this)
+ if (sesame.status < 0)
+ error (0, "Cannot resolve object `" // this // "'")
+ lra = sesame.ra
+ ldec = sesame.dec
+ lsr = sr
+ img = ""
+ obj = this
+ }
+
+ filter = ""
+ if (stype == "qso") {
+ filter = "Qso"
+ } else if (stype == "galaxy") {
+ filter = "Galaxy"
+ }
+ ;
+
+ # Create temp files.
+ stab = mktemp ("tmp$stab")
+ ttab = mktemp ("tmp$ttab")
+
+ # Display an image early on so we have something to look at.
+ if (display) {
+ if (img == "" || imaccess(img) == no) {
+ # Display an image from the DSS.
+ img = mktemp ("tmp$sspec") // ".fits"
+ sv_img = img
+
+ # Get an image of the field if the user didn't supply one.
+ siap = dalSiapSvc(regResolver("ivo://nasa.heasarc/skyview/dss1","siap"), lra,ldec,lsr,lsr)
+
+ count = dalRecordCount(siap)
+ if (count <= 0)
+ error (0, "No optical images found")
+ s1 = dalGetData(siap, 0, osfn(img))
+
+ display (img//"[0]", 1, fill+, bpmask="", >& "dev$null")
+ img = ""
+ } else {
+ display (img, 1, fill+, bpmask="", >& "dev$null")
+ }
+ }
+
+
+ # Query for the spectra.
+ if (verb) {
+ printf ("#\n")
+ if (img != "")
+ printf ("# Search Params: Img='%s' RA=%.5f Dec=%.5f SR=%.2f\n",
+ img, lra, ldec, lsr)
+ else if (obj != "")
+ printf ("# Search Params: Obj='%s' RA=%.5f Dec=%.5f SR=%.2f\n",
+ obj, lra, ldec, lsr)
+ else
+ printf ("# Search Position: RA=%.5f Dec=%.5f SR=%.2f\n",
+ lra, ldec, lsr)
+ print ("#\n")
+ }
+ ssquery (image=img, object=obj, ra=lra, dec=ldec, sr=(lsr * 60.0),
+ zlow=z1, zhigh=z2, output="STDOUT", maxrec=maxrec, verb-) | \
+ match (filter, "STDIN", >& stab)
+
+ status = ssquery.status
+ if (ssquery.status < 0) {
+ error (0, "No results found.")
+
+ } else if (img != "") {
+ wcsinfo (img)
+ lra = wcsinfo.midx # decimal degrees
+ ldec = wcsinfo.midy
+
+ } else if (obj != "") {
+ sesame (obj)
+ lra = sesame.ra # decimal degrees
+ ldec = sesame.dec
+ }
+ #printf("img='%s' obj='%s' ra=%.4f dec=%.4f sr=%.2f\n",img,obj,lra,ldec,lsr)
+
+
+
+ # See whether we display the image or simply download a cutout of the
+ # field we want.
+ if (display) {
+ coords = mktemp ("tmp$coords")
+ tvcoords = mktemp ("tmp$coords")
+
+ if (img == "" || imaccess(img) == no) {
+# # Display an image from the DSS.
+# img = mktemp ("tmp$sspec") // ".fits"
+ img = sv_img
+#
+# # Get an image of the field if the user didn't supply one.
+# siap = dalSiapSvc(regResolver("DSS2R","siap"), lra,ldec,lsr,lsr)
+#
+# count = dalRecordCount(siap)
+# if (count <= 0)
+# error (0, "No optical images found")
+# s1 = dalGetData(siap, 0, osfn(img))
+#
+# display (img//"[0]", 1, fill+, bpmask="", >& "dev$null")
+ fields (stab, "2,3", >& coords)
+ wcsctran (coords, tvcoords, img//"[0]", "world", "logical",
+ units="h n", columns="1 2", verb-)
+
+ wcsinfo (img//"[0]")
+
+ sv_img = img
+ img = img // "[0]"
+
+ if (!interact && imaccess(sv_img//".fits"))
+ delete (sv_img//".fits", verify-, >& "dev$null")
+
+ } else {
+ # Display the image.
+# display (img, 1, fill+, bpmask="", >& "dev$null")
+ fields (stab, "2,3", >& coords)
+ wcsctran (coords, tvcoords, img, "world", "logical",
+ units="h n", verb-)
+ sv_img = img
+ wcsinfo (img)
+ }
+
+ if (verb) {
+ printf ("#\n")
+ if (img != "")
+ printf ("# Image: %s\n", img)
+ else if (obj != "")
+ printf ("# Object %s\n", obj)
+
+ if (img == "" && obj == "")
+ printf ( "# Search Pos: (%H,%h) Size: %.2fx%.2f arcmin\n",
+ ra, dec, lsr, lsr)
+ else
+ printf ( "# Search Pos: (%H,%h) Size: %.2fx%.2f arcmin\n",
+ wcsinfo.midx, wcsinfo.midy, wcsinfo.width, wcsinfo.height)
+ printf ("#\n")
+ fields (stab, "1-5")
+ }
+
+ # Create local catalog of spectra.
+ joinlines (tvcoords//","//stab) | match ("-", "STDIN", stop+, >& ttab)
+
+ if (access(coords)) delete (coords, verify-, >& "dev$null")
+ if (access(tvcoords)) delete (tvcoords, verify-, >& "dev$null")
+
+
+ mtab = mktemp ("tmp$mtab")
+ fields (ttab, "1,2,3", >& mtab)
+type (mtab)
+ tvmark (1, mtab, mark="circle", radii=szmark, col=mkcolor,
+ lab+, txsize=1)
+
+ if (access(mtab)) delete (mtab, verify-, >& "dev$null")
+
+ # Overlay the NED objects?
+ if (do_ned)
+ nedoverlay (img)
+
+ # Draw the coordinate overlay grid?
+ if (do_grid)
+ wcslab (img, 1, use-, fill+, overplot+, append+,
+ labout-, dev="imdy")
+
+ if (interact) {
+ # When verbose we printed the table above, otherwise we want some
+ # kind of summary visible here.
+ if (!verbose)
+ type (ttab)
+
+ print ("\n\nIMSSPEC Command Summary:")
+ print ("b Batch display w/in a box")
+ print ("d Download spectrum")
+ print ("i Print Info about spectrum")
+ print ("n NED Overlay")
+ print ("r Radio contour overlay")
+ print ("s Show spectrum")
+ print ("w WCS Overlay")
+ print ("q Quit")
+ printf ("\nCommand? ")
+
+ while (fscan (imcur, x, y, wcs, cmd) != EOF) {
+ # Find nearest point. All other commands will depend on the
+ # chosen spectrum.
+ d0 = 999999999.0
+ d1 = 0.0
+ found = no
+ llist = ttab
+ while (fscan(llist, xp,yp, name,ra,dec,z,class,line) != EOF) {
+ d1 = sqrt ((xp-x)*(xp-x) + (yp-y)*(yp-y))
+ if (d1 < d0) {
+ d0 = d1
+ sx = xp ; sy = yp
+ sra = lra ; sdec = ldec
+ sz = z
+ sname = name
+ sclass = class
+ found = yes
+ }
+ }
+ llist = ""
+ if (!found)
+ print ("Error: object not found")
+
+ print ("")
+ switch (cmd) {
+ case "i": # Show info on spectrum
+ { printf ("%s %H %h %.5f %s\n",
+ sname, (sra*15.), sdec, sz, sclass)
+ }
+
+ case "b": # Get spectrum in the box
+ { printf ("Again...")
+ x1 = x
+ y1 = y
+ n = fscan (imcur, x2, y2, wcs, ch)
+ tnames = mktemp ("tmp$tname")
+ imlist = mktemp ("tmp$imlist")
+ tabclip (ttab, "STDOUT", "c1","c2", x1,y1, x2,y2) | \
+ fields ("STDIN", "1,2,3,9", >& tnames)
+
+ # Draw a box around the selected region
+ printf ("%f %f 101 b\n%f %f 101 b\n", x1,y1,x2,y2) | \
+ tvmark (1, "", commands="STDIN", lab-, col=200)
+
+ print ("\nDownloading images ....")
+ llist = tnames
+ while (fscan (llist, x, y, sname, sid) != EOF) {
+ name = substr (sname, 1, 10) // ".fits"
+ print (name, >>& imlist)
+ printf ("%f %f %s\n", x, y, sname) | \
+ tvmark (1, "STDIN", mark="circle",
+ radii=szmark, col=205, lab+, txsize=1)
+ if (imaccess(name) == no)
+ ssget (sid, name, verbose+)
+ else
+ printf ("Image '%s' exists already...\n", name)
+ }
+ llist = ""
+
+ printf ("Running SPECLOT ....")
+ specplot ("@"//imlist, label="imname",cursor="dev$null")
+
+ if (!saving)
+ imdelete ("@"//imlist, >& "dev$null")
+ delete (imlist, verify-, >& "dev$null")
+ delete (tnames, verify-, >& "dev$null")
+ gflush
+
+ }
+ case "d": # Get spectrum
+ {
+ match (sname, stab) | scan (line)
+ print (line) | fields ("STDIN","1,7") | scan(sname,sid)
+ name = substr (sname, 1, 10) // ".fits"
+ printf ("%f %f %s\n", sx, sy, sname) | \
+ tvmark (1, "STDIN", mark="circle", radii=szmark,
+ col=205, lab+, txsize=1)
+ if (imaccess(name) == no)
+ ssget (sid, name, verbose+)
+ }
+ case "o": # Observation Overlay
+ { while (yes) {
+ printf ("Mission (HST|XMM|Spitzer|Chandra|Rosat)? "
+ i = scan (mission)
+ if (i > 0)
+ break
+ }
+ obslogoverlay (img, mission)
+ }
+ case "r": # NVSS Radio contour overlay
+ { radiooverlay (img)
+ }
+ case "n": # NED Overlay
+ { nedoverlay (img)
+ }
+ case "w": # WCS Overlay
+ { wcslab (img, 1, use-, fill+, overplot+, append+,
+ labout-, dev="imdy")
+ }
+ case "s": # SPLOT spectrum
+ {
+ match (sname, stab) | scan (line)
+ print (line) | fields ("STDIN","1,7") | scan(sname,sid)
+ name = substr (sname, 1, 10) // ".fits"
+ printf ("%f %f %s\n", sx, sy, sname) | \
+ tvmark (1, "STDIN", mark="circle", radii=szmark,
+ col=205, lab+, txsize=1)
+ if (imaccess(name) == no)
+ ssget (sid, name, verbose+)
+
+ if (imaccess(name) == yes) {
+ printf ("Running SPLOT on image '%s'....", name)
+ splot (name)
+ } else
+ printf ("Error loading image '%s'\n", name)
+
+ if (!saving)
+ imdelete (name, >& "dev$null")
+ gflush
+ }
+ case "q": # Quit
+ { break
+ }
+ }
+
+ printf ("\nCommand? ")
+ }
+ }
+
+ } else {
+ type (stab)
+
+ if (getdata) {
+ spectab (stab, imroot="", verbose+)
+ }
+ }
+
+
+ # Clean up
+ if (access(stab)) delete (stab, verify-, >& "dev$null")
+ if (access(ttab)) delete (ttab, verify-, >& "dev$null")
+
+ ra = INDEF # reset params
+ dec = INDEF
+
+ if (interact && imaccess(sv_img//".fits"))
+ delete (sv_img//".fits", verify-, >& "dev$null")
+end
+
+
diff --git a/vo/src/OLD/vizier.cl b/vo/src/OLD/vizier.cl
new file mode 100644
index 00000000..bf9209ba
--- /dev/null
+++ b/vo/src/OLD/vizier.cl
@@ -0,0 +1,65 @@
+#{ VIZIER -- Call a service Vizier TABULARSKY service.
+
+procedure vizier (tab_id)
+
+string tab_id { prompt = "Table reference" }
+
+string output = "STDOUT" { prompt = "Output filename" }
+string otype = "ascii" { prompt = "Output format",
+ min="ascii|csv|votable|fits" }
+bool all = yes { prompt = "Get all matching tables?" }
+bool verbose = no { prompt = "Verbose output?" }
+
+int status = 0 { prompt = "Service status code" }
+
+begin
+ string id, url, oname, tname, ctype, oroot
+ string sfile, fields, catid, svc_type
+ bool verb, do_all
+ int fnum, nrecords
+
+
+ id = tab_id
+ ctype = otype
+ oroot = output
+ do_all = all
+ verb = verbose
+
+ svc_type = "tabularskyservice"
+ fields = "ServiceURL,Identifier"
+ fnum = 1
+
+
+ # Create a temporary url file and output name.
+ sfile = mktemp ("tmp$vizier")
+ tname = mktemp ("tmp$vizier") // ".xml"
+
+ if (do_all)
+ print (regResolver (id, svc_type, fields, -1), > sfile)
+ else
+ print (regResolver (id, svc_type, fields), > sfile)
+
+ nrecords = nresolved()
+
+ list = sfile
+ while (fscan (list, url, catid) != EOF) {
+
+ if (nrecords > 1)
+ oname = oroot // "." // fnum
+ else
+ oname = oroot
+
+ if (verb)
+ printf ("Downloading %s ... to %s\n", catid, oname)
+
+ # Call the Vizier service url
+ rawcaller (url, otype="votable", output=tname)
+
+ # Output the table.
+ tabout (tname, oname, ctype)
+
+ delete (tname, verify-)
+ fnum = fnum + 1
+ }
+
+end
diff --git a/vo/src/mkpkg b/vo/src/mkpkg
new file mode 100644
index 00000000..e646e506
--- /dev/null
+++ b/vo/src/mkpkg
@@ -0,0 +1,26 @@
+# Make the VO package compiled tasks.
+
+$call relink
+$exit
+
+update:
+ $call relink
+ $call install
+ ;
+
+relink:
+ $set LIBS = "-lasttools libvoclient.a"
+
+ #$update libpkg.a
+ #$omake x_voapps.x
+ #$link x_voapps.o libpkg.a $(LIBS) -o xx_voapps.e
+ ;
+
+install:
+ #$move xx_voapps.e vobin$x_voapps.e
+ ;
+
+
+libpkg.a:
+ $set XFLAGS = "$(XFLAGS) -g -q"
+ ;
diff --git a/vo/src/registry.cl b/vo/src/registry.cl
new file mode 100644
index 00000000..793b782a
--- /dev/null
+++ b/vo/src/registry.cl
@@ -0,0 +1,269 @@
+#{ REGISTRY -- Do a Registry query.
+
+procedure registry (query)
+
+string query { prompt = "Query terms" }
+
+string type = "" { prompt = "Sevice type constraint" }
+string bandpass = "" { prompt = "Bandpass constraint" }
+string content = "" { prompt = "ContentLevel constraint" }
+string sql = "" { prompt = "SQL Query terms" }
+
+string fields="Title,Subject,CoverageSpectral" \
+ { prompt = "Verbose output fields" }
+bool header = yes { prompt = "Header output?" }
+bool verbose = no { prompt = "Verbose output?" }
+bool interactive = no { prompt = "Interactive processing?" }
+
+int record = -1 { prompt = "Record number to list?" }
+bool metadata = no { prompt = "List resource metadata?" }
+int nlines = 5 { prompt = "Number lines in Vizier preview" }
+
+int qres = 0 { prompt = "Saved resource record pointer" }
+int qcount = 0 { prompt = "Saved record count" }
+string qstring = "" { prompt = "Saved query string" }
+string qbandpass = "" { prompt = "Saved bandpass constraint" }
+string qcontent = "" { prompt = "Saved ContentLevel constraint" }
+string qsvc = "" { prompt = "Saved service type constraint" }
+string qsql = "" { prompt = "Saved SQL constraint" }
+
+int status = 0 { prompt = "Service status code" }
+
+begin
+ string qterm, fstr, ffile, qstr, id, typ, str
+ string bpass, clevel, sqlstr, stype, ch
+ bool verb, meta, interact, summary
+ int res, count, istart, iend, n, vnlines, rec
+
+
+ verb = verbose
+ fstr = fields
+ meta = metadata
+ stype = type
+ bpass = bandpass
+ clevel = content
+ sqlstr = sql
+ interact = interactive
+ vnlines = nlines
+
+
+
+ # Set the environment.
+ reset clobber = yes
+ summary = no
+
+ # Print the resource alias list
+ if (query == "aliases") {
+ if (access ("home$registry.dat") == yes)
+ type ("home$registry.dat")
+ return
+ } else if (query == "alias") {
+ return
+ }
+
+ # See if all we want is a list of the available metadata.
+ if (meta) {
+ regmetalist(all-)
+ return
+ }
+
+submit:
+ # Build a sql predicate string from the contraints (if any).
+ qstr = ""
+ if (stype != "") {
+ str = strlwr (stype)
+ if (str == "sia" || substr (str,1,2) == "im")
+ qstr = "(Tag like '%images%')"
+ else
+ qstr = "(xml like '%" // stype // "%')"
+ }
+ if (bpass != "") {
+ str = "([coverage/waveband] like '%" // bpass // "%')"
+ if (qstr != "")
+ qstr = qstr // " AND " // str
+ else
+ qstr = str
+ }
+ if (clevel != "") {
+ str = "([content/contentLevel] like '%" // clevel // "%')"
+ if (qstr != "")
+ qstr = qstr // " AND " // str
+ else
+ qstr = str
+ }
+ if (sqlstr != "") {
+ str = "(" // sqlstr // ")"
+ if (qstr != "")
+ qstr = qstr // " AND " // str
+ else
+ qstr = str
+ }
+
+ # Get a temp file so we can loop over the fields. Dump the fields
+ # string to the file for easy reading.
+ ffile = mktemp ("tmp$reg")
+again:
+ if (record > 0 || fstr == "all") {
+ regmetalist (all+, > ffile)
+ } else {
+ print (fstr) | translit ("STDIN",",","\n",del-, > ffile)
+ }
+
+
+ # Do the query
+ if (record >= 0) {
+ res = qres
+ count = qcount
+ if (record == 0) {
+ istart = 0
+ iend = qcount
+ } else {
+ istart = record - 1
+ iend = record
+ verb = yes # reset verbose flag for single full record
+ }
+ qterm = qstring
+ stype = qsvc
+ bpass = qbandpass
+ clevel = qcontent
+ sqlstr = qsql
+ if (header)
+ printf ("#\n# Record: %d\n#\n", record)
+
+ } else {
+ qterm = query
+ if (qstr != "")
+ res = regSearch (qstr, qterm, 0)
+ else
+ res = regSearch (qterm, 0)
+ count = regResCount (res)
+ istart = 0
+ iend = count
+ if (header)
+ printf ("#\n# Found %d records\n#\n", count)
+ }
+
+ # Dump the query constraints we used in the search.
+ if (header) {
+ printf ("# Registry Query Constraints:\n")
+ if (qterm != "") printf ("#\t Query Term: '%s'\n", qterm)
+ if (stype != "") printf ("#\t ServiceType: %s\n", stype)
+ if (bpass != "") printf ("#\t Bandpass: %s\n", bpass)
+ if (clevel != "") printf ("#\tContentLevel: %s\n", clevel)
+ if (sqlstr != "") printf ("#\tSQL: %s\n", sqlstr)
+ printf ("#\n")
+ }
+
+ if (record <= 0 && header) {
+ printf ("#No ShortName ServiceType Identifier\n")
+ printf ("#-- --------- ----------- ----------\n#\n")
+ }
+
+ for (i=istart; i < iend; i=i+1) {
+ if (record <= 0 && fstr != "all") {
+ printf ("%3d %-18.18s %-10.10s %s\n",
+ (i+1),
+ trim (regValue (res, "ShortName", i)),
+ trim (regValue (res, "ServiceType", i)),
+ trim (regValue (res, "Identifier", i)))
+ } else if (fstr == "all")
+ printf ("Record: %d\n", i)
+
+ if (!summary && verb) {
+ list = ffile
+ while (fscan (list, str) != EOF) {
+ printf (" %12.12s: ", str)
+ line = regValue (res, str, i)
+ prettystr (trim(line))
+ }
+ list = ""
+ printf ("\n")
+ }
+ }
+
+ # Save the resource pointer and record count in case we come back.
+ if (record < 0) {
+ qres = res
+ qcount = count
+ qstring = qterm
+ qbandpass = bpass
+ qcontent = clevel
+ qsvc = stype
+ qsql = sqlstr
+ }
+
+
+ if (interact) {
+nextcmd:
+ printf ("\nCommand? ")
+ summary = no
+
+ ch = cl.ukey
+ if (substr(ch,1,4) == "\\015") {
+ goto nextcmd
+ }
+
+ switch (ch) {
+ case "?": # print help
+ { print ("\n\n REGISTRY Command Summary:")
+ print (" t constrain by service Type")
+ print (" b constrain by Bandpass")
+ print (" r view details of individual Record")
+ print (" s print Summary table of results")
+ print (" p Preview a vizier table")
+ print (" v set Verbose flag")
+ print (" q Quit")
+ goto nextcmd
+ }
+ case "t": # Record
+ { printf ("\nService Type? ")
+ n = scan (stype)
+ record = -1
+ summary = yes
+ goto submit
+ }
+ case "b": # Record
+ { printf ("\nBandpass? ")
+ n = scan (bpass)
+ record = -1
+ summary = yes
+ goto submit
+ }
+ case "r": # Record
+ { printf ("\nRecord number? ")
+ n = scan (record)
+ goto again
+ }
+ case "s": # Summary list
+ { record = 0
+ summary = yes
+ goto again
+ }
+ case "p": # Preview a VizieR table
+ { printf ("\nRecord number? ")
+ n = scan (rec)
+ id = trim (regValue (res, "Identifier", rec-1))
+ typ = strlwr (trim (regValue (res, "ServiceType", rec-1)))
+ if (substr(typ,1,7) != "tabular") {
+ printf ("\nError: Record %d is not a VizieR table\n", n)
+ goto nextcmd
+ } else {
+ vizier (id, output="STDOUT", otype="ascii", all-) | \
+ head ("STDIN", nlines=vnlines)
+ }
+ goto nextcmd
+ }
+ case "v": # Set verbose
+ { verb = yes
+ goto again
+ }
+ case "q": # Quit
+ { record = -1
+ print ("")
+ }
+ }
+ }
+
+ # Clean up.
+ delete (ffile, verify-, >& "dev$null")
+end
diff --git a/vo/src/skybot.cl b/vo/src/skybot.cl
new file mode 100644
index 00000000..c2f1186f
--- /dev/null
+++ b/vo/src/skybot.cl
@@ -0,0 +1,129 @@
+#{ SKYBOT -- Find the minor planets in an image, display it and mark the
+# asteroids.
+
+procedure skybot (image)
+
+string image { prompt = "Input image" }
+
+bool display = yes { prompt = "Display result?" }
+bool ned = no { prompt = "Overlay NED sources?" }
+bool grid = no { prompt = "Overlay coordinate grid?" }
+
+real nhours = 6.0 { prompt = "Number of hours of movement" }
+
+bool verbose = yes { prompt = "Verbose output?" }
+int status = 0 { prompt = "Service status code" }
+
+begin
+ string img, date, res, coords, tvcoords, cmd
+ real ra, dec, size, mjd, nh
+ real radius, x1, x2, y1, y2, vmag, dra, ddec
+ bool verb, disp, do_ned, do_grid
+
+
+ img = image
+ verb = verbose
+ disp = display
+
+ nh = nhours
+ do_ned = ned
+ do_grid = grid
+
+ set clobber = yes
+ set imclobber = yes
+
+ if (imaccess (img)) {
+ # Compute the MJD from the DATE-OBS keyword
+ hselect (img, "DATE-OBS", yes) | scan (date)
+ if (date == "") {
+ errror (0, "No DATE-OBS keyword in the image.")
+ } else {
+ print ("print(julday(\""//date//"\"))") | \
+ astcalc (commands="STDIN") | scan (mjd)
+ }
+
+ iferr { wcsinfo (img) } then {
+ error (0, "Cannot determine image coords for `"//img//"'")
+ } else {
+ ra = wcsinfo.midx
+ dec = wcsinfo.midy
+ size = max (wcsinfo.width, wcsinfo.height) * 60.0 / 2.0
+ }
+ } else
+ error (0, "Image not found.")
+
+
+ # Create temp files for the output
+ res = mktemp ("tmp$imsky")
+
+ # Call the SKYBOT task to do the search.
+ sbquery(ra, dec, size, epoc=mjd, fields="ra,dec,vmag,dra,ddec,name", >& res)
+
+# if (verbose || display == no)
+# type (res)
+
+ if (display) {
+ cmd = mktemp ("tmp$imsky")
+ coords = mktemp ("tmp$imsky")
+ tvcoords = mktemp ("tmp$imsky")
+
+ display (img, 1, fill+, bpmask="", select+, >& "dev$null")
+
+
+ fields (res, "1-", >& "foo")
+ list = "foo"
+ while (fscan (list, ra, dec, vmag, dra, ddec, line) != EOF) {
+ printf ("%h %h %.1f\n", ra, dec, vmag) |& \
+ wcsctran ("STDIN", "STDOUT", img, "world", "logical",
+ units="h n", verbose-, >& tvcoords )
+
+ # Compute a radius representing 2-hours of movement.
+ x = dra # in "/hr
+ y = ddec # in "/hr
+ rad = max (10., sqrt((x*x)+(y*y)) * wcsinfo.scale) # in pixels
+
+ type (tvcoords) | scan (x, y)
+ printf ("%-11h %-12h %7.1f %7.1f %4.1f %6.4f %6.4f %4.1f %s\n",
+ ra, dec, x, y, vmag, dra, ddec, rad, line)
+
+ tvmark (1, tvcoords, mark="circle", radii="10", col=205,
+ nxoffset=12, nyoffset=2, lab+)
+
+ x1 = ra - (nh * (dra / 3600.) / 15.)
+ y1 = dec - (nh * (ddec / 3600.))
+ x2 = ra + (nh * (dra / 3600.) / 15.)
+ y2 = dec + (nh * (ddec / 3600.))
+
+ printf ("%h %h 101 s\n%h %h 101 s\n",
+ x1, y1, (ra-(dra/3600./15./2.)), (dec-(ddec/3600./2.))) |&
+ wcsctran ("STDIN", "STDOUT", img, "world", "logical",
+ units="h n", verbose-, >& tvcoords )
+ tvmark (1, coords="", commands=tvcoords, interact-, col=206, lab-)
+
+ printf ("%h %h 101 s\n%h %h 101 s\n",
+ (ra+(dra/3600./15./2.)), (dec+(ddec/3600./2.)), x2, y2) |&
+ wcsctran ("STDIN", "STDOUT", img, "world", "logical",
+ units="h n", verbose-, >& tvcoords )
+ tvmark (1, coords="", commands=tvcoords, interact-, col=204, lab-)
+ }
+
+
+ # Overlay the NED objects?
+ if (do_ned)
+ nedoverlay (img)
+
+ # Draw the coordinate overlay grid?
+ if (do_grid)
+ wcslab (img, 1, use-, fill+, overplot+, append+,
+ labout-, dev="imdy")
+
+ # Clean up
+ delete (cmd, verify-, >& "dev$null")
+ delete (coords, verify-, >& "dev$null")
+ delete (tvcoords, verify-, >& "dev$null")
+ }
+
+ # Clean up
+ delete (res, verify-, >& "dev$null")
+end
+