pvlib
pvlib python is a free and open source library that provides a set of functions and classes for simulating the performance of photovoltaic energy systems. It includes tools for solar position, clear sky irradiance, array sizing, PV system modeling, and data input/output. The current version is 0.15.0, with major releases typically occurring annually, and minor releases addressing bugs and adding features more frequently.
Warnings
- breaking Several `ModelChain.run_*` methods (e.g., `run_cec_sam`, `run_tmy_data`, `run_poa_cec_inverter`) were removed in v0.14.0. Users should now use the more general `ModelChain.run_model()` method and pass appropriate data structures for inputs.
- breaking The `pvlib.irradiance.perez` function no longer accepts `dni_extra` or `airmass` as explicit parameters since v0.14.0. These values are now computed internally if not provided through `dni_extra_kwargs` or `airmass_model`.
- breaking The `wind_speed` parameter was renamed to `temp_air_wind_speed` in `pvlib.temperature.sapm_module` (v0.13.0) and in `pvlib.temperature.pvsyst_cell` (v0.15.0) to improve naming consistency.
- breaking The `pvlib.singlediode.bishop88_i_from_v` function was removed in v0.13.0, and `pvlib.singlediode.bishop88` (the main function) was deprecated in v0.13.0 and removed in v0.15.0.
- gotcha Since v0.12.0, `Location.tz` and `PVSystem.tz` attributes now store `pytz.timezone` objects directly instead of string representations of timezones. This can break code that expects a string for timezone checking or serialization.
Install
-
pip install pvlib
Imports
- Location
from pvlib.location import Location
- get_solarposition
from pvlib.solar_position import get_solarposition
- ModelChain
from pvlib.modelchain import ModelChain
- PVSystem
from pvlib.pvsystem import PVSystem
- get_total_irradiance
from pvlib.irradiance import get_total_irradiance
Quickstart
import pandas as pd
from pvlib.location import Location
from pvlib.solar_position import get_solarposition
# Define a location (Tucson, Arizona)
tucson = Location(32.2, -110.9, 'US/Arizona', 792, 'Tucson')
# Define time range
times = pd.date_range('2024-01-01 12:00:00', freq='H', periods=3, tz=tucson.tz)
# Get solar position
solpos = get_solarposition(times, tucson.latitude, tucson.longitude)
print(solpos)