brian-provenzano / weather

Created as a lab exercise in using python and public web APIs to report / chart data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weather Histogram

Function

Originally created as a lab exercise in using python and public web APIs to report / chart data

Description

Creates a tsv file of histogram bins of weather forecast based on logfile input (containing IP addresses) and requested bin size

Usage

usage: create-weather-histogram [-h] [-d] [-v] logfile outputfile buckets

Creates a tsv file of histogram bins of weather forecasts based on logfile
location input (containing IP addresses) and requested bin size. Uses 3rd
party web APIs (weatherunderground).Please see source of this file to set
options appropriately (keys, etc)

positional arguments:
  logfile        Log source file containing locations to find weather forecast
                 data for
  outputfile     Name of the file to output the histogram data to in tsv
                 format
  buckets        Number of buckets for histogram

optional arguments:
  -h, --help     show this help message and exit
  -d, --debug    Debug mode - show more informational messages for debugging
  -v, --version  show program's version number and exit

Initial Setup

You will need the following third party modules, just pip3 install them as needed or use the requirements.txt file as noted below:

Example pip3 install the requirements:

pip3 install -r requirements.txt

Note: Tested and developed on python 3.6.5 on Linux (Fedora)

The following settings must be manually preconfigured in 'create-weather-histogram.py'

1 Go to https://www.wunderground.com/weather/api/ and obtain a free tier API key (note the limitations; this code should respect them). Fill in your API key here:

WUNDERGROUND_APIKEY = ""

There are also a few other settings (e.g. caching expirations) you may wish to set. Those are located in the following section in 'create-weather-histogram':

##########################################
#- Modify the options below as needed
##########################################

 ...settings here...

##########################################
#- END - Do not modify below here!!!
##########################################
NOTE: This code was tested on Fedora Linux (python 3.6.5) - there are no guarantees it will work on other platforms. It should but YMMV.

Third Party Web Service APIs Used

Weather Underground API

Thanks

About

Created as a lab exercise in using python and public web APIs to report / chart data


Languages

Language:Python 100.0%