1 ! Copyright (C) 2013 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors arrays ascii assocs calendar calendar.format
5 classes.tuple combinators command-line continuations csv
6 formatting fry grouping http.client io io.encodings.ascii
7 io.files io.styles kernel math math.extras math.parser memoize
8 namespaces regexp sequences sorting.human splitting strings urls
13 TUPLE: station cccc name state country latitude longitude ;
19 ERROR: bad-location str ;
21 : parse-location ( str -- n )
22 "-" split dup length {
23 { 3 [ first3 [ string>number ] tri@ 60.0 / + 60.0 / + ] }
24 { 2 [ first2 [ string>number ] bi@ 60.0 / + ] }
25 { 1 [ first string>number ] }
29 : string>longitude ( str -- lon/f )
30 dup R/ \d+-\d+(-\d+(\.\d+)?)?[WE]/ matches? [
33 [ CHAR: W = [ neg ] when ] bi*
36 : string>latitude ( str -- lat/f )
37 dup R/ \d+-\d+(-\d+(\.\d+)?)?[NS]/ matches? [
40 [ CHAR: S = [ neg ] when ] bi*
43 : stations-data ( -- seq )
44 URL" http://tgftp.nws.noaa.gov/data/nsd_cccc.txt"
45 http-get nip CHAR: ; [ string>csv ] with-delimiter ;
49 MEMO: all-stations ( -- seq )
56 [ 7 swap nth string>latitude ]
57 [ 8 swap nth string>longitude ]
61 : all-stations. ( -- )
62 all-stations standard-table-style [
68 dup string? [ "%.2f" sprintf ] unless write
76 : find-by-cccc ( cccc -- station )
77 all-stations swap '[ cccc>> _ = ] find nip ;
79 : find-by-country ( country -- stations )
80 all-stations swap '[ country>> _ = ] filter ;
82 : find-by-state ( state -- stations )
83 all-stations swap '[ state>> _ = ] filter ;
87 TUPLE: metar-report type station timestamp modifier wind
88 visibility rvr weather sky-condition temperature dew-point
89 altimeter remarks raw ;
91 CONSTANT: pressure-tendency H{
92 { "0" "increasing then decreasing" }
93 { "1" "increasing more slowly" }
95 { "3" "increasing more quickly" }
97 { "5" "decreasing then increasing" }
98 { "6" "decreasing more slowly" }
100 { "8" "decreasing more quickly" }
103 CONSTANT: lightning H{
104 { "CA" "cloud-air lightning" }
105 { "CC" "cloud-cloud lightning" }
106 { "CG" "cloud-ground lightning" }
107 { "IC" "in-cloud lightning" }
114 { "DR" "low drifting" }
116 { "DU" "widespread dust" }
118 { "FC" "funnel clouds" }
123 { "GS" "small hail and/or snow pellets" }
125 { "IC" "ice crystals" }
127 { "PL" "ice pellets" }
128 { "PO" "well-developed dust/sand whirls" }
134 { "SG" "snow grains" }
139 { "TS" "thuderstorm" }
141 { "VA" "volcanic ash" }
144 MEMO: glossary ( -- assoc )
145 "vocab:metar/glossary.txt" ascii file-lines
146 [ "," split1 ] H{ } map>assoc ;
148 : parse-glossary ( str -- str' )
153 [ glossary ?at drop ] if
157 : parse-timestamp ( str -- str' )
158 [ now [ year>> ] [ month>> ] bi ] dip
159 2 cut 2 cut 2 cut drop [ string>number ] tri@
161 [ drop 0 ] dip 0 instant <timestamp> 1 days time+
163 0 instant <timestamp>
164 ] if timestamp>rfc822 ;
166 CONSTANT: compass-directions H{
186 : direction>compass ( direction -- compass )
187 22.5 round-to-step compass-directions at ;
189 : parse-compass ( str -- str' )
190 string>number [ direction>compass ] keep "%s (%s°)" sprintf ;
192 : parse-direction ( str -- str' )
193 dup "VRB" = [ drop "variable" ] [
194 parse-compass "from %s" sprintf
197 : kt>mph ( kt -- mph ) 1.15077945 * ;
199 : mph>kt ( mph -- kt ) 1.15077945 / ;
201 : parse-speed ( str units -- str'/f )
202 [ string>number ] dip '[
204 [ drop dup kt>mph "%s knots (%.1f mph)" sprintf ]
205 [ "%s %s" sprintf ] if
208 : parse-wind ( str -- str' )
209 dup "00000" head? [ drop "calm" ] [
210 "/" split1 [ 3 cut ] unless*
211 [ parse-direction ] dip {
212 { [ "KT" ?tail ] [ "knots" ] }
213 { [ "MPS" ?tail ] [ "meters per second" ] }
214 } cond [ "G" split1 ] dip '[ _ parse-speed ] bi@
215 [ "%s at %s with gusts to %s " sprintf ]
216 [ "%s at %s" sprintf ] if*
219 : parse-wind-variable ( str -- str' )
220 "V" split1 [ parse-compass ] bi@
221 ", variable from %s to %s" sprintf ;
223 : parse-visibility ( str -- str' )
226 { CHAR: M [ rest "less than " ] }
227 { CHAR: P [ rest "more than " ] }
230 CHAR: \s over index [ " " "+" replace ] when
231 string>number "%s%s statute miles" sprintf
235 { [ dup 800 < ] [ "%dm" sprintf ] }
236 { [ dup 5000 < ] [ 1000 /f "%.1fkm" sprintf ] }
237 { [ dup 9999 < ] [ 1000 /f "%dkm" sprintf ] }
238 [ drop "more than 10km" ]
248 ] { } map-as unclip-last
249 [ "-" join ] dip append " " glue
253 : parse-rvr ( str -- str' )
255 { [ "U" ?tail ] [ " with improvement" ] }
256 { [ "D" ?tail ] [ " with aggravation" ] }
257 { [ "N" ?tail ] [ " with no change" ] }
260 "R" ?head drop "/" split1 "FT" ?tail [
262 [ string>number ] bi@
263 "varying between %s and %s" sprintf
265 string>number "of %s" sprintf
266 ] if* "runway %s visibility %s" sprintf
267 ] dip " ft" " meters" ? append
270 : (parse-weather) ( str -- str' )
271 dup "+FC" = [ drop "tornadoes or waterspouts" ] [
273 { CHAR: + [ rest "heavy " ] }
274 { CHAR: - [ rest "light " ] }
277 2 group dup [ weather key? ] all?
278 [ [ weather at ] map " " join ]
279 [ concat parse-glossary ] if
283 : parse-weather ( str -- str' )
284 "VC" over subseq? [ "VC" "" replace t ] [ f ] if
286 [ [ " in the vicinity" append ] when ] bi* ;
288 : parse-altitude ( str -- str' )
289 string>number " at %s00 ft" sprintf ;
295 { "SCT" "scattered" }
296 { "SKC" "clear sky" }
297 { "CLR" "clear sky" }
298 { "NSC" "clear sky" }
300 { "ACC" "altocumulus castellanus" }
301 { "ACSL" "standing lenticular altocumulus" }
302 { "CCSL" "cirrocumulus standing lenticular cloud" }
304 { "SC" "stratocumulus" }
305 { "SCSL" "stratocumulus standing lenticular cloud" }
306 { "TCU" "towering cumulus" }
309 : parse-sky-condition ( str -- str' )
314 [ sky at [ " (%s)" sprintf ] [ f ] if* ]
318 : F>C ( F -- C ) 32 - 5/9 * ;
320 : C>F ( C -- F ) 9/5 * 32 + ;
322 : parse-temperature ( str -- temp dew-point )
325 "M" ?head [ string>number ] [ [ neg ] when ] bi*
326 dup C>F "%d °C (%.1f °F)" sprintf
330 : parse-altimeter ( str -- str' )
331 unclip [ string>number ] [ CHAR: A = ] bi*
332 [ 100 /f "%.2f Hg" sprintf ] [ "%s hPa" sprintf ] if ;
334 CONSTANT: re-timestamp R/ \d{6}Z/
335 CONSTANT: re-station R/ \w{4}/
336 CONSTANT: re-temperature R/ [M]?\d{2}\/([M]?\d{2})?/
337 CONSTANT: re-wind R/ (VRB|\d{3})(\/\d+|\d{2,3})(G\d{2,3})?(KT|MPS)/
338 CONSTANT: re-wind-variable R/ \d{3}V\d{3}/
339 CONSTANT: re-visibility R/ ((\d+|[MP])?\d+(\/\d+)?SM|\d{4}[NSEW]{0,2})/
340 CONSTANT: re-rvr R/ R\d{2}[RLC]?\/[MP]?\d{4}(V\d{4})?(FT)?[UDN]?/
341 CONSTANT: re-weather R/ [+-]?(VC)?(\w{2}|\w{4})/
342 CONSTANT: re-sky-condition R/ (\w{2,3}\d{3}(\w+)?|\w{3}|CAVOK)/
343 CONSTANT: re-altimeter R/ [AQ]\d{4}/
345 : find-one ( seq quot: ( elt -- ? ) -- seq' elt/f )
346 dupd find [ [ swap remove-nth ] when* ] dip ; inline
348 : find-all ( seq quot: ( elt -- ? ) -- seq elts )
349 [ dupd find drop ] keep '[
351 [ dup ?first _ [ f ] if* ] [ unclip ] produce
355 : fix-visibility ( seq -- seq' )
356 dup [ R/ \d+(\/\d+)?SM/ matches? ] find drop [
357 dup 1 - pick ?nth [ R/ \d+/ matches? ] [ f ] if* [
358 cut [ unclip-last ] [ unclip swap ] bi*
359 [ " " glue 1array ] [ 3append ] bi*
363 : metar-body ( report seq -- report )
364 [ { "METAR" "SPECI" } member? ] find-one
365 [ pick type<< ] when*
367 [ re-station matches? ] find-one
368 [ pick station<< ] when*
370 [ re-timestamp matches? ] find-one
371 [ parse-timestamp pick timestamp<< ] when*
373 [ { "AUTO" "COR" } member? ] find-one
374 [ pick modifier<< ] when*
376 [ re-wind matches? ] find-one
377 [ parse-wind pick wind<< ] when*
379 [ re-wind-variable matches? ] find-one
380 [ parse-wind-variable pick wind>> prepend pick wind<< ] when*
383 [ re-visibility matches? ] find-all
384 [ parse-visibility ] map ", " join pick visibility<<
386 [ re-rvr matches? ] find-all
387 [ parse-rvr ] map ", " join pick rvr<<
389 [ re-weather matches? ] find-all
390 [ parse-weather ] map ", " join pick weather<<
392 [ re-sky-condition matches? ] find-all
393 [ parse-sky-condition ] map ", " join pick sky-condition<<
395 [ re-temperature matches? ] find-one
398 [ pick temperature<< ]
399 [ pick dew-point<< ] bi*
402 [ re-altimeter matches? ] find-one
403 [ parse-altimeter pick altimeter<< ] when*
407 : signed-number ( sign value -- n )
408 [ string>number ] bi@ swap zero? [ neg ] unless 10.0 / ;
410 : single-value ( str -- str' )
411 1 cut signed-number ;
413 : double-value ( str -- m n )
414 1 cut 3 cut [ signed-number ] dip 1 cut signed-number ;
416 : parse-1hr-temp ( str -- str' )
417 "T" ?head drop dup length 4 > [
419 [ dup C>F "%.1f °C (%.1f °F)" sprintf ] bi@
420 "hourly temperature %s and dew point %s" sprintf
423 "hourly temperature %.1f °C (%.1f °F)" sprintf
426 : parse-6hr-max-temp ( str -- str' )
427 "1" ?head drop single-value dup C>F
428 "6-hour maximum temperature %.1f °C (%.1f °F)" sprintf ;
430 : parse-6hr-min-temp ( str -- str' )
431 "2" ?head drop single-value dup C>F
432 "6-hour minimum temperature %.1f °C (%.1f °F)" sprintf ;
434 : parse-24hr-temp ( str -- str' )
435 "4" ?head drop double-value
436 [ dup C>F "%.1f °C (%.1f °F)" sprintf ] bi@
437 "24-hour maximum temperature %s minimum temperature %s"
440 : parse-1hr-pressure ( str -- str' )
441 "5" ?head drop 1 cut single-value [ pressure-tendency at ] dip
442 "hourly pressure %s %s hPa" sprintf ;
444 : parse-snow-depth ( str -- str' )
445 "4/" ?head drop string>number "snow depth %s inches" sprintf ;
447 CONSTANT: low-clouds H{
448 { 1 "cumulus (fair weather)" }
449 { 2 "cumulus (towering)" }
450 { 3 "cumulonimbus (no anvil)" }
451 { 4 "stratocumulus (from cumulus)" }
452 { 5 "stratocumuls (not cumulus)" }
453 { 6 "stratus or Fractostratus (fair)" }
454 { 7 "fractocumulus / fractostratus (bad weather)" }
455 { 8 "cumulus and stratocumulus" }
456 { 9 "cumulonimbus (thunderstorm)" }
460 CONSTANT: mid-clouds H{
461 { 1 "altostratus (thin)" }
462 { 2 "altostratus (thick)" }
463 { 3 "altocumulus (thin)" }
464 { 4 "altocumulus (patchy)" }
465 { 5 "altocumulus (thickening)" }
466 { 6 "altocumulus (from cumulus)" }
467 { 7 "altocumulus (with altocumulus, altostratus, nimbostratus)" }
468 { 8 "altocumulus (with turrets)" }
469 { 9 "altocumulus (chaotic)" }
470 { -1 "above overcast" }
473 CONSTANT: high-clouds H{
474 { 1 "cirrus (filaments)" }
475 { 2 "cirrus (dense)" }
476 { 3 "cirrus (often with cumulonimbus)" }
477 { 4 "cirrus (thickening)" }
478 { 5 "cirrus / cirrostratus (low in sky)" }
479 { 6 "cirrus / cirrostratus (hi in sky)" }
480 { 7 "cirrostratus (entire sky)" }
481 { 8 "cirrostratus (partial)" }
482 { 9 "cirrocumulus or cirrocumulus / cirrus / cirrostratus" }
483 { -1 "above overcast" }
486 : parse-cloud-cover ( str -- str' )
487 "8/" ?head drop first3 [ CHAR: 0 - ] tri@
488 [ [ f ] [ low-clouds at "low clouds are %s" sprintf ] if-zero ]
489 [ [ f ] [ mid-clouds at "middle clouds are %s" sprintf ] if-zero ]
490 [ [ f ] [ high-clouds at "high clouds are %s" sprintf ] if-zero ]
491 tri* 3array " " join ;
493 : parse-inches ( str -- str' )
494 dup [ CHAR: / = ] all? [ drop "unknown" ] [
496 [ "trace" ] [ 100 /f "%.2f inches" sprintf ] if-zero
499 : parse-1hr-precipitation ( str -- str' )
500 "P" ?head drop parse-inches
501 "%s precipitation in last hour" sprintf ;
503 : parse-6hr-precipitation ( str -- str' )
504 "6" ?head drop parse-inches
505 "%s precipitation in last 6 hours" sprintf ;
507 : parse-24hr-precipitation ( str -- str' )
508 "7" ?head drop parse-inches
509 "%s precipitation in last 24 hours" sprintf ;
511 ! XXX: "on the hour" instead of "00 minutes past the hour" ?
513 : parse-recent-time ( str -- str' )
516 [ " minutes past the hour" append ] if ;
518 : parse-peak-wind ( str -- str' )
519 "/" split1 [ parse-wind ] [ parse-recent-time ] bi*
520 "%s occuring at %s" sprintf ;
522 : parse-sea-level-pressure ( str -- str' )
523 "SLP" ?head drop string>number 10.0 /f 1000 +
524 "sea-level pressure is %s hPa" sprintf ;
526 : parse-lightning ( str -- str' )
527 "LTG" ?head drop 2 group [ lightning at ] map " " join ;
529 CONSTANT: re-recent-weather R/ ((\w{2})?[BE]\d{2,4}((\w{2})?[BE]\d{2,4})?)+/
531 : parse-began/ended ( str -- str' )
533 [ CHAR: B = "began" "ended" ? ]
534 [ parse-recent-time ] bi* "%s at %s" sprintf ;
536 : split-recent-weather ( str -- seq )
538 dup [ digit? ] find drop
539 over [ digit? not ] find-from drop
540 [ cut ] [ f ] if* swap
543 : (parse-recent-weather) ( str -- str' )
544 dup [ digit? ] find drop 2 > [
545 2 cut [ weather at " " append ] dip
546 ] [ f swap ] if parse-began/ended "" append-as ;
548 : parse-recent-weather ( str -- str' )
550 [ (parse-recent-weather) ] map " " join ;
552 : parse-varying ( str -- str' )
553 "V" split1 [ string>number ] bi@
554 "varying between %s00 and %s00 ft" sprintf ;
556 : parse-from-to ( str -- str' )
557 "-" split [ parse-glossary ] map " to " join ;
559 : parse-water-equivalent-snow ( str -- str' )
560 "933" ?head drop parse-inches
561 "%s water equivalent of snow on ground" sprintf ;
563 : parse-duration-of-sunshine ( str -- str' )
564 "98" ?head drop string>number
565 [ "no" ] [ "%s minutes of" sprintf ] if-zero
566 "%s sunshine" sprintf ;
568 : parse-6hr-snowfall ( str -- str' )
569 "931" ?head drop parse-inches
570 "%s snowfall in last 6 hours" sprintf ;
572 : parse-probability ( str -- str' )
573 "PROB" ?head drop string>number
574 "probability of %d%%" sprintf ;
576 : parse-remark ( str -- str' )
578 { [ dup glossary key? ] [ glossary at ] }
579 { [ dup R/ 1\d{4}/ matches? ] [ parse-6hr-max-temp ] }
580 { [ dup R/ 2\d{4}/ matches? ] [ parse-6hr-min-temp ] }
581 { [ dup R/ 4\d{8}/ matches? ] [ parse-24hr-temp ] }
582 { [ dup R/ 4\/\d{3}/ matches? ] [ parse-snow-depth ] }
583 { [ dup R/ 5\d{4}/ matches? ] [ parse-1hr-pressure ] }
584 { [ dup R/ 6[\d\/]{4}/ matches? ] [ parse-6hr-precipitation ] }
585 { [ dup R/ 7\d{4}/ matches? ] [ parse-24hr-precipitation ] }
586 { [ dup R/ 8\/\d{3}/ matches? ] [ parse-cloud-cover ] }
587 { [ dup R/ 931\d{3}/ matches? ] [ parse-6hr-snowfall ] }
588 { [ dup R/ 933\d{3}/ matches? ] [ parse-water-equivalent-snow ] }
589 { [ dup R/ 98\d{3}/ matches? ] [ parse-duration-of-sunshine ] }
590 { [ dup R/ T\d{4,8}/ matches? ] [ parse-1hr-temp ] }
591 { [ dup R/ \d{3}\d{2,3}\/\d{2,4}/ matches? ] [ parse-peak-wind ] }
592 { [ dup R/ P\d{4}/ matches? ] [ parse-1hr-precipitation ] }
593 { [ dup R/ SLP\d{3}/ matches? ] [ parse-sea-level-pressure ] }
594 { [ dup R/ LTG\w+/ matches? ] [ parse-lightning ] }
595 { [ dup R/ PROB\d+/ matches? ] [ parse-probability ] }
596 { [ dup R/ \d{3}V\d{3}/ matches? ] [ parse-varying ] }
597 { [ dup R/ [^-]+(-[^-]+)+/ matches? ] [ parse-from-to ] }
598 { [ dup R/ [^\/]+(\/[^\/]+)+/ matches? ] [ ] }
599 { [ dup R/ \d+.\d+/ matches? ] [ ] }
600 { [ dup re-recent-weather matches? ] [ parse-recent-weather ] }
601 { [ dup re-weather matches? ] [ parse-weather ] }
602 { [ dup re-sky-condition matches? ] [ parse-sky-condition ] }
606 : metar-remarks ( report seq -- report )
607 [ parse-remark ] map " " join >>remarks ;
609 : <metar-report> ( metar -- report )
610 [ metar-report new ] dip [ >>raw ] keep
611 [ blank? ] split-when { "RMK" } split1
612 [ metar-body ] [ metar-remarks ] bi* ;
614 : row. ( name quot -- )
616 [ _ write ] with-cell
617 [ @ [ 65 wrap-string write ] when* ] with-cell
620 : metar-report. ( report -- )
621 standard-table-style [
623 [ "Station" [ station>> ] row. ]
624 [ "Timestamp" [ timestamp>> ] row. ]
625 [ "Wind" [ wind>> ] row. ]
626 [ "Visibility" [ visibility>> ] row. ]
627 [ "RVR" [ rvr>> ] row. ]
628 [ "Weather" [ weather>> ] row. ]
629 [ "Sky condition" [ sky-condition>> ] row. ]
630 [ "Temperature" [ temperature>> ] row. ]
631 [ "Dew point" [ dew-point>> ] row. ]
632 [ "Altimeter" [ altimeter>> ] row. ]
633 [ "Remarks" [ remarks>> ] row. ]
634 [ "Raw Text" [ raw>> ] row. ]
636 ] tabular-output nl ;
640 GENERIC: metar ( station -- metar )
642 M: station metar cccc>> metar ;
645 "http://tgftp.nws.noaa.gov/data/observations/metar/stations/%s.TXT"
646 sprintf http-get nip ;
648 GENERIC: metar. ( station -- )
650 M: station metar. cccc>> metar. ;
653 [ metar <metar-report> metar-report. ]
654 [ drop "%s METAR not found\n" printf ] recover ;
658 : parse-wind-shear ( str -- str' )
659 "WS" ?head drop "/" split1
660 [ parse-altitude ] [ parse-wind ] bi* prepend
661 "wind shear " prepend ;
663 CONSTANT: re-from-timestamp R/ FM\d{6}/
665 : parse-from-timestamp ( str -- str' )
666 "FM" ?head drop parse-timestamp ;
668 CONSTANT: re-valid-timestamp R/ \d{4}\/\d{4}/
670 : parse-valid-timestamp ( str -- str' )
671 "/" split1 [ "00" append parse-timestamp ] bi@ " to " glue ;
673 TUPLE: taf-report station timestamp valid-timestamp wind
674 visibility rvr weather sky-condition partials raw ;
676 TUPLE: taf-partial from-timestamp wind visibility rvr weather
679 : taf-body ( report str -- report )
680 [ blank? ] split-when
682 [ "TAF" = ] find-one drop
684 [ { "AMD" "COR" "RTD" } member? ] find-one drop
686 [ re-station matches? ] find-one
687 [ pick station<< ] when*
689 [ re-timestamp matches? ] find-one
690 [ parse-timestamp pick timestamp<< ] when*
692 [ re-valid-timestamp matches? ] find-one
693 [ parse-valid-timestamp pick valid-timestamp<< ] when*
695 [ re-wind matches? ] find-one
696 [ parse-wind pick wind<< ] when*
698 [ re-wind-variable matches? ] find-one
699 [ parse-wind-variable pick wind>> prepend pick wind<< ] when*
701 [ re-visibility matches? ] find-one
702 [ parse-visibility pick visibility<< ] when*
704 [ re-rvr matches? ] find-all " " join
705 [ parse-rvr ] map ", " join pick rvr<<
707 [ re-weather matches? ] find-all
708 [ parse-weather ] map ", " join pick weather<<
710 [ re-sky-condition matches? ] find-all
711 [ parse-sky-condition ] map ", " join pick sky-condition<<
715 : <taf-partial> ( str -- partial )
716 [ taf-partial new ] dip [ blank? ] split-when
718 [ re-from-timestamp matches? ] find-one
719 [ parse-from-timestamp pick from-timestamp<< ] when*
721 [ re-wind matches? ] find-one
722 [ parse-wind pick wind<< ] when*
724 [ re-wind-variable matches? ] find-one
725 [ parse-wind-variable pick wind>> prepend pick wind<< ] when*
727 [ re-visibility matches? ] find-one
728 [ parse-visibility pick visibility<< ] when*
730 [ re-rvr matches? ] find-all " " join
731 [ parse-rvr ] map ", " join pick rvr<<
733 [ re-weather matches? ] find-all
734 [ parse-weather ] map ", " join pick weather<<
736 [ re-sky-condition matches? ] find-all
737 [ parse-sky-condition ] map ", " join pick sky-condition<<
741 : taf-partials ( report seq -- report )
742 [ <taf-partial> ] map >>partials ;
744 : <taf-report> ( taf -- report )
745 [ taf-report new ] dip [ >>raw ] keep
746 lines [ [ blank? ] trim ] map
747 rest dup first "TAF" = [ rest ] when
748 harvest unclip swapd taf-body swap taf-partials ;
750 : taf-report. ( report -- )
752 standard-table-style [
754 [ "Station" [ station>> ] row. ]
755 [ "Timestamp" [ timestamp>> ] row. ]
756 [ "Valid From" [ valid-timestamp>> ] row. ]
757 [ "Wind" [ wind>> ] row. ]
758 [ "Visibility" [ visibility>> ] row. ]
759 [ "RVR" [ rvr>> ] row. ]
760 [ "Weather" [ weather>> ] row. ]
761 [ "Sky condition" [ sky-condition>> ] row. ]
762 [ "Raw Text" [ raw>> ] row. ]
767 standard-table-style [
769 [ "From" [ from-timestamp>> ] row. ]
770 [ "Wind" [ wind>> ] row. ]
771 [ "Visibility" [ visibility>> ] row. ]
772 [ "RVR" [ rvr>> ] row. ]
773 [ "Weather" [ weather>> ] row. ]
774 [ "Sky condition" [ sky-condition>> ] row. ]
782 GENERIC: taf ( station -- taf )
784 M: station taf cccc>> taf ;
787 "http://tgftp.nws.noaa.gov/data/forecasts/taf/stations/%s.TXT"
788 sprintf http-get nip ;
790 GENERIC: taf. ( station -- )
792 M: station taf. cccc>> taf. ;
795 [ taf <taf-report> taf-report. ]
796 [ drop "%s TAF not found\n" printf ] recover ;
800 [ metar print ] [ taf print ] bi nl