7 Day Weather forecast
The module provides a 7 day weather forecast from the Open Weather Map and then converted to am image using quickcharts.io See a full article from PythonHowToProgram
What problem does this solve?
The module will help to return a 7 day weather forecast for a given location either as a dictionary, a chart image file, or a web link with the chart image
How does it do this?
There are three key services that are used for this module:
- The
geopylibrary to convert a string to lat-long - Open Weather Map online service (you can get an API key through a free account in the profile section)
- Then finally from QuickCharts to convert the time series weather data into a chart
How do you install this?
MCLogger is avaialble through PyPi and you may use pip:
pip install weatherchart
Or, through git:
git clone https://github.com/pub12/weatherchart.git
How do you use weatherchart?
The weatherchart library is super easy to use. You need to simply pass the Open Weather API key, a timezone, and then a location string. A URL will be returned of the chart or saved as a file
from weatherchart import WeatherChart
wchart = WeatherChart('<open weather map token>', 'Asia/Hong_Kong')
print( wchart.get_forecast_chart_image_by_loc('Tokyo', 'out_file.jpg' ) )
Class Methods overview
-
constructor(self, map_key, tz_location='Asia/Singapore'):
Constructor must include the Open Weather MAP API key, and also a timezone. The timezone list can be found on the Wiki Timezone page. The reason for the timzone is to ensure the right time period is extract for the next 7 days
-
get_full_weather_data(self, lat, long):
Return a dictionary with weather a full detailed range of data (temperature, min, max, humidity and many more) for next 7 days including today. The location must be provided as a lat long.
-
get_forecast_by_location(self, loc_string):
Return a dictionary with weather data (temperature, min, max, humidity) for next 7 days including today. The location must be provided as a location description (e.g. "Seattle", "New York, New York"). Output is the same as the method
get_forecast() -
get_forecast(self, lat, long):
Return a dictionary with weather data (temperature, min, max, humidity) for next 7 days including today. The location must be provided as a lat long.
A ditionary will be returned with the following:{ 'temp': <float>, 'temp_min': <float>, 'temp_max': <float>, 'wind_speed': <float>, 'humidity': <float> } -
get_forecast_chart_image_by_loc( self, loc_string, output_file=None):
This will return an image with a chart showing the 7 day forecast. If a filename is provided then the image will be saved as an image as well (.jpg). Input is a location sring and the function will return a URL string. An example output below:
Metadata
Release files for weatherchart 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| weatherchart-1.0.6.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| weatherchart-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / weatherchart-1.0.6.tar.gz
| Download URL | weatherchart-1.0.6.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e01b55725bb4ed0d2f057d74c258c31f0eac4a65dceaebc0d78517c623353304
|
|
BLAKE2b-256 checksum How to use checksums |
536af4655052ce643d8c060b2cc3005f89ee17f11f23e3d8e6be9d1e585ff1f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.6 Linux/4.4.0-176-generic
|
Release files / weatherchart-1.0.6-py3-none-any.whl
| Download URL | weatherchart-1.0.6-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bbbf131f5a4645a4e7ba0fddfead33dd75984dfb7f5b9805c98f53a75679df6
|
|
BLAKE2b-256 checksum How to use checksums |
ef75e92b7d541c217ff95ae3fc7430cfedd0b80d7ccd5ca94c7611681a76ff40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.6 Linux/4.4.0-176-generic
|