-
Notifications
You must be signed in to change notification settings - Fork 3
/
Weather.py
32 lines (26 loc) · 910 Bytes
/
Weather.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# FYP2017
# Program to get average forecast of temperature and cloud cover for 2 days
# Author: Kunal Jagadeesh
# License: Public Domain
from forecastiopy import *
import datetime
f = open('DS_APIkey.txt','r')
apikey = f.read()
f.close()
Bangalore = [12.9716, 77.5946]
fio = ForecastIO.ForecastIO(apikey,
units=ForecastIO.ForecastIO.UNITS_SI,
lang=ForecastIO.ForecastIO.LANG_ENGLISH,
latitude=Bangalore[0], longitude=Bangalore[1],
)
tempc = 0
clouds = 0
if fio.has_hourly() is True:
hourly = FIOHourly.FIOHourly(fio)
for hour in range(0, 48):
tempc = tempc + float(str(hourly.get_hour(hour)['temperature']))
clouds = clouds + float(str(hourly.get_hour(hour)['cloudCover']))
else:
print('No Hourly data')
tempc = round(tempc / 48, 2)
clouds = round(clouds / 48, 2)