Calculate max sun angle each day at my location

111 views
Skip to first unread message

bgra...@umw.edu

unread,
Mar 21, 2025, 6:58:03 PM3/21/25
to weewx-user
Hello,
I would like to display (Standard skin) the max sun angle for the day at my latitude. Not being a programmer, I’m not sure how to do this. I have a solar hot water heater.
My system is an RPI5 with pip install of the latest weewx.
Thanks in advance.
Cheers,
Bob

michael.k...@gmx.at

unread,
Mar 22, 2025, 4:29:23 AM3/22/25
to weewx-user

Note: ephem has to be installed 

Assuming the maximum angle of the sun is really when it transits, then the maximum height can be calculated like this: set almanac time to transit time, and then calculate the altitude for the sun at this time:
$almanac(almanac_time=$almanac.sun.transit.raw).sun.alt


But as far as I know, $almanac.sun.transit doesn't yield today's transit, but next transit, which may be tomorrow, if the current time is after today's transit. For today's transit, you calculate the next transit from today's start of day, and then calculate the sun's altitude for this time:
$almanac(almanac_time=$almanac(almanac_time=$day.start.raw).sun.transit.raw).sun.alt


Then put the above code in a template of your choice (which may arise your next question) in a way, it survives a WeeWX update/skin update.
You also may want to format the result in a way, it doesn't show a dozen of decimals and add degrees(°), which requires additional code.

There may be other and/or easier ways. 

bgra...@umw.edu

unread,
Mar 22, 2025, 2:53:08 PM3/22/25
to weewx-user
Thanks, Michael, I’ll work with your suggestion but I’m not sure how to put this in a template other than the Standard skin. I guess this would be code in another file that would be called from Standard? Sorry, I’m not very Python literate—only enough to get myself into trouble.
Cheers,
Bob

michael.k...@gmx.at

unread,
Mar 24, 2025, 4:01:47 PM3/24/25
to weewx-user
Just put the code in a template and see, if it does, what you want. Anythings else: step by step :)
Reply all
Reply to author
Forward
0 new messages