#!/usr/bin/env wish # calibrator locator gui by tyu #=> Begin Initialization set xplore_version 1.0 package require http set blt_avail 0 if {[catch {package require BLT}] == 0} { set blt_avail 1 namespace import blt::* } else { if {[info exists env(BLT_LIBRARY)]} { lappend auto_path $env(BLT_LIBRARY) if {[catch {package require BLT}] == 0} { set blt_avail 1 namespace import blt::* } } } option add *background #d9d9d9 interactive option add *foreground black interactive option add *activeBackground #ececec interactive option add *activeForeground black interactive option add *selectColor #b03060 interactive option add *selectBackground #c3c3c3 interactive option add *selectForeground black interactive option add *troughColor #c3c3c3 interactive option add *disabledForeground #a3a3a3 interactive option add *font 6x13 interactive set support_pth ~/.xplore_support set http_help_url "http://bima.astro.umd.edu/~tyu/xplore/xplore_support" set http_xfer_url "http://bima.astro.umd.edu/~tyu/xplore/xplore_support" set http_cgi_url "http://bima.astro.umd.edu:80/cgi-bin" set http_xfer_status normal set proj_trak_status disabled set voice_synth_status normal set wkday_list [list sun mon tue wed thu fri sat] set month_list [list jan feb mar apr may jun jul aug sep oct nov dec] set telpar_elm_list [list 0 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] set solsys_nam_list [list mercury venus mars jupiter saturn uranus \ neptune sol] set carcat_nam_list {} set time_zone(GMT) 0 set voice_report_cycle 300000 set privilege_user obs@hat if {$argv != {}} { foreach i $argv { if {[llength [split $i =]] == 2} { set command [concat set [split $i =]] eval $command } } } #=> End Initialization set filename [file join $support_pth flux_files] if {![file exists $filename]} { file mkdir $filename file attributes $filename -permissions 0755 } #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv proc Open { initial_pth } { global carma_catlog parent_pth working_pth open_list_widg \ carcat_fram_widg if {![winfo exists .dlg_open]} { toplevel .dlg_open -class Dialog wm title .dlg_open "Open" wm transient .dlg_open . frame .dlg_open.part1 \ -relief ridge \ -borderwidth 3 label .dlg_open.part1.label \ -justify center \ -text "Look Into:" entry .dlg_open.part1.enter \ -width 20 \ -textvariable parent_pth button .dlg_open.part1.button \ -text "GO" \ -background black \ -foreground green \ -command { List_File } pack .dlg_open.part1.label -side left -fill both pack .dlg_open.part1.enter -side left -fill both -expand yes pack .dlg_open.part1.button -side left -fill both frame .dlg_open.part2 \ -relief ridge \ -borderwidth 3 set open_list_widg [listbox .dlg_open.part2.list \ -height 10 \ -yscrollcommand ".dlg_open.part2.scrb set" \ -selectbackground yellow1 \ -selectmode single] scrollbar .dlg_open.part2.scrb \ -command ".dlg_open.part2.list yview" pack .dlg_open.part2.scrb \ -side right \ -fill y pack .dlg_open.part2.list \ -side left \ -fill both \ -expand yes frame .dlg_open.part3 label .dlg_open.part3.label \ -justify center \ -text "CHOOSE CARMA CATALOG" pack .dlg_open.part3.label -side left -fill both -expand yes frame .dlg_open.part4 \ -relief ridge \ -borderwidth 3 label .dlg_open.part4.label \ -justify center \ -text "File Name:" entry .dlg_open.part4.enter \ -width 20 \ -textvariable carma_catlog pack .dlg_open.part4.label -side left -fill both pack .dlg_open.part4.enter -side left -fill both -expand yes frame .dlg_open.part5 \ -relief ridge \ -borderwidth 3 button .dlg_open.part5.button1 \ -text "SUBMIT" \ -background black \ -foreground green \ -command { destroy .dlg_open if {$carma_catlog != ""} { if {![winfo exists .dlg_extobj]} { set extobj_log \ [Text_Window .dlg_extobj "CARMA Catalog Import"] } file copy -force \ [file join $parent_pth $carma_catlog] \ [file join $working_pth carcat.txt] Update normal } else { $carcat_fram_widg.no invoke } } button .dlg_open.part5.button2 \ -text "CANCEL" \ -background black \ -foreground green \ -command { $carcat_fram_widg.no invoke destroy .dlg_open } pack .dlg_open.part5.button1 .dlg_open.part5.button2 \ -side left \ -fill both \ -expand yes pack .dlg_open.part1 -side top -fill both pack .dlg_open.part2 -side top -fill both -expand yes pack .dlg_open.part3 -side top -fill both pack .dlg_open.part4 -side top -fill both pack .dlg_open.part5 -side top -fill both bind .dlg_open.part1.enter \ {List_File} bind $open_list_widg {Pick_File %W} tkwait visibility .dlg_open Center_Window .dlg_open } if {$parent_pth == ""} { set parent_pth $initial_pth } List_File } proc List_File { } { global parent_pth open_list_widg if {[file exists $parent_pth]} { if {[file isdirectory $parent_pth]} { cd $parent_pth $open_list_widg delete 0 end eval {$open_list_widg insert end} [glob -nocomplain *] .dlg_open.part5.button1 config -state normal } else { $open_list_widg delete 0 end .dlg_open.part5.button1 config -state disabled } } else { $open_list_widg delete 0 end .dlg_open.part5.button1 config -state disabled } } proc Pick_File { e } { global carma_catlog parent_pth open_list_widg set list [$open_list_widg get 0 end] set indx [$open_list_widg curselection] set mark [lindex $list $indx] if {[file isdirectory $mark]} { set parent_pth [file join $parent_pth $mark] List_File } else { set carma_catlog $mark } } #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ proc Voice_Synth { text } { global voice_synth_status vsock if {$voice_synth_status == "normal"} { if {![info exists vsock]} { set command [list exec ps -ef | grep "festival" | \ grep -v grep | wc -l] if {[catch $command info] == 0} { if {$info > 0} { set command [list socket localhost 1314] if {[catch $command vsock] == 0} { fconfigure $vsock -buffering line } else { set voice_synth_status "disabled" } } else { set voice_synth_status "disabled" } } else { set voice_synth_status "disabled" } } if {[info exists vsock] && ($text != "")} { set command [list puts $vsock "(SayText \"$text\")"] if {[catch $command result] != 0} { if {[info exists vsock]} { catch {close $vsock} unset vsock } Voice_Synth $text } } if {! ($voice_synth_status == "normal")} { .menubar.hear.menu entryconfigure "Mute" -state disabled .menubar.hear.menu entryconfigure "Loud" -state disabled } } } proc Back_Handler { } { global ra_hrs ra_min dec_deg dec_min if {[gets stdin request] < 0} { exit } elseif {$request == "kill_xplore"} { Handle_Close . } else { set ra_hrs [lindex $request 0] set ra_min [lindex $request 1] set dec_deg [lindex $request 2] set dec_min [lindex $request 3] Update normal } } proc Load_Data { filename obj args } { # args is the object name for list_widg and text_widg objects set data "" if {[file exists $filename]} { set fileid [open $filename "r"] switch -exact -- $obj \ list_widg { while {[gets $fileid data] >= 0} { if {![string match #* $data]} { $args insert end $data } } } \ list { set list "" while {[gets $fileid data] >= 0} { if {![string match #* $data]} { lappend list $data } } } \ text_widg { while {[gets $fileid data] >= 0} { $args insert end $data\n } $args delete "end -1 char" $args insert end "\n" } close $fileid if {$obj == "list"} { return $list } } } proc Reticle_Track { c flag } { global canvas_deg_xmin canvas_deg_ymin canvas_pix_xmax \ canvas_pix_ymax canvas_pix_xdel canvas_pix_ydel \ reticle_deg_xcen reticle_deg_ycen reticle_pix_xcen \ reticle_pix_ycen reticle_pix_xcen_old reticle_pix_ycen_old \ vport_pix_xcen vport_pix_ycen xpix_per_deg ypix_per_deg \ comand_pjt_butn_widg catlog_nam_list_widg catlog_nam_indx \ catlog_del_ctrl_widg catlog_add_ctrl_widg \ coords_string coords_string_old if {![winfo exists $c]} { tkwait visibility $c } set reticle_pix_xcen [$c canvasx $vport_pix_xcen] set reticle_pix_ycen [$c canvasy $vport_pix_ycen] if {[llength [$c gettags reticle]] == 0} { set reticle_pix_xmin [expr {$reticle_pix_xcen-30}] set reticle_pix_ymin [expr {$reticle_pix_ycen-30}] set reticle_pix_xmax [expr {$reticle_pix_xcen+30}] set reticle_pix_ymax [expr {$reticle_pix_ycen+30}] $c create oval \ $reticle_pix_xmin $reticle_pix_ymin \ $reticle_pix_xmax $reticle_pix_ymax \ -outline red \ -tags {reticle reticle_perim} $c create line \ $reticle_pix_xcen $reticle_pix_ymin \ $reticle_pix_xcen $reticle_pix_ymax \ -fill red \ -tags {reticle reticle_vline} $c create line \ $reticle_pix_xmin $reticle_pix_ycen \ $reticle_pix_xmax $reticle_pix_ycen \ -fill red \ -tags {reticle reticle_hline} } else { $c move reticle \ [expr {$reticle_pix_xcen-$reticle_pix_xcen_old}] \ [expr {$reticle_pix_ycen-$reticle_pix_ycen_old}] } set reticle_pix_xcen_old $reticle_pix_xcen set reticle_pix_ycen_old $reticle_pix_ycen if {$flag == "scroll"} { if {[$comand_pjt_butn_widg cget -relief] == "sunken"} { Auto_Pilot $comand_pjt_butn_widg .f.fb.canvas3 } set reticle_deg_xcen \ [expr {($canvas_pix_xmax-$reticle_pix_xcen)/double($xpix_per_deg) \ +$canvas_deg_xmin}] set reticle_deg_ycen \ [expr {($canvas_pix_ymax-$reticle_pix_ycen)/double($ypix_per_deg) \ +$canvas_deg_ymin}] Convert from_deg if {[info exists catlog_nam_indx]} { $catlog_nam_list_widg selection clear 0 end unset catlog_nam_indx $catlog_del_ctrl_widg config -state disabled $catlog_add_ctrl_widg config -state normal } } if {$flag == "normal"} { if {[info exists catlog_nam_indx]} { if {$coords_string != $coords_string_old} { $catlog_nam_list_widg selection clear 0 end unset catlog_nam_indx $catlog_del_ctrl_widg config -state disabled $catlog_add_ctrl_widg config -state normal } else { $catlog_del_ctrl_widg config -state normal $catlog_add_ctrl_widg config -state disabled } } else { $catlog_del_ctrl_widg config -state disabled $catlog_add_ctrl_widg config -state normal } } HA_Range $reticle_deg_xcen $reticle_deg_ycen 35 red src_har Erase } proc LST_Track { c } { global lng_deg support_pth lstnow_hhmm lsticon_pix_xcen \ lsticon_pix_xcen_old working_pth xpix_per_hr \ telpar_nam_list telpar_nam_indx lst_labl_widg #Julian Day (p.600), Greenwich Mean Sidereal Time (p.50) #from Explanatory Supplement to the Astronomical Almanac #by Seidelmann set cron \ [clock format [clock seconds] -format %d%%%m%%%Y%%%H%%%M -gmt 1] set t [split $cron %] set d [format %2.0f [lindex $t 0]] set m [format %2.0f [lindex $t 1]] set y [format %2.0f [lindex $t 2]] set H [format %2.0f [lindex $t 3]] set M [format %2.0f [lindex $t 4]] set jd \ [expr {int((1461*($y+4800+int(($m-14)/12.)))/4.) \ +int((367*($m-2-12*int(($m-14)/12.)))/12.) \ -int((3*int(($y+4900+int(($m-14)/12.))/100.))/4.) \ +$d-32075}] set tu [expr {(double($jd)-0.5-2451545.0)/36525.}] set gst \ [expr {(24110.54841 \ +8640184.812866*$tu \ +0.093104*pow($tu,2.) \ -0.0000062*pow($tu,3.))/86400.}] set gst [expr {($gst-int($gst))*24.}] if {$gst < 0.} { set gst [expr {$gst+24.}] } if {$gst > 24.} { set gst [expr {$gst-24.}] } set lst \ [expr {1.002737909*(double($H)+(double($M)/60.)) \ +$gst+$lng_deg/15.}] while {1} { if {$lst < 0.} { set lst [expr {$lst+24.}] } else { break } } while {1} { if {$lst > 24.} { set lst [expr {$lst-24.}] } else { break } } set lsticon_pix_xcen [expr {$xpix_per_hr*$lst}] set lst_hrs [expr {int($lst)}] set lst_min [format %2.2d [expr {int(60*($lst-$lst_hrs))}]] set lst_hrs [format %2.2d [expr {int($lst)}]] set lstnow_hhmm $lst_hrs$lst_min if {$c == "voice_synth"} { Voice_Synth \ "[lindex $telpar_nam_list $telpar_nam_indx] LST $lst_hrs:$lst_min" } else { $lst_labl_widg config \ -text "[lindex $telpar_nam_list $telpar_nam_indx]\nLST $lstnow_hhmm" if {![winfo exists $c]} { tkwait visibility $c } if {[llength [$c gettags lsticon]] == 0} { $c create poly \ $lsticon_pix_xcen 38 \ [expr {$lsticon_pix_xcen+5.77}] 48 \ [expr {$lsticon_pix_xcen-5.77}] 48 \ -outline black \ -fill black \ -tags {lsticon} $c create poly \ $lsticon_pix_xcen 12 \ [expr {$lsticon_pix_xcen+5.77}] 2 \ [expr {$lsticon_pix_xcen-5.77}] 2 \ -outline black \ -fill black \ -tags {lsticon} } else { $c move lsticon \ [expr {$lsticon_pix_xcen-$lsticon_pix_xcen_old}] 0 } set lsticon_pix_xcen_old $lsticon_pix_xcen } } proc Telescope_Track { c } { global src_com ra_com ra_com_old dec_com dec_com_old \ ra_hrs ra_min ra_sec \ dec_deg dec_min dec_sec \ reticle_pix_xcen reticle_pix_xcen_old \ reticle_pix_ycen reticle_pix_ycen_old set test1 [catch {exec value name=RA op=h} ra_com] set test2 [catch {exec value name=DEC op=d} dec_com] set test3 [catch {exec value name=SOURCE} tmp_com] if {!($test1) && !($test2) && !($test3)} { set ra_com [lindex $ra_com 4] set dec_com [lindex $dec_com 4] set src_com [lindex $tmp_com 4] if {[winfo exists .f.fb]} { if {($ra_com != "00:00:00.000") && \ ($dec_com != "00:00:00.000")} { if {($ra_com != $ra_com_old) && \ ($dec_com != $dec_com_old)} { set list [split $ra_com :] set ra_hrs [lindex $list 0] set ra_min [lindex $list 1] set ra_sec [lindex $list 2] set list [split $dec_com :] set dec_deg [lindex $list 0] set dec_min [lindex $list 1] set dec_sec [lindex $list 2] if {$ra_com_old != "99:99:99.999"} { set list [$c coords reticle_hline] $c coords cross_hline \ [lindex $list 0] [lindex $list 1] \ [lindex $list 2] [lindex $list 3] set list [$c coords reticle_vline] $c coords cross_vline \ [lindex $list 0] [lindex $list 1] \ [lindex $list 2] [lindex $list 3] } Update normal set ra_com_old $ra_com set dec_com_old $dec_com } } } } } proc HA_Range { x y bar_pos bar_col bar_tag } { global dec_deg_lolimt dec_deg_hilimt elm_sin lat_sin \ lat_cos rad_per_deg xpix_per_hr .f.fb.canvas0 delete $bar_tag .f.fb.canvas1 delete $bar_tag .f.fb.canvas2 delete $bar_tag set sum 0 if {(($lat_sin > 0) && ($y > $dec_deg_lolimt) && ($y < $dec_deg_hilimt)) || (($lat_sin < 0) && ($y < $dec_deg_lolimt) && ($y > $dec_deg_hilimt))} { set var1 \ [expr {acos(($elm_sin-($lat_sin*sin($rad_per_deg*$y))) \ / ($lat_cos*cos($rad_per_deg*$y)))/($rad_per_deg*15)}] set var2 [expr {$x/15.}] if {$var2 < 0} {set var2 [expr {$var2+24}]} if {$var2 > 24} {set var2 [expr {$var2-24}]} set lst1 [expr {$var2-$var1}] set lst2 [expr {$var2+$var1}] set lst3 0 set lst4 0 if {$lst1 < 0} { set lst3 [expr {24+$lst1}] set lst4 24 set lst1 0 } if {$lst2 > 24} { set lst4 [expr {$lst2-24}] set lst3 0 set lst2 24 } if {$lst1 != $lst2} { .f.fb.canvas2 create line \ [expr {$xpix_per_hr*$lst1}] $bar_pos \ [expr {$xpix_per_hr*$lst2}] $bar_pos \ -fill $bar_col \ -tags $bar_tag \ -width 4 set sum [expr {$sum+$lst2-$lst1}] } if {$lst3 != $lst4} { .f.fb.canvas2 create line \ [expr {$xpix_per_hr*$lst3}] $bar_pos \ [expr {$xpix_per_hr*$lst4}] $bar_pos \ -fill $bar_col \ -tags $bar_tag \ -width 4 set sum [expr {$sum+$lst4-$lst3}] } } if {(($lat_sin > 0) && ($y >= $dec_deg_hilimt)) || (($lat_sin < 0) && ($y <= $dec_deg_hilimt))} { .f.fb.canvas2 create line \ 0 $bar_pos [expr {$xpix_per_hr*24}] $bar_pos \ -fill $bar_col \ -tags $bar_tag \ -width 4 set sum 24 } set ha_hrs [expr {int($sum)}] set ha_min [expr {int(60*($sum-$ha_hrs))}] .f.fb.canvas0 create text \ 0 $bar_pos \ -tags $bar_tag \ -fill $bar_col \ -text "[format %2.2d $ha_hrs]h" \ -anchor w \ -justify center .f.fb.canvas1 create text \ 0 $bar_pos \ -tags $bar_tag \ -fill $bar_col \ -text "[format %2.2d $ha_min]m" \ -anchor w \ -justify center } proc Convert { flag } { global dec_deg dec_min dec_sec ra_hrs ra_min ra_sec \ reticle_deg_xcen reticle_deg_ycen switch -exact -- $flag \ from_deg { set dec_deg [expr {int($reticle_deg_ycen)}] if {($reticle_deg_ycen < 0) && ($dec_deg == 0)} { set dec_deg -0 } set nexstep [expr {abs(60*($reticle_deg_ycen-$dec_deg))}] if {[expr {abs(round($nexstep)-$nexstep)}] < 1.0e-3} { set nexstep [expr {round($nexstep)}] } set dec_min [expr {floor($nexstep)}] set nexstep [expr {60*($nexstep-$dec_min)}] set dec_sec [expr {round($nexstep)}] set dec_min [format %02.0f $dec_min] set dec_sec [format %02.0f $dec_sec] set ra_conv [expr {$reticle_deg_xcen/15.}] set ra_hrs [expr {int($ra_conv)}] if {($reticle_deg_xcen < 0) && ($ra_hrs == 0)} { set ra_hrs -0 } set nexstep [expr {abs(60*($ra_conv-$ra_hrs))}] if {[expr {abs(round($nexstep)-$nexstep)}] < 1.0e-3} { set nexstep [expr {round($nexstep)}] } set ra_min [expr {floor($nexstep)}] set nexstep [expr {60*($nexstep-$ra_min)}] set ra_sec [expr {round($nexstep)}] set ra_min [format %02.0f $ra_min] set ra_sec [format %02.0f $ra_sec] } \ to_deg { set a [format %1.4f $ra_hrs] set b [format %1.4f $ra_min] set c [format %1.4f $ra_sec] set f [string match {-*} $ra_hrs] set reticle_deg_xcen [expr {15*(abs($a)+($b+$c/60.)/60.)}] if {($a < 0) || $f} { set reticle_deg_xcen [expr {-1*$reticle_deg_xcen}] } set a [format %1.4f $dec_deg] set b [format %1.4f $dec_min] set c [format %1.4f $dec_sec] set f [string match {-*} $dec_deg] set reticle_deg_ycen [expr {abs($a)+($b+$c/60.)/60.}] if {($a < 0) || $f} { set reticle_deg_ycen [expr {-1*$reticle_deg_ycen}] } } } proc AltAzm { lst ra dec bar_tag } { global 1pi 2pi lat_deg lat_sin lat_cos rad_per_deg \ reticle_deg_xcen reticle_deg_ycen vport_pix_xdel \ xpix_per_hr set lst_hrs [expr {int($lst/$xpix_per_hr)}] set lst_min [format %2.2d [expr {int(60*($lst/$xpix_per_hr-$lst_hrs))}]] set lst_hrs [format %2.2d [expr {int($lst/$xpix_per_hr)}]] set lst_hhmm $lst_hrs$lst_min set ha [expr {$rad_per_deg*(15*$lst/$xpix_per_hr-$ra)}] if {$ha > $1pi} { set ha [expr {$ha-$2pi}] } if {$ha < -$1pi} { set ha [expr {$2pi+$ha}] } #Horizon Coordinates Calculation, p.10,37 #from Astronomy on the Personal Computer #by Montenbruck and Pfleger set x [expr {cos($rad_per_deg*$dec)*$lat_sin*cos($ha) \ - sin($rad_per_deg*$dec)*$lat_cos}] set y [expr {cos($rad_per_deg*$dec)*sin($ha)}] set z [expr {cos($rad_per_deg*$dec)*$lat_cos*cos($ha) \ + sin($rad_per_deg*$dec)*$lat_sin}] set rho [expr {sqrt(pow($x,2)+pow($y,2))}] set alt [expr {atan2($z,$rho)/$rad_per_deg}] set azm [expr {atan2($y,$x)/$rad_per_deg}] if {($azm < 0)} {set azm [expr {$azm+360}]} if {$bar_tag == "voice_synth"} { regsub -all {\+} [format %+2.1f $alt] {plus } x regsub -all {\-} $x {minus } u regsub -all {\+} [format %+2.1f $azm] {plus } y regsub -all {\-} $y {minus } v Voice_Synth \ "central target has altitude $u degrees and azimuth \ $v degrees" } else { if {$bar_tag == "src_har"} { set yc 9 } if {$bar_tag == "cal_har"} { set yc 38 } set xc [expr {$vport_pix_xdel/2.}] if {[winfo exists .f.fb.canvas2.wf]} { .f.fb.canvas2 delete altazm_info destroy .f.fb.canvas2.wf } set wf \ [frame .f.fb.canvas2.wf -borderwidth 0 -relief flat -takefocus 0] .f.fb.canvas2 create window $xc $yc \ -anchor center \ -tags {altazm_info} \ -window $wf text $wf.t \ -width 67 \ -height 1 \ -borderwidth 0 \ -background white \ -foreground black \ -takefocus 0 pack $wf.t $wf.t tag add alltext 1.0 end $wf.t tag configure alltext -justify center $wf.t insert end \ "LST : $lst_hhmm BEARING : ALT=[format %2.1f $alt] Deg \ AZM=[format %+2.1f $azm] Deg (S->W->N->E->S)" {alltext} } } proc Jul_To_Greg { jd zone } { global wkday_list month_list time_zone #Julian Day Number to Gregorian Calendar Date Conversion, p.604 #from Explanatory Supplement to the Astronomical Almanac #by Fliegel and Van Flandern set inp [expr {$jd-$time_zone($zone)/24.}] set part1 [expr {int($inp)}] set part2 [expr {$inp-$part1}] if {$part2 >= 0.5} { incr part1 set part2 [expr {24*($part2-0.5)}] } else { set part2 [expr {24*($part2+0.5)}] } set L [expr {$part1+68569}] set N [expr {int((4*$L)/146097)}] set L [expr {$L-int((146097*$N+3)/4)}] set I [expr {int((4000*($L+1))/1461001)}] set L [expr {$L-int((1461*$I)/4)+31}] set J [expr {int((80*$L)/2447)}] set D [expr {$L-int((2447*$J)/80)}] set L [expr {int($J/11)}] set M [expr {$J+2-(12*$L)}] set Y [expr {100*($N-49)+$I+$L}] set I [expr {$part1-7*int(($part1+1)/7)+2}] set I [lindex $wkday_list [incr I -1]] set M [lindex $month_list [incr M -1]] set h [expr {int($part2)}] set m [expr {60*($part2-$h)}] set info "[format %02.0f $D]$M$Y" } proc What_Is_Date { values } { global htext_label scan $values "%e %e" x y $htext_label config -text "[Jul_To_Greg $x GMT] , [format %02.1f $y] Jy" } proc Show_History { x y } { global all_flx_list support_pth loc_indx loc_jndx cal_col \ htext_label vport_pix_xdel vport_pix_ydel coord_list \ lambda cal_alias_list if {[info exists loc_indx]} { set cal_flx [lindex $all_flx_list $loc_jndx] set cal_nam [lindex $cal_flx 0] set filename $cal_nam append filename _ $lambda .dat set filename [file join $support_pth flux_files $filename] if {[file exists $filename]} { set flag 1 } else { set flag 0 if {[info exists cal_alias_list]} { foreach i $cal_alias_list { if {[lsearch -exact $i $cal_nam] != -1} { set cal_nam [lindex $i 0] set filename $cal_nam append filename _ $lambda .dat set filename \ [file join $support_pth flux_files $filename] if {[file exists $filename]} { append cal_nam -alias set flag 1 } break } } } } if {$flag} { set coord_list [Load_Data $filename list] foreach i $coord_list { lappend x_list [lindex $i 0] lappend y_list [lindex $i 1] } if {[llength $x_list] > 1} { if {$y > [expr {$vport_pix_ydel/2.}]} { set yc [.f.fb.canvas3 canvasy [expr {$vport_pix_ydel/5.}]] } else { set yc [.f.fb.canvas3 canvasy [expr {4*$vport_pix_xdel/5.}]] } set xc [.f.fb.canvas3 canvasx [expr {$vport_pix_xdel/2.}]] set wf2 \ [frame .f.fb.canvas3.wf2 -borderwidth 3 -relief ridge -takefocus 0] .f.fb.canvas3 create window $xc $yc \ -anchor center \ -tags {cal_hist} \ -window $wf2 htext $wf2.h \ -height 20 \ -text {Move mouse to see Gregorian date and Flux here: %% label $htext(widget).greg -text "ddmmmyyyy , Jy" -width 19 $htext(widget) append $htext(widget).greg %% } set htext_label $htext(widget).greg graph $wf2.g \ -plotbackground gray \ -height 200 \ -title "$cal_nam Flux History" $wf2.g element create line \ -xdata $x_list \ -ydata $y_list \ -symbol scross \ -color $cal_col \ -label "" $wf2.g axis configure x \ -title "Julian Date" $wf2.g axis configure y \ -title "Flux (Jy)" pack $wf2.h $wf2.g \ -side top Blt_ZoomStack $wf2.g Blt_Crosshairs $wf2.g bind $wf2.g \ {What_Is_Date [ %W invtransform %x %y ]} } } } } proc Locate { x y } { global all_id_list loc_indx loc_jndx cal_col set xc [.f.fb.canvas3 canvasx $x] set yc [.f.fb.canvas3 canvasy $y] set id [.f.fb.canvas3 find overlapping \ [expr {$xc-2}] [expr {$yc-2}] [expr {$xc+2}] [expr {$yc+2}]] if {$id != {}} { foreach i [lsort -integer -decreasing $id] { if {[lsearch $all_id_list $i] != -1} { break } } set loc_indx $i set loc_jndx [lsearch $all_id_list $loc_indx] set cal_col [.f.fb.canvas3 itemcget $loc_indx -fill] } } proc Show_Current { x y } { global all_flx_list all_pos_list rad_per_deg loc_indx loc_jndx \ reticle_deg_xcen reticle_deg_ycen vport_pix_xdel vport_pix_ydel \ cal_pos cal_col #Angular Distance Calculation, p.67 #from Astrophys by Zombeck if {[info exists loc_indx]} { set cal_flx [lindex $all_flx_list $loc_jndx] set cal_pos [lindex $all_pos_list $loc_jndx] if {($reticle_deg_xcen == [lindex $cal_pos 0]) && \ ($reticle_deg_ycen == [lindex $cal_pos 1])} { set cal_sep 0 } else { set cal_sep \ [expr {acos(sin($rad_per_deg*$reticle_deg_ycen) \ * sin($rad_per_deg*[lindex $cal_pos 1]) \ + cos($rad_per_deg*$reticle_deg_ycen) \ * cos($rad_per_deg*[lindex $cal_pos 1]) \ * cos($rad_per_deg*($reticle_deg_xcen-[lindex $cal_pos 0]))) \ / $rad_per_deg}] } HA_Range \ [lindex $cal_pos 0] [lindex $cal_pos 1] 15 $cal_col cal_har if {$x > [expr {$vport_pix_xdel/2.}]} { set xc [.f.fb.canvas3 canvasx [expr {$vport_pix_xdel/5.}]] } else { set xc [.f.fb.canvas3 canvasx [expr {4*$vport_pix_xdel/5.}]] } set yc [.f.fb.canvas3 canvasy [expr {$vport_pix_ydel/2.}]] set wf1 \ [frame .f.fb.canvas3.wf1 -borderwidth 3 -relief ridge -takefocus 0] .f.fb.canvas3 create window $xc $yc \ -anchor center \ -tags {cal_curr} \ -window $wf1 text $wf1.t \ -width 30 \ -height 5 \ -spacing1 5 \ -spacing3 5 \ -borderwidth 0 \ -takefocus 0 pack $wf1.t $wf1.t tag add alltext 1.0 end $wf1.t tag configure alltext -justify left -lmargin1 40 $wf1.t insert end "NAME : [lindex $cal_flx 0]\n" {alltext} $wf1.t insert end "FLUX : [lindex $cal_flx 1] Jy\n" {alltext} $wf1.t insert end "DATE : [lindex $cal_flx 2]\n" {alltext} $wf1.t insert end "FREQ : [lindex $cal_flx 3] GHz\n" {alltext} $wf1.t insert end "DIST : [format %2.1f $cal_sep] Deg\n" {alltext} regsub -all {\+} [lindex $cal_flx 0] {plus} x regsub -all {\-} $x {minus} y regsub -all {\-} [lindex $cal_flx 1] {minus} z Voice_Synth "$y flux $z Janskies" } } proc Declare_Error { source log } { global working_pth switch -exact -- $source \ carcat { $log insert end \ "*** WARNING: Import failed.\n" set tmp [file join $working_pth carcat_nonawk_err] if {[file exists $tmp]} { file delete -force $tmp $log insert end \ "*** WARNING: Carcat plugin requires unix awk command.\n" $log see end } else { set tmp [file join $working_pth carcat_coords_err] if {[file exists $tmp]} { file delete -force $tmp $log insert end \ "*** WARNING: Coordinates contain illegal format.\n" $log insert end "\n" $log insert end \ " Example of proper catalog coordinates is:\n" $log insert end "\n" $log insert end \ " #| Source | RA | DEC |\n" $log insert end \ " HORSHEAD 05:41:01.20 -02:28:12.49\n" $log see end } else { set tmp [file join $working_pth carcat_nodata_err] if {[file exists $tmp]} { file delete -force $tmp $log insert end \ "*** WARNING: Catalog contains no data.\n" $log see end } } } } \ solsys { } } proc External_Objects { } { global all_id_list all_flx_list all_pos_list cal_id_list \ cal_flx_list cal_pos_list canvas_pix_xmax canvas_pix_ymax \ canvas_deg_xmin canvas_deg_ymin date date_old include_solsys \ solsys_id_list solsys_flx_list solsys_pos_list solsys_vis_list \ include_carcat carcat_id_list carcat_flx_list carcat_pos_list \ carcat_vis_list vport_deg_xdel vport_deg_xdel_old support_pth \ working_pth xpix_per_deg lambda lambda_old \ http_xfer_url http_cgi_url extobj_log solsys_non_butn_widg \ carcat_fram_widg if {$include_solsys == "n"} { Catalog unload solsys if {[info exists solsys_id_list]} { .f.fb.canvas3 delete solsys } } if {$include_carcat == "n"} { Catalog unload carcat if {[info exists carcat_id_list]} { .f.fb.canvas3 delete carcat } } if {$include_solsys == "y"} { if {([.f.fb.canvas3 find withtag solsys] == {}) || \ ($date != $date_old) || \ ($lambda != $lambda_old) || \ ($vport_deg_xdel != $vport_deg_xdel_old)} { set command1 [list \ exec [file join $support_pth solsys] date=$date \ xpix_per_deg=$xpix_per_deg \ canvas_pix_xmax=$canvas_pix_xmax \ canvas_pix_ymax=$canvas_pix_ymax \ canvas_deg_xmin=$canvas_deg_xmin \ canvas_deg_ymin=$canvas_deg_ymin \ working_pth=$working_pth \ ] if {[catch $command1 result] != 0} { if {![winfo exists .dlg_extobj]} { set extobj_log \ [Text_Window .dlg_extobj "ExtObj Download"] } if {![file exists [file join $support_pth solsys]]} { $extobj_log insert end \ "*** Downloading solsys plugin (support script) ...\n" $extobj_log see end set url "$http_xfer_url/solsys" set tmp [file join $support_pth solsys] set command2 [list ::http::copy $url $tmp $extobj_log] if {[catch $command2 result] == 0} { if {[Check_File $tmp "text/plain" ok 200]} { $extobj_log insert end \ "*** SUCCESS: Download completed; installed solsys\ in $support_pth.\n" file attributes \ [file join $support_pth solsys] -permissions 0755 } else { $extobj_log insert end \ "*** WARNING: Download failed; try again later.\n" } } else { $extobj_log insert end \ "*** WARNING: Download failed; try again later.\n" } } $extobj_log insert end "\n" $extobj_log see end if {[file exists [file join $support_pth solsys]]} { $extobj_log insert end \ "*** Downloading solar system data for $date ...\n" $extobj_log see end set url "$http_cgi_url/gen4xplore?$date" set tmp [file join $working_pth solsys.$date.txt] set command3 [list ::http::copy $url $tmp $extobj_log] if {[catch $command3 result] == 0} { if {[Check_File $tmp "text/plain" ok 200]} { $extobj_log insert end \ "*** SUCCESS: Download completed.\n" $extobj_log insert end "\n" Load_Data $tmp text_widg $extobj_log if {[catch $command1 result] == 0} { $extobj_log insert end "\n" $extobj_log insert end "Done.\n" } else { $extobj_log insert end \ "*** WARNING: Please contact the author.\n" $solsys_non_butn_widg invoke } } else { $extobj_log insert end \ "*** WARNING: Download failed; try again later.\n" $solsys_non_butn_widg invoke if { [file exists solsys.$date.txt] } { file delete -force solsys.$date.txt } } } else { $extobj_log insert end \ "*** WARNING: Download failed; try again later.\n" $solsys_non_butn_widg invoke if { [file exists solsys.$date.txt] } { file delete -force solsys.$date.txt } } $extobj_log insert end "\n" $extobj_log see end } } if {$include_solsys == "y"} { Catalog unload solsys Catalog load solsys set solsys_pos_list \ [Load_Data [file join $working_pth solsys_posdat] list] set solsys_flx_list \ [Load_Data [file join $working_pth solsys_flxdat] list] set solsys_vis_list \ [Load_Data [file join $working_pth solsys_visual] list] .f.fb.canvas3 delete solsys foreach i $solsys_vis_list { eval \ {.f.fb.canvas3 create oval} $i {-tags {calib solsys}} } } } } #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv if {$include_carcat == "y"} { if {([.f.fb.canvas3 find withtag carcat] == {}) || \ ($date != $date_old) || \ ($lambda != $lambda_old) || \ ($vport_deg_xdel != $vport_deg_xdel_old)} { set command1 [list \ exec [file join $support_pth carcat] \ date=[string tolower [clock format [clock seconds] \ -format %y%b%d -gmt 1]] \ xpix_per_deg=$xpix_per_deg \ canvas_pix_xmax=$canvas_pix_xmax \ canvas_pix_ymax=$canvas_pix_ymax \ canvas_deg_xmin=$canvas_deg_xmin \ canvas_deg_ymin=$canvas_deg_ymin \ working_pth=$working_pth \ data=carcat.txt \ ] if {[catch $command1 result] != 0} { if {![winfo exists .dlg_extobj]} { set extobj_log \ [Text_Window .dlg_extobj "CARMA Catalog Import"] } if {![file exists [file join $support_pth carcat]]} { $extobj_log insert end \ "*** Downloading carcat plugin (support script) ...\n" $extobj_log see end set url "$http_xfer_url/carcat" set tmp [file join $support_pth carcat] set command2 [list ::http::copy $url $tmp $extobj_log] if {[catch $command2 result] == 0} { if {[Check_File $tmp "text/plain" ok 200]} { $extobj_log insert end \ "*** SUCCESS: Download completed; installed carcat\ in $support_pth.\n" file attributes \ [file join $support_pth carcat] -permissions 0755 } else { $extobj_log insert end \ "*** WARNING: Download failed; try again later.\n" } } else { $extobj_log insert end \ "*** WARNING: Download failed; try again later.\n" } if {[file exists [file join $support_pth carcat]]} { if {[catch $command1 result] == 0} { $extobj_log insert end \ "*** Importing CARMA catalog ...\n" $extobj_log insert end "\n" set tmp [file join $working_pth carcat.txt] Load_Data $tmp text_widg $extobj_log $extobj_log insert end "\n" $extobj_log insert end "Done.\n" } else { Declare_Error carcat $extobj_log $carcat_fram_widg.no invoke file delete -force [file join $working_pth carcat.txt] } } } else { Declare_Error carcat $extobj_log $carcat_fram_widg.no invoke file delete -force [file join $working_pth carcat.txt] } $extobj_log insert end "\n" $extobj_log see end #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } else { if {[winfo exists .dlg_extobj]} { $extobj_log insert end \ "*** Importing CARMA catalog ...\n" $extobj_log insert end "\n" set tmp [file join $working_pth carcat.txt] Load_Data $tmp text_widg $extobj_log $extobj_log insert end "\n" $extobj_log insert end "Done.\n" $extobj_log see end } } if {$include_carcat == "y"} { Catalog unload carcat Catalog load carcat set carcat_pos_list \ [Load_Data [file join $working_pth carcat_posdat] list] set carcat_flx_list \ [Load_Data [file join $working_pth carcat_flxdat] list] set carcat_vis_list \ [Load_Data [file join $working_pth carcat_visual] list] .f.fb.canvas3 delete carcat foreach i $carcat_vis_list { eval \ {.f.fb.canvas3 create oval} $i {-tags {calib carcat}} } } } } if {$include_solsys == "n"} { if {$include_carcat == "n"} { set all_id_list $cal_id_list set all_flx_list $cal_flx_list set all_pos_list $cal_pos_list } if {$include_carcat == "y"} { if {[.f.fb.canvas3 find withtag reticle] != {}} { .f.fb.canvas3 lower carcat reticle } set carcat_id_list [.f.fb.canvas3 find withtag carcat] set all_id_list [concat $cal_id_list $carcat_id_list] set all_pos_list [concat $cal_pos_list $carcat_pos_list] set all_flx_list [concat $cal_flx_list $carcat_flx_list] } } if {$include_solsys == "y"} { if {$include_carcat == "n"} { if {[.f.fb.canvas3 find withtag reticle] != {}} { .f.fb.canvas3 lower solsys reticle } set solsys_id_list [.f.fb.canvas3 find withtag solsys] set all_id_list [concat $cal_id_list $solsys_id_list] set all_pos_list [concat $cal_pos_list $solsys_pos_list] set all_flx_list [concat $cal_flx_list $solsys_flx_list] } if {$include_carcat == "y"} { if {[.f.fb.canvas3 find withtag reticle] != {}} { .f.fb.canvas3 lower carcat reticle } if {[.f.fb.canvas3 find withtag carcat] != {}} { .f.fb.canvas3 lower solsys carcat } set solsys_id_list [.f.fb.canvas3 find withtag solsys] set carcat_id_list [.f.fb.canvas3 find withtag carcat] set all_id_list \ [concat $cal_id_list $solsys_id_list $carcat_id_list] set all_pos_list \ [concat $cal_pos_list $solsys_pos_list $carcat_pos_list] set all_flx_list \ [concat $cal_flx_list $solsys_flx_list $carcat_flx_list] } } } proc Erase { } { global loc_indx animate4_handle .f.fb.canvas0 delete cal_har .f.fb.canvas1 delete cal_har .f.fb.canvas2 delete cal_har .f.fb.canvas2 delete altazm_info destroy .f.fb.canvas2.wf .f.fb.canvas3 delete cal_curr destroy .f.fb.canvas3.wf1 .f.fb.canvas3 delete cal_hist destroy .f.fb.canvas3.wf2 if {[info exists animate4_handle]} { after cancel $animate4_handle unset animate4_handle .f.fb.canvas3 itemconfigure $loc_indx -outline black } } proc Animate0 { t } { global animate0_handle \ lsticon_pix_xcen reticle_deg_xcen reticle_deg_ycen LST_Track voice_synth AltAzm \ $lsticon_pix_xcen $reticle_deg_xcen $reticle_deg_ycen voice_synth set animate0_handle [after $t Animate0 $t] Voice_Synth "Next audio update in [expr {$t/60000}] minutes" } proc Animate1 { c } { global animate1_handle title_string_prefix set title_string "$title_string_prefix \ [clock format [clock seconds] -format "%a %b %d %H:%M %Z %Y" -gmt 1]" wm title . $title_string LST_Track $c set animate1_handle [after 60000 Animate1 $c] } proc Animate2 { c } { global animate2_handle Telescope_Track $c set animate2_handle [after 30000 Animate2 $c] } proc Animate3 { c } { global animate3_handle src_com comand_pjt_butn_widg if {[winfo exists .f.fb]} { if {[$c itemcget reticle_perim -outline] == "red"} { $c itemconfigure reticle_perim -outline black } else { $c itemconfigure reticle_perim -outline red } if {[$comand_pjt_butn_widg cget -text] == "PJTRAK"} { $comand_pjt_butn_widg config -text "$src_com" } else { $comand_pjt_butn_widg config -text "PJTRAK" } set animate3_handle [after 3000 Animate3 $c] } } proc Animate4 { c } { global animate4_handle cal_col loc_indx if {[$c itemcget $loc_indx -outline] == "black"} { $c itemconfigure $loc_indx -outline white } else { $c itemconfigure $loc_indx -outline black } set animate4_handle [after 500 Animate4 $c] } proc BindXview { lists args } { foreach l $lists { eval {$l xview} $args } Reticle_Track .f.fb.canvas3 scroll } proc BindYview { lists args } { foreach l $lists { eval {$l yview} $args } Reticle_Track .f.fb.canvas3 scroll } proc BindDragto { x y args } { foreach w $args { $w scan dragto $x $y } Reticle_Track .f.fb.canvas3 scroll } proc BindMark { x y args } { foreach w $args { $w scan mark $x $y } } proc Handle_Close { widgetname } { global working_pth argv vsock if {[info exists vsock]} { close $vsock } if { $widgetname == "." } { cd /tmp file delete -force $working_pth exit } else { destroy $widgetname } } proc About { } { global support_pth if {![winfo exists .dlg_about]} { toplevel .dlg_about -class Dialog wm title .dlg_about "About Xplore" wm transient .dlg_about . frame .dlg_about.top set fileid [open [file join $support_pth xplore_about.txt] "r"] set data [read $fileid] close $fileid message .dlg_about.top.mesg \ -aspect 1000 \ -justify center \ -text $data pack .dlg_about.top.mesg \ -side left \ -fill both \ -expand true button .dlg_about.but \ -text "Dismiss" \ -background black \ -foreground green \ -command {destroy .dlg_about} pack .dlg_about.top .dlg_about.but \ -side top tkwait visibility .dlg_about Center_Window .dlg_about } } proc Text_Window {widget title} { toplevel $widget -class Dialog wm title $widget $title wm transient $widget . frame $widget.top text $widget.top.log \ -width 80 -height 20 \ -borderwidth 3 \ -relief ridge \ -setgrid true \ -yscrollcommand [list $widget.top.scroll set] scrollbar $widget.top.scroll \ -command [list $widget.top.log yview] pack $widget.top.scroll \ -side right \ -fill y pack $widget.top.log \ -side left \ -fill both \ -expand yes button $widget.but \ -text "Dismiss" \ -background black \ -foreground green \ -command [list destroy $widget] pack $widget.top \ -fill both \ -expand yes pack $widget.but tkwait visibility $widget Center_Window $widget return $widget.top.log } proc Tutor { } { global support_pth working_pth http_xfer_url tutor_log if {![winfo exists .dlg_tutor]} { set tutor_log [Text_Window .dlg_tutor Tutor] set filename [file join $support_pth xplore_help.txt] if { [file exists $filename] } { Load_Data $filename text_widg $tutor_log } else { $tutor_log insert end \ "*** Downloading xplore help file ...\n" $tutor_log see end set url "$http_xfer_url/xplore_help.txt" set tmp [file join $working_pth xplore_help.txt] set command [list ::http::copy $url $tmp $tutor_log] if {[catch $command result] == 0} { if {[Check_File $tmp "text/plain" ok 200]} { $tutor_log insert end \ "*** SUCCESS: Download completed.\n" $tutor_log insert end "\n" Load_Data $tmp text_widg $tutor_log } else { $tutor_log insert end \ "*** WARNING: Download failed; try again later.\n" } } else { $tutor_log insert end \ "*** WARNING: Download failed; try again later.\n" } $tutor_log insert end "\n" $tutor_log see end } } } # Copy a URL to a file and print meta-data namespace eval http { proc copy { url file log {chunk 4096} } { global ::http_stat ::http_type ::http_code if {[file exists $file]} { file delete -force $file } set token [geturl $url -validate 1 -timeout 30000] if {[::http::status $token] == "ok"} { set out [open $file w] set token [geturl $url -channel $out \ -progress [list ::http::Progress $log] \ -blocksize $chunk -timeout 60000] close $out # This ends the line started by http::Progress $log insert end "\n" $log see end upvar #0 $token state set max 0 foreach {name value} $state(meta) { if {[string length $name] > $max} { set max [string length $name] } } incr max foreach {name value} $state(meta) { $log insert end [format "%-*s %s \n" $max $name: $value] $log see end } $log insert end "\n" $log see end set ::http_stat $state(status) set ::http_type $state(type) set ::http_code [lindex [code $token] 1] } else { upvar #0 $token state $log insert end "\n" $log see end } } proc Progress { log args } { $log insert end "->" $log see end } } proc Check_File { file type stat code } { global http_stat http_type http_code set check_flag 0 if {[file exists $file]} { if {($http_type == $type) && ($http_stat == $stat) \ && ($http_code == $code)} { set check_flag 1 } } return $check_flag } proc Center_Window { e } { set mainx [winfo x .] set mainy [winfo y .] set mainw [winfo width .] set mainh [winfo height .] set diagw [winfo width $e] set diagh [winfo height $e] set diagx [expr {$mainx+($mainw-$diagw)/2}] set diagy [expr {$mainy+($mainh-$diagh)/2}] wm geometry $e +$diagx+$diagy } proc Xfer { } { global support_pth working_pth lambda http_xfer_url \ xfer_log vport_deg_xdel_old if {![winfo exists .dlg_xfer]} { set xfer_log [Text_Window .dlg_xfer Xfer] } $xfer_log insert end \ "*** Validating calibrator database ...\n" $xfer_log see end set tmp [file join $support_pth xplore_stamp.dat] if {[file exists $tmp]} { set fileid [open $tmp "r"] while {[gets $fileid data] >= 0} { set loc_version [lindex $data 0] } close $fileid } set url "$http_xfer_url/xplore_stamp.dat" set tmp [file join $working_pth xplore_stamp.dat] set command [list ::http::copy $url $tmp $xfer_log] if {[catch $command result] == 0} { if {[Check_File $tmp "text/plain" ok 200]} { set fileid [open $tmp "r"] while {[gets $fileid data] >= 0} { set rem_version [lindex $data 0] } close $fileid set xfer_flag 1 $xfer_log insert end "\n" $xfer_log insert end \ "*** The remote timestamp is $rem_version.\n" if {[info exists loc_version]} { $xfer_log insert end \ "*** The local timestamp is $loc_version.\n" if {$loc_version == $rem_version} { set xfer_flag 0 $xfer_log insert end \ "*** The database timestamp has not changed.\n" } else { $xfer_log insert end \ "*** The database timestamp has changed.\n" } } } else { set xfer_flag 0 $xfer_log insert end \ "*** WARNING: Unable to verify database timestamp; \ try again later.\n" } } else { set xfer_flag 0 $xfer_log insert end \ "*** WARNING: Download failed; try again later.\n" $xfer_log see end } $xfer_log insert end "\n" $xfer_log see end if {$xfer_flag} { set xfer_flag 0 $xfer_log insert end \ "*** Downloading flux history archive " set url "$http_xfer_url/flux_files.zip" set pth [file join [glob $support_pth] flux_files] set tmp [file join $pth flux_files.zip] file delete -force $pth file mkdir $pth ::http::copy $url $tmp $xfer_log if {[Check_File $tmp "application/zip" ok 200]} { set command "exec -keepnewline -- unzip -o $tmp -d $pth" if {[catch $command result] == 0} { set xfer_flag 1 $xfer_log insert end \ "*** SUCCESS: Download completed.\n" $xfer_log insert end "\n" $xfer_log insert end $result } else { $xfer_log insert end \ "*** SUCCESS: Download completed.\n" $xfer_log insert end \ "*** WARNING: Unable to extract compressed zip archive.\n" } } else { $xfer_log insert end \ "*** WARNING: Download failed; try again later.\n" } if {! $xfer_flag} { $xfer_log insert end \ "*** WARNING: Flux history feature will not be available.\n" } $xfer_log insert end "\n" set xfer_flag 0 $xfer_log insert end \ "*** Downloading primary calibrator archive (compressed version) " set url "$http_xfer_url/xplore_data.zip" set tmp [file join $working_pth xplore_data.zip] ::http::copy $url $tmp $xfer_log if {[Check_File $tmp "application/zip" ok 200]} { set command "exec -keepnewline -- unzip -o $tmp" if {[catch $command result] == 0} { set xfer_flag 1 $xfer_log insert end \ "*** SUCCESS: Download completed.\n" $xfer_log insert end "\n" $xfer_log insert end $result } else { $xfer_log insert end \ "*** SUCCESS: Download completed.\n" $xfer_log insert end \ "*** WARNING: Unable to extract compressed zip archive.\n" } } else { $xfer_log insert end \ "*** WARNING: Download failed; try again later.\n" } if {! $xfer_flag} { $xfer_log insert end \ "*** Downloading primary calibrator archive (uncompressed version).\n" set xfer_flag 1 foreach band {1cm 3mm 1mm} { set files [list cal_pos_$band cal_flx_$band \ cal_fov10deg_$band cal_fov20deg_$band \ cal_fov40deg_$band cal_fov60deg_$band \ cal_fov120deg_$band cal_fov180deg_$band] foreach name $files { $xfer_log insert end \ "*** Downloading $name " $xfer_log see end set url "$http_xfer_url/$name.dat" set tmp [file join $working_pth $name.dat] ::http::copy $url $tmp $xfer_log if {![Check_File $tmp "text/plain" ok 200]} { set xfer_flag 0 break } } } if {! $xfer_flag} { $xfer_log insert end \ "*** WARNING : Download failed; try again later.\n" } } $xfer_log see end if {$xfer_flag} { foreach name [glob cal*.dat] { file copy -force $name $support_pth } file copy -force \ [file join $working_pth xplore_stamp.dat] $support_pth file copy -force \ [file join $working_pth xplore_data.zip] $support_pth set vport_deg_xdel_old 0 Update normal } } $xfer_log insert end "\n" $xfer_log insert end "Done.\n" $xfer_log see end } proc Auto_Pilot { b c } { global tcl_platform animate2_handle animate3_handle \ ra_com_old dec_com_old src_com\ coords_rah_entr_widg coords_ram_entr_widg coords_ras_entr_widg \ coords_dcd_entr_widg coords_dcm_entr_widg coords_dcs_entr_widg \ comand_upd_butn_widg privilege_user if {[$b cget -relief] == "raised"} { if {$tcl_platform(platform) == "unix"} { if {([exec whoami]@[info hostname] == "$privilege_user")} { $comand_upd_butn_widg config -state disabled $coords_rah_entr_widg config -state disabled $coords_ram_entr_widg config -state disabled $coords_ras_entr_widg config -state disabled $coords_dcd_entr_widg config -state disabled $coords_dcm_entr_widg config -state disabled $coords_dcs_entr_widg config -state disabled $b config -relief sunken $b config -foreground red $foview_fram_widg.180deg config -state disabled set src_com "" set ra_com_old "99:99:99.999" set dec_com_old "99:99:99.999" Animate2 $c Animate3 $c } else { tk_dialog .dlg_warn3 "WARNING" \ "Must be user obs on hat" warning 0 OK } } } elseif {[$b cget -relief] == "sunken"} { $comand_upd_butn_widg config -state normal $coords_rah_entr_widg config -state normal $coords_ram_entr_widg config -state normal $coords_ras_entr_widg config -state normal $coords_dcd_entr_widg config -state normal $coords_dcm_entr_widg config -state normal $coords_dcs_entr_widg config -state normal $b config -relief raised $b config -foreground green $foview_fram_widg.180deg config -state normal if {[info exists animate2_handle]} { after cancel $animate2_handle unset animate2_handle } if {[info exists animate3_handle]} { after cancel $animate3_handle unset animate3_handle } $c itemconfigure reticle_perim -outline red $c coords cross_hline 0 0 0 0 $c coords cross_vline 0 0 0 0 $b config -text "PJTRAK" } } proc Update { flag } { global animate0_handle animate1_handle voice_synth_status \ voice_report_cycle boundary_deg_xmin boundary_deg_ymin \ boundary_deg_xmax boundary_deg_ymax canvas_deg_xmin \ canvas_deg_ymin canvas_pix_xdel canvas_pix_ydel \ canvas_pix_xmax canvas_pix_ymax date date_old \ dec_deg dec_min dec_sec dec_deg_lolimt dec_deg_hilimt \ elm_deg elm_sin lat_deg lat_sin lat_cos rad_per_deg \ ra_hrs ra_min ra_sec resolution reticle_deg_xcen \ reticle_deg_ycen vport_deg_xdel vport_deg_ydel \ vport_deg_xdel_old vport_pix_xcen vport_pix_ycen \ vport_pix_xdel xpix_per_deg ypix_per_deg \ lambda lambda_old cal_pos cal_col support_pth \ cal_pos_list cal_flx_list cal_id_list include_solsys \ comand_upd_butn_widg coords_string coords_string_old $comand_upd_butn_widg configure -foreground red if {[info exists animate0_handle]} { after cancel $animate0_handle unset animate0_handle } if {[info exists animate1_handle]} { after cancel $animate1_handle unset animate1_handle } set result 1 set pat \ {(0|9)[0-9](jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[0-3][0-9]} if {$include_solsys == "y"} { if {![regexp $pat $date]} { set result [tk_dialog .dlg_warn4 "WARNING" \ "Date syntax must be YYmmmdd" warning 0 OK] } } if {$result} { if {($vport_deg_xdel != $vport_deg_xdel_old) || \ ($lambda != $lambda_old) || \ (![winfo exists .f.fb])} { set a \ [format %1.2f \ [expr {60*double($vport_deg_xdel)/($vport_pix_xdel-1)}]] set resolution "MAP RESOLUTION $a ARCMIN/PIXEL" set cal_pos_list \ [Load_Data [file join $support_pth cal_pos_$lambda.dat] list] set cal_flx_list \ [Load_Data [file join $support_pth cal_flx_$lambda.dat] list] Build_Map Erase pack .f.fa .f.fb \ -side left \ -fill both \ -expand true pack .menubar .f \ -side top \ -fill both \ -expand true } if {[info exists cal_id_list]} { External_Objects } set vport_deg_xdel_old $vport_deg_xdel set lambda_old $lambda set date_old $date } if {$flag != "catlog"} { foreach i {ra_hrs ra_min ra_sec dec_deg dec_min dec_sec} { if {[set [set i]] == ""} { set [set i] 0 } } Convert to_deg } set result 0 if {$reticle_deg_xcen > $boundary_deg_xmax} { set reticle_deg_xcen $boundary_deg_xmax set result 1 } if {$reticle_deg_xcen < $boundary_deg_xmin} { set reticle_deg_xcen $boundary_deg_xmin set result 1 } if {$reticle_deg_ycen > $boundary_deg_ymax} { set reticle_deg_ycen $boundary_deg_ymax set result 1 } if {$reticle_deg_ycen < $boundary_deg_ymin} { set reticle_deg_ycen $boundary_deg_ymin set result 1 } set reticle_pix_xcen \ [expr {$canvas_pix_xmax-$xpix_per_deg*($reticle_deg_xcen \ -$canvas_deg_xmin)}] set reticle_pix_ycen \ [expr {$canvas_pix_ymax-$ypix_per_deg*($reticle_deg_ycen \ -$canvas_deg_ymin)}] set a [expr {($reticle_pix_xcen-$vport_pix_xcen)/$canvas_pix_xdel}] set b [expr {($reticle_pix_ycen-$vport_pix_ycen)/$canvas_pix_ydel}] .f.fb.canvas3 xview moveto $a .f.fb.canvas4 xview moveto $a .f.fb.canvas3 yview moveto $b .f.fb.canvas5 yview moveto $b set lat_sin [expr {sin($rad_per_deg*$lat_deg)}] set lat_cos [expr {cos($rad_per_deg*$lat_deg)}] set elm_sin [expr {sin($rad_per_deg*$elm_deg)}] if {$lat_sin > 0} { set dec_deg_lolimt [expr {$elm_deg+$lat_deg-90}] set dec_deg_hilimt [expr {$elm_deg-$lat_deg+90}] } else { set dec_deg_lolimt [expr {-$elm_deg+$lat_deg+90}] set dec_deg_hilimt [expr {-$elm_deg-$lat_deg-90}] } if {[.f.fb.canvas2 find withtag cal_har] != {}} { HA_Range \ [lindex $cal_pos 0] [lindex $cal_pos 1] 15 $cal_col cal_har } Convert from_deg set coords_string "$dec_deg $dec_min $dec_sec $ra_hrs $ra_min $ra_sec" Reticle_Track .f.fb.canvas3 $flag set coords_string_old $coords_string Animate1 .f.fb.canvas2 if {$voice_synth_status == "normal"} { Animate0 $voice_report_cycle } if {$result == 1} { tk_dialog .dlg_warn5 "WARNING" \ "Unable to center at requested coords; try reducing FOV" warning 0 OK } $comand_upd_butn_widg configure -foreground green } proc Build_Map { } { global boundary_deg_xmin boundary_deg_ymin boundary_deg_xmax \ boundary_deg_ymax cal_id_list cal_vis_list canvas_deg_xmin \ canvas_deg_ymin canvas_pix_xmin canvas_pix_ymin canvas_pix_xmax \ canvas_pix_ymax canvas_pix_xdel canvas_pix_ydel support_pth \ vport_deg_xdel vport_deg_ydel vport_pix_xdel vport_pix_ydel \ vport_pix_xcen vport_pix_ycen xpix_per_hr xpix_per_deg \ ypix_per_deg loc_indx_old lambda set loc_indx_old -1 set vport_deg_ydel $vport_deg_xdel set vport_pix_xdel 701 set vport_pix_ydel 701 set vport_pix_xcen [expr {($vport_pix_xdel-1)/2.}] set vport_pix_ycen [expr {($vport_pix_ydel-1)/2.}] set canvas_deg_xdel 480 set canvas_deg_ydel 240 set canvas_deg_xmin -60 set canvas_deg_ymin -90 set xpix_per_deg [expr {($vport_pix_xdel-1)/double($vport_deg_xdel)}] set ypix_per_deg [expr {($vport_pix_ydel-1)/double($vport_deg_ydel)}] set canvas_pix_xdel [expr {$xpix_per_deg*$canvas_deg_xdel+1}] set canvas_pix_ydel [expr {$ypix_per_deg*$canvas_deg_ydel+1}] set canvas_pix_xmin 0 set canvas_pix_ymin 0 set canvas_pix_xmax [expr {$canvas_pix_xdel-1}] set canvas_pix_ymax [expr {$canvas_pix_ydel-1}] set boundary_deg_xmin [expr {$canvas_deg_xmin+$vport_deg_xdel/2.}] set boundary_deg_ymin [expr {$canvas_deg_ymin+$vport_deg_ydel/2.}] set boundary_deg_xmax \ [expr {$canvas_deg_xmin+$canvas_deg_xdel-$vport_deg_xdel/2.}] set boundary_deg_ymax \ [expr {$canvas_deg_ymin+$canvas_deg_ydel-$vport_deg_ydel/2.}] if {[winfo exists .f.fb.xscroll]} { destroy .f.fb.xscroll } if {[winfo exists .f.fb.yscroll]} { destroy .f.fb.yscroll } if {[winfo exists .f.fb.canvas0]} { destroy .f.fb.canvas0 } if {[winfo exists .f.fb.canvas1]} { destroy .f.fb.canvas1 } if {[winfo exists .f.fb.canvas2]} { destroy .f.fb.canvas2 } if {[winfo exists .f.fb.canvas3]} { destroy .f.fb.canvas3 } if {[winfo exists .f.fb.canvas4]} { destroy .f.fb.canvas4 } if {[winfo exists .f.fb.canvas5]} { destroy .f.fb.canvas5 } if {![winfo exists .f.fb]} { frame .f.fb \ -borderwidth 3 \ -relief ridge } canvas .f.fb.canvas0 \ -width 21 \ -height 55 \ -highlightthickness 0 \ -borderwidth 0 canvas .f.fb.canvas1 \ -width 21 \ -height 55 \ -highlightthickness 0 \ -borderwidth 0 canvas .f.fb.canvas2 \ -width $vport_pix_xdel \ -height 55 \ -highlightthickness 0 \ -borderwidth 0 set xpix_per_hr [expr {($vport_pix_xdel-1)/24.}] for {set i 0} {$i <= 24} {incr i 1} { set canvas_pix_x [expr {$xpix_per_hr*$i}] .f.fb.canvas2 create line \ $canvas_pix_x 0 $canvas_pix_x 50 \ -tags {lst_grid} .f.fb.canvas2 create text \ $canvas_pix_x 25 \ -tags {lst_valu} \ -text "${i}h" \ -anchor w \ -justify center } .f.fb.canvas2 create rect \ 0 50 [expr {$vport_pix_xdel-1}] 54 \ -fill black \ -stipple gray50 canvas .f.fb.canvas3 \ -width $vport_pix_xdel \ -height $vport_pix_ydel \ -scrollregion \ [list $canvas_pix_xmin $canvas_pix_ymin \ $canvas_pix_xdel $canvas_pix_ydel] \ -xscrollcommand [list .f.fb.xscroll set] \ -xscrollincrement 1 \ -yscrollcommand [list .f.fb.yscroll set] \ -yscrollincrement 1 \ -highlightthickness 0 \ -borderwidth 0 canvas .f.fb.canvas4 \ -width $vport_pix_xdel \ -height 21 \ -scrollregion \ [list $canvas_pix_xmin $canvas_pix_ymin $canvas_pix_xdel 20] \ -xscrollcommand [list .f.fb.xscroll set] \ -xscrollincrement 1 \ -highlightthickness 0 \ -borderwidth 0 canvas .f.fb.canvas5 \ -width 21 \ -height $vport_pix_ydel \ -scrollregion \ [list $canvas_pix_xmin $canvas_pix_ymin 20 $canvas_pix_ydel] \ -yscrollcommand [list .f.fb.yscroll set] \ -yscrollincrement 1 \ -highlightthickness 0 \ -borderwidth 0 scrollbar .f.fb.xscroll -orient horizontal \ -command [list BindXview [list .f.fb.canvas3 .f.fb.canvas4]] scrollbar .f.fb.yscroll -orient vertical \ -command [list BindYview [list .f.fb.canvas3 .f.fb.canvas5]] grid .f.fb.canvas2 .f.fb.canvas0 .f.fb.canvas1 -sticky news grid .f.fb.canvas3 .f.fb.canvas5 .f.fb.yscroll -sticky news grid .f.fb.canvas4 -sticky news grid .f.fb.xscroll -sticky news for {set i -4} {$i <= 28} {incr i 1} { set canvas_pix_x \ [expr {$canvas_pix_xmax-$xpix_per_deg*(15*$i-$canvas_deg_xmin)}] .f.fb.canvas3 create line \ $canvas_pix_x $canvas_pix_ymin $canvas_pix_x $canvas_pix_ymax \ -tags {equat_grid longitude_line} .f.fb.canvas4 create text \ $canvas_pix_x 10 \ -tags {equat_grid longitude_valu} \ -text "${i}h" \ -anchor c \ -justify center } for {set j -90} {$j <= 90} {incr j 15} { set canvas_pix_y \ [expr {$canvas_pix_ymax-$ypix_per_deg*($j-$canvas_deg_ymin)}] .f.fb.canvas3 create line \ $canvas_pix_xmin $canvas_pix_y $canvas_pix_xmax $canvas_pix_y \ -tags {equat_grid latitude_line} .f.fb.canvas5 create text \ 10 $canvas_pix_y \ -tags {equat_grid latitude_valu} \ -text "$j" \ -anchor c \ -justify center } .f.fb.canvas3 create line 0 0 0 0 \ -fill red \ -tags cross_hline .f.fb.canvas3 create line 0 0 0 0 \ -fill red \ -tags cross_vline set filename cal_fov append filename $vport_deg_xdel deg _ $lambda .dat set filename [file join $support_pth $filename] if {[file exists $filename]} { set cal_vis_list [Load_Data $filename list] foreach i $cal_vis_list { eval {.f.fb.canvas3 create rect} $i -tags calib } set cal_id_list [.f.fb.canvas3 find withtag calib] } .f.fb.canvas2 bind src_har { AltAzm %x $reticle_deg_xcen $reticle_deg_ycen src_har } .f.fb.canvas2 bind cal_har { AltAzm %x [lindex $cal_pos 0] [lindex $cal_pos 1] cal_har } .f.fb.canvas2 bind src_har { .f.fb.canvas2 delete altazm_info destroy .f.fb.canvas2.wf } .f.fb.canvas2 bind cal_har { .f.fb.canvas2 delete altazm_info destroy .f.fb.canvas2.wf } .f.fb.canvas3 bind calib { Erase Locate %x %y if {$loc_indx != $loc_indx_old} { Animate4 .f.fb.canvas3 Show_Current %x %y if {$blt_avail} {Show_History %x %y} set loc_indx_old $loc_indx } else { set loc_indx_old -1 } } foreach i {.f.fb.xscroll .f.fb.yscroll} { $i configure -takefocus 0 } } proc Legend { c } { global lambda \ lst_fram_widg lst_labl_widg \ catlog_fram_widg \ catlog_nam_fram_widg catlog_nam_list_widg \ catlog_ctrl_fram_widg catlog_add_ctrl_widg catlog_del_ctrl_widg \ catlog_labl_fram_widg catlog_labl_widg \ catlog_nam_list $c delete all if {[info exists lst_fram_widg]} { if {[winfo exists $lst_fram_widg]} { destroy $lst_fram_widg } } set lst_fram_widg \ [frame $c.f1 -borderwidth 0 -relief flat -takefocus 0] $c create window 0 5 \ -anchor nw \ -window $lst_fram_widg set lst_labl_widg [label $lst_fram_widg.l \ -width 16 \ -height 2 \ -background black \ -foreground white \ -takefocus 0] pack $lst_labl_widg if {[info exists catlog_fram_widg]} { if {[winfo exists $catlog_fram_widg]} { destroy $catlog_fram_widg } } set catlog_fram_widg \ [frame $c.f2 -borderwidth 0 -relief flat -takefocus 0] $c create window 0 40 \ -anchor nw \ -window $catlog_fram_widg if {[info exists catlog_labl_fram_widg]} { if {[winfo exists $catlog_labl_fram_widg]} { destroy $catlog_labl_fram_widg } } set catlog_labl_fram_widg \ [frame $catlog_fram_widg.f1 -borderwidth 0 -relief flat -takefocus 0] set catlog_labl_widg [label $catlog_labl_fram_widg.l \ -justify center \ -foreground white \ -background black \ -text "GOTO CATALOG"] pack $catlog_labl_widg \ -side left \ -fill both \ -expand yes if {[info exists catlog_ctrl_fram_widg]} { if {[winfo exists $catlog_ctrl_fram_widg]} { destroy $catlog_ctrl_fram_widg } } set catlog_ctrl_fram_widg \ [frame $catlog_fram_widg.f2 -borderwidth 0 -relief flat -takefocus 0] set catlog_add_ctrl_widg [button $catlog_ctrl_fram_widg.b1 \ -relief raised \ -background black \ -foreground green \ -text "+" \ -command {Catalog add custom}] set catlog_del_ctrl_widg [button $catlog_ctrl_fram_widg.b2 \ -relief raised \ -background black \ -foreground green \ -text "-" \ -command {Catalog del custom}] pack $catlog_add_ctrl_widg $catlog_del_ctrl_widg \ -side left \ -fill both \ -expand yes if {[info exists catlog_nam_fram_widg]} { if {[winfo exists $catlog_nam_fram_widg]} { destroy $catlog_nam_fram_widg } } set catlog_nam_fram_widg \ [frame $catlog_fram_widg.f3 -borderwidth 0 -relief flat -takefocus 0] set catlog_nam_list_widg [listbox $catlog_nam_fram_widg.l \ -height 16 \ -width 12 \ -yscrollcommand "$catlog_nam_fram_widg.s set" \ -selectbackground yellow1 \ -selectmode single] scrollbar $catlog_nam_fram_widg.s \ -command "$catlog_nam_list_widg yview" pack $catlog_nam_fram_widg.s \ -side right \ -fill y pack $catlog_nam_list_widg \ -side left \ -fill both \ -expand yes pack $catlog_labl_fram_widg $catlog_ctrl_fram_widg $catlog_nam_fram_widg \ -side top \ -fill both \ -expand yes if {[info exists catlog_nam_list]} {unset catlog_nam_list} Catalog load custom Catalog load solsys Catalog load carcat bind $catlog_nam_list_widg { if {[info exists catlog_nam_list]} { if {$catlog_nam_list != {}} { Extract $catlog_nam_list_widg Update catlog if {$catlog_nam_indx <= $custom_max_indx} { $catlog_del_ctrl_widg config -state normal } else { $catlog_del_ctrl_widg config -state disabled } $catlog_add_ctrl_widg config -state disabled } } } bind $catlog_nam_list_widg { if {[info exists catlog_nam_indx]} { Refresh_List $catlog_nam_list_widg } } switch -exact -- $lambda \ 1cm { $c create rect 122 248 138 264 \ -fill ivory1 \ -stipple gray75 $c create oval 122 282 138 298 \ -fill ivory1 $c create oval 126 312 134 330 \ -fill yellow1 $c create text 190 256 \ -anchor c \ -text "Calib Flux ?" $c create text 190 290 \ -anchor c \ -text "Solar System" $c create text 190 324 \ -anchor c \ -text "Carma Catlog" } \ 3mm { $c create rect 112 0 148 36 \ -fill yellow1 $c create rect 114 42 146 74 \ -fill DeepPink3 $c create rect 116 80 144 108 \ -fill DarkOrange3 $c create rect 118 114 142 138 \ -fill green4 $c create rect 120 148 140 168 \ -fill purple1 $c create rect 122 182 138 198 \ -fill blue1 $c create rect 122 214 138 230 \ -fill ivory1 \ -stipple gray75 $c create rect 122 248 138 264 \ -fill black $c create oval 122 282 138 298 \ -fill ivory1 $c create oval 126 312 134 330 \ -fill yellow1 $c create text 190 18 \ -anchor c \ -text "Flux >=15 Jy" $c create text 190 58 \ -anchor c \ -text "\[10.0,15.0) Jy" $c create text 190 94 \ -anchor c \ -text "\[ 5.0,10.0) Jy" $c create text 190 126 \ -anchor c \ -text "\[ 3.0, 5.0) Jy" $c create text 190 158 \ -anchor c \ -text "\[ 1.5, 3.0) Jy" $c create text 190 190 \ -anchor c \ -text "\[ 0.0, 1.5) Jy" $c create text 190 222 \ -anchor c \ -text "Calib Flux ?" $c create text 190 256 \ -anchor c \ -text "Extended Obj" $c create text 190 290 \ -anchor c \ -text "Solar System" $c create text 190 324 \ -anchor c \ -text "Carma Catlog" } \ 1mm { $c create rect 122 248 138 264 \ -fill ivory1 \ -stipple gray75 $c create oval 122 282 138 298 \ -fill ivory1 $c create oval 126 312 134 330 \ -fill yellow1 $c create text 190 256 \ -anchor c \ -text "Calib Flux ?" $c create text 190 290 \ -anchor c \ -text "Solar System" $c create text 190 324 \ -anchor c \ -text "Carma Catlog" } } proc Extract { widgetname } { global elm_deg lat_deg lng_deg reticle_deg_xcen reticle_deg_ycen \ telpar_nam_indx telpar_elm_indx catlog_nam_indx \ telpar_nam_list_widg telpar_elm_list_widg catlog_nam_list_widg \ telpar_lat_list telpar_lng_list catlog_ras_list catlog_dec_list set i [$widgetname curselection] switch -exact -- $widgetname \ $telpar_nam_list_widg { set lat_deg [lindex $telpar_lat_list $i] set lng_deg [lindex $telpar_lng_list $i] set telpar_nam_indx $i } \ $telpar_elm_list_widg { set elm_deg [$widgetname get $i] set telpar_elm_indx $i } \ $catlog_nam_list_widg { set reticle_deg_xcen [lindex $catlog_ras_list $i] set reticle_deg_ycen [lindex $catlog_dec_list $i] set catlog_nam_indx $i } } proc Refresh_List { widgetname } { global telpar_nam_indx telpar_elm_indx catlog_nam_indx \ telpar_nam_list_widg telpar_elm_list_widg catlog_nam_list_widg set flag 0 if {$widgetname == "$telpar_nam_list_widg"} { set i $telpar_nam_indx } if {$widgetname == "$telpar_elm_list_widg"} { set i $telpar_elm_indx } if {$widgetname == "$catlog_nam_list_widg"} { set i $catlog_nam_indx } $widgetname selection set $i } proc Catalog { action what } { global support_pth working_pth \ catlog_nam_list catlog_ras_list catlog_dec_list catlog_nam_indx \ catlog_nam_list_widg catlog_del_ctrl_widg catlog_add_ctrl_widg \ catlog_nam_msg catlog_nam_tag \ ra_hrs ra_min ra_sec dec_deg dec_min dec_sec\ reticle_deg_xcen reticle_deg_ycen \ solsys_nam_list carcat_nam_list \ custom_max_indx switch -exact -- $action \ load { if {![info exists catlog_nam_list]} { set catlog_nam_list {} set catlog_ras_list {} set catlog_dec_list {} $catlog_del_ctrl_widg config -state disabled } if {$what == "custom"} { set custom_max_indx -1 set filename [file join $support_pth custom_goto_catlog.txt] } if {$what == "solsys"} { set filename [file join $working_pth solsys_goto_catlog.txt] } if {$what == "carcat"} { set filename [file join $working_pth carcat_goto_catlog.txt] } if {[file exists $filename]} { set newadd_nam_list {} set cat_par_list [Load_Data $filename list] foreach i $cat_par_list { lappend newadd_nam_list [lindex $i 0] lappend catlog_nam_list [lindex $i 0] lappend catlog_ras_list [lindex $i 1] lappend catlog_dec_list [lindex $i 2] } eval {$catlog_nam_list_widg insert end} $newadd_nam_list if {$what == "custom"} { set custom_max_indx [expr {[llength $newadd_nam_list]-1}] } if {$what == "solsys"} { set solsys_nam_list $newadd_nam_list } if {$what == "carcat"} { set carcat_nam_list $newadd_nam_list } } } \ unload { if {$what == "solsys"} { set nam_list $solsys_nam_list } if {$what == "carcat"} { set nam_list $carcat_nam_list } foreach i $nam_list { set indx [lsearch $catlog_nam_list $i] if {$indx != -1} { if {[info exists catlog_nam_indx]} { if {$catlog_nam_indx == $indx} { unset catlog_nam_indx } } $catlog_nam_list_widg delete $indx set catlog_nam_list \ [lreplace $catlog_nam_list $indx $indx] set catlog_ras_list \ [lreplace $catlog_ras_list $indx $indx] set catlog_dec_list \ [lreplace $catlog_dec_list $indx $indx] } } } \ add { if {![winfo exists .dlg_catalog]} { toplevel .dlg_catalog -class Dialog wm title .dlg_catalog "Catalog" wm transient .dlg_catalog . set coords "$ra_hrs h $ra_min m $ra_sec s ," append coords " $dec_deg d $dec_min m $dec_sec s" set catlog_nam_msg "Specify Name Tag:" frame .dlg_catalog.part1 \ -borderwidth 3 label .dlg_catalog.part1.labl1 \ -justify center \ -text "Add Coordinates to GOTO Catalog:" label .dlg_catalog.part1.labl2 \ -justify center \ -text $coords pack .dlg_catalog.part1.labl1 .dlg_catalog.part1.labl2 \ -side top -fill both -expand yes frame .dlg_catalog.part2 \ -borderwidth 3 entry .dlg_catalog.part2.entr1 \ -width 17 \ -textvariable catlog_nam_msg entry .dlg_catalog.part2.entr2 \ -width 12 \ -textvariable catlog_nam_tag pack .dlg_catalog.part2.entr1 .dlg_catalog.part2.entr2 \ -side left -fill both -expand yes frame .dlg_catalog.part3 \ -borderwidth 3 button .dlg_catalog.part3.butt1 \ -text "OK" \ -command { if {$catlog_nam_tag == ""} { set catlog_nam_msg "Blank! Try Again:" } else { set indx \ [lsearch $catlog_nam_list $catlog_nam_tag] if {$indx == -1} { set filename \ [file join $support_pth custom_goto_catlog.txt] set catlog_nam_list \ [linsert $catlog_nam_list 0 $catlog_nam_tag] set catlog_ras_list \ [linsert $catlog_ras_list 0 $reticle_deg_xcen] set catlog_dec_list \ [linsert $catlog_dec_list 0 $reticle_deg_ycen] set fileid [open $filename "w"] set i 0 set imax [expr {[llength $catlog_nam_list]-1}] while {$i <= $imax} { set x [lindex $catlog_nam_list $i] set indx [lsearch [concat \ $solsys_nam_list $carcat_nam_list] $x] if {$indx == -1} { append x " [lindex $catlog_ras_list $i]" append x " [lindex $catlog_dec_list $i]" puts $fileid $x } incr i 1 } close $fileid file attributes $filename -permissions 0755 incr custom_max_indx 1 $catlog_nam_list_widg insert 0 $catlog_nam_tag $catlog_nam_list_widg yview 0 $catlog_nam_list_widg selection set 0 $catlog_del_ctrl_widg config -state normal $catlog_add_ctrl_widg config -state disabled Extract $catlog_nam_list_widg destroy .dlg_catalog } else { set catlog_nam_msg "Exists! Try Again:" } } } button .dlg_catalog.part3.butt2 \ -text "CANCEL" \ -command { destroy .dlg_catalog } pack .dlg_catalog.part3.butt1 .dlg_catalog.part3.butt2 \ -side left -fill both -expand yes pack .dlg_catalog.part1 .dlg_catalog.part2 \ .dlg_catalog.part3 \ -side top -fill both tkwait visibility .dlg_catalog Center_Window .dlg_catalog } } \ del { $catlog_nam_list_widg delete $catlog_nam_indx set catlog_nam_list \ [lreplace $catlog_nam_list $catlog_nam_indx $catlog_nam_indx] set catlog_ras_list \ [lreplace $catlog_ras_list $catlog_nam_indx $catlog_nam_indx] set catlog_dec_list \ [lreplace $catlog_dec_list $catlog_nam_indx $catlog_nam_indx] set filename [file join $support_pth custom_goto_catlog.txt] if {$catlog_nam_list != {}} { set fileid [open $filename "w"] set i 0 set imax [expr {[llength $catlog_nam_list]-1}] while {$i <= $imax} { set x [lindex $catlog_nam_list $i] set indx [lsearch [concat \ $solsys_nam_list $carcat_nam_list] $x] if {$indx == -1} { append x " [lindex $catlog_ras_list $i]" append x " [lindex $catlog_dec_list $i]" puts $fileid $x } incr i 1 } close $fileid incr custom_max_indx -1 } else { file delete -force $filename } $catlog_nam_list_widg selection clear 0 end $catlog_del_ctrl_widg config -state disabled $catlog_add_ctrl_widg config -state normal unset catlog_nam_indx } } frame .menubar \ -relief raised \ -borderwidth 2 menubutton .menubar.file \ -text "File" \ -underline 0 \ -menu .menubar.file.menu menu .menubar.file.menu .menubar.file.menu add command \ -label "Xfer" \ -underline 0 \ -command { Xfer } #=> Begin experimental voice interface===================================== menubutton .menubar.hear \ -text "Hear" \ -underline 0 \ -menu .menubar.hear.menu menu .menubar.hear.menu .menubar.hear.menu add radio \ -label "Mute" \ -variable voice_synth_status \ -value disabled \ -command { if {[info exists animate0_handle]} { after cancel $animate0_handle unset animate0_handle } } .menubar.hear.menu add radio \ -label "Loud" \ -variable voice_synth_status \ -value normal \ -command { if {![info exists animate0_handle]} { Animate0 $voice_report_cycle } } #=> End experimental voice interface======================================= .menubar.file.menu add command \ -label "Exit" \ -underline 0 \ -command { Handle_Close . } pack .menubar.file .menubar.hear \ -side left menubutton .menubar.help \ -text "Help" \ -underline 0 \ -menu .menubar.help.menu menu .menubar.help.menu .menubar.help.menu add command \ -label "Tutor" \ -underline 0 \ -command { Tutor } .menubar.help.menu add command \ -label "About" \ -underline 0 \ -command { About } pack .menubar.help \ -side right frame .f frame .f.fa \ -relief ridge \ -borderwidth 3 set mapleg_fram_widg [frame .f.fa.mapleg \ -relief ridge \ -borderwidth 3] canvas $mapleg_fram_widg.can \ -width 200 \ -height 344 \ -highlightthickness 0 \ -borderwidth 0 pack $mapleg_fram_widg.can \ -side top \ -fill both \ -expand true set coords_fram_widg [frame .f.fa.coords \ -relief ridge \ -borderwidth 3] label $coords_fram_widg.lab \ -justify center \ -foreground white \ -background black \ -text "CENTER COORDINATES" pack $coords_fram_widg.lab \ -side top \ -fill both \ -expand true frame $coords_fram_widg.ra \ -relief flat \ -borderwidth 3 label $coords_fram_widg.ra.lab \ -justify center \ -text "RA J2000" set coords_rah_entr_widg [entry $coords_fram_widg.ra.hrs \ -width 3 \ -textvariable ra_hrs] label $coords_fram_widg.ra.txt1 \ -justify center \ -text "HRS" set coords_ram_entr_widg [entry $coords_fram_widg.ra.min \ -width 2 \ -textvariable ra_min] label $coords_fram_widg.ra.txt2 \ -justify center \ -text "MIN" set coords_ras_entr_widg [entry $coords_fram_widg.ra.sec \ -width 2 \ -textvariable ra_sec] label $coords_fram_widg.ra.txt3 \ -justify right \ -text "SEC" pack $coords_fram_widg.ra.lab $coords_rah_entr_widg \ $coords_fram_widg.ra.txt1 $coords_ram_entr_widg \ $coords_fram_widg.ra.txt2 $coords_ras_entr_widg \ $coords_fram_widg.ra.txt3 \ -padx 2 \ -side left frame $coords_fram_widg.dec \ -relief flat \ -borderwidth 3 label $coords_fram_widg.dec.lab \ -justify center \ -text "DEC J2000" set coords_dcd_entr_widg [entry $coords_fram_widg.dec.deg \ -width 3 \ -textvariable dec_deg] label $coords_fram_widg.dec.txt1 \ -justify center \ -text "DEG" set coords_dcm_entr_widg [entry $coords_fram_widg.dec.min \ -width 2 \ -textvariable dec_min] label $coords_fram_widg.dec.txt2 \ -justify center \ -text "MIN" set coords_dcs_entr_widg [entry $coords_fram_widg.dec.sec \ -width 2 \ -textvariable dec_sec] label $coords_fram_widg.dec.txt3 \ -justify center \ -text "SEC" pack $coords_fram_widg.dec.lab $coords_dcd_entr_widg \ $coords_fram_widg.dec.txt1 $coords_dcm_entr_widg \ $coords_fram_widg.dec.txt2 $coords_dcs_entr_widg \ $coords_fram_widg.dec.txt3 \ -padx 2 \ -side left pack $coords_fram_widg.lab $coords_fram_widg.ra $coords_fram_widg.dec \ -side top set telpar_fram_widg [frame .f.fa.telpar \ -relief ridge \ -borderwidth 3] label $telpar_fram_widg.l \ -justify center \ -foreground white \ -background black \ -text "TELESCOPE LOCATION & ELVLIM (DEG)" pack $telpar_fram_widg.l \ -side top \ -fill both \ -expand true set telpar_nam_fram_widg [frame $telpar_fram_widg.f1 \ -relief ridge \ -borderwidth 0] set telpar_nam_list_widg [listbox $telpar_nam_fram_widg.l \ -height 3 \ -yscrollcommand "$telpar_nam_fram_widg.s set" \ -selectbackground yellow1 \ -selectmode single] scrollbar $telpar_nam_fram_widg.s \ -command "$telpar_nam_list_widg yview" pack $telpar_nam_fram_widg.s \ -side right \ -fill y pack $telpar_nam_list_widg \ -side left \ -fill both \ -expand true set telpar_elm_fram_widg [frame $telpar_fram_widg.f2 \ -relief ridge \ -borderwidth 0] set telpar_elm_list_widg [listbox $telpar_elm_fram_widg.l \ -height 3 \ -width 3 \ -yscrollcommand "$telpar_elm_fram_widg.s set" \ -selectbackground yellow1 \ -selectmode single] scrollbar $telpar_elm_fram_widg.s \ -command "$telpar_elm_list_widg yview" eval {$telpar_elm_list_widg insert end} $telpar_elm_list pack $telpar_elm_fram_widg.s \ -side right \ -fill y pack $telpar_elm_list_widg \ -side left \ -fill both \ -expand true pack $telpar_nam_fram_widg $telpar_elm_fram_widg \ -side left \ -fill both \ -expand true set lambda_fram_widg [frame .f.fa.lambda \ -relief ridge \ -borderwidth 3] label $lambda_fram_widg.l \ -justify center \ -foreground white \ -background black \ -text "CALIBRATOR WAVELENGTH BAND" pack $lambda_fram_widg.l \ -side top \ -fill both \ -expand true foreach x {1cm 3mm 1mm} { radiobutton $lambda_fram_widg.$x \ -text "$x" \ -width 2 \ -variable lambda \ -value $x \ -command { Legend $mapleg_fram_widg.can Update normal } } pack $lambda_fram_widg.1cm .f.fa.lambda.3mm \ $lambda_fram_widg.1mm \ -side left \ -fill both \ -expand true set foview_fram_widg [frame .f.fa.foview \ -relief ridge \ -borderwidth 3] label $foview_fram_widg.l1 \ -justify center \ -foreground white \ -background black \ -text "FIELD OF VIEW (DEG)" label $foview_fram_widg.l2 \ -justify center \ -width 31 \ -textvariable resolution pack $foview_fram_widg.l1 $foview_fram_widg.l2 \ -side top \ -fill both \ -expand true foreach x {10 20 40 60 120 180} { set y $foview_fram_widg radiobutton [append y . $x deg] \ -text "$x" \ -width 2 \ -variable vport_deg_xdel \ -value $x \ -command { Update normal } } pack $foview_fram_widg.10deg $foview_fram_widg.20deg \ $foview_fram_widg.40deg $foview_fram_widg.60deg \ $foview_fram_widg.120deg $foview_fram_widg.180deg \ -side left \ -fill both \ -expand true set solsys_fram_widg [frame .f.fa.solsys \ -relief ridge \ -borderwidth 3] label $solsys_fram_widg.l \ -justify center \ -foreground white \ -background black \ -text "SOLAR SYSTEM OBJECTS" pack $solsys_fram_widg.l \ -side top \ -fill both \ -expand true set solsys_yes_butn_widg [radiobutton $solsys_fram_widg.y \ -text "Y" \ -width 1 \ -variable include_solsys \ -value y \ -command { $solsys_dat_entr_widg \ config -state normal Update normal }] set solsys_non_butn_widg [radiobutton $solsys_fram_widg.n \ -text "N" \ -width 1 \ -variable include_solsys \ -value n \ -command { $solsys_dat_entr_widg \ config -state disabled Update normal }] set solsys_dat_fram_widg [frame $solsys_fram_widg.f \ -relief ridge \ -borderwidth 3] label $solsys_dat_fram_widg.l \ -justify center \ -text "EPOCH" set solsys_dat_entr_widg [entry $solsys_dat_fram_widg.e \ -width 7 \ -textvariable date] pack $solsys_dat_fram_widg.l \ -side left pack $solsys_dat_entr_widg \ -side right pack $solsys_yes_butn_widg $solsys_non_butn_widg $solsys_dat_fram_widg \ -side left \ -fill both \ -expand true set carcat_fram_widg [frame .f.fa.carcat \ -relief ridge \ -borderwidth 3] label $carcat_fram_widg.lab \ -justify center \ -foreground white \ -background black \ -text "CARMA CATALOG OBJECTS" pack $carcat_fram_widg.lab \ -side top \ -fill both \ -expand true radiobutton $carcat_fram_widg.yes \ -text "Y" \ -width 1 \ -variable include_carcat \ -value y \ -command { if {[.f.fb.canvas3 find withtag carcat] == {}} { Open $support_pth } } radiobutton $carcat_fram_widg.no \ -text "N" \ -width 1 \ -variable include_carcat \ -value n \ -command { Update normal } pack $carcat_fram_widg.yes $carcat_fram_widg.no \ -side left \ -fill both \ -expand true set command_fram_widg [frame .f.fa.command \ -relief ridge \ -borderwidth 3] frame $command_fram_widg.top set comand_upd_butn_widg [button $command_fram_widg.top.update \ -relief raised \ -text "SUBMIT" \ -background black \ -foreground green \ -command { Update normal }] set comand_pjt_butn_widg [button $command_fram_widg.top.pjtrak \ -relief raised \ -text "PJTRAK" \ -background black \ -foreground green \ -width 10 \ -padx 0 \ -command { Auto_Pilot \ $command_fram_widg.top.pjtrak \ .f.fb.canvas3 }] pack $comand_upd_butn_widg $comand_pjt_butn_widg \ -side left \ -fill both \ -expand true set comand_dis_butn_widg [button $command_fram_widg.dismiss \ -relief raised \ -text "DISMISS" \ -background black \ -foreground green \ -command {Handle_Close .}] pack $command_fram_widg.top $comand_dis_butn_widg \ -side top \ -fill both \ -expand true pack $mapleg_fram_widg $coords_fram_widg $telpar_fram_widg \ $lambda_fram_widg $foview_fram_widg $solsys_fram_widg \ $carcat_fram_widg $command_fram_widg \ -side top \ -fill both \ -expand true bind $solsys_dat_entr_widg {Update normal} bind $coords_rah_entr_widg {Update normal} bind $coords_ram_entr_widg {Update normal} bind $coords_ras_entr_widg {Update normal} bind $coords_dcd_entr_widg {Update normal} bind $coords_dcm_entr_widg {Update normal} bind $coords_dcs_entr_widg {Update normal} set this_process [pid] set working_pth [file join /tmp xplore$this_process] file mkdir $working_pth cd $working_pth if {$blt_avail} { set title_string_prefix \ "Xplore" } else { set title_string_prefix \ "Xplore (w/out BLT extension)" } wm title . $title_string_prefix wm protocol . WM_DELETE_WINDOW { Handle_Close . } wm resizable . 0 0 . configure -cursor left_ptr set rad_per_deg [expr {asin(1.0)/90.}] set 2pi [expr {360*$rad_per_deg}] set 1pi [expr {$2pi/2.}] set vport_pix_xdel 701 set vport_deg_xdel_old $vport_deg_xdel set lambda_old $lambda set fileid [open crush.sed "w"] puts $fileid "#!/bin/sed -f" puts $fileid "s/\\\\/ /g" puts $fileid "s/#//g" puts $fileid "/^\[\t \]*\$/d" close $fileid file attributes crush.sed -permissions 0755 foreach i {carcat solsys} { set filename [file join $support_pth $i] if {[file exists $filename]} { if {![file executable $filename]} { file attributes $filename -permissions 0755 } } } set filename [file join $support_pth flux_files cal_alias.dat] if {[file exists $filename]} { file copy -force $filename $working_pth set cal_alias_list [Load_Data cal_alias.dat list] } set filename [file join $support_pth tel_par.txt] if {![file exists $filename]} { set fileid [open tel_par.txt "w"] puts $fileid "# name long lat" puts $fileid "#-------------------------------------------" puts $fileid "Arecibo_NAIC -66.75333 18.34333" puts $fileid "Atacama_ALMA -67.75436 -23.02271" puts $fileid "Berkeley_HOME -122.30000 37.95000" puts $fileid "Cedar-Flat_CARMA -118.14165 37.28038" puts $fileid "Effelsberg_MPIFR 6.88500 50.52667" puts $fileid "Greenbank_NRAO -79.84167 38.43000" puts $fileid "Hat-Creek_HCRO -121.47333 40.81833" puts $fileid "Kitt-Peak_NRAO -111.61500 31.95333" puts $fileid "Mauna-Kea_CSO -155.47500 19.82167" puts $fileid "Mauna-Kea_JCMT -155.47972 19.82583" puts $fileid "Mopra_ATNF 149.09944 -31.26778" puts $fileid "Mt-Graham_MGIO -109.89167 32.70167" puts $fileid "Narrabri_ATNF 149.54889 -30.31444" puts $fileid "Nobeyama_NRO 138.48333 35.93333" puts $fileid "Owens-Valley_OVRO -118.28167 37.23167" puts $fileid "Parkes_ATNF 148.26222 -32.99994" puts $fileid "Pico-Veleta_IRAM -3.40000 37.06833" puts $fileid "Plateau-de-Bure_IRAM 5.90667 44.63333" puts $fileid "Socorro_NRAO -107.61833 34.07833" puts $fileid "Westerbork_WSRT 6.60500 52.91667" close $fileid file copy -force tel_par.txt $support_pth } set fileid [open xplore_about.txt "w"] puts $fileid "XPLORE $xplore_version" puts $fileid "tyu@hcro.org" puts $fileid "http://www.hcro.org/tyu" close $fileid file copy -force xplore_about.txt $support_pth set lstnow_hhmm "hhmm" $lambda_fram_widg.3mm select $foview_fram_widg.60deg select set date [string tolower [clock format [clock seconds] \ -format %y%b%d -gmt 1]] $solsys_non_butn_widg select $solsys_dat_entr_widg config -state disabled $carcat_fram_widg.no select Legend $mapleg_fram_widg.can foreach i "$telpar_nam_fram_widg $telpar_elm_fram_widg $foview_fram_widg \ $solsys_fram_widg $command_fram_widg $catlog_nam_fram_widg" { foreach j [winfo children $i] { $j configure -takefocus 0 } } bind $telpar_nam_list_widg { Extract $telpar_nam_list_widg $lst_labl_widg config \ -text "[lindex $telpar_nam_list $telpar_nam_indx]\nLST $lstnow_hhmm" Update normal } bind $telpar_nam_list_widg \ {Refresh_List $telpar_nam_list_widg} bind $telpar_elm_list_widg { Extract $telpar_elm_list_widg Update normal } bind $telpar_elm_list_widg \ {Refresh_List $telpar_elm_list_widg} set tel_par_list [Load_Data [file join $support_pth tel_par.txt] list] foreach i $tel_par_list { lappend telpar_nam_list [lindex $i 0] lappend telpar_lng_list [lindex $i 1] lappend telpar_lat_list [lindex $i 2] } eval {$telpar_nam_list_widg insert end} $telpar_nam_list set def_indx [lsearch $telpar_nam_list *CARMA*] if {$def_indx < 0} {set def_indx 0} $telpar_nam_list_widg selection set $def_indx $telpar_nam_list_widg yview $def_indx Extract $telpar_nam_list_widg set def_indx [lsearch -exact $telpar_elm_list 15] if {$def_indx < 0} {set def_indx 0} $telpar_elm_list_widg selection set $def_indx $telpar_elm_list_widg yview $def_indx Extract $telpar_elm_list_widg .menubar.file.menu entryconfigure "Xfer" -state $http_xfer_status $comand_pjt_butn_widg configure -state $proj_trak_status set ra_hrs 12 set ra_min 0 set ra_sec 0 set dec_deg 0 set dec_min 0 set dec_sec 0 focus $coords_rah_entr_widg Voice_Synth "X-plore calibrator navigation interface is on-line" Update normal