converting archive/loop data to a desired unit system

47 views
Skip to first unread message

Vince Skahan

unread,
Sep 8, 2024, 8:52:39 PM9/8/24
to weewx-development
I'm working on an app that reads the archive and loop data as it comes in and emits JSON-formatted output.  I want to make sure to always convert that data to metric values.

Is there a weewx-ish standard way to take a speed and always generate mps ?  Or a temperature and always emit degC, and so on ?

I didn't see any mph=>mps conversion routines but that's easy of course.  What I wasn't certain on was how to decide from the packet/record if that conversion needed to be done, given how configurable weewx is for setting unit systems on a field by field basis ?

Any suggestions or examples I might look at ?

Tom Keffer

unread,
Sep 8, 2024, 9:31:45 PM9/8/24
to Vince Skahan, weewx-development
I'm not exactly sure what you want to do, but take a look through the convenience functions at the bottom of weewx/units.py. It may be as simple as:

record_metric = weewx.units.to_METRICWX(record)

But, if your goal is to emit JSON formatted output, be sure to look through the wiki article Tags for series. WeeWX may be able to do what you want already!

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/47b87add-2c44-40cc-9979-6c2e18a36d35n%40googlegroups.com.

Vince Skahan

unread,
Sep 8, 2024, 9:55:10 PM9/8/24
to weewx-development
What I'm doing is writing a service/extension to broadcast the LOOP and Archive data in a particular JSON format to be compliant with the WeatherFlow UDP API (link) that I'm well familiar with.  The goal is to permit any weewx user, not just a WeatherFlow station type user, to use the very cool wfpiconsole app and dashboard (link) that already exists.

Short description is the console is pretty slick, so I'm trying to make it available to all weewx users including me of course :-)

The WeatherFlow gear emits its UDP messages in metric units, so I need to convert weewx data to metric only if needed.    If the weewx LOOP and archive data is in the correct units already, then I don't want to needlessly mess up an already good value.   If it's not in metric, I need to convert it to metric and match the WF UDP API expectations.

METRICWX is probably pretty close to the units I need.  I'll give it a try.  Thanks.
Reply all
Reply to author
Forward
0 new messages