<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 What's new in the Forecastwrapper
• No more seperate objects Weather_Days and Weather_Hours, just Weather
• The Weather object has methods days() and hours() which return a dataframe in the desired resolution. (We chose this approach because now you only need 1 call to forecast.io to get both resolutions, in V1 you needed 2 calls if you wanted both)
• More verbose and pythonian named arguments. Eg. the flag heatingDegreeDays is now called include_heating_degree_days
• The temperature equivalent is now by default included in the daily dataframe. It can be excluded by using the flag include_temperature_equivalent = False
Demo of the forecast.io wrapper to get past and future weather data
Important
Step1:  Get Forecast.io API key from config file
Step2:  Import API wrapper module
Step3:  Get weather data in daily and hourly resolution
To get started, create a Weather object for a certain location and a period
Step4:  You can use the methods days() and hours() to get a dataframe in daily or hourly resolution
Step5:  Degree Days
Daily resolution has the option of adding degree days.
By default, the temperature equivalent and heating degree days with a base temperature of 16.5°C are added.
Heating degree days are calculated as follows
Step6:  Daytime Averages
Daily resolution has the option of adding average values during the daytime only (between sunrise and sunset). Implemented are daytimeCloudCover and daytimeTemperature, and are included by default. They can be excluded by setting include_daytime_cloud_cover = False or include_daytime_temperature = False.
By default, daily weather data is extended with daytimeCloudCover and daytimeTemperature.  These are the averaged cloud cover and temperature between sunrise and sunset.
Step7:  Hourly resolution example
Location can also be coördinates
Step8:  Deal with different timezones
By default, all dataframes are localized to the timezone of the specified location.
If you want, you can specify the tz argument to get all dataframes localized to a specified timezone.
<ASSISTANT_TASK:>
Python Code:
import os
import sys
import inspect
import pandas as pd
import charts
from opengrid import config
Explanation: What's new in the Forecastwrapper
• No more seperate objects Weather_Days and Weather_Hours, just Weather
• The Weather object has methods days() and hours() which return a dataframe in the desired resolution. (We chose this approach because now you only need 1 call to forecast.io to get both resolutions, in V1 you needed 2 calls if you wanted both)
• More verbose and pythonian named arguments. Eg. the flag heatingDegreeDays is now called include_heating_degree_days
• The temperature equivalent is now by default included in the daily dataframe. It can be excluded by using the flag include_temperature_equivalent = False
Demo of the forecast.io wrapper to get past and future weather data
Important: you need to register for an apikey here: https://developer.forecast.io/  Put the key you obtain in the opengrid.cfg file as follows:
[Forecast.io]
apikey: your_key
End of explanation
config = config.Config()
#get Forecast.io API Key
api_key = config.get('Forecast.io', 'apikey')
Explanation: Get Forecast.io API key from config file
End of explanation
from opengrid.library import forecastwrapper
Explanation: Import API wrapper module
End of explanation
start = pd.Timestamp('20150813')
end = pd.Timestamp('20150816')
Weather_Ukkel = forecastwrapper.Weather(api_key=api_key, location='Ukkel', start=start, end=end)
Explanation: Get weather data in daily and hourly resolution
To get started, create a Weather object for a certain location and a period
End of explanation
Weather_Ukkel.days().info()
Weather_Ukkel.hours().info()
Explanation: You can use the methods days() and hours() to get a dataframe in daily or hourly resolution
End of explanation
Weather_Ukkel.days(include_heating_degree_days = True,
                   heating_base_temperatures = [15,18],
                   include_cooling_degree_days = True,
                   cooling_base_temperatures = [18,24]).filter(like='DegreeDays')
Explanation: Degree Days
Daily resolution has the option of adding degree days.
By default, the temperature equivalent and heating degree days with a base temperature of 16.5°C are added.
Heating degree days are calculated as follows:
$$heatingDegreeDays = max(0 , baseTemp - 0.6 * T_{today} + 0.3 * T_{today-1} + 0.1 * T_{today-2} )$$
Cooling degree days are calculated in an analog way:
$$coolingDegreeDays = max(0, 0.6 * T_{today} + 0.3 * T_{today-1} + 0.1 * T_{today-2} - baseTemp )$$
Add degree days by setting the flag include_heating_degree_days or include_cooling_degree_days and supplying heating_base_temperatures and/or cooling_base_temperatures as a list (you can add multiple base temperatures, or just a list of 1 element)
Get some more degree days
End of explanation
Weather_Ukkel.days().filter(like='daytime')
Explanation: Daytime Averages
Daily resolution has the option of adding average values during the daytime only (between sunrise and sunset). Implemented are daytimeCloudCover and daytimeTemperature, and are included by default. They can be excluded by setting include_daytime_cloud_cover = False or include_daytime_temperature = False.
By default, daily weather data is extended with daytimeCloudCover and daytimeTemperature.  These are the averaged cloud cover and temperature between sunrise and sunset.
End of explanation
start = pd.Timestamp('20150916')
end = pd.Timestamp('20150918')
Weather_Brussel = forecastwrapper.Weather(api_key=api_key, location=[50.8503396, 4.3517103], start=start, end=end)
Weather_Boutersem = forecastwrapper.Weather(api_key=api_key, location='Kapelstraat 1, 3370 Boutersem', start=start, end=end)
df_combined = pd.merge(Weather_Brussel.hours(), Weather_Boutersem.hours(), suffixes=('_Brussel', '_Boutersem'), 
                       left_index=True, right_index=True)
charts.plot(df_combined.filter(like='cloud'), stock=True, show='inline')
Explanation: Hourly resolution example
Location can also be coördinates
End of explanation
start = pd.Timestamp('20150815')
end = pd.Timestamp('20150816')
Weather_London = forecastwrapper.Weather(api_key=api_key, location='London', start=start, end=end, tz='Asia/Singapore')
Weather_Brussels = forecastwrapper.Weather(api_key=api_key, location='Brussels', start=start, end=end, tz='Asia/Singapore')
Weather_London.days()
Weather_Brussels.days()
Explanation: Deal with different timezones
By default, all dataframes are localized to the timezone of the specified location.
If you want, you can specify the tz argument to get all dataframes localized to a specified timezone.
End of explanation
<END_TASK>