summaryrefslogtreecommitdiffstats
path: root/ds9/library/vlss.tcl
blob: cf2ba368b1e4faa74b4dbab1ba83903be7f1c62c (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#  Copyright (C) 1999-2018
#  Smithsonian Astrophysical Observatory, Cambridge, MA, USA
#  For conditions of distribution and use, see copyright notice in "copyright"

package provide DS9 1.0

proc VLSSDef {} {
    global vlss
    global ivlss

    set ivlss(top) .vlss
    set ivlss(mb) .vlsstmb

    set vlss(sky) fk5
    set vlss(rformat) arcmin
    set vlss(width) 15
    set vlss(height) 15
    set vlss(mode) new
    set vlss(save) 0
}

proc VLSSDialog {} {
    global vlss
    global ivlss
    global wcs

    if {[winfo exists $ivlss(top)]} {
	raise $ivlss(top)
	return
    }

    set varname dvlss
    upvar #0 $varname var
    global $varname

    set var(top) $ivlss(top)
    set var(mb) $ivlss(mb)
    set var(sky) $vlss(sky)
    set var(skyformat) $wcs(skyformat)
    set var(rformat) $vlss(rformat)
    set var(width) $vlss(width)
    set var(height) $vlss(height)
    # not used
    set var(width,pixels) 300
    set var(height,pixels) 300
    set var(mode) $vlss(mode)
    set var(save) $vlss(save)

    set w $var(top)
    IMGSVRInit $varname "VLSS [msgcat::mc {Server}]" \
	VLSSExec VLSSAck ARDone ARError

    IMGSVRUpdate $varname
}

proc VLSSExec {varname} {
    upvar #0 $varname var
    global $varname

    if {$var(save)} {
	set var(fn) [SaveFileDialog savefitsfbox]
	if {$var(fn) == {}} {
	    ARDone $varname
	    return
	}
    } else {
	set var(fn) [tmpnam {.fits}]
    }

    # skyformat
    switch -- $var(skyformat) {
	degrees {
	    set xx [uformat d h: $var(x)]
	    set yy [uformat d d: $var(y)]
	}
	sexagesimal {
	    set xx $var(x)
	    set yy $var(y)
	}
    }
    regsub -all {:} $xx { } xx
    regsub -all {:} $yy { } yy

    # size - convert to arcmin
    switch -- $var(rformat) {
	degrees {
	    set ww $var(width)
	    set hh $var(height)
	}
	arcmin {
	    set ww [expr $var(width)/60.]
	    set hh [expr $var(height)/60.]
	}
	arcsec {
	    set ww [expr $var(width)/60./60.]
	    set hh [expr $var(height)/60./60.]
	}
    }

    set var(query) [http::formatQuery submit Submit Equinox J2000 RA $xx Dec $yy Size "$ww $hh" Cells "25.0 25.0" MAPROJ SIN rotate 0.0 Type image/x-fits]
    set url "http://www.cv.nrao.edu/cgi-bin/newVLSSpostage.pl"
    IMGSVRGetURL $varname $url
}

proc VLSSAck {varname} {
    upvar #0 $varname var
    global $varname

    set msg {Acknowledgments for the VLSS 

The VLSS survey is being carried out by the NRAO and the 
Naval Research Lab. 
    }

    SimpleTextDialog ${varname}ack [msgcat::mc {Acknowledgment}] \
	80 40 insert top $msg
}

# Process Cmds

proc ProcessVLSSCmd {varname iname} {
    upvar $varname var
    upvar $iname ii

    VLSSDialog

    vlss::YY_FLUSH_BUFFER
    vlss::yy_scan_string [lrange $var $ii end]
    vlss::yyparse
    incr ii [expr $vlss::yycnt-1]
}

proc oProcessVLSSCmd {varname iname} {
    upvar $varname var
    upvar $iname i

    VLSSDialog
    IMGSVRProcessCmd $varname $iname dvlss
}

proc ProcessSendVLSSCmd {proc id param} {
    VLSSDialog
    IMGSVRProcessSendCmd $proc $id $param dvlss
}