Python interface for NREL PVWatts's API.
Project description
A NREL PVWAtts API v4 Python wrapper.
Installing
There are two ways
Using PIP
$ pip install pypvwatts
Using setup.py
$ python setup.py install
Usage - with class methods
>>> from pypvwatts import PVWatts >>> PVWatts.api_key = 'myapikeyHLM6x2In2KmX4fxsTRRBT2r9KfDagJjU' >>> result = PVWatts.request(system_size=4, dataset='tmy2', derate=0.77, lat=40, lon=-105) >>> result.ac_annual 7607.97607421875
Usage - with instance methods
>>> from pypvwatts import PVWatts >>> p = PVWatts(api_key='myapikeyHLM6x2In2KmX4fxsTRRBT2r9KfDagJjU') >>> result = p.request(system_size=4, dataset='tmy2', derate=0.77, lat=40, lon=-105) >>> result.ac_annual 7607.97607421875
Request parameters and responses
All request parameters correspond to NREL PVWatts API parameters.
This library provides shortcuts for all response output fields, all can be accessed as a result property.
Please refer to NREL PVWatts documentation for further details.
Raw data
Raw result data can be queried using the result.raw attribute.
>>> from pypvwatts import PVWatts >>> result = PVWatts.request(system_size=4, dataset='tmy2', derate=0.77, lat=40, lon=-105) >>> result.raw {u'errors': [u'You have exceeded your rate limit. Try again later or contact us at http://developer.nrel.gov/contact for assistance']}
Errors
All API errors are reported via JSON response, using the errors attribute.
>>> from pypvwatts import PVWatts >>> result = PVWatts.request(system_size=4, dataset='tmy2', derate=0.77, lat=40, lon=-105) >>> result.errors [u'You have exceeded your rate limit. Try again later or contact us at http://developer.nrel.gov/contact for assistance']
All other service errors, such as connectivity are raised as request’s python library exceptions.
Tests
Unit tests are provided in test.py
Changelog
1.0.0 - First release
Author: Miguel Paolino <mpaolino@gmail.com>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pypvwatts-1.0.0.tar.gz
.
File metadata
- Download URL: pypvwatts-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a658c0767d849ebf29ce4b0a4fd50549c5ad42c559163c871bb159286babec18
|
|
MD5 |
34c449639dc81a754cb4d0a04546bc04
|
|
BLAKE2b-256 |
cbb164a9cb74f21c46b4dbe248c35201d6b323a7a2ca2047eaa4c0d3086cf4b5
|