Improve overview and experiment naming
[khatus.git] / x2 / src / awk / exe / parse_metar_d_output.awk
CommitLineData
654ea6e2
SK
1# Qualifying the name as "_d_output" lest it be mistaken for parser of actual
2# metar format.
3
654ea6e2
SK
4/METAR pattern not found in NOAA data/ {
5 failures++
6 exit
7}
8
9/[A-z][a-z]+ *: / {
10 split($0, line, ":")
8482fea6
SK
11 key = str_strip(line[1])
12 val = str_strip(line[2])
654ea6e2
SK
13 values[NR] = val
14 first[key] = NR
15 last[key] = NR
16}
17
18/^ +/ {
8482fea6 19 values[NR] = str_strip($0)
654ea6e2
SK
20 last[key] = NR
21}
22
23END {
24 if (failures) {
25 print "metar fetch failed" > "/dev/stderr"
26 } else {
27 temp_string = values[first["Temperature"]]
28 split(temp_string, temp_parts, " +")
29 temp_celsius = temp_parts[1]
30 temp_fahrenheit = (temp_celsius * (9 / 5)) + 32
75b23ff8
SK
31 print("temperature_c", temp_celsius) # °C
32 print("temperature_f", temp_fahrenheit) # °F
654ea6e2 33 for (i=first["Phenomena"]; i<=last["Phenomena"]; i++) {
3fc7fe2c
SK
34 phenomenon = values[i]
35 if (phenomenon) {
75b23ff8 36 print("phenomenon" Kfs i, phenomenon)
3fc7fe2c 37 }
654ea6e2
SK
38 }
39 }
40}
This page took 0.034828 seconds and 4 git commands to generate.