metafsrc2raw.pl - convert data from different sources to standard format
metafsrc2raw.pl -F<format> [OPTION]... [FILE]...
This script is an example interface to the Perl module metaf2xml::src2raw
. It converts METAR, TAF, SYNOP, BUOY or AMDAR information provided in files on various public Internet servers to messages delimited by a newline and in the format specified by the WMO Manual No. 306, without modifications due to distribution like providing the initial part of messages only once for several messages, or appending an "=" (equal sign) to terminate a message. It prepends parts of the WMO header according to the option -H. The output can then be used by the module metaf2xml::parser
.
If no input files are specified, then the standard input is read.
Additionally, files with binary BUFR messages can be decoded (using the Perl module Geo::BUFR
) to a text format which can be processed by the module metaf2xml::parser
.
The Perl module metaf2xml::src2raw
is required.
print version of metafsrc2raw.pl and exit
origin of the input data: for allowed values and their meaning see the parameter "format" in metaf2xml::src2raw(3pm). Additionally, format can be bufr
.
suppress duplicate messages
suppress messages that only contain NIL
which parts of the WMO header (T1T2A1A2[ii] CCCC YYGGgg [BBB]
) to prepend to each message: for allowed values and their meaning see the parameter "wmo_prefix" in metaf2xml::src2raw(3pm)
Names for input files can be given as arguments. If no arguments are given, input is read from standard input.
If an invalid option was provided, or the option -F was not provided, or the function start_file() in metaf2xml::src2raw(3pm) returned an error, the script will exit with status 1, otherwise it will exit with status 0.
Parse SYNOP messages from NOAA/NWS, suppressing NIL messages and duplicates:
metafsrc2raw.pl -DNF synop_nws << "EOF"
####018000228####
SMPY01 SGAS 060600
AAXX 06064
86134 32970 02402 10250 20235 40105 56005=
86297 NIL=
86134 32970 02402 10250 20235 40105 56005=
86218 32970 01810 10240 20209 40103 58011=
####018000158####
SMFG01 SOCA 060600
AAXX 06064
81405 01259 60505 10241 20229 30105 40114 60071 76086 86200
333 32024 55048 60067 58002 70098 82705 86813
555 69905=####018000118####
SMCS01 MROC 060600
AAXX 06064
78762 32970 00915 10220 20160 39094 40101 57005
333 10280 20193 30/// 59006=
EOF
results in:
AAXX 06064 86134 32970 02402 10250 20235 40105 56005
AAXX 06064 86218 32970 01810 10240 20209 40103 58011
AAXX 06064 81405 01259 60505 10241 20229 30105 40114 60071 76086 86200 333 32024 55048 60067 58002 70098 82705 86813 555 69905
AAXX 06064 78762 32970 00915 10220 20160 39094 40101 57005 333 10280 20193 30/// 59006
Parse METAR/SPECI messages from the College of DuPage with the WMO header TTAAII
prepended:
metafsrc2raw.pl -F metaf_cod -H2 << "EOF"
355
SAUS70 KWBC 161200
METAR
KDZJ 161146Z AUTO 00000KT 10SM -DZ SCT002 BKN075 OVC100 09/09
A3013 RMK AO2=
KLDJ 161150Z AUTO 00000KT 10SM CLR 03/M01 A3027 RMK AO2=
KMLJ 161145Z AUTO 00000KT 4SM RA BKN005 BKN012 OVC033 12/12 A3017
RMK AO2=
351
SPCN51 CWAO 161254
SPECI CWCL 161254Z AUTO 19008KT 9SM FEW008 FEW015 BKN027 BKN043
M04/M06 A2947=
EOF
results in:
SAUS70 METAR KDZJ 161146Z AUTO 00000KT 10SM -DZ SCT002 BKN075 OVC100 09/09 A3013 RMK AO2
SAUS70 METAR KLDJ 161150Z AUTO 00000KT 10SM CLR 03/M01 A3027 RMK AO2
SAUS70 METAR KMLJ 161145Z AUTO 00000KT 4SM RA BKN005 BKN012 OVC033 12/12 A3017 RMK AO2
SPCN51 SPECI CWCL 161254Z AUTO 19008KT 9SM FEW008 FEW015 BKN027 BKN043 M04/M06 A2947
metaf2xml::parser(3pm), metaf2xml::src2raw(3pm), https://metaf2xml.sourceforge.io/
copyright (c) 2009-2020 metaf2xml @
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.