jim-easterbrook / pywws

Python software for USB Wireless WeatherStations
https://pywws.readthedocs.io/
GNU General Public License v2.0
204 stars 62 forks source link

pywws.livelog crashed with math domain error. Impossible to relaunch. #113

Open pablus opened 1 year ago

pablus commented 1 year ago

livelog crashed with this error:

File "/usr/local/lib/python3.9/dist-packages/pywws/conversions.py", line 199, in dew_point gamma = ((a * temp) / (b + temp)) + math.log(float(hum) / 100) ValueError: math domain error

When this happened, every time we tried to relaunch the program it failed with the same error message. Somehow, it seems that hum took a value of zero, hence the math domain error of the logarithm.

To work around the problem we have locally changed line 195 of conversion.py to:

if temp is None or hum is None or hum == 0:

Weather station model is PCE-FWS 20N. pywws-version is 23.2.0. It is running on a Raspberry Pi.

jim-easterbrook commented 1 year ago

A humidity value of zero is invalid, so ideally you need to find it in your data and remove it.

If it happens a lot with your station you could deal with it in a user calibration module:

class Calib(object):
    def calib(self, raw):
        result = dict(raw)
        if not (result['hum_in'] and result['hum_in'] >= 20):
            result['hum_in'] = None
        if not (result['hum_out'] and result['hum_out'] >= 20):
            result['hum_out'] = None
        return result