metaf2xml::src2raw - convert data from different sources to standard format
use metaf2xml::src2raw 2.009;
metaf2xml::src2raw::start_file($format,$suppressNIL,$wmo_prefix);
while (1) {
my $line = <>;
@msgs = metaf2xml::src2raw::next_line($line);
# process contents of @msgs ...
last unless defined $line;
}
metaf2xml::src2raw::start_bufr($wmo_prefix,$file_name,$filter_cb);
while (1) {
my ($hdr, $data, $desc, $assoc, $msg) = next_bufr(1);
last unless defined $hdr;
# process returned data ...
}
next_bufr();
This Perl module contains functions to convert 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 argument wmo_prefix
. The output can then be used by the module metaf2xml::parser
.
National Oceanic and Atmospheric Administration
the National Weather Service department of the NOAA
the Internet Weather Source of the NWS
the Text Data Server API service of the Aviation Weather Center of the NOAA
College of DuPage
Iowa State University
This function must be called before processing a file. The following arguments are expected:
origin of the input data: metar_cycle_iws, staf_cycle_iws, taf_cycle_iws, metaf_nws, metaf_cod, metaf_isu, synop_nws, synop_cod, synop_isu, buoy_nws, buoy_isu, amdar_nws, amdar_isu
if true, messages that only contain NIL
are not returned
which parts of the WMO header (T1T2A1A2[ii] CCCC YYGGgg [BBB]
) to prepend to each message:
0
(no header) (default)
1
T1T2
(data type):
aviation routine reports (METAR)
special aviation weather reports (SPECI)
aerodrome forecast (TAF) with forecast period >= 12 hours
aerodrome forecast (TAF) with forecast period < 12 hours
surface data (SYNOP) at main hours (00:00, 06:00, 12:00, 18:00 UTC)
surface data (SYNOP) at intermediate (main + 3) hours
surface data (SYNOP) at non-standard (other than main and intermediate) hours
buoy observations (BUOY)
aircraft reports (AMDAR)
2
T1T2A1A2[ii]
(like 1
plus geographical/data type/time designators plus 2-digit bulletin differentiator (optional))
3
T1T2A1A2[ii] CCCC
(like 2
plus station or centre originating or compiling the bulletin)
4
T1T2A1A2[ii] CCCC YYGGgg
(like 3
plus report observation/transmission/compilation time (UTC))
5
T1T2A1A2[ii] CCCC YYGGgg [BBB]
(like 4
plus indicator for additional/corrected/amended bulletins (optional))
The function will return 0 on success, or a string describing the error which occurred.
This function must be called for each line in a file and once with the argument undef
at the end of file.
The following arguments are expected:
string that contains a line from the file, or undef
after the last line of the file
The return value is an array of 0, 1 or 2 messages, or an array with one element which is undef
if start_file() was not called (never, or after next_line() was called with undef
).
This function must be called to start processing a BUFR file. The following arguments are expected:
Like the argument wmo_prefix
for start_file(), except for the possible values returned for T1T2
:
observational surface/sea level data encoded as BUFR
if T1T2A1
is ISM
/ISI
/ISN
: surface data (SYNOP) at main/intermediate/non-standard hours
observational oceanographic/limnographic data encoded as BUFR
if T1T2A1
is IOB
: buoy observations (BUOY)
observational upper-air data encoded as BUFR
if T1T2A1
is IUA
: aircraft reports (AMDAR)
file name for a (plain) file with binary BUFR message.
reference to a filter callback function
The callback function is invoked for each BUFR message before decoding BUFR section 4 (Data Section). The following argument is passed:
bufr
the current Geo::BUFR
object
The callback function should return one the following values:
message should not be filtered out
message should be filtered out
The function will return 0 on success, or a string describing the error which occurred.
This function must be called for each line in a file and once with an value of false to end processing.
The following arguments are expected:
false if processing of current file should be ended, true otherwise
The returned value is a decoded BUFR message, or undef
if start_bufr() was not called (never, or after next_bufr() was called with false).
If binary BUFR messages are to be processed, the Perl module Geo::BUFR
with version 1.37+ and ECC BUFR table files from ECWMF are required.
metaf2xml::parser(3pm), metafsrc2raw(1), metaf(1), https://metaf2xml.sourceforge.io/
copyright (c) 2011-2023 metaf2xml @
This file is part of metaf2xml.
metaf2xml 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.
metaf2xml 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 metaf2xml. If not, see https://www.gnu.org/licenses/.