Appendix¶
Aggregation types¶
Aggregation type | Meaning |
avg | The average value in the aggregation period. |
avg_ge(val) | The number of days where the average value is greater than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
avg_le(val) | The number of days where the average value is less than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
count | The number of non-null values in the aggregation period. |
diff | The difference between the last and first value in the aggregation period. |
exists | Returns True if the observation type exists in the database. |
first | The first non-null value in the aggregation period. |
firsttime | The time of the first non-null value in the aggregation period. |
gustdir | The direction of the max gust in the aggregation period. |
has_data | Returns True if the observation type exists in the database and is non-null. |
last | The last non-null value in the aggregation period. |
lasttime | The time of the last non-null value in the aggregation period. |
max | The maximum value in the aggregation period. |
maxmin | The maximum daily minimum in the aggregation period. Aggregation period must be one day or longer. |
maxmintime | The time of the maximum daily minimum. |
maxsum | The maximum daily sum in the aggregation period. Aggregation period must be one day or longer. |
maxsumtime | The time of the maximum daily sum. |
maxtime | The time of the maximum value. |
max_ge(val) | The number of days where the maximum value is greater than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
max_le(val) | The number of days where the maximum value is less than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
meanmax | The average daily maximum in the aggregation period. Aggregation period must be one day or longer. |
meanmin | The average daily minimum in the aggregation period. Aggregation period must be one day or longer. |
min | The minimum value in the aggregation period. |
minmax | The minimum daily maximum in the aggregation period. Aggregation period must be one day or longer. |
minmaxtime | The time of the minimum daily maximum. |
minsum | The minimum daily sum in the aggregation period. Aggregation period must be one day or longer. |
minsumtime | The time of the minimum daily sum. |
mintime | The time of the minimum value. |
min_ge(val) | The number of days where the minimum value is greater than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
min_le(val) | The number of days where the minimum value is less than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
not_null | Returns truthy if any value over the aggregation period is non-null. |
rms | The root mean square value in the aggregation period. |
sum | The sum of values in the aggregation period. |
sum_ge(val) | The number of days where the sum of value is greater than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
sum_le(val) | The number of days where the sum of value is less than or equal to val. Aggregation period must be one day or longer. The argument val is a ValueTuple. |
tderiv | The time derivative between the last and first value in the aggregation period. This is the difference in value divided by the difference in time. |
vecavg | The vector average speed in the aggregation period. |
vecdir | The vector averaged direction during the aggregation period. |
Units¶
WeeWX offers three different unit systems:
Name | Encoded value | Note |
US | 0x01 | U.S. Customary |
METRICWX | 0x11 | Metric, with rain related measurements in mm and speeds in m/s |
METRIC | 0x10 | Metric, with rain related measurements in cm and speeds in km/hr |
The table below lists all the unit groups, their members, which units are options for the group, and what the defaults are for each standard unit system.
Group | Members | Unit options | US | METRICWX | METRIC |
group_altitude | altitude cloudbase |
foot meter |
foot | meter | meter |
group_amp | amp | amp | amp | amp | |
group_boolean | boolean | boolean | boolean | boolean | |
group_concentration | no2 pm1_0 pm2_5 pm10_0 |
microgram_per_meter_cubed | microgram_per_meter_cubed | microgram_per_meter_cubed | microgram_per_meter_cubed |
group_count | leafWet1 leafWet2 lightning_disturber_count lightning_noise_count lightning_strike_count |
count | count | count | count |
group_data | byte bit |
byte | byte | byte | |
group_db | noise | dB | dB | dB | dB |
group_delta_time | daySunshineDur rainDur sunshineDurDoc |
second minute hour day |
second | second | second |
group_degree_day | cooldeg heatdeg growdeg |
degree_F_day degree_C_day |
degree_F_day | degree_C_day | degree_C_day |
group_direction | gustdir vecdir windDir windGustDir |
degree_compass | degree_compass | degree_compass | degree_compass |
group_distance | windrun lightning_distance |
mile km |
mile | km | km |
group_energy | kilowatt_hour mega_joule watt_hour watt_second |
watt_hour | watt_hour | watt_hour | |
group_energy2 | kilowatt_hour watt_hour watt_second |
watt_second | watt_second | watt_second | |
group_fraction | co co2 nh3 o3 pb so2 |
ppm | ppm | ppm | ppm |
group_frequency | hertz | hertz | hertz | hertz | |
group_illuminance | illuminance | lux | lux | lux | lux |
group_interval | interval | minute | minute | minute | minute |
group_length | inch cm |
inch | cm | cm | |
group_moisture | soilMoist1 soilMoist2 soilMoist3 soilMoist4 |
centibar | centibar | centibar | centibar |
group_percent |
cloudcover extraHumid1 extraHumid2 inHumidity outHumidity pop rxCheckPercent snowMoisture |
percent | percent | percent | percent |
group_power | kilowatt watt |
watt | watt | watt | |
group_pressure |
barometer altimeter pressure |
inHg mbar hPa kPa |
inHg | mbar | mbar |
group_pressurerate |
barometerRate altimeterRate pressureRate |
inHg_per_hour mbar_per_hour hPa_per_hour kPa_per_hour |
inHg_per_hour | mbar_per_hour | mbar_per_hour |
group_radiation | maxSolarRad radiation |
watt_per_meter_squared | watt_per_meter_squared | watt_per_meter_squared | watt_per_meter_squared |
group_rain | rain ET hail snowDepth snowRate |
inch cm mm |
inch | mm | cm |
group_rainrate | rainRate hailRate |
inch_per_hour cm_per_hour mm_per_hour |
inch_per_hour | mm_per_hour | cm_per_hour |
group_speed | wind windGust windSpeed windgustvec windvec |
mile_per_hour km_per_hour knot meter_per_second beaufort |
mile_per_hour | meter_per_second | km_per_hour |
group_speed2 | rms vecavg |
mile_per_hour2 km_per_hour2 knot2 meter_per_second2 |
mile_per_hour2 | meter_per_second2 | km_per_hour2 |
group_temperature | appTemp dewpoint extraTemp1 extraTemp2 extraTemp3 heatindex heatingTemp humidex inTemp leafTemp1 leafTemp2 outTemp soilTemp1 soilTemp2 soilTemp3 soilTemp4 windchill THSW |
degree_C degree_F degree_E degree_K |
degree_F | degree_C | degree_C |
group_time | dateTime | unix_epoch dublin_jd |
unix_epoch | unix_epoch | unix_epoch |
group_uv | UV | uv_index | uv_index | uv_index | uv_index |
group_volt | consBatteryVoltage heatingVoltage referenceVoltage supplyVoltage |
volt | volt | volt | volt |
group_volume | cubic_foot gallon liter |
gallon | liter | liter | |
group_NONE | NONE | NONE | NONE | NONE | NONE |
Durations¶
Rather than give a value in seconds, many durations can be expressed using a shorthand notation.
For example, in a skin configuration file skin.conf
, a value for aggregate_interval
can be
given as either
aggregate_interval = 3600
or
aggregate_interval = 1h
The same notation can be used in trends. For example:
<p>Barometer trend over the last 2 hours: $trend(time_delta='2h').barometer</p>
Here is a summary of the notation:
Example | Meaning |
---|---|
10800 |
3 hours |
3h |
3 hours |
1d |
1 day |
2w |
2 weeks |
1m |
1 month |
1y |
1 year |
hour |
Synonym for 1h |
day |
Synonym for 1d |
week |
Synonym for 1w |
month |
Synonym for 1m |
year |
Synonym for 1y |
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")
Class ValueHelper
¶
Class ValueHelper
contains all the information necessary to do
the proper formatting of a value, including a unit label.
Instance attribute¶
ValueHelper.value_t¶
Returns the ValueTuple
instance held internally.
Instance methods¶
ValueHelper.str()¶
Formats the value as a string, including a unit label, and returns it.
ValueHelper.format(format_string=None, None_string=None, add_label=True, localize=True)¶
Format the value as a string, using various specified options, and return it. Unless otherwise specified, a label is included.
Its parameters:
-
format_string
A string to be used for formatting. It must include one, and only one, format specifier. -
None_string
In the event of a value of PythonNone
, this string will be substituted. IfNone
, then a default string fromskin.conf
will be used. -
add_label
If truthy, then an appropriate unit label will be attached. Otherwise, no label is attached. -
localize
If truthy, then the results will be localized. For example, in some locales, a comma will be used as the decimal specifier.