Skip to content

Class ValueTuple

A value, along with the unit it is in, can be represented by a 3-way tuple called a "value tuple". They are used throughout WeeWX. All WeeWX routines can accept a simple unadorned 3-way tuple as a value tuple, but they return the type ValueTuple. It is useful because its contents can be accessed using named attributes. You can think of it as a unit-aware value, useful for converting to and from other units.

The following attributes, and their index, are present:

Index Attribute Meaning
0 value The data value(s). Can be a series (e.g., [20.2, 23.2, ...]) or a scalar (e.g., 20.2)
1 unit The unit it is in ("degree_C")
2 group The unit group ("group_temperature")

It is valid to have a datum value of None.

It is also valid to have a unit type of None (meaning there is no information about the unit the value is in). In this case, you won't be able to convert it to another unit.

Here are some examples:

from weewx.units import ValueTuple

freezing_vt = ValueTuple(0.0, "degree_C", "group_temperature")
body_temperature_vt = ValueTuple(98.6, "degree_F", "group_temperature")
station_altitude_vt = ValueTuple(120.0, "meter", "group_altitude")