Convert temperature differences between degree_F and degree_C

34 views
Skip to first unread message

Karen K

unread,
Nov 20, 2020, 2:22:41 PM11/20/20
to weewx-development
I write the driver for Wetternetz Sachsen, and I have to upload some temperature differences there. 

And I wonder what is the intended way to convert those differences from one unit to another.

The template for a restful service driver says that I have to put code to read or calculate additional values into the "get_record" function, where the archive unit system is used. The conversion to the target unit system I have to put into the "format_url" function. 

Temperatures and temperature differences are converted in a different way because of the offset between the units.

But I found no "group_temperaturediff" or "group_temperaturerate" unit group, that could cover that. 

Because I did not know I put the code to read the start and end temperature of the given interval into the "get_record" function. No difference is calculated there. In "format_url" function first the data record is converted into the target unit system and then the temperature difference is calculated. 

Shall I do so or is there a better way?

Tom Keffer

unread,
Nov 20, 2020, 6:56:41 PM11/20/20
to Karen K, weewx-development
As you've discovered, temperature conversion functions are not distributive. That is, F_to_C(68F - 50F) is not equal to F_to_C(68F) - F_to_C(50F).

No, there is no group_temperaturediff.

The tag $trend has a problem similar to yours. It needs to calculate the difference between the temperature some time ago, and the current temperature. It solves the problem the same way you are: perform the conversion just before use. 

I think your approach is very sensible.

-tk

--
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/d0f8e51c-9474-4287-b067-aae6524fa21cn%40googlegroups.com.

Karen K

unread,
Nov 21, 2020, 4:58:40 PM11/21/20
to weewx-development
Thank you for clarification.
Reply all
Reply to author
Forward
0 new messages