pvlib-python is a community supported tool that provides a set of documented functions for simulating the performance of photovoltaic energy systems. The toolbox was originally developed in MATLAB at Sandia National Laboratories and it implements many of the models and methods developed at the Labs. More information on Sandia Labs PV performance modeling programs can be found at https://pvpmc.sandia.gov/. We collaborate with the PVLIB-MATLAB project, but operate independently of it.
Full documentation can be found at readthedocs.
We need your help to make pvlib-python a great tool! Please see the Contributing to pvlib-python wiki for more on how you can contribute. The long-term success of pvlib-python requires substantial community support.
To obtain the most recent stable release, just use pip
or conda
:
pip install pvlib
conda install -c http://conda.anaconda.org/pvlib pvlib
If your system complains that you don't have access privileges or asks for a password then you're trying to install pvlib into your system's Python distribution. This is a very bad idea and you should instead follow the If you don't have Python instructions below.
There are many ways to install Python on your system, but the Anaconda Scientific Python distribution provides by far the easiest way for new users to get started. Anaconda includes all of the popular libraries that you'll need for pvlib, including Pandas, NumPy, and SciPy. "Anaconda installs cleanly into a single directory, does not require Administrator or root privileges, does not affect other Python installs on your system, or interfere with OSX Frameworks." -Anaconda Documentation.
Install the full Anaconda Scientific Python distribution available here.
Install pvlib: conda install -c http://conda.anaconda.org/pvlib pvlib
If you have trouble, see the Anaconda FAQ, Google your error messages, or make a new issue on our Issues page.
We strongly recommend working in a virtual environment if you're going to use the development versions of the code. There are many ways to use virtual environments in Python, but Anaconda again provides the easiest solution:
conda create --name pvlibdev python pandas scipy ephem
source activate pvlibdev
pip install git+https://github.com/pvlib/pvlib-python.git
pip install -e .
conda install ipython-notebook nose seaborn
The conda documentation has more information on how to use virtual environments.
pvlib-python is distributed with several validated, high-precision, and high-performance solar position calculators. It also includes wrappers for the official NREL SPA algorithm. To use the NREL SPA algorithm, a pip install from the web cannot be used. Instead:
pvlib-python/pvlib/spa_c_files
pvlib-python
directory, run pip uninstall pvlib
followed by pip install .
You're now ready to start some version of the Python interpreter and use pvlib. The easiest way to start is with one of our IPython notebook tutorials:
ipython notebook
. This should open a web browser with the IPython Notebook's file/folder listing. If not, navigate to the url shown in the command line history, likely http://localhost:8888
shift-enter
to execute the notebook cell-by-cell. There is also a Play button that will execute all of the cells in the notebook.You can also experiment with the following simple code in a new IPython notebook or any other Python interpreter:
# built-in imports
import sys
import datetime
# add-on imports
import pandas as pd
# pvlib imports
from pvlib.location import Location
import pvlib.solarposition
import pvlib.clearsky
# make a location
tus = Location(32.2, -111, 'MST', 700)
# make a pandas DatetimeIndex for some day
times = pd.date_range(start=datetime.datetime(2014,6,24), end=datetime.datetime(2014,6,25), freq='1Min')
# calculate the solar position
solpos = pvlib.solarposition.get_solarposition(times, tus)
solpos.plot()
# calculate clear sky data
tus_cs = pvlib.clearsky.ineichen(times, tus, airmass_model='young1994')
tus_cs.plot()
Many good online resources exist for getting started with scientific Python.
3 clause BSD.
pvlib-python is compatible with Python versions 2.7, 3.3, 3.4, 3.5 and Pandas versions 0.13.1 through 0.17. Note that our Numba-accelerated solar position algorithms have more specific version requirements that will be resolved by the Numba installer.
For Linux + Python 3 users: Continuum's Python 3.x SciPy conda package is not compiled properly and has a few bugs related to complex arithmetic. The most common place for these bugs to show up when using pvlib-python is in calculating IV curve parameters using the singlediode
function. We reported the issue to Continuum and are waiting for it to be fixed. In the meantime, you can compile your own SciPy distribution, or you can use this trick on Python 3.3 and 3.4 (not 3.5): Downgrade your NumPy to 1.8 and SciPy to 0.14, then install whatever version of pandas you want but without dependencies. The conda commands for this are:
conda install numpy=1.8 scipy=0.14
conda install pandas --no-deps
Testing can easily be accomplished by running nosetests
on the pvlib directory:
nosetests -v pvlib
Unit test code should be placed in the corresponding test module in the pvlib/test directory. Use pip
or conda
to install nose
. Developers must include comprehensive tests for any additions or modifications to pvlib.
Here are some of the major differences between the latest build and the original Sandia PVLIB_Python project.
Library wide changes:
pvl_
from module names.pvl_clearsky_ineichen.py
and pvl_clearsky_haurwitz.py
have been consolidated into clearsky.py
. Vars=Locals(); Expect...; var=pvl\_tools.Parse(Vars,Expect);
pattern. Very few tests of input validitity remain. Garbage in, garbage or nan
out.nan
values./pvlib/data
for lookup tables, test, and tutorial data.More specific changes:
irradiance.py
has more AOI, projection, and irradiance sum and calculation functionspvlib.location.Location
objects, not structs.clearsky.ineichen
supports interpolating monthly Linke Turbidities to daily resolution.Documentation:
/
rather than /pvlib/docs
./docs/tutorials
.Testing:
nosetests
for more concise test code.