Skip to content

Instantly share code, notes, and snippets.

@dvdme
Created January 6, 2016 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdme/ba2132e040bf402fc7c2 to your computer and use it in GitHub Desktop.
Save dvdme/ba2132e040bf402fc7c2 to your computer and use it in GitHub Desktop.
Hot to use forecastiopy module to retrieve maximum temperature, minimum temperature and precipitation information for only one day from daily data.
from forecastiopy import *
apikey = 'YOUR_APY_KEY'
Lisbon = [38.7252993, -9.1500364]
# 'units', 'lang' and 'exclude' options are optional but it is nice to ensure that
# the reply comes in correct language and unit. Setting the 'exclude' option
# reduces the reply size. If ou don't need the data, don't ask for it.
fio = ForecastIO.ForecastIO(apikey,
units=ForecastIO.ForecastIO.UNITS_SI,
lang=ForecastIO.ForecastIO.LANG_ENGLISH,
exclude=('hourly','minutely', 'flags', 'alerts'),
latitude=Lisbon[0], longitude=Lisbon[1])
# check if daily data is present in the reply, just in case...
if fio.has_daily() is True:
daily = FIODaily.FIODaily(fio)
print 'Day 3'
# Using this properties you can access values directly.
# They always follow this partern, for day 3 use
# 'day_3_temperatureMax', for day 7 use 'day_7_temperatureMax'
print 'Max Temperature:', daily.day_3_temperatureMax
print 'Mix Temperature:', daily.day_3_temperatureMin
print 'Precipitation Type:', daily.day_3_precipType
print 'Precipitation Pobability:', daily.day_3_precipProbability
print 'Precipitation Intensity:', daily.day_3_precipIntensity
else:
print 'No Daily data'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment