sfws wrote:If anyone is interested, I have written in PHP 7 a METAR decoding script that takes into account all the 2017 changes
Since I wrote that quote, I changed my decoder to use "pow(base, value)" instead of "base ** value", and changed all my array declarations to use "x = array (value_list)" instead of "x =[value_list]", I made sure that I do not restrain type of return value in my user defined functions. As a result my scripts are now compatible with PHP versions from 5.4.0 to 7.1.14 (but not earlier versions of PHP that do not support PHP constructs like "labels" as these are an essential part of my design). There is more information about all the research I did to inform my suite in the PDF paper included in the zip. That paper also decribes how ICAO and WMO are forcing abandonment of METAR in TAC format of traditional alphanumerical characters. They have agreed a new international XML style combined with GML, which is already in use by some nations (including part of USA) and is not made directly available to pilots, let alone the public at large. My decoder is not compatible with that that digital based format. So you only have until 2020 to try my script with the latest routine aviation weather reports whilst there are METAR reports still using TAC and available to the public!
From perfecting the decoder and writing the different web pages I have learnt a lot about PHP, especially about using it with HTML forms and the advantages of using global variables and breaking a script up into lots of sub-functions. My final suite represents a complex mixture of approaches to the design because I wanted to try all possibilities; and it may be in-efficient because I am self-taught for all the web languages and do not have the expertise to improve that aspect. Essentially, this was my project for July to November 2017
. I have not tried to make my decoder work with PHP 7.2 because that is not compatible with my Windows Vista PC.
I have developed many web pages that call my decoder. None of these are in the attached zip of the suite as they were all created to aid my testing and may not suit you. One web page script is available at http://www.komokaweather.com/metar/metar_display.php?view=metar_display
and the second of my two alternatives specially written for "PaulMy" is at http://www.komokaweather.com/metar/metar_display-alt.php
. For his web pages I choose to show all three possible units for wind speed by combining three outputs from my suite, but you could choose just one unit of measure. A major aim of my suite is to produce lots of output, but leave it to the user to decide what to show! There are thousands and thousands of lines of code because the traditional alphanuneric character (TAC) format for METAR are designed for trained humans to read, not for computers. Indeed, the WMO states it is impossible to write a computer programme than can decode any more than the basic METAR and that probably accounts for why I have not found any other decoder as ambitous as mine. To ensure I can decode almost all worldwide METAR my Remarks Group decoding script covers the most widely used codes (I call them Common) plus those relating specifically to Australia, Canada, New Zealand (including Antarctica), Italy, and USA. This decoder has been in continuous use at http://www.komokaweather.com/metar/metar_display.php
since November 2017.
(You can compare the output from my decoder with the output for similar airports using Saratoga version at http://www.komokaweather.ca/wxmetar.php
The top level script of my decoder can be found at http://www.komokaweather.com/metar/metar_display.php?view=decodeMETAR
or in the zip.
The script at the next level down is at http://www.komokaweather.com/metar/metar_display.php?view=decodeMETAR_sub_funct
or in the zip.
For USA I am decoding specifications in both Civil and Air Force handbooks as there are some differences, and although both books specify a sequence to be followed, in practice USA content in the Remarks Group has both inconsistent sequencing and a free format for much of the abbreviated codes; together those issues mean that my understanding of USA Remarks content is a continuing challenge for me and a significant amount of work remains before I can release an update for Remarks Group handling. I believe I have cracked all but one (inconsistency in recognizing pressure tendency segment) of the outstanding Canadian Remarks Group issues in my testing environment ready for next release (not yet in zip).
Meanwhile you cannot yet view the source on Paul's site to see if he uses the same version as in the zip, this is partly because there may sometimes be a little delay between my release of an update to remarks group processing and his adoption or I may release a script to him for testing in advance of updating the zip on this post.
I can guarantee that not
everything that will ever be included in a METAR will be recognized by my decoder. However, I have probably gone further than is reasonable in covering a very wide range of possible METAR element combinations, including some misformed content. Remember, the TAC format for METAR that my suite addresses is not precisely specified and in some places almost any text may be be found. As I can't therefore cover all possibilities, from time to time there will be some text included that I have not anticipated, or an observer will input a METAR that does not obey the published guidance so I may not have anticipated that particular content. To help me any failures to understand any METAR content for Canada and USA are logged at http://www.komokaweather.com/metar/failed_to_decode_metar.log
. If I can spot an easy obvious improvement for coping with something in that log, I issue an update (see zip below). Ideally, people elsewhere in the world would be producing similar logs to help me to check how well my decoder deals with their local METAR. I have tested my decoder against METAR issued by around 220 different aerodromes around the world,
but I do not have the time to do lots of testing and a key point about METAR is what is issued at the time of my testing may be totally different to what is issued one hour/day/week/month later!
Read the pdf documentation for full background on my project, but essentially to use my suite everything bar the PDF goes into same directory on your web site. Then as explained in pdf, you call a function specifying a raw METAR as the first parameter, and the function returns an array from which you extract anything you want to see.Feb 2018
: EDITS to ZIP - For full version history, see end of each script as I have brought the version history right up to date now. Predominately recent changes are just format improvements to the outputs from the decoder scripts. EDIT ends.
29 Jan 2018 EDIT - Just a few more edits to last year's version of suite, principally for decoding of remark group for Canada based on its use in Komoka (as already highlighted), but also some corrections to other functions (see version history in files). One key improvement is to the output for pressure, sea level pressure is now clearly identified separated from any altimeter pressure. (That is one of the key advantages of my decoder if you use it to get a pressure reading to compare against your own personal weather station). EDIT ends.
30 Dec EDIT - Release update at end of 2017, consolidated the improvements and corrections that I have been doing since PaulMy started using my decoder prior to 8 November when I created this post, as his live running identified a few problems. I have had other priorities in my life since then, so can't do very much now. EDIT ends.
[DEC 2017 - Various edits that are just correcting my spelling errors and changing the paragraph order from that I used when I made this post originally; not releasing any updates yet]
November 2017 - Original post - original completion of my project with an update to my suite so it will cover more possible content and more PHP versions.