Skip to main content

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:

  1. The geopy library to convert a string to lat-long
  2. Open Weather Map online service (you can get an API key through a free account in the profile section)
  3. 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:

    7 day forecast for Tokyo, Japan

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weatherchart-1.0.6.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weatherchart-1.0.6-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file weatherchart-1.0.6.tar.gz.

File metadata

  • Download URL: weatherchart-1.0.6.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.6 Linux/4.4.0-176-generic

File hashes

Hashes for weatherchart-1.0.6.tar.gz
Algorithm Hash digest
SHA256 e01b55725bb4ed0d2f057d74c258c31f0eac4a65dceaebc0d78517c623353304
MD5 0ce7a6e746f13387e96d1c7e2d88c955
BLAKE2b-256 536af4655052ce643d8c060b2cc3005f89ee17f11f23e3d8e6be9d1e585ff1f2

See more details on using hashes here.

File details

Details for the file weatherchart-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: weatherchart-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.6 Linux/4.4.0-176-generic

File hashes

Hashes for weatherchart-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1bbbf131f5a4645a4e7ba0fddfead33dd75984dfb7f5b9805c98f53a75679df6
MD5 3edf9d81bbfa68517ab1dac9d3038169
BLAKE2b-256 ef75e92b7d541c217ff95ae3fc7430cfedd0b80d7ccd5ca94c7611681a76ff40

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page