aboutsummaryrefslogtreecommitdiff
path: root/vo/votools/radiooverlay.cl
blob: 07a2e14cbd4b175cf18af41c49c48699cf1c0986 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#{ RADIOOVERLAY -- Overlay a radio contour on the image display.

procedure radiooverlay (image)

string	image			{ prompt = "Input image"		}

real	size	  = 0.25	{ prompt = "Query size"			}
int	ncontours = 0		{ prompt = "No. contours to draw"	}

bool	append    = yes		{ prompt = "Append display?"		}
bool	verbose   = yes		{ prompt = "Verbose output?"		}
string  device    = "imdred"	{ prompt = "Overlay device"		}
int	status    = 0		{ prompt = "Service status code"	}

begin
    string img, rimg, imname, ovdev, url, query, base
    string fields, pos_all, pos_l, pos_w, restab
    real   ra, dec, sz
    bool   verb, app, disp
    int    siap, count, ncont


    img    = image		# Get params to local variables
    sz     = size
    verb   = verbose
    app    = append
    ncont  = ncontours
    ovdev  = device
    restab = mktemp ("tmp$res") // ".xml"
    rimg   = mktemp ("tmp$img") // ".fits"


    if (imaccess (img)) {
        iferr { wcsinfo (img) } then {
            error (0, "Cannot determine image coords for `"//img//"'")
        } else {
            ra  = wcsinfo.midx
            dec = wcsinfo.midy
            sz = max (wcsinfo.width, wcsinfo.height) / 60.0
	    if (!app)
	        display (img, 1, >& "dev$null")
        }
    } else {
        sesame (img, verbose-)
        ra  = sesame.ra
        dec = sesame.dec
	if (!app)
	    dss (img, size=sz, use_display+)
    }


    # Create temp files for the output
    rimg = mktemp ("tmp$rad") // ".fits"

    # Get NVSS image, force the use of the SkyView service.
    base = "http://skyview.gsfc.nasa.gov/cgi-bin/vo/sia.pl?survey=nvss&" 
    printf ("POS=%.5f,%.5f&SIZE=%.3f", ra, dec, sz) | scan (query)
    url = base // query // "&RUNID=" // vo.runid

    # Download the query string.
    urlget (url, restab, use_cache+, cache="cache$")

    tdump (restab, row=1, col="URL", pwidth=2048, cdfile="dev$null",
        pfile="dev$null") | scan (rimg)

    # Overlay the contours
    contour (rimg, dev=ovdev, title="", perim-, fill+, xres=64, yres=64,
	ncontours=ncont, >& "dev$null")
    
    # Clean up.
    delete (restab, verify-, >& "dev$null")
    imdelete (rimg, >& "dev$null")
end