Menu

#36 metar

none
pending
None
5
2026-03-24
2026-03-11
Anonymous
No

I have used your program for years and always wanted to ask if it is possible to feed a text file of metar messages or whatever via the command line in the same manner as I would if I was using metar id's etc. I am on Debian. Thanks for your years of work. Phil

Discussion

  • metaf2xml

    metaf2xml - 2026-03-14
    • status: open --> accepted
    • assigned_to: metaf2xml
     
  • metaf2xml

    metaf2xml - 2026-03-14
    • status: accepted --> pending
     
  • metaf2xml

    metaf2xml - 2026-03-14

    Hi Phil,

    happy to hear that this project is useful for you.

    If you mean the script metaf.pl, then no, it can't process files with messages. But if you already have the messages, you can use metafsrc2raw.pl and metaf2xml.pl, and they support this.

    If you have files from some internet server, e.g. METAR cycle files from NOAA IWS, or METAR/SYNOP/... files from NOAA NWS, you can process them with metafsrc2raw.pl by giving the file name(s) as argument on the command line. The processed messages are written to standard output and have the correct format as input for metaf2xml.pl.

    If the file already contains data with the format required by metaf2xml.pl, i.e. one METAR/SYNOP/... message per line without any leading or trailing text , the script can be used with the option -f to specify the file name. If you have several files, use the command cat and pipe its output to the script omitting the option -f. With the option -o- (the minus sign), its output is written to standard output.

    The last step is to transform the XML to text or HTML in one of the languages supported by the project. For this you can use the program xsltproc. The language English for the output can be requested with the option -stringparam lang en. The first argument to the program is the XSL script to use. For the detailed output use metaf-text.xsl for text, or metaf-html.xsl for HTML. If you want the summary view of the messages, use metaf-sum-text.xsl or metaf-sum-html.xsl instead, respectively. The second argument specifies the input, and should therefore be - (minus).

    To put all this together, the outputs should be connected to the inputs via UNIX pipes. E.g. to process NOAA NWS METAR files to get text output in English:

    metafsrc2raw.pl -Fmetaf_nws [FILE]... | metaf2xml.pl -o- | xsltproc -stringparam lang en metaf-text.xsl -
    

    If you have just one input file which contains METAR messages with the format required by metaf2xml.pl, this simplifies to:

    metaf2xml.pl -o- < [FILE] | xsltproc -stringparam lang en metaf-text.xsl -
    

    Maybe it is helpful to put all this into a one-liner shell script.

    If you provide the first 5 or so lines of one of your input files, or an example URL four your source, I could be more specific what the best way to process them would be. If the messages have leading or trailing text, additional text processing programs like sed may be required.

    Hope this helps.

    Kind regards
    Thomas

     
  • Anonymous

    Anonymous - 2026-03-24

    Hey Thomas Sorry for the delay in getting back to you. I read your response when you posted it and appreciate the quick and thorough answer. Unfortunately I seem to be running into some permission problems on my machine when I implement your instructions. Then after way too much time I put it aside and forgot to respond to you!
    I am just now going to look at what I have done to my setup. I have a horrible habit of working in root. That is the problem with being self taught. I will let you know when I get it straightened out. Thanks Phil

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB