Whether you’re already a user and want a refresher on the documentation or you’re evaluating the package for the first time, you’ve come to the right place. So what do you want to learn more about?
Introduction
WunderWeather attempts to expose data supplied by Weather Underground in a way that is easy to use and easy to get weather data into your application quickly without having to deal with all of the details.
About the Wunderground API
The Wunderground API supplies different endpoints called data features which, when supplied the proper arguments, return numerous data points describing the feature being queried.
About the WunderWeather API
WunderWeather was built to expose the data supplied by Wunderground in a uniform fashion. For certain data features where it applied, wrapper classes were created to normalize the data returned and supply ease of access to that data.
- When developing WunderWeather there were a few key concepts kept in mind which are listed below. If you intend on contributing, please keep these ideas in mind.
- Out of the hundreds of data points that Wunderground so graciously supplies, expose shortcuts to the more frequently used/popular data points such as temperature and date through the data feature specific wrappers.
For the history data feature, Wunderground exposes the average temperature data point using 3 keys rather than the one abstracted in WunderWeather
Wunderground:
>>> response["history"]["daily_summary"]["meantempi"]
WunderWeather:
>>> response.temp_f
- Normalize the data point names being exposed.
The Wunderground API does a great job at supplying endless amounts of weather data but unfortunately similar data points across different features have different names. A case where this crops up frequently is for imperial (i) and metric (m) and their respective Fahrenheit (f) and Celsius (c) identifiers for temperature.
Example Data Points:
temp_i vs temp_f
temp_m vs temp_c
Installation
pip install WunderWeather
Code Examples
The following code snippets are examples of extracting data from data feature responses. Some examples build off of previous examples (as to avoid repetition) but should be properly documented as continuation from NNN example.
Weather Underground Example
Not using Requests
Example listed in Wunderground documentation
import urllib2
import json
f = urllib2.urlopen('http://api.wunderground.com/api/<YOUR_API_KEY>/geolookup/conditions/q/IA/Cedar_Rapids.json')
json_string = f.read()
parsed_json = json.loads(json_string)
location = parsed_json['location']['city']
temp_f = parsed_json['current_observation']['temp_f']
print "Current temperature in %s is: %s" % (location, temp_f)
f.close()
Using Requests
Example listed in Wunderground doc converted to use requests
import requests # learn more: https://python.org/pypi/requests
response = requests.get('http://api.wunderground.com/api/<YOUR_API_KEY>/geolookup/conditions/q/MA/Boston.json').json()
location = response['location']['city']
temp_f = response['current_observation']['temp_f']
print("Current Temperature in %s is: %s" %(location,temp_f))
Using WunderWeather
Example listed in Wunderground doc converted to use WunderWeather
from wunder import weather
extractor = weather.Extract(api_key)
[location,current] = extractor.features("MA/Boston",(('geolookup',''),('now','')))
print("Current Temperature in %s is: %s" %(location.data.city,current.temp_f))
In the example above, notice how data points can be extracted from a feature using dotted notation whether there is a feature specific wrapper class or not to provide a uniform look in the calling application. When referencing shortcuts from wrapper classes or directly accessing the data, the look is the same. As of writing this documentation Geolookup does not have a wrapper so all data extracted from that feature must use the WeatherBase.data member to use the dotted notation.
Additional Examples
From pprint import pprint
import arrow
From WunderWeather import weather
# setup
api_key = "your api key"
location = 'MA/Boston'
extractor = weather.Extract(api_key)
# alerts
response = extractor.alerts(location)
pprint(response.data)
# astronomy
response = extractor.astronomy(location)
pprint(response.data)
# geolookup
response = extractor.geolookup(location)
pprint(response.data)
# history
date = arrow.get("20170601","YYYYMMDD")
response = extractor.date(location,date.format('YYYYMMDD'))
pprint(response.data)
# addl date detail
for observation in response.observations:
print("Date:",observation.date_pretty)
print("Temp:",observation.temp_f)
Contributors
Thanks for checking out this section and showing interest in making this package better. The following are points of interest that could use polishing or expanding. As always, if you see data points across data features that could use a level of abstraction just add a wrapper class if not already defined and add a property member to that class to provide a shortcut or normalized external name across features.
TODOs
- Several Data Features only exist using the generic WeatherBase, base class and thus their data is accessed using the data member. There are likely reasons to create wrappers for these features. current hurricane seemed to need a wrapper the most. But some others that might benefit from abstraction are listed below.
currenthurricane
rawtide and tide
hourly* based features
And of course, help with documentation, documentation, and more documentation.
Mentions
I just want give mention and thanks to the following:
Weather Underground for supplying the data.
requests for making http for me.
EasyDict for supplying the dotted dictionary notation functionality.
Metadata
Release files for WunderWeather 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| WunderWeather-1.1.0.tar.gz | 29.0 kB | Without provenance | Details for WunderWeather-1.1.0.tar.gz |
Release files / WunderWeather-1.1.0.tar.gz
| Download URL | WunderWeather-1.1.0.tar.gz |
|---|---|
| Size | 29.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7156a98fae2aca1213b664ec5b4fa09149ba6b40bd5fea1799da8ff2368a5e68
|
|
BLAKE2b-256 checksum How to use checksums |
045a0f29a58369f0e490b0201e5788af7b89e8711a132bd8fe18d421311d8b8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for WunderWeather 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.