Classes¶
pvlib-python provides a collection of classes for users that prefer object-oriented programming. These classes can help users keep track of data in a more organized way, and can help to simplify the modeling process. The classes do not add any functionality beyond the procedural code. Most of the object methods are simple wrappers around the corresponding procedural code.
Location¶
-
class
pvlib.location.
Location
(latitude, longitude, tz='UTC', altitude=0, name=None, **kwargs)[source]¶ Bases:
object
Location objects are convenient containers for latitude, longitude, timezone, and altitude data associated with a particular geographic location. You can also assign a name to a location object.
Location objects have two timezone attributes:
tz
is a IANA timezone string.pytz
is a pytz timezone object.
Location objects support the print method.
Parameters: latitude : float.
Positive is north of the equator. Use decimal degrees notation.
longitude : float.
Positive is east of the prime meridian. Use decimal degrees notation.
tz : str, int, float, or pytz.timezone.
See http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of valid time zones. pytz.timezone objects will be converted to strings. ints and floats must be in hours from UTC.
alitude : float.
Altitude from sea level in meters.
name : None or string.
Sets the name attribute of the Location object.
**kwargs
Arbitrary keyword arguments. Included for compatibility, but not used.
See also
pvsystem.PVSystem
-
classmethod
from_tmy
(tmy_metadata, tmy_data=None, **kwargs)[source]¶ Create an object based on a metadata dictionary from tmy2 or tmy3 data readers.
Parameters: tmy_metadata : dict
Returned from tmy.readtmy2 or tmy.readtmy3
tmy_data : None or DataFrame
Optionally attach the TMY data to this object.
Returns: Location object (or the child class of Location that you
called this method from).
-
get_airmass
(times=None, solar_position=None, model='kastenyoung1989')[source]¶ Calculate the relative and absolute airmass.
Automatically chooses zenith or apparant zenith depending on the selected model.
Parameters: times : None or DatetimeIndex
Only used if solar_position is not provided.
solar_position : None or DataFrame
DataFrame with with columns ‘apparent_zenith’, ‘zenith’.
model : str
Relative airmass model
Returns: airmass : DataFrame
Columns are ‘airmass_relative’, ‘airmass_absolute’
-
get_clearsky
(times, model='ineichen', **kwargs)[source]¶ Calculate the clear sky estimates of GHI, DNI, and/or DHI at this location.
Parameters: times : DatetimeIndex
model : str
The clear sky model to use.
kwargs passed to the relevant function(s).
Returns: clearsky : Series or DataFrame
Column names are:
ghi, dni, dhi
.
-
get_solarposition
(times, pressure=None, temperature=12, **kwargs)[source]¶ Uses the
solarposition.get_solarposition()
function to calculate the solar zenith, azimuth, etc. at this location.Parameters: times : DatetimeIndex
pressure : None, float, or array-like
If None, pressure will be calculated using
atmosphere.alt2pres()
andself.altitude
.temperature : None, float, or array-like
kwargs passed to :py:func:`solarposition.get_solarposition`
Returns: solar_position : DataFrame
Columns depend on the
method
kwarg, but always includezenith
andazimuth
.
PVSystem¶
-
class
pvlib.pvsystem.
PVSystem
(surface_tilt=0, surface_azimuth=180, albedo=None, surface_type=None, module=None, module_parameters=None, series_modules=None, parallel_modules=None, inverter=None, inverter_parameters=None, racking_model='open_rack_cell_glassback', **kwargs)[source]¶ Bases:
object
The PVSystem class defines a standard set of PV system attributes and modeling functions. This class describes the collection and interactions of PV system components rather than an installed system on the ground. It is typically used in combination with
Location
andModelChain
objects.See the
LocalizedPVSystem
class for an object model that describes an installed PV system.The class is complementary to the module-level functions.
The attributes should generally be things that don’t change about the system, such the type of module and the inverter. The instance methods accept arguments for things that do change, such as irradiance and temperature.
Parameters: surface_tilt: float or array-like
Tilt angle of the module surface. Up=0, horizon=90.
surface_azimuth: float or array-like
Azimuth angle of the module surface. North=0, East=90, South=180, West=270.
albedo : None, float
The ground albedo. If
None
, will attempt to usesurface_type
andirradiance.SURFACE_ALBEDOS
to lookup albedo.surface_type : None, string
The ground surface type. See
irradiance.SURFACE_ALBEDOS
for valid values.module : None, string
The model name of the modules. May be used to look up the module_parameters dictionary via some other method.
module_parameters : None, dict or Series
Module parameters as defined by the SAPM, CEC, or other.
inverter : None, string
The model name of the inverters. May be used to look up the inverter_parameters dictionary via some other method.
inverter_parameters : None, dict or Series
Inverter parameters as defined by the SAPM, CEC, or other.
racking_model : None or string
Used for cell and module temperature calculations.
**kwargs
Arbitrary keyword arguments. Included for compatibility, but not used.
See also
pvlib.location.Location
,pvlib.tracking.SingleAxisTracker
,pvlib.pvsystem.LocalizedPVSystem
-
ashraeiam
(aoi)[source]¶ Determine the incidence angle modifier using
self.module_parameters['b']
,aoi
, and theashraeiam()
function.Parameters: aoi : numeric
The angle of incidence in degrees.
Returns: modifier : numeric
The AOI modifier.
-
calcparams_desoto
(poa_global, temp_cell, **kwargs)[source]¶ Use the
calcparams_desoto()
function, the input parameters andself.module_parameters
to calculate the module currents and resistances.Parameters: poa_global : float or Series
The irradiance (in W/m^2) absorbed by the module.
temp_cell : float or Series
The average cell temperature of cells within a module in C.
**kwargs
See pvsystem.calcparams_desoto for details
Returns: See pvsystem.calcparams_desoto for details
-
get_aoi
(solar_zenith, solar_azimuth)[source]¶ Get the angle of incidence on the system.
Parameters: solar_zenith : float or Series.
Solar zenith angle.
solar_azimuth : float or Series.
Solar azimuth angle.
Returns: aoi : Series
The angle of incidence
-
get_irradiance
(solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra=None, airmass=None, model='haydavies', **kwargs)[source]¶ Uses the
irradiance.total_irrad()
function to calculate the plane of array irradiance components on a tilted surface defined byself.surface_tilt
,self.surface_azimuth
, andself.albedo
.Parameters: solar_zenith : float or Series.
Solar zenith angle.
solar_azimuth : float or Series.
Solar azimuth angle.
dni : float or Series
Direct Normal Irradiance
ghi : float or Series
Global horizontal irradiance
dhi : float or Series
Diffuse horizontal irradiance
dni_extra : float or Series
Extraterrestrial direct normal irradiance
airmass : float or Series
Airmass
model : String
Irradiance model.
**kwargs
Passed to
irradiance.total_irrad()
.Returns: poa_irradiance : DataFrame
Column names are:
total, beam, sky, ground
.
-
i_from_v
(resistance_shunt, resistance_series, nNsVth, voltage, saturation_current, photocurrent)[source]¶ Wrapper around the
i_from_v()
function.Parameters: See pvsystem.i_from_v for details Returns: See pvsystem.i_from_v for details
-
localize
(location=None, latitude=None, longitude=None, **kwargs)[source]¶ Creates a LocalizedPVSystem object using this object and location data. Must supply either location object or latitude, longitude, and any location kwargs
Parameters: location : None or Location
latitude : None or float
longitude : None or float
**kwargs : see Location
Returns: localized_system : LocalizedPVSystem
-
physicaliam
(aoi)[source]¶ Determine the incidence angle modifier using
self.module_parameters['K']
,self.module_parameters['L']
,self.module_parameters['n']
,aoi
, and thephysicaliam()
function.Parameters: See pvsystem.physicaliam for details Returns: See pvsystem.physicaliam for details
-
sapm
(poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi, **kwargs)[source]¶ Use the
sapm()
function, the input parameters, andself.module_parameters
to calculate Voc, Isc, Ix, Ixx, Vmp/Imp.Parameters: poa_direct : Series
The direct irradiance incident upon the module (W/m^2).
poa_diffuse : Series
The diffuse irradiance incident on module.
temp_cell : Series
The cell temperature (degrees C).
airmass_absolute : Series
Absolute airmass.
aoi : Series
Angle of incidence (degrees).
**kwargs
See pvsystem.sapm for details
Returns: See pvsystem.sapm for details
-
sapm_celltemp
(irrad, wind, temp)[source]¶ Uses
sapm_celltemp()
to calculate module and cell temperatures based onself.racking_model
and the input parameters.Parameters: See pvsystem.sapm_celltemp for details Returns: See pvsystem.sapm_celltemp for details
-
ModelChain¶
-
class
pvlib.modelchain.
ModelChain
(system, location, orientation_strategy='south_at_latitude_tilt', clearsky_model='ineichen', transposition_model='haydavies', solar_position_method='nrel_numpy', airmass_model='kastenyoung1989', **kwargs)[source]¶ Bases:
object
A class that represents all of the modeling steps necessary for calculating power or energy for a PV system at a given location.
Consider an abstract base class.
Parameters: system : PVSystem
The connected set of modules, inverters, etc.
location : location
The physical location at which to evaluate the model.
times : DatetimeIndex
Times at which to evaluate the model.
orientation_strategy : None or str
The strategy for aligning the modules. If not None, sets the
surface_azimuth
andsurface_tilt
properties of thesystem
.clearsky_model : str
Passed to location.get_clearsky.
transposition_model : str
Passed to system.get_irradiance.
solar_position_method : str
Passed to location.get_solarposition.
**kwargs
Arbitrary keyword arguments. Included for compatibility, but not used.
See also
location.Location
,pvsystem.PVSystem
-
orientation_strategy
¶
-
run_model
(times, irradiance=None, weather=None)[source]¶ Run the model.
Parameters: times : DatetimeIndex
irradiance : None or DataFrame
If None, calculates clear sky data. Columns must be ‘dni’, ‘ghi’, ‘dhi’
weather : None or DataFrame
If None, assumes air temperature is 20 C and wind speed is 0 m/s. Columns must be ‘wind_speed’, ‘temp_air’.
Returns: output : DataFrame
Some combination of AC power, DC power, POA irrad, etc.
-
MoreSpecificModelChain¶
-
class
pvlib.modelchain.
MoreSpecificModelChain
(*args, **kwargs)[source]¶ Bases:
pvlib.modelchain.ModelChain
Something more specific.
LocalizedPVSystem¶
-
class
pvlib.pvsystem.
LocalizedPVSystem
(pvsystem=None, location=None, **kwargs)[source]¶ Bases:
pvlib.pvsystem.PVSystem
,pvlib.location.Location
The LocalizedPVSystem class defines a standard set of installed PV system attributes and modeling functions. This class combines the attributes and methods of the PVSystem and Location classes.
See the
PVSystem
class for an object model that describes an unlocalized PV system.
SingleAxisTracker¶
-
class
pvlib.tracking.
SingleAxisTracker
(axis_tilt=0, axis_azimuth=0, max_angle=90, backtrack=True, gcr=0.2857142857142857, **kwargs)[source]¶ Bases:
pvlib.pvsystem.PVSystem
Inherits all of the PV modeling methods from PVSystem.