README for wreport Python bindings

wreport provides access to weather data in BUFR and CREX formats.

Contents

The wreport API

The 'wreport' module has a few global methods:

and several classes, documented in their own sections.

wreport.Var

Var holds a measured value, which can be integer, float or string, and a wreport.Varinfo with all available information (description, unit, precision, ...) related to it.

Var objects can be created from a wreport.Varinfo object, and an optional value. Omitting the value creates an unset variable.

Examples:

v = wreport.Var(table["B12101"], 32.5)
# v.info returns detailed informations about the variable in a Varinfo object.
print("%s: %s %s %s" % (v.code, str(v), v.info.unit, v.info.desc))

Members

code
variable code
enq

enq() -> str|float|long

get the value of the variable, as int, float or str according the variable definition

enqc

enqc() -> str

get the value of the variable, as a str

enqd

enqd() -> float

get the value of the variable, as a float

enqi

enqi() -> long

get the value of the variable, as an int

format

format(default="") -> str

return a string with the formatted value of the variable

get

get(default=None) -> str|float|long|default

get the value of the variable, with a default if it is unset

info
Varinfo for this variable
isset
true if the value is set

wreport.Varinfo

Varinfo object holds all possible information about a variable, such as its measurement unit, description and number of significant digits.

Varinfo objects cannot be instantiated directly, and are created by querying wreport.Vartable objects.

Members

bit_len
number of bits used to encode the value in BUFR
bit_ref
reference value added after scaling, for BUFR decoding
code
variable code
desc
description
len
number of significant digits
scale
scale of the value as a power of 10
type
return a string describing the type of the variable (string, binary, integer, decimal)
unit
measurement unit

wreport.Vartable

Collection of Varinfo objects indexed by WMO BUFR/CREX table B code.

A Vartable is instantiated by the name (without extension) of the table file installed in wreport's data directory (normally, /usr/share/wreport/):

table = wreport.Vartable("B0000000000000023000")
print(table["B12101"].desc)

for i in table:
    print(i.code, i.desc)

Members

get_bufr
Vartable.get_bufr(basename=None, originating_centre=0, originating_subcentre=0,
master_table_number=0, master_table_version_number=None, master_table_version_number_local=0) -> wreport.Vartable

Look up a table B file using the information given, then load BUFR information from it.

You need to provide either basename or master_table_version_number.

get_crex
Vartable.get_crex(basename=None, edition_number=2,
originating_centre=0, originating_subcentre=0, master_table_number=0, master_table_version_number=None, master_table_version_number_bufr=None, master_table_version_number_local=0) -> wreport.Vartable

Look up a table B file using the information given, then load CREX information from it.

You need to provide either basename or master_table_version_number or master_table_version_number_bufr.

load_bufr

Vartable.load_bufr(pathname) -> wreport.Vartable

Load BUFR information from a Table B file and return it as a wreport.Vartable.

load_crex

Vartable.load_crex(pathname) -> wreport.Vartable

Load CREX information from a Table B file and return it as a wreport.Vartable.

pathname
name of the table