Possible bug in hourly data calculation in process.py

2 views
Skip to first unread message

Paul Cheffings

unread,
Dec 4, 2025, 10:07:58 AM (9 days ago) Dec 4
to pywws
Hi

My weather station just had a rain overflow event which was logged however the rainfall that caused the overflow was not recorded in the hourly data (its in the raw). The relevant code is shown below

    def add_raw(self, data):
        idx = data['idx']
        self.wind_fil.add(data)
        wind_gust = data['wind_gust']
        if wind_gust is not None and wind_gust > self.wind_gust[0]:
            self.wind_gust = (wind_gust, idx)
        rain = data['rain']
        if rain is not None:
            if self.last_rain is not None:
                diff = rain - self.last_rain
                if diff < -0.001:
                    logger.warning(
                        '%s rain reset %.1f -> %.1f', str(idx), self.last_rain, rain)

At this point the rainfall causing the overflow is not recorded as the self.rain variable is only updated by the else clause which doesn't get executed in this scenario

Something like self.rain += self.last_rain - abs(diff) maybe required here

                elif diff > float(data['delay'] * 5):
                    # rain exceeds 5mm / minute, assume corrupt data and ignore it
                    logger.warning(
                        '%s rain jump %.1f -> %.1f', str(idx), self.last_rain, rain)
                else:
                    self.rain += max(0.0, diff)
            self.last_rain = rain
        # copy some current readings
        if 'illuminance' in data and not 'illuminance' in self.copy_keys:
            self.copy_keys.append('illuminance')
            self.copy_keys.append('uv')
        # if already have data to return, ignore 'lost contact' readings
        if data['temp_out'] is not None or not self.retval:
            for key in self.copy_keys:
                self.retval[key] = data[key]

Cheers

Paul

Jim Easterbrook

unread,
Dec 4, 2025, 10:25:22 AM (9 days ago) Dec 4
to py...@googlegroups.com
On 04/12/2025 15:07, Paul Cheffings wrote:
>
> My weather station just had a rain overflow event which was logged
> however the rainfall that caused the overflow was not recorded in the
> hourly data (its in the raw). The relevant code is shown below

The processed data can't know how much rain fell during an interval
(e.g. last 5 minutes, last 60 minutes, since midnight, etc.) because it
doesn't know what value the rain count reached before it reset.
Sometimes the reset will be an overflow, other times it might be an
outside sensor battery replacement.

If you know what value it reached then you could put something in your
user calibration module to add that value to all rain data after the
timestamp where it reset.

--
Jim Easterbrook <http://www.jim-easterbrook.me.uk/>

Paul Cheffings

unread,
Dec 4, 2025, 10:37:21 AM (9 days ago) Dec 4
to pywws
Hi

Thanks that makes sense.

Cheers

Paul

Reply all
Reply to author
Forward
0 new messages