#!/usr/bin/env tclsh # solsys: xplore support script by tyu, for importing solar system data # ported from csh to tclsh set this_process [pid] set solsys_nam_list [list mercury venus mars jupiter saturn uranus \ neptune sun] if {$argv != {}} { foreach i $argv { if {[llength [split $i =]] == 2} { set command [concat set [split $i =]] eval $command } } } proc Load_Data { filename obj args } { set data "" if {[file exists $filename]} { set fileid [open $filename "r"] switch -exact -- $obj \ list { set list "" while {[gets $fileid data] >= 0} { if {![string match #* $data]} { lappend list $data } } } close $fileid if {$obj == "list"} { return $list } } } cd $working_pth set ypix_per_deg $xpix_per_deg set planets_outfile solsys.$date.txt if {![file exists $planets_outfile]} { if {[info exists env(MIRBIN)]} { set fileid [open $planets_outfile "a"] foreach i $solsys_nam_list { set command [list \ exec [file join $env(MIRBIN) planets] source=$i epoch=$date] if {[catch $command result] != 0} { close $fileid file delete -force $planets_outfile exit 1 } else { puts $fileid $result } } close $fileid set planets_outlist [Load_Data $planets_outfile list] } else { exit 1 } } else { set planets_outlist [Load_Data $planets_outfile list] if {[lindex $planets_outlist 0] == "gen4xplore failed"} { file delete -force $planets_outfile exit 1 } } foreach i $planets_outlist { set indx [lsearch -exact $i RA:] if {$indx != -1} { incr indx set j [split [lindex $i $indx] :] lappend solsys_ra_list \ [expr {15*([scan [lindex $j 0] %d]+ \ ([scan [lindex $j 1] %d]+[scan [lindex $j 2] %f]/60)/60)}] } } foreach i $planets_outlist { set indx [lsearch -exact $i DEC:] if {$indx != -1} { incr indx set j [split [lindex $i $indx] :] if {[scan [lindex $j 0] %d] < 0} { lappend solsys_dec_list \ [expr {-(-[scan [lindex $j 0] %d]+ \ ([scan [lindex $j 1] %d]+[scan [lindex $j 2] %f]/60)/60)}] } else { lappend solsys_dec_list \ [expr {([scan [lindex $j 0] %d]+ \ ([scan [lindex $j 1] %d]+[scan [lindex $j 2] %f]/60)/60)}] } } } set fileid [open solsys_goto_catlog.txt "w"] foreach i $solsys_nam_list { set indx [lsearch $solsys_nam_list $i] puts $fileid "$i [lindex $solsys_ra_list $indx] [lindex $solsys_dec_list $indx]" } close $fileid set solsys_ra_org_list $solsys_ra_list set indx 0 set imax [llength $solsys_ra_org_list] incr imax -1 while {$indx <= $imax} { set x [lindex $solsys_ra_org_list $indx] if {$x < 60} { lappend solsys_ra_list [expr {360+$x}] lappend solsys_dec_list [lindex $solsys_dec_list $indx] lappend solsys_nam_list [lindex $solsys_nam_list $indx] } if {$x > 300} { lappend solsys_ra_list [expr {$x-360}] lappend solsys_dec_list [lindex $solsys_dec_list $indx] lappend solsys_nam_list [lindex $solsys_nam_list $indx] } incr indx 1 } set fileid1 [open solsys_flxdat "w"] set fileid2 [open solsys_posdat "w"] set fileid3 [open solsys_visual "w"] set indx 0 set imax [llength $solsys_ra_list] incr imax -1 while {$indx <= $imax} { set x [lindex $solsys_ra_list $indx] set y [lindex $solsys_dec_list $indx] set a \ [expr {$canvas_pix_xmax-$xpix_per_deg*($x-$canvas_deg_xmin)}] set b \ [expr {$canvas_pix_ymax-$ypix_per_deg*($y-$canvas_deg_ymin)}] puts $fileid1 "[lindex $solsys_nam_list $indx] NA $date NA" puts $fileid2 "$x $y" puts $fileid3 "[expr {$a-8}] [expr {$b+8}] [expr {$a+8}] [expr {$b-8}] -fill ivory1" incr indx 1 } close $fileid1 close $fileid2 close $fileid3 exit 0