User Tools

Site Tools


weatherbot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
weatherbot [2014/08/30 13:09]
sekula [Source Code]
weatherbot [2014/08/30 23:23] (current)
sekula [Talking to WeatherBot]
Line 123: Line 123:
 def CelsiusToFarenheit(temp_celsius):​ def CelsiusToFarenheit(temp_celsius):​
     return temp_celsius*1.8 + 32.0     return temp_celsius*1.8 + 32.0
 +
 +def FarenheitToCelsius(temp_farenheit):​
 +    return (temp_farenheit - 32.0)/1.8
  
 def KPHToMPH(speed_kph):​ def KPHToMPH(speed_kph):​
Line 136: Line 139:
     wind_speed_kmh = weather_data['​wind'​]['​speed'​]     wind_speed_kmh = weather_data['​wind'​]['​speed'​]
     wind_speed_mph = KPHToMPH(wind_speed_kmh)     wind_speed_mph = KPHToMPH(wind_speed_kmh)
 +    ​
 +    heat_index_farenheit = -42.379 + 2.04901523*temp_farenheit + 10.14333127*humidity - .22475541*temp_farenheit*humidity - .00683783*temp_farenheit*temp_farenheit - .05481717*humidity*humidity + .00122874*temp_farenheit*temp_farenheit*humidity + .00085282*temp_farenheit*humidity*humidity - .00000199*temp_farenheit*temp_farenheit*humidity*humidity
 +    heat_index_celsius = FarenheitToCelsius(heat_index_farenheit)
     ​     ​
     response = ""​     response = ""​
Line 144: Line 150:
     response += "<​li>​ Temperature:​ %0.1fC (%0.1fF) </​li>​\n"​ % (temp_celsius,​ temp_farenheit)     response += "<​li>​ Temperature:​ %0.1fC (%0.1fF) </​li>​\n"​ % (temp_celsius,​ temp_farenheit)
     response += "<​li>​ Humidity: %0.1f%% </li> \n" % (humidity)     response += "<​li>​ Humidity: %0.1f%% </li> \n" % (humidity)
 +    response += "<​li>​ Heat Index: %0.1fC (%0.1fF) </​li>​\n"​ % (heat_index_celsius,​heat_index_farenheit) ​   ​
     response += "<​li>​ Wind Speed: %.1fkm/h (%.1fmph) </​li>​\n"​ % (wind_speed_kmh,​wind_speed_mph)     response += "<​li>​ Wind Speed: %.1fkm/h (%.1fmph) </​li>​\n"​ % (wind_speed_kmh,​wind_speed_mph)
     response += "<​li>​ Conditions: %s - %s</​li>​ \n" % (weather_data['​weather'​][0]['​main'​],​ weather_data['​weather'​][0]['​description'​])     response += "<​li>​ Conditions: %s - %s</​li>​ \n" % (weather_data['​weather'​][0]['​main'​],​ weather_data['​weather'​][0]['​description'​])
Line 403: Line 410:
 New York,NY,US New York,NY,US
 or or
-New York,US+Stockholm,SE
 </​code>​ </​code>​
  
weatherbot.1409418591.txt.gz ยท Last modified: 2014/08/30 13:09 by sekula