Custom Search Min/Max/Avg during daylight hours

84 views
Skip to first unread message

Russell van vlack

unread,
Mar 27, 2021, 6:59:58 PM3/27/21
to weewx-user
I want to be able to find the min/max/avg value for various weather observations (uv index for example) but only during the time when the sun is up. I am struggling to write a custom search item for that and wonder who could get it started for me or lead me in a good direction.

If it is before sunrise for the day, the min/max/avg would all be null or undefined or none... something like that.
If it is after sunrise but before sunset, the min/max/avg would be calculated from sunrise to current time.
If it is after both sunrise and sunset, the min/max/avg would be calculated for times between the sunrise and sunset times only.

Is it possible?

Any thoughts or help would be appreciated. I'm not a real adept Python programmer.


Karen K

unread,
Mar 28, 2021, 2:26:56 AM3/28/21
to weewx-user
Then sun starts the day deep east with very low radiation, almost zero. During the morning the radiation increases, and during afternoon decreases. In the evening it is almost zero again. So, what exactly is your definition of "min" regarding sun radiation?

The UV index is always zero during morning hours and evening hours. Values above zero start in the late morning, and they occur until late afternoon. In early morning and early evening the sun is too low to get an UV index. So, again, what exactly is your definition of "min" regarding UV index?

You can look at the observation type "maxSolarRad". It is a calculated value, and it shows the maximum solar radiation possible at that time. Be aware, if clouds are involved, the real value can be more than the theoretical value for a short time.

Russell van vlack

unread,
Mar 28, 2021, 8:59:06 PM3/28/21
to weewx-user
I merely used uv index as an example. It could be any observation (temperature, wind speed, humidity, dewpoint, etc.) So the definition of minimum is the lowest value of whatever observation it is looking at.  Yes, UV or solar radiation may be 0 by default (unless you're in Alaska during the period where the sun never sets) but for temperature or dewpoint or wind speed it may not be zero.

What I'm basically wanting to do is be able to write something like $daylightHours.outTemp.avg or $daylightHours.UV.avg (similar to $day.outTemp.avg or $day.UV.avg except would only calculate the average using values for the observation when it is daylight.)

I have written a couple of other custom search "extensions" for weewx like last7days and last24hours which gather values for the last week or last 24 hours but wondering if something like daylightHours as above is even possible and/or how it could be done.

And you're example of clouds enters into it. We get a lot of clouds in MI. And being able to get the average UV index or solar radiation but not factor in all the zero values that were either before dawn or after sundown is roughly what I'm looking for.

Karen K

unread,
Mar 29, 2021, 11:50:49 AM3/29/21
to weewx-user
If you already wrote SearchList extensions I guess you can write one involving $almanac.sun.rise and $almanac.sun.set.
Reply all
Reply to author
Forward
0 new messages