#510359 Parsing limitations in metar

Package:
metar
Source:
metar
Description:
utility to download/decode METAR reports
Submitter:
"Anon Y. Mous"
Date:
2024-09-15 07:45:02 UTC
Severity:
normal
Tags:
#510359#5
Date:
2008-12-31 21:55:43 UTC
From:
To:
Given the following METAR file:
2008/12/31 19:00
KPAO 311900Z VRB05KT 3/4SM FG VV002 08/ A3028

I get the following output:
% (setenv METARURL file:$HOME;metar -dv KPAO)
Using environment variable METARURL: file:/home/foo
Retrieving URL file:/home/foo/KPAO.TXT
KPAO 311900Z VRB05KT 3/4SM FG VV002 08/ A3028
Parsing token `KPAO'
   Found station KPAO
Parsing token `311900Z'
   Found Day/Time 31/1900
Parsing token `VRB05KT'
   Found Winddir/str/gust/unit -1/5/5/KT
Parsing token `3/4SM'
   Unmatched token = 3/4SM
Parsing token `FG'
   Phenomena Fog
Parsing token `VV002'
   Unmatched token = VV002
Parsing token `08/'
   Unmatched token = 08/
Parsing token `A3028'
   Pressure/unit 3028/"Hg
Station       : KPAO
Day           : 31
Time          : 19:00 UTC
Wind direction: Variable
Wind speed    : 5 KT
Wind gust     : 5 KT
Visibility    : 0
Temperature   : 0 C
Dewpoint      : 0 C
Pressure      : 30.28 "Hg
Clouds        :
Phenomena     : Fog

I notice at least two bugs and several things I think would be nice enhancements.
- The visibility is not properly parsed when it involves fractional units.  The parser should handle the slant character and internally store the visibility in floating point.  Does it handle RVR?
- The temperature is not reported when the dewpoint is missing (since the station's dewpoint sensor is broken and dewpoint is not reported).
- If something is unknown, it probably shouldn't be printed.  The parser could pass back the dewpoint value and a valid flag (or invalid could be encoded as 0x7fffffff or something like that).  If the dewpoint isn't valid then don't print it or print "Dewpoint: Unknown" (and the same for all the other fields like visibility in this case where the parser failed).  Similarly, I think that gusts shouldn't be printed if there are no gusts.
- VV002 should probably be reported in the "Clouds" field.
- Using local time would be nice, but I'm sure it's beyond the scope of metar to figure out the proper timezone for the station (though a command line option to convert UTC to the timezone of the local computer would be nice since people often get METARs for stations in their same timezone).

Also, I think that the man page should say that METARURL needs to be set to file:$HOME instead of just $HOME since that didn't work for me.

Sorry to dump a laundry list on you, but I just want to help improve the program.  Accept or reject my suggestions as you see fit.

Thanks!

#510359#10
Date:
2024-09-15 07:40:40 UTC
From:
To: