pvsystem tutorial

This tutorial explores the pvlib.pvsystem module. The module has functions for importing PV module and inverter data and functions for modeling module and inverter performance.

  1. systemdef
  2. Angle of Incidence Modifiers
  3. Sandia Cell Temp correction
  4. Sandia Inverter Model
  5. Sandia Array Performance Model
    1. SAPM IV curves
  6. DeSoto Model
  7. Single Diode Model

This tutorial has been tested against the following package versions:

  • pvlib 0.4.5
  • Python 3.6.2
  • IPython 6.0
  • Pandas 0.20.1

It should work with other Python and Pandas versions. It requires pvlib >= 0.4.0 and IPython >= 3.0.

Authors:

  • Will Holmgren (@wholmgren), University of Arizona. 2015, March 2016, November 2016, May 2017.
In [3]:
# built-in python modules
import os
import inspect
import datetime

# scientific python add-ons
import numpy as np
import pandas as pd

# plotting stuff
# first line makes the plots appear in the notebook
%matplotlib inline 
import matplotlib.pyplot as plt
# seaborn makes your plots look better
try:
    import seaborn as sns
    sns.set(rc={"figure.figsize": (12, 6)})
except ImportError:
    print('We suggest you install seaborn using conda or pip and rerun this cell')

# finally, we import the pvlib library
import pvlib

systemdef

In [4]:
import pvlib
from pvlib import pvsystem

pvlib can import TMY2 and TMY3 data. Here, we import the example files.

In [5]:
pvlib_abspath = os.path.dirname(os.path.abspath(inspect.getfile(pvlib)))

tmy3_data, tmy3_metadata = pvlib.tmy.readtmy3(os.path.join(pvlib_abspath, 'data', '703165TY.csv'))
tmy2_data, tmy2_metadata = pvlib.tmy.readtmy2(os.path.join(pvlib_abspath, 'data', '12839.tm2'))
In [6]:
pvlib.pvsystem.systemdef(tmy3_metadata, 0, 0, .1, 5, 5)
Out[6]:
{'albedo': 0.1,
 'altitude': 7.0,
 'latitude': 55.317,
 'longitude': -160.517,
 'modules_per_string': 5,
 'name': '"SAND POINT"',
 'strings_per_inverter': 5,
 'surface_azimuth': 0,
 'surface_tilt': 0,
 'tz': -9.0}
In [7]:
pvlib.pvsystem.systemdef(tmy2_metadata, 0, 0, .1, 5, 5)
Out[7]:
{'albedo': 0.1,
 'altitude': 2.0,
 'latitude': 25.8,
 'longitude': -80.26666666666667,
 'modules_per_string': 5,
 'name': 'MIAMI',
 'strings_per_inverter': 5,
 'surface_azimuth': 0,
 'surface_tilt': 0,
 'tz': -5}

Angle of Incidence Modifiers

In [8]:
angles = np.linspace(-180,180,3601)
ashraeiam = pd.Series(pvsystem.ashraeiam(angles, .05), index=angles)

ashraeiam.plot()
plt.ylabel('ASHRAE modifier')
plt.xlabel('input angle (deg)')
Out[8]:
Text(0.5,0,'input angle (deg)')
In [9]:
angles = np.linspace(-180,180,3601)
physicaliam = pd.Series(pvsystem.physicaliam(angles), index=angles)

physicaliam.plot()
plt.ylabel('physical modifier')
plt.xlabel('input index')
Out[9]:
Text(0.5,0,'input index')
In [10]:
plt.figure()
ashraeiam.plot(label='ASHRAE')
physicaliam.plot(label='physical')
plt.ylabel('modifier')
plt.xlabel('input angle (deg)')
plt.legend()
Out[10]:
<matplotlib.legend.Legend at 0x1ef51a8acc0>

Sandia Cell Temp correction

PV system efficiency can vary by up to 0.5% per degree C, so it's important to accurately model cell and module temperature. The sapm_celltemp function uses plane of array irradiance, ambient temperature, wind speed, and module and racking type to calculate cell and module temperatures. From King et. al. (2004):

$$T_m = E e^{a+b*WS} + T_a$$$$T_c = T_m + \frac{E}{E_0} \Delta T$$

The $a$, $b$, and $\Delta T$ parameters depend on the module and racking type. The default parameter set is open_rack_cell_glassback.

sapm_celltemp works with either scalar or vector inputs, but always returns a pandas DataFrame.

In [11]:
# scalar inputs
pvsystem.sapm_celltemp(900, 5, 20) # irrad, wind, temp
Out[11]:
temp_cell temp_module
0 43.509191 40.809191
In [12]:
# vector inputs
times = pd.DatetimeIndex(start='2015-01-01', end='2015-01-02', freq='12H')
temps = pd.Series([0, 10, 5], index=times)
irrads = pd.Series([0, 500, 0], index=times)
winds = pd.Series([10, 5, 0], index=times)

pvtemps = pvsystem.sapm_celltemp(irrads, winds, temps)
pvtemps.plot()
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x1ef51ca3f98>

Cell and module temperature as a function of wind speed.

In [13]:
wind = np.linspace(0,20,21)
temps = pd.DataFrame(pvsystem.sapm_celltemp(900, wind, 20), index=wind)

temps.plot()
plt.legend()
plt.xlabel('wind speed (m/s)')
plt.ylabel('temperature (deg C)')
Out[13]:
Text(0,0.5,'temperature (deg C)')

Cell and module temperature as a function of ambient temperature.

In [14]:
atemp = np.linspace(-20,50,71)
temps = pvsystem.sapm_celltemp(900, 2, atemp).set_index(atemp)

temps.plot()
plt.legend()
plt.xlabel('ambient temperature (deg C)')
plt.ylabel('temperature (deg C)')
Out[14]:
Text(0,0.5,'temperature (deg C)')

Cell and module temperature as a function of incident irradiance.

In [15]:
irrad = np.linspace(0,1000,101)
temps = pvsystem.sapm_celltemp(irrad, 2, 20).set_index(irrad)

temps.plot()
plt.legend()
plt.xlabel('incident irradiance (W/m**2)')
plt.ylabel('temperature (deg C)')
Out[15]:
Text(0,0.5,'temperature (deg C)')

Cell and module temperature for different module and racking types.

In [16]:
models = ['open_rack_cell_glassback',
          'roof_mount_cell_glassback',
          'open_rack_cell_polymerback',
          'insulated_back_polymerback',
          'open_rack_polymer_thinfilm_steel',
          '22x_concentrator_tracker']

temps = pd.DataFrame(index=['temp_cell','temp_module'])

for model in models:
    temps[model] = pd.Series(pvsystem.sapm_celltemp(1000, 5, 20, model=model).iloc[0])

temps.T.plot(kind='bar') # try removing the transpose operation and replotting
plt.legend()
plt.ylabel('temperature (deg C)')
Out[16]:
Text(0,0.5,'temperature (deg C)')

snlinverter

In [17]:
inverters = pvsystem.retrieve_sam('sandiainverter')
inverters
Out[17]:
ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_ ABB__MICRO_0_25_I_OUTD_US_208__208V__208V__CEC_2018_ ABB__MICRO_0_25_I_OUTD_US_240_240V__CEC_2014_ ABB__MICRO_0_25_I_OUTD_US_240__240V__240V__CEC_2018_ ABB__MICRO_0_3_I_OUTD_US_208_208V__CEC_2014_ ABB__MICRO_0_3_I_OUTD_US_208__208V__208V__CEC_2018_ ABB__MICRO_0_3_I_OUTD_US_240_240V__CEC_2014_ ABB__MICRO_0_3_I_OUTD_US_240__240V__240V__CEC_2018_ ABB__MICRO_0_3HV_I_OUTD_US_208_208V__CEC_2014_ ABB__MICRO_0_3HV_I_OUTD_US_208__208V__208V__CEC_2018_ ... i_Energy_Corporation__GT260_240V__CEC_2013_ i_Energy__GT260__240V__240V__CEC_2018_ iPower__SHO_1_1__120V__120V__CEC_2018_ iPower__SHO_2_0__240V__240V__CEC_2018_ iPower__SHO_2_5__240V__240V__CEC_2018_ iPower__SHO_3_0__240V__240V__CEC_2018_ iPower__SHO_3_5__240V__240V__CEC_2018_ iPower__SHO_4_6__208V__208V__CEC_2018_ iPower__SHO_4_8__240V__240V__CEC_2018_ iPower__SHO_5_2__240V__240V__CEC_2018_
Vac 208.000000 208.000000 240.000000 240.000000 208.000000 208.000000 240.000000 240.000000 208.000000 208.000000 ... 240.000000 240.000000 120.000000 240.000000 240.000000 240.000000 240.000000 208.000000 240.000000 240.000000
Paco 250.000000 250.000000 250.000000 250.000000 300.000000 300.000000 300.000000 300.000000 300.000000 300.000000 ... 230.000000 230.000000 1100.000000 2000.000000 2500.000000 3000.000000 3500.000000 4600.000000 4800.000000 5200.000000
Pdco 259.522050 259.589000 259.552697 259.492000 311.714554 311.669000 311.504961 311.581000 312.523347 312.423000 ... 245.790658 245.630000 1194.090000 2161.880000 2632.840000 3205.930000 3641.830000 4797.810000 4968.030000 5382.860000
Vdco 40.242603 40.000000 39.982246 40.000000 40.227111 40.000000 40.136095 40.000000 45.259429 45.000000 ... 40.709524 40.000000 182.000000 199.000000 218.000000 222.500000 263.000000 254.000000 263.000000 280.000000
Pso 1.771614 2.089610 1.931194 2.240410 1.971053 1.846510 1.991342 1.950540 1.882620 1.762100 ... 2.511675 2.530100 22.095400 24.465800 42.776500 31.682000 64.768100 54.570100 85.145700 62.486700
C0 -0.000025 -0.000041 -0.000027 -0.000039 -0.000036 -0.000033 -0.000031 -0.000034 -0.000049 -0.000045 ... 0.000048 0.000062 -0.000021 -0.000013 -0.000014 -0.000008 -0.000009 -0.000006 -0.000006 -0.000005
C1 -0.000090 -0.000091 -0.000158 -0.000132 -0.000256 -0.000192 -0.000289 -0.000256 -0.000241 -0.000198 ... -0.000086 -0.000098 0.000057 0.000055 0.000061 0.000036 0.000035 0.000028 0.000034 0.000044
C2 0.000669 0.000494 0.001480 0.002418 -0.000833 0.000907 -0.002110 0.002453 0.000975 0.002208 ... -0.002590 0.000231 0.002001 0.001703 0.002053 0.001708 0.001417 0.001381 0.000586 0.001260
C3 -0.018900 -0.013171 -0.034600 -0.014926 -0.039100 -0.031742 -0.049500 -0.028223 -0.027600 -0.023681 ... 0.157676 0.121032 0.000623 0.000315 0.001530 0.000860 0.001218 0.000889 0.000195 0.000367
Pnt 0.020000 0.020000 0.050000 0.050000 0.020000 0.020000 0.050000 0.050000 0.060000 0.060000 ... 0.150000 0.150000 3.600000 3.600000 3.900000 3.630000 3.860000 4.000000 4.100000 4.000000
Vdcmax 65.000000 50.000000 65.000000 50.000000 65.000000 50.000000 65.000000 50.000000 79.000000 60.000000 ... 59.000000 49.000000 380.000000 380.000000 400.000000 380.000000 400.000000 400.000000 400.000000 400.000000
Idcmax 10.000000 6.489710 10.000000 6.487300 10.000000 7.791730 10.000000 7.789520 10.500000 6.942740 ... 10.000000 6.140760 6.560960 10.863700 12.077200 14.408700 13.847300 18.889000 18.889800 19.224500
Mppt_low 20.000000 30.000000 20.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 ... 30.000000 30.000000 100.000000 100.000000 100.000000 100.000000 100.000000 100.000000 100.000000 240.000000
Mppt_high 50.000000 50.000000 50.000000 50.000000 50.000000 50.000000 50.000000 50.000000 75.000000 60.000000 ... 50.000000 49.000000 380.000000 380.000000 400.000000 380.000000 400.000000 400.000000 400.000000 400.000000

14 rows × 5100 columns

In [18]:
vdcs = pd.Series(np.linspace(0,50,51))
idcs = pd.Series(np.linspace(0,11,110))
pdcs = idcs * vdcs

pacs = pvsystem.snlinverter(vdcs, pdcs, inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'])
#pacs.plot()
plt.plot(pacs, pdcs)
plt.ylabel('ac power')
plt.xlabel('dc power')
C:\Users\cliff\Anaconda3\lib\site-packages\pvlib\pvsystem.py:2200: RuntimeWarning: invalid value encountered in minimum
  ac_power = np.minimum(Paco, ac_power)
Out[18]:
Text(0.5,0,'dc power')

Need to put more effort into describing this function.

DC model

This example shows use of the Desoto module performance model and the Sandia Array Performance Model (SAPM). Both models reuire a set of parameter values which can be read from SAM databases for modules.

Foe the Desoto model, the database content is returned by supplying the keyword cecmod to pvsystem.retrievesam.

In [19]:
cec_modules = pvsystem.retrieve_sam('cecmod')
cec_modules
Out[19]:
1Soltech_1STH_215_P 1Soltech_1STH_220_P 1Soltech_1STH_225_P 1Soltech_1STH_230_P 1Soltech_1STH_235_WH 1Soltech_1STH_240_P 1Soltech_1STH_240_WH 1Soltech_1STH_245_P 1Soltech_1STH_245_WH 1Soltech_1STH_250_P ... iTek_iT_240 iTek_iT_260_HE iTek_iT_265_HE iTek_iT_270_HE iTek_iT_275_HE iTek_iT_280_HE iTek_iT_285_HE iTek_iT_290_HE iTek_iT_295_HE iTek_iT_300_HE
BIPV N N N N N N N N N N ... N N N N N N N N N N
Date 10/7/2010 10/4/2010 10/4/2010 10/4/2010 3/4/2010 4/2/2014 3/4/2010 4/2/2014 3/4/2010 4/2/2014 ... 10/26/2011 2/2/2015 2/2/2015 2/2/2015 2/2/2015 2/2/2015 5/29/2015 5/29/2015 5/29/2015 5/29/2015
T_NOCT 47.4 47.4 47.4 47.4 49.9 43 49.9 43 49.9 43 ... 48.2 44.5 44.5 44.5 44.5 44.5 48.8 48.8 48.7 48.8
A_c 1.567 1.567 1.567 1.567 1.635 1.561 1.635 1.561 1.635 1.561 ... 1.637 1.634 1.634 1.634 1.634 1.634 1.62 1.62 1.62 1.62
N_s 60 60 60 60 60 60 60 60 60 60 ... 60 60 60 60 60 60 60 60 60 60
I_sc_ref 7.84 7.97 8.09 8.18 8.54 8.62 8.58 8.65 8.62 8.69 ... 8.7 8.9 9 9.1 9.2 9.3 10.05 10.08 9.9 10.08
V_oc_ref 36.3 36.6 36.9 37.1 37 36.9 37.1 37.1 37.2 37.3 ... 38 38.6 38.7 38.9 39 39.2 40.9 41.2 41.2 41.2
I_mp_ref 7.35 7.47 7.58 7.65 8.02 8.08 8.07 8.14 8.1 8.25 ... 8.2 8.2 8.3 8.4 8.5 8.6 9.53 9.57 9.43 9.57
V_mp_ref 29 29.3 29.6 29.9 29.3 29.7 29.7 30.1 30.2 30.3 ... 30 31.7 31.8 32 32.1 32.3 33.6 34 34.5 34
alpha_sc 0.007997 0.008129 0.008252 0.008344 0.00743 0.010085 0.007465 0.010121 0.007499 0.010167 ... 0.00348 0.00356 0.0036 0.00364 0.00368 0.00372 0.00376 0.0038 0.00384 0.00388
beta_oc -0.13104 -0.13213 -0.13321 -0.13393 -0.13653 -0.13432 -0.1369 -0.13504 -0.13727 -0.13577 ... -0.1292 -0.10808 -0.10836 -0.10892 -0.1092 -0.10976 -0.11397 -0.11455 -0.11513 -0.11542
a_ref 1.6413 1.6572 1.6732 1.6888 1.6292 1.6068 1.6425 1.6195 1.6617 1.629 ... 1.6204 1.527 1.5306 1.5386 1.5422 1.5503 1.5904 1.5986 1.6069 1.6107
I_L_ref 7.843 7.974 8.094 8.185 8.543 8.626 8.582 8.653 8.623 8.781 ... 8.7 8.923 9.022 9.121 9.221 9.32 9.418 9.517 9.617 9.716
I_o_ref 1.936e-09 2.03e-09 2.126e-09 2.332e-09 1.166e-09 9.08e-10 1.325e-09 9.68e-10 1.623e-09 9.92e-10 ... 5.68e-10 9e-11 9.06e-11 9.19e-11 9.25e-11 9.39e-11 1.69e-10 1.71e-10 1.74e-10 1.75e-10
R_s 0.359 0.346 0.334 0.311 0.383 0.316 0.335 0.282 0.272 0.275 ... 0.411 0.276 0.271 0.265 0.26 0.254 0.241 0.235 0.229 0.225
R_sh_ref 839.4 751.03 670.65 462.56 1257.84 452.56 1463.82 790.96 724.06 600.38 ... 25925.1 109.16 111.38 113.85 116.21 118.83 125.87 128.9 132.03 135.1
Adjust 16.5 16.8 17.1 17.9 8.7 7.736 9.8 8.259 11.6 8.361 ... 11.88 17.19 17.14 17.17 17.12 17.15 18.44 18.47 18.5 18.47
gamma_r -0.495 -0.495 -0.495 -0.495 -0.482 -0.43 -0.482 -0.43 -0.482 -0.43 ... -0.5 -0.4 -0.4 -0.4 -0.4 -0.4 -0.42 -0.42 -0.42 -0.42
Version MM107 MM107 MM107 MM107 MM107 NRELv1 MM107 NRELv1 MM107 NRELv1 ... NRELv1 NRELv1 NRELv1 NRELv1 NRELv1 NRELv1 NRELv1 NRELv1 NRELv1 NRELv1
PTC 189.4 194 198.5 203.1 205.1 220.6 209.6 225.3 214.1 230 ... 210.6 239 243.7 248.4 253.1 257.8 292.1 296.8 296.9 296.8
Technology Multi-c-Si Multi-c-Si Multi-c-Si Multi-c-Si Mono-c-Si Multi-c-Si Mono-c-Si Multi-c-Si Mono-c-Si Multi-c-Si ... Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si Mono-c-Si

21 rows × 19254 columns

In [20]:
cecmodule = cec_modules.Example_Module 
cecmodule
Out[20]:
BIPV                   Y
Date           4/28/2008
T_NOCT                65
A_c                 0.67
N_s                   18
I_sc_ref             7.5
V_oc_ref            10.4
I_mp_ref             6.6
V_mp_ref             8.4
alpha_sc           0.003
beta_oc            -0.04
a_ref              0.473
I_L_ref            7.545
I_o_ref         1.94e-09
R_s                0.094
R_sh_ref           15.72
Adjust              10.6
gamma_r             -0.5
Version            MM105
PTC                 48.9
Technology    Multi-c-Si
Name: Example_Module, dtype: object

The Sandia module database is read by the same function with the keyword SandiaMod.

In [21]:
sandia_modules = pvsystem.retrieve_sam(name='SandiaMod')
sandia_modules
Out[21]:
Advent_Solar_AS160___2006_ Advent_Solar_Ventura_210___2008_ Advent_Solar_Ventura_215___2009_ Aleo_S03_160__2007__E__ Aleo_S03_165__2007__E__ Aleo_S16_165__2007__E__ Aleo_S16_170__2007__E__ Aleo_S16_175__2007__E__ Aleo_S16_180__2007__E__ Aleo_S16_185__2007__E__ ... Panasonic_VBHN235SA06B__2013_ Trina_TSM_240PA05__2013_ Hanwha_HSL60P6_PA_4_250T__2013_ Suniva_OPT300_72_4_100__2013_ Canadian_Solar_CS6X_300M__2013_ LG_LG290N1C_G3__2013_ Sharp_NDQ235F4__2013_ Solar_Frontier_SF_160S__2013_ SolarWorld_Sunmodule_250_Poly__2013_ Silevo_Triex_U300_Black__2014_
Vintage 2006 2008 2009 2007 (E) 2007 (E) 2007 (E) 2007 (E) 2007 (E) 2007 (E) 2007 (E) ... 2013 2013 2013 2013 2013 2013 2013 2013 2013 2014
Area 1.312 1.646 1.646 1.28 1.28 1.378 1.378 1.378 1.378 1.378 ... 1.26 1.63 1.65 1.93 1.91 1.64 1.56 1.22 1.68 1.68
Material mc-Si mc-Si mc-Si c-Si c-Si mc-Si mc-Si mc-Si mc-Si mc-Si ... a-Si / mono-Si mc-Si mc-Si c-Si c-Si c-Si mc-Si CIS mc-Si c-Si
Cells_in_Series 72 60 60 72 72 50 50 50 50 50 ... 72 60 60 72 72 60 60 172 60 96
Parallel_Strings 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1
Isco 5.564 8.34 8.49 5.1 5.2 7.9 7.95 8.1 8.15 8.2 ... 5.8738 8.8449 8.5935 8.5753 8.6388 9.8525 8.6739 2.0259 8.3768 5.771
Voco 42.832 35.31 35.92 43.5 43.6 30 30.1 30.2 30.3 30.5 ... 52.0042 36.8926 36.8075 44.2921 43.5918 39.6117 36.8276 112.505 36.3806 68.5983
Impo 5.028 7.49 7.74 4.55 4.65 7.08 7.23 7.38 7.53 7.67 ... 5.5383 8.2955 8.0822 7.963 8.1359 9.2473 8.1243 1.8356 7.6921 5.383
Vmpo 32.41 27.61 27.92 35.6 35.8 23.3 23.5 23.7 23.9 24.1 ... 43.1204 29.066 29.2011 35.0837 34.9531 31.2921 29.1988 86.6752 28.348 55.4547
Aisc 0.000537 0.00077 0.00082 0.0003 0.0003 0.0008 0.0008 0.0008 0.0008 0.0008 ... 0.0005 0.0004 0.0004 0.0006 0.0005 0.0002 0.0006 0.0001 0.0006 0.0003
Aimp -0.000491 -0.00015 -0.00013 -0.00025 -0.00025 -0.0003 -0.0003 -0.0003 -0.0003 -0.0003 ... -0.0001 -0.0003 -0.0003 -0.0002 -0.0001 -0.0004 -0.0002 -0.0003 -0.0001 -0.0003
C0 1.0233 0.937 1.015 0.99 0.99 0.99 0.99 0.99 0.99 0.99 ... 1.0015 1.0116 1.0061 0.999 1.0121 1.0145 1.0049 1.0096 1.0158 0.995
C1 -0.0233 0.063 -0.015 0.01 0.01 0.01 0.01 0.01 0.01 0.01 ... -0.0015 -0.0116 -0.0061 0.001 -0.0121 -0.0145 -0.0049 -0.0096 -0.0158 0.005
Bvoco -0.1703 -0.133 -0.135 -0.152 -0.152 -0.11 -0.11 -0.11 -0.11 -0.11 ... -0.1411 -0.137 -0.1263 -0.155 -0.1532 -0.1205 -0.1279 -0.3044 -0.1393 -0.1913
Mbvoc 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
Bvmpo -0.1731 -0.135 -0.136 -0.158 -0.158 -0.115 -0.115 -0.115 -0.115 -0.115 ... -0.1366 -0.1441 -0.1314 -0.1669 -0.1634 -0.1337 -0.1348 -0.2339 -0.1449 -0.184
Mbvmp 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
N 1.174 1.495 1.373 1.25 1.25 1.35 1.35 1.35 1.35 1.35 ... 1.029 1.2073 1.0686 1.0771 1.0025 1.0925 1.0695 1.2066 1.226 1.345
C2 -0.76444 0.0182 0.0036 -0.15 -0.15 -0.12 -0.12 -0.12 -0.12 -0.12 ... 0.2859 -0.07993 -0.2585 -0.355 -0.171 -0.4647 -0.2718 -0.5426 -0.09677 0.3221
C3 -15.5087 -10.758 -7.2509 -8.96 -8.96 -11.08 -11.08 -11.08 -11.08 -11.08 ... -5.48455 -7.27624 -9.85905 -13.0643 -9.39745 -11.9008 -11.4033 -15.2598 -8.51148 -6.7178
A0 0.9281 0.9067 0.9323 0.938 0.938 0.924 0.924 0.924 0.924 0.924 ... 0.9161 0.9645 0.9428 0.9327 0.9371 0.9731 0.9436 0.9354 0.9288 0.9191
A1 0.06615 0.09573 0.06526 0.05422 0.05422 0.06749 0.06749 0.06749 0.06749 0.06749 ... 0.07968 0.02753 0.0536 0.07283 0.06262 0.02966 0.04765 0.06809 0.07201 0.09988
A2 -0.01384 -0.0266 -0.01567 -0.009903 -0.009903 -0.012549 -0.012549 -0.012549 -0.012549 -0.012549 ... -0.01866 -0.002848 -0.01281 -0.02402 -0.01667 -0.01024 -0.007405 -0.02094 -0.02065 -0.04273
A3 0.001298 0.00343 0.00193 0.0007297 0.0007297 0.0010049 0.0010049 0.0010049 0.0010049 0.0010049 ... 0.002278 -0.0001439 0.001826 0.003819 0.002168 0.001793 0.0003818 0.00293 0.002862 0.00937
A4 -4.6e-05 -0.0001794 -9.81e-05 -1.907e-05 -1.907e-05 -2.8797e-05 -2.8797e-05 -2.8797e-05 -2.8797e-05 -2.8797e-05 ... -0.0001118 2.219e-05 -0.0001048 -0.000235 -0.0001087 -0.0001286 -1.101e-05 -0.0001564 -0.0001544 -0.0007643
B0 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1
B1 -0.002438 -0.002438 -0.002438 -0.002438 -0.002438 -0.002438 -0.002438 -0.002438 -0.002438 -0.002438 ... -0.01053 -0.00261 -0.007861 -0.006801 -0.00789 -0.0154 -0.00464 -0.0152 -0.00308 -0.006498
B2 0.0003103 0.00031 0.00031 0.0003103 0.0003103 0.0003103 0.0003103 0.0003103 0.0003103 0.0003103 ... 0.001149 0.0003279 0.0009058 0.0007968 0.0008656 0.001572 0.000559 0.001598 0.0004053 0.0006908
B3 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 -1.246e-05 ... -4.268e-05 -1.458e-05 -3.496e-05 -3.095e-05 -3.298e-05 -5.525e-05 -2.249e-05 -5.682e-05 -1.729e-05 -2.678e-05
B4 2.11e-07 2.11e-07 2.11e-07 2.11e-07 2.11e-07 2.11e-07 2.11e-07 2.11e-07 2.11e-07 2.11e-07 ... 6.517e-07 2.654e-07 5.473e-07 4.896e-07 5.178e-07 8.04e-07 3.673e-07 8.326e-07 2.997e-07 4.322e-07
B5 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 -1.36e-09 ... -3.556e-09 -1.732e-09 -3.058e-09 -2.78e-09 -2.918e-09 -4.202e-09 -2.144e-09 -4.363e-09 -1.878e-09 -2.508e-09
DTC 3 3 3 3 3 3 3 3 3 3 ... 2.03 3.03 2.55 2.58 3.2 3.05 3.27 3.29 3.19 3.13
FD 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1
A -3.35 -3.45 -3.47 -3.56 -3.56 -3.56 -3.56 -3.56 -3.56 -3.56 ... -3.7489 -3.5924 -3.5578 -3.7566 -3.6024 -3.4247 -3.7445 -3.6836 -3.73 -3.6866
B -0.1161 -0.077 -0.087 -0.075 -0.075 -0.075 -0.075 -0.075 -0.075 -0.075 ... -0.1287 -0.1319 -0.1766 -0.156 -0.2106 -0.0951 -0.149 -0.1483 -0.1483 -0.104
C4 0.9974 0.972 0.989 0.995 0.995 0.995 0.995 0.995 0.995 0.995 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
C5 0.0026 0.028 0.012 0.005 0.005 0.005 0.005 0.005 0.005 0.005 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
IXO 5.54 8.25 8.49 5.04 5.14 7.8 7.85 8 8.05 8.1 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
IXXO 3.56 5.2 5.45 3.16 3.25 4.92 5.08 5.18 5.39 5.54 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
C6 1.173 1.067 1.137 1.15 1.15 1.15 1.15 1.15 1.15 1.15 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
C7 -0.173 -0.067 -0.137 -0.15 -0.15 -0.15 -0.15 -0.15 -0.15 -0.15 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Notes Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... Source: Sandia National Laboratories Updated 9... ... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2013. Mo... Source: CFV Solar Test Lab. Tested 2014. Mo...

42 rows × 523 columns

In [22]:
sandia_module = sandia_modules.Canadian_Solar_CS5P_220M___2009_
sandia_module
Out[22]:
Vintage                                                          2009
Area                                                            1.701
Material                                                         c-Si
Cells_in_Series                                                    96
Parallel_Strings                                                    1
Isco                                                          5.09115
Voco                                                          59.2608
Impo                                                          4.54629
Vmpo                                                          48.3156
Aisc                                                         0.000397
Aimp                                                         0.000181
C0                                                            1.01284
C1                                                         -0.0128398
Bvoco                                                        -0.21696
Mbvoc                                                               0
Bvmpo                                                       -0.235488
Mbvmp                                                               0
N                                                              1.4032
C2                                                           0.279317
C3                                                           -7.24463
A0                                                           0.928385
A1                                                           0.068093
A2                                                         -0.0157738
A3                                                          0.0016606
A4                                                          -6.93e-05
B0                                                                  1
B1                                                          -0.002438
B2                                                          0.0003103
B3                                                         -1.246e-05
B4                                                           2.11e-07
B5                                                          -1.36e-09
DTC                                                                 3
FD                                                                  1
A                                                            -3.40641
B                                                          -0.0842075
C4                                                           0.996446
C5                                                           0.003554
IXO                                                           4.97599
IXXO                                                          3.18803
C6                                                            1.15535
C7                                                          -0.155353
Notes               Source: Sandia National Laboratories Updated 9...
Name: Canadian_Solar_CS5P_220M___2009_, dtype: object

Generate some irradiance data for modeling.

In [23]:
from pvlib import clearsky
from pvlib import irradiance
from pvlib import atmosphere
from pvlib.location import Location

tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')

times_loc = pd.date_range(start=datetime.datetime(2014,4,1), end=datetime.datetime(2014,4,2), freq='30s', tz=tus.tz)
solpos = pvlib.solarposition.get_solarposition(times_loc, tus.latitude, tus.longitude)
dni_extra = pvlib.irradiance.extraradiation(times_loc)
airmass = pvlib.atmosphere.relativeairmass(solpos['apparent_zenith'])
pressure = pvlib.atmosphere.alt2pres(tus.altitude)
am_abs = pvlib.atmosphere.absoluteairmass(airmass, pressure)
cs = tus.get_clearsky(times_loc)

surface_tilt = tus.latitude
surface_azimuth = 180  # pointing south

aoi = pvlib.irradiance.aoi(surface_tilt, surface_azimuth,
                           solpos['apparent_zenith'], solpos['azimuth'])
total_irrad = pvlib.irradiance.total_irrad(surface_tilt,
                                           surface_azimuth,
                                           solpos['apparent_zenith'],
                                           solpos['azimuth'],
                                           cs['dni'], cs['ghi'], cs['dhi'],
                                           dni_extra=dni_extra,
                                           model='haydavies')

Now we can run the module parameters and the irradiance data through the SAPM functions.

In [24]:
module = sandia_module

# a sunny, calm, and hot day in the desert
temps = pvsystem.sapm_celltemp(total_irrad['poa_global'], 0, 30)

effective_irradiance = pvlib.pvsystem.sapm_effective_irradiance(
    total_irrad['poa_direct'], total_irrad['poa_diffuse'],
    am_abs, aoi, module)

sapm_1 = pvlib.pvsystem.sapm(effective_irradiance, temps['temp_cell'], module)

sapm_1.plot()
C:\Users\cliff\Anaconda3\lib\site-packages\pvlib\pvsystem.py:1479: RuntimeWarning: invalid value encountered in maximum
  spectral_loss = np.maximum(0, np.polyval(am_coeff, airmass_absolute))
Out[24]:
<matplotlib.axes._subplots.AxesSubplot at 0x1ef526a50f0>
In [25]:
def plot_sapm(sapm_data, effective_irradiance):
    """
    Makes a nice figure with the SAPM data.
    
    Parameters
    ----------
    sapm_data : DataFrame
        The output of ``pvsystem.sapm``
    """
    fig, axes = plt.subplots(2, 3, figsize=(16,10), sharex=False, sharey=False, squeeze=False)
    plt.subplots_adjust(wspace=.2, hspace=.3)

    ax = axes[0,0]
    sapm_data.filter(like='i_').plot(ax=ax)
    ax.set_ylabel('Current (A)')

    ax = axes[0,1]
    sapm_data.filter(like='v_').plot(ax=ax)
    ax.set_ylabel('Voltage (V)')

    ax = axes[0,2]
    sapm_data.filter(like='p_').plot(ax=ax)
    ax.set_ylabel('Power (W)')

    ax = axes[1,0]
    [ax.plot(effective_irradiance, current, label=name) for name, current in
     sapm_data.filter(like='i_').iteritems()]
    ax.set_ylabel('Current (A)')
    ax.set_xlabel('Effective Irradiance')
    ax.legend(loc=2)

    ax = axes[1,1]
    [ax.plot(effective_irradiance, voltage, label=name) for name, voltage in
     sapm_data.filter(like='v_').iteritems()]
    ax.set_ylabel('Voltage (V)')
    ax.set_xlabel('Effective Irradiance')
    ax.legend(loc=4)

    ax = axes[1,2]
    ax.plot(effective_irradiance, sapm_data['p_mp'], label='p_mp')
    ax.set_ylabel('Power (W)')
    ax.set_xlabel('Effective Irradiance')
    ax.legend(loc=2)

    # needed to show the time ticks
    for ax in axes.flatten():
        for tk in ax.get_xticklabels():
            tk.set_visible(True)
In [26]:
plot_sapm(sapm_1, effective_irradiance)

For comparison, here's the SAPM for a sunny, windy, cold version of the same day.

In [27]:
temps = pvsystem.sapm_celltemp(total_irrad['poa_global'], 10, 5)

sapm_2 = pvlib.pvsystem.sapm(effective_irradiance, temps['temp_cell'], module)

plot_sapm(sapm_2, effective_irradiance)
In [28]:
sapm_1['p_mp'].plot(label='30 C,  0 m/s')
sapm_2['p_mp'].plot(label=' 5 C, 10 m/s')
plt.legend()
plt.ylabel('Pmp')
plt.title('Comparison of a hot, calm day and a cold, windy day')
Out[28]:
Text(0.5,1,'Comparison of a hot, calm day and a cold, windy day')

SAPM IV curves

The IV curve function only calculates the 5 points of the SAPM. We will add arbitrary points in a future release, but for now we just interpolate between the 5 SAPM points.

In [29]:
import warnings
warnings.simplefilter('ignore', np.RankWarning)
In [30]:
def sapm_to_ivframe(sapm_row):
    pnt = sapm_row

    ivframe = {'Isc': (pnt['i_sc'], 0),
              'Pmp': (pnt['i_mp'], pnt['v_mp']),
              'Ix': (pnt['i_x'], 0.5*pnt['v_oc']),
              'Ixx': (pnt['i_xx'], 0.5*(pnt['v_oc']+pnt['v_mp'])),
              'Voc': (0, pnt['v_oc'])}
    ivframe = pd.DataFrame(ivframe, index=['current', 'voltage']).T
    ivframe = ivframe.sort_values(by='voltage')
    
    return ivframe

def ivframe_to_ivcurve(ivframe, points=100):
    ivfit_coefs = np.polyfit(ivframe['voltage'], ivframe['current'], 30)
    fit_voltages = np.linspace(0, ivframe.loc['Voc', 'voltage'], points)
    fit_currents = np.polyval(ivfit_coefs, fit_voltages)
    
    return fit_voltages, fit_currents
In [31]:
times = ['2014-04-01 07:00:00', '2014-04-01 08:00:00', '2014-04-01 09:00:00', 
         '2014-04-01 10:00:00', '2014-04-01 11:00:00', '2014-04-01 12:00:00']
times.reverse()

fig, ax = plt.subplots(1, 1, figsize=(12,8))

for time in times:
    ivframe = sapm_to_ivframe(sapm_1.loc[time])

    fit_voltages, fit_currents = ivframe_to_ivcurve(ivframe)

    ax.plot(fit_voltages, fit_currents, label=time)
    ax.plot(ivframe['voltage'], ivframe['current'], 'ko')
    
ax.set_xlabel('Voltage (V)')
ax.set_ylabel('Current (A)')
ax.set_ylim(0, None)
ax.set_title('IV curves at multiple times')
ax.legend()
Out[31]:
<matplotlib.legend.Legend at 0x1ef55d9cc18>

desoto

The same weather data run through the Desoto model.

In [33]:
photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth = (
    pvsystem.calcparams_desoto(total_irrad['poa_global'],
                               temp_cell=temps['temp_cell'],
                               alpha_sc=cecmodule['alpha_sc'],
                               a_ref=cecmodule['a_ref'],
                               I_L_ref=cecmodule['I_L_ref'],
                               I_o_ref=cecmodule['I_o_ref'],
                               R_sh_ref=cecmodule['R_sh_ref'],
                               R_s=cecmodule['R_s']) )
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-33-3b8f2876ffe0> in <module>()
      7                                I_o_ref=cecmodule['I_o_ref'],
      8                                R_sh_ref=cecmodule['R_sh_ref'],
----> 9                                R_s=cecmodule['R_s']) )

TypeError: calcparams_desoto() got an unexpected keyword argument 'alpha_sc'
In [34]:
photocurrent.plot()
plt.ylabel('Light current I_L (A)')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-34-216ea8098a3e> in <module>()
----> 1 photocurrent.plot()
      2 plt.ylabel('Light current I_L (A)')

NameError: name 'photocurrent' is not defined
In [35]:
saturation_current.plot()
plt.ylabel('Saturation current I_0 (A)')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-35-34fefecf2a4a> in <module>()
----> 1 saturation_current.plot()
      2 plt.ylabel('Saturation current I_0 (A)')

NameError: name 'saturation_current' is not defined
In [33]:
resistance_series
Out[33]:
0.094
In [34]:
resistance_shunt.plot()
plt.ylabel('Shunt resistance (ohms)')
plt.ylim(0,100)
Out[34]:
(0, 100)
In [35]:
nNsVth.plot()
plt.ylabel('nNsVth')
Out[35]:
<matplotlib.text.Text at 0x11479d160>

Single diode model

In [36]:
single_diode_out = pvsystem.singlediode(photocurrent, saturation_current,
                                        resistance_series, resistance_shunt, nNsVth)
/Users/holmgren/git_repos/pvlib2/pvlib-python/pvlib/pvsystem.py:1943: RuntimeWarning: invalid value encountered in true_divide
  I = -V/(Rs + Rsh) - (nNsVth/Rs)*lambertwterm + Rsh*(IL + I0)/(Rs + Rsh)
In [37]:
single_diode_out['i_sc'].plot()
Out[37]:
<matplotlib.axes._subplots.AxesSubplot at 0x116445a20>
In [38]:
single_diode_out['v_oc'].plot()
Out[38]:
<matplotlib.axes._subplots.AxesSubplot at 0x113d9aef0>
In [39]:
single_diode_out['p_mp'].plot()
Out[39]:
<matplotlib.axes._subplots.AxesSubplot at 0x1151764a8>
In [ ]: