metaf2xml: manual for metaf2xml::src2raw 2.9

NAME

metaf2xml::src2raw - convert data from different sources to standard format

SYNOPSIS

 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();

DESCRIPTION

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.

ABBREVIATIONS

noaa

National Oceanic and Atmospheric Administration

nws

the National Weather Service department of the NOAA

iws

the Internet Weather Source of the NWS

addsds

the Text Data Server API service of the Aviation Weather Center of the NOAA

cod

College of DuPage

isu

Iowa State University

SUBROUTINES/METHODS

start_file($format,$suppressNIL,$wmo_prefix)

This function must be called before processing a file. The following arguments are expected:

format

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

suppressNIL

if true, messages that only contain NIL are not returned

wmo_prefix

which parts of the WMO header (T1T2A1A2[ii] CCCC YYGGgg [BBB]) to prepend to each message:

0

(no header) (default)

1

T1T2 (data type):

SA

aviation routine reports (METAR)

SP

special aviation weather reports (SPECI)

FT

aerodrome forecast (TAF) with forecast period >= 12 hours

FC

aerodrome forecast (TAF) with forecast period < 12 hours

SM

surface data (SYNOP) at main hours (00:00, 06:00, 12:00, 18:00 UTC)

SI

surface data (SYNOP) at intermediate (main + 3) hours

SN

surface data (SYNOP) at non-standard (other than main and intermediate) hours

SS

buoy observations (BUOY)

UD

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.

next_line($line)

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:

line

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).

start_bufr($wmo_prefix,$file_name,$filter_cb)

This function must be called to start processing a BUFR file. The following arguments are expected:

wmo_prefix

Like the argument wmo_prefix for start_file(), except for the possible values returned for T1T2:

IS

observational surface/sea level data encoded as BUFR

if T1T2A1 is ISM/ISI/ISN: surface data (SYNOP) at main/intermediate/non-standard hours

IO

observational oceanographic/limnographic data encoded as BUFR

if T1T2A1 is IOB: buoy observations (BUOY)

IU

observational upper-air data encoded as BUFR

if T1T2A1 is IUA: aircraft reports (AMDAR)

file_name

file name for a (plain) file with binary BUFR message.

filter_cb

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:

false

message should not be filtered out

true

message should be filtered out

The function will return 0 on success, or a string describing the error which occurred.

next_bufr($get_more)

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:

get_more

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).

DEPENDENCIES

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.

SEE ALSO

metaf2xml::parser(3pm), metafsrc2raw(1), metaf(1), https://metaf2xml.sourceforge.io/

copyright (c) 2011-2023 metaf2xml @ SourceForge.net Logo

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/.