# SIABROWSER -- Given an object name, resolve its position and query an SIA # server for images of a given size around that object. Loop through the # returned image table and download the FITS files, optionally displaying or # analyzing them. procedure siabrowser (object, size) string object { prompt = "Object name" } real size { prompt = "Size of search" } string service = "DSS" { prompt = "SIA Service to query" } begin string obj, svc, url, ch, imname, res real sz int siap, nrows, ncols, imnum = 0 # Get params to local variables. Note we assume the NVO package # is loaded so we won't explicitly check for it here. obj = object sz = size svc = service reset imclobber = yes # set environment # Resolve to a position. sesame (obj) if (sesame.status < 0) { error ("Cannot resolve coordinates for '" // obj // "'") } else { printf ("Object '%s' resolved to coords '%s'\n", obj, sesame.pos) } # Query the SIA service, resolve it on the fly. print ("Querying server ....") siap = dalSiapSvc (regResolver (svc,"siap"), sesame.ra, sesame.dec, sz, sz) # Print some stats about the table. nrows = dalRecordCount (siap) # get number of images found ncols = dalAttrCount(dalGetRecord(siap,0)) # count columns printf ("\nFound : %d rows with %d attributes\n", nrows, ncols) # Loop over the image list, downloading the file and displaying it. for (i=0; i < nrows; i=i+1) { # Download the image in the record. We assume we get a plain FITS # file from the service, note however that some services return MEF # or compressed data. imname = "image0" // imnum // ".fits" print ("Downloading image " // imnum // " ....") url = dalGetStr (siap, "AccessReference", imnum) res = getData (url, imname) # res = dalGetData (siap, imnum, imname) # alternative get # Cheat: Default DSS service returns an MEF, tweak the image name # to access the image extension. imname = res // "[0]" for (ch = "d"; ch != "n"; ch = cl.ukey) { print ("") if (ch == "\015") next switch (ch) { case "?": print ("help for commands here...") case "h": imheader (imname, long+) case "e": imexamine (imname, 1) case "d": display (imname, 1, fill+) case "n": break case "q": goto cleanup case "s": imstat (imname) case "\015": ; } printf ("Command? ") } imnum = imnum + 1 } cleanup: ; end