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() -> Union[str, float, int]

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

enqa

enqa(code: str) -> Optional[wreport.Var]

get the variable for the attribute with the given code, or None if not found

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

get the value of the variable, as an int

format

format(default: str=) -> str

return a string with the formatted value of the variable

get

get(default: Any=None) -> Union[str, float, long, Any]

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

get_attrs

get_attrs() -> List[wreport.Var]

get the attributes of this variable

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

seta(var: wreport.Var)

set an attribute in the variable

unseta

unseta(code: str)

unset the given attribute from the variable

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

get_bufr(basename: str=None, originating_centre: int=0, originating_subcentre: int=0,master_table_number: int=0, master_table_version_number: int=None, master_table_version_number_local: int=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

get_crex(basename: str=None, edition_number=2, originating_centre: int=0, originating_subcentre: int=0,master_table_number: int=0, master_table_version_number: int=None,master_table_version_number_bufr: int=None, master_table_version_number_local: int=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

load_bufr(pathname: str) -> wreport.Vartable

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

load_crex

load_crex(pathname: str) -> wreport.Vartable

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

pathname
name of the table