get_dew_point raises unhandled ValueError with negative humidity

Bug #1169750 reported by rwx
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
my-weather-indicator
Fix Released
Critical
Lorenzo Carbonell

Bug Description

kolson@rwx:~$ /opt/extras.ubuntu.com/my-weather-indicator/bin/my-weather-indicator
/home/kolson
<gettext.GNUTranslations instance at 0x1930290>
No LSB modules are available.
#####################################################
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
Version: x86_64
#####################################################

My-Weather-Indicator version: 0.6.1.2.precise.1
#####################################################
('/home/kolson/.config/my-weather-indicator/my-weather-indicator.conf', True)
{"time":"2013-04-16 08:42","countryName":"United States","sunset":"2013-04-16 19:40","rawOffset":-7,"dstOffset":-6,"countryCode":"US","gmtOffset":-7,"lng":-105.084423,"sunrise":"2013-04-16 06:20","timezoneId":"America/Denver","lat":40.5852602}
SE
(<type 'str'>, u'26 \xb0F')
################
mwi-wind12.png
SE
(<type 'str'>, u'26 \xb0F')
################
mwi-wind12.png
start now
East
(<type 'str'>, u'26 \xb0F')
################
mwi-wind00.png
SE
(<type 'str'>, u'26 \xb0F')
################
mwi-wind12.png
ESE
(<type 'str'>, u'31 \xb0F')
################
mwi-wind10.png
ESE
(<type 'str'>, u'32 \xb0F')
################
mwi-wind10.png
Traceback (most recent call last):
  File "/opt/extras.ubuntu.com/my-weather-indicator/share/my-weather-indicator/myweatherindicator.py", line 196, in work
    self.set_menu()
  File "/opt/extras.ubuntu.com/my-weather-indicator/share/my-weather-indicator/myweatherindicator.py", line 464, in set_menu
    weather = self.weatherservice1.get_weather()
  File "/opt/extras.ubuntu.com/my-weather-indicator/share/my-weather-indicator/wundergroundapi.py", line 148, in get_weather
    weather_data = self._get_weather()
  File "/opt/extras.ubuntu.com/my-weather-indicator/share/my-weather-indicator/wundergroundapi.py", line 101, in _get_weather
    weather_data['current_conditions']['dew_point'] = weatherservice.get_dew_point(humidity,temperature,self.units.temperature)
  File "/opt/extras.ubuntu.com/my-weather-indicator/share/my-weather-indicator/weatherservice.py", line 457, in get_dew_point
    dp = math.pow(h/100.0,1.0/8.0)*(110.0+t) - 110.0
ValueError: math domain error

Revision history for this message
rwx (karl-olson) wrote :

I believe the only possible cause for this is when h is negative. I have no idea how this changes the dew point calculation, but with the following change I have been running without error for 24 hours now:

  dp = math.pow(math.fabs(h)/100.0,1.0/8.0)*(110.0+t) - 110.0

Revision history for this message
rwx (karl-olson) wrote :

With the above fix in place, I now occasionally see that humidity is being reported as -999%.

Revision history for this message
Cas (calumlind) wrote :

-999% suggests an error in feed data and you cannot have negative humidity so simply test that h > 0 before attempting calculation, and if not let it return 'n/a'

Changed in my-weather-indicator:
status: New → Confirmed
summary: - ValueError: math domain error
+ get_dew_point raises unhandled ValueError with negative humidity
Changed in my-weather-indicator:
assignee: nobody → Lorenzo Carbonell (lorenzo-carbonell)
importance: Undecided → Critical
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.