another batch of files with a light sprinkle of comments
This commit is contained in:
@@ -8,9 +8,8 @@ from rowers.models import Rower, Workout
|
||||
|
||||
from rowsandall_app.settings import FORECAST_IO_KEY
|
||||
|
||||
|
||||
# Get weather data from the DarkSky API
|
||||
def get_weather_data(long,lat,unixtime):
|
||||
# url = "https://api.forecast.io/forecast/"+FORECAST_IO_KEY+"/"
|
||||
url = "https://api.darksky.net/forecast/"+FORECAST_IO_KEY+"/"
|
||||
url += str(long)+","+str(lat)+","+str(unixtime)
|
||||
|
||||
@@ -21,6 +20,7 @@ def get_weather_data(long,lat,unixtime):
|
||||
else:
|
||||
return 0
|
||||
|
||||
# Get wind data (and translate from knots to m/s)
|
||||
def get_wind_data(lat,long,unixtime):
|
||||
data = get_weather_data(lat,long,unixtime)
|
||||
if data:
|
||||
@@ -39,6 +39,7 @@ def get_wind_data(lat,long,unixtime):
|
||||
|
||||
try:
|
||||
temperature = data['currently']['temperature']
|
||||
# Temp is given in Fahrenheit, so convert to Celsius for Europeans
|
||||
temperaturec = (temperature-32.)*(5./9.)
|
||||
temperaturec = int(10*temperaturec)/10.
|
||||
except KeyError:
|
||||
@@ -54,7 +55,8 @@ def get_wind_data(lat,long,unixtime):
|
||||
windbearing = 0
|
||||
message = 'Not able to get weather data'
|
||||
|
||||
# apply Hellman's coefficient for neutral air above human inhabitated areas
|
||||
# apply Hellman's coefficient for neutral air above human
|
||||
# inhabitated areas
|
||||
windspeed = windspeed*(0.1)**0.34
|
||||
windspeed = 0.01*int(100*windspeed)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user