1# JStrack: copyright 1997/2010 by Jim Graham, N5IAL, all rights reserved. 2# 3 4# Called by the user to get a listing of forecasts available 5 6proc fc_index {{name ""}} { 7 global st_names 8 9 set name [string toupper $name] 10 if {[test_st_data] == -1} { return } 11 if {$name != "" && [test_st_data $name] == -1} { return } 12 13 if {$name == ""} { 14 foreach name $st_names { display_indexes $name ; puts "" } 15 } else { 16 display_indexes $name 17 } 18} 19 20 21# Called by the user to get info for a specific forecast (or forecasts) 22 23proc fc_info {name timestamp {fc_ts *}} { 24 global forecasts fc_tm_idx 25 26 set name [string toupper $name] 27 if {[test_st_data] == -1} return 28 if {$name != "" && [test_st_data $name] == -1} { return } 29 30 set timestamp [string toupper $timestamp] 31 set fc_ts [string toupper $fc_ts] 32 33 if {[array get fc_tm_idx $name$timestamp] == ""} { 34 puts "No forecast data loaded for $name at $timestamp" 35 } 36 foreach i $fc_tm_idx($name$timestamp) { 37 set idx "$name $timestamp $i" 38 set xt $forecasts($idx,xt) 39 eval plot_fc_info $name $timestamp $i $forecasts($idx) $xt 40 } 41} 42 43 44# This procedure calls puts_stinfo to print the latest data for the 45# storm (name) as of the NHC advisory (timestamp). 46 47proc st_info {name timestamp {cmd "puts"}} { 48 global stinfo 49 50 set name [string toupper $name] 51 if {[test_st_data] == -1} { return } 52 if {$name != "" && [test_st_data $name] == -1 } { return } 53 54 set timestamp [string toupper $timestamp] 55 56 puts_stinfo $stinfo($name$timestamp) $cmd 57} 58 59 60# Like fc_index, called by the user to display a listing of past/current 61# positions for the storm (name/timestamp only) 62 63proc st_index {{name ""}} { 64 global st_names st_times advisory_list 65 66 set name [string toupper $name] 67 if {[test_st_data] == -1} { return } 68 if {$name != "" && [test_st_data $name] == -1} { return } 69 70 if {$name == ""} { 71 foreach name $st_names { 72 foreach timestamp $st_times($name) { 73 set idx $name$timestamp 74 set advtxt "" 75 catch { set advtext " (Advisory $advisory_list($idx))" } 76 puts "$name $timestamp$advtext" 77 } 78 } 79 puts "" 80 } else { 81 foreach timestamp $st_times($name) { 82 set idx $name$timestamp 83 set advtxt "" 84 catch { set advtext " (Advisory $advisory_list($idx))" } 85 puts "$name $timestamp$advtext" 86 } 87 } 88} 89 90 91# Called by the user to produce a chart showing a history of the storm. 92# This could probably be done a lot better...but at least it works. 93 94proc st_hist {name {cmd "puts"}} { 95 global st_times stinfo units advisory_list 96 97 if {$units == "KT"} { set du " (NM/KT)" 98 } else { set du "(Miles/MPH)" } 99 100 set name [string toupper $name] 101 102 103 if {[test_st_data] == -1} { return } 104 if {$name != "" && [test_st_data $name] == -1} { return } 105 106 set lineno 0 107 set last_press -1 108 $cmd ".----------------------------------------------------------------------------." 109 foreach timestamp $st_times($name) { 110 incr lineno 111 set pe 0 112 if {[string compare $advisory_list($name$timestamp) "PE"] == 0} { 113 set pe 1 114 } 115 116 if {$lineno == 1} { 117 $cmd "| [format "%37s" $name] $du |" 118 $cmd "| Time | Type | Lat. Long. | Dir/speed | Pressure | wnd/gst | eye |" 119 $cmd "|----------|------|----------------|-----------|-------------|---------|-----|" 120 } elseif {$cmd == "puts" && $lineno == 18} { 121 set lineno 1 122 $cmd "`----------------------------------------------------------------------------'" 123 puts "Press RETURN to continue" 124 gets stdin 125 $cmd ".----------------------------------------------------------------------------." 126 $cmd "| [format "%37s" $name] $du |" 127 $cmd "| Time | Type | Lat. Long. | Dir/speed | Pressure | wnd/gst | eye |" 128 $cmd "|----------|------|----------------|-----------|-------------|---------|-----|" 129 } 130 set cat " " 131 foreach {type xa xb latt long course speed press winds gusts eye} \ 132 $stinfo($name$timestamp) { break } 133 set type [get_st_type $name $timestamp] 134 135 if {$type == "HR"} { set cat "[st_cat $winds]" } 136 set latt [format "%4.1f" $latt]N 137 set long [format "%5.1f" $long]W 138 if {$pe == 0} { 139 if {$course == "XX"} { 140 set course " " 141 } else { 142 set course [format "%3.0f" $course] 143 } 144 if {$speed == "XX"} { 145 set speed " " 146 } else { 147 if {$units == "MPH"} { set speed [expr {round($speed * 1.15)}] } 148 set speed [format "%2d" $speed] 149 } 150 set pdir " " 151 if {$last_press != -1 && [string compare $press "XX"]} { 152 if {$press > $last_press} { 153 set pdir "(R)" 154 } elseif {$press < $last_press} { 155 set pdir "(F)" 156 } 157 } 158 set last_press $press 159 set press [format "%4d" $press] 160 if {$units == "MPH"} { 161 set winds [expr {round($winds * 1.15)}] 162 if {[string compare $gusts XX]} { 163 set gusts [expr {round($gusts * 1.15)}] 164 } 165 } 166 set winds [format "%3d" $winds] 167 if {[string compare $gusts XX]} { 168 set gusts [format "%3d" $gusts] 169 } else { 170 set gusts " " 171 } 172 if {$eye == "XX"} { 173 set eye " " 174 } else { 175 if {$units == "MPH"} { set eye [expr {round($eye * 1.15)}] } 176 set eye [format "%3d" $eye] 177 } 178 $cmd -nonewline "| $timestamp | $type $cat | $latt $long | " 179 if {[string compare $course " "]} { 180 $cmd -nonewline "$course at $speed " 181 } else { 182 $cmd -nonewline " " 183 } 184 $cmd "| $press MB $pdir | $winds/$gusts | $eye |" 185 } else { 186 $cmd "| $timestamp | $type | $latt $long | | | | |" 187 } 188 } 189 $cmd "`----------------------------------------------------------------------------'" 190} 191 192