change rain height in cm to rain quantity in liters per square meter

108 views
Skip to first unread message

Stefan Gliessmann

unread,
May 30, 2025, 3:51:55 AM5/30/25
to weewx-user
Dear all,

I always struggle when I want to change the unit of a certain entity.
This time, it is rain and rain rate. The WeeWX default is cm and cm/h, respectively.
I would like to change it to l / m2 and l /m2 / h.
The calculation seems straight forward as 1 mm rain = 1 liter / m2 rain and its rate accordingly as 1 mm / h = 1 l/(m2 h).
Do I add this as a new label in weewx.conf under [Units] or do I add a new unit in extensions.py as per https://weewx.com/docs/5.1/custom/units/ ?

Any help / hint would be highly appreciated!

TIA,
Stefan 

Stefan Gliessmann

unread,
May 30, 2025, 6:20:33 AM5/30/25
to weewx-user
I probably should add that I use the Belchertown skin ;)
and would like to display the rain & rate there in l / m2 and l / m2 / h with the station_observations.

gjr80

unread,
May 31, 2025, 10:10:08 PM5/31/25
to weewx-user
Can't help you with the Belchertown specifics, but assuming you want WeeWX to support l/m2 and l/m2/h for rain and rain rate, at a minimum you will need to add appropriate entries to weewx.units.conversionDict.  This cannot be done through weewx.conf and needs to be done via some python code. This can be done in a number of ways, but in your case adding some entries to extensions.py is probably easiest and quickest. You want something like step 4 here. Note that as you are adding a new unit to group_rain and group_rainrate you will need to add entries to the existing conversionDict entries for each group_rain and group_rainrate unit, ie: 'mm', 'cm', 'inch', 'mm_per_hour', 'cm_per_hour' and 'inch_per_hour'.

You could also add default formats and unit labels for your new units to weewx.units.default_unit_format_dict and weewx.units.default_unit_label_dict respectively. This is not essential to use your new units in WeeWX reports and plots, not sure about Belchertown though.

Gary

Karen K

unread,
Jun 1, 2025, 12:47:30 AM6/1/25
to weewx-user
As you already said, mm and l/m^2 have the same values. So you could set up rain to mm and change the label for mm to " l/m^2". This can be done in weewx.conf

michael.k...@gmx.at

unread,
Jun 1, 2025, 2:37:14 PM6/1/25
to weewx-user
I don't get the point why one would want to use m³/m² which cancels to m in the first place.

vince

unread,
Jun 1, 2025, 3:03:25 PM6/1/25
to weewx-user
Volume per unit of area to me is an obvious point.   For example how many liters of water fell on their lawn or roof.

michael.k...@gmx.at

unread,
Jun 1, 2025, 3:08:42 PM6/1/25
to weewx-user
For me length is an obvious point. For example, how many mm of water fell on the lawn or the roof. :D
Either way, l/m² vs. mm: it is exactly the same. With l/m² you specify a length unit more commonly known as mm.
Reply all
Reply to author
Forward
0 new messages