# The ID of the data source is the name of this file. Should be short, consists of one or two words. No space and special characters. Hyphen ("_") is allowed. The ID is for the program identify the data source.

# Data source name. Should be clear, meaningful, and human readable.
data_source_name = 'OpenWeather'

# provide a brief description (1 line) of the data source to inform AI whether need to use this data source.
# Need to contain critical information such as extent and period.
brief_description = '''
It provides historical, current, and forecast weather data. The historical data can be back to month ago. API limited: [Hourly forecast: 4 days, Daily forecast: 16 days, 3 hour forecast: 5 days].
'''

# Put the technical requirements or details for the data source. One line for a requirement. No need to number them.
# Line by line.
# If the data source need s API key, put the key in a separate text file (e.g., "OpenWeather.keys") in the "Keys" directory. Note that the file name is the data source ID! The content in the file is like: OpenWeather_key = "XXX". The double quotation mark is needed. Then, in the first line of handbook use the key as "The OpenWeather API key is: {OpenWeather_key}". NEVER share the key in the handbook!
# Note that the placeholder of "{OpenWeather_key}" will be replaced by the real key in the .keys file.
handbook = '''
The OpenWeather API key is: {OpenWeather_key}
The endpoint for current weather is: https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&units=metric&appid={API key}
Hourly forecast for 4 days (96 timestamps) end point is: https://pro.openweathermap.org/data/2.5/forecast/hourly?lat={lat}&lon={lon}&units=metric&appid={API key}
Daily Forecast (16 days at most) end point is: api.openweathermap.org/data/2.5/forecast/daily?lat={lat}&lon={lon}&cnt={cnt}&appid={API key}
Climate Forecast (30 days) end point is: https://pro.openweathermap.org/data/2.5/forecast/climate?lat={lat}&lon={lon}&appid={API key}
The endpoints for historical weather are 1) https://history.openweathermap.org/data/2.5/history/city?lat={lat}&lon={lon}&type=hour&start={start}&end={end}&units=metric&appid={API key}, 2) https://history.openweathermap.org/data/2.5/history/city?lat={lat}&lon={lon}&type=hour&start={start}&cnt={cnt}&units=metric&appid={API key}
Each query can get one week data at most, including historical and forecast data. You may need to query multiple times if the requested period is longer than a week.
If the data request does not mention using historical/current/forecast API, you need to get the current time to determine using the forecast or historical API endpoint.
Need to use metric units. E.g., the temperature units should be Celsius.
Do not use 'One Call API' since we have not subscribed it.
Other parameters and values in the API: [mode: default is `json`. cnt: optional, a number of timestamps in response.].
Put your reply into a Python code block. Explanation or conversation can be Python comments at the beginning of the code block(enclosed by ```python and ```).
The download code is only in a function named 'download_data()'. The last line is to execute this function.
API calls per minute is 3000, so make your program sleep for a while if you request too many times in a minute.
Save the results in a CSV file; columns include place name, date (YYYY-MM-DD), hour (e.g., '01'), and all the returned weather variables in separate columns, including sub-levels in all top-levels, such as 'main' and 'weather'. Using '_' to join the top- and sub-levels, e.g., 'main_temp'. Note that the 'weather' node has a list value, e.g., `'weather': [ {'id': 501,'main': 'Rain', 'description': 'moderate rain', 'icon': '10n' }]`. Other nodes have a dictionary value, e.g., `'main': { 'temp': 275.45, 'feels_like': 271.7, 'pressure': 1014, 'humidity': 74, 'temp_min': 274.26, 'temp_max': 276.48}`. Please handle the 'weather' node correctly.
Using Python code to numerate the returned sub-level weather variables, rather than using your own memory.
Store the requested place name or lat/lon in the result file.
'''

# Python code example for the data source. If no, just leave the empty as below. Do not remove it.
code_example = '''

'''