Skip to content

Updated pointers to current SAM files, updated column names, ... #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/sphinx/source/whatsnew/v0.2.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This is a minor release from 0.2. It includes a large number of bug fixes
for the IPython notebook tutorials.
We recommend that all users upgrade to this version.

Enhancements
~~~~~~~~~~~~

* Update component info from SAM (csvs dated 2015-6-30) (:issue:`75`)


Bug fixes
~~~~~~~~~

Expand All @@ -16,4 +22,5 @@ Bug fixes
Contributors
~~~~~~~~~~~~

* Will Holmgren
* Will Holmgren
* Jessica Forbess
52 changes: 31 additions & 21 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
database. The module_parameters dict must contain the
following 5 fields:

* A_ref - modified diode ideality factor parameter at
* a_ref - modified diode ideality factor parameter at
reference conditions (units of eV), a_ref can be calculated
from the usual diode ideality factor (n),
number of cells in series (Ns),
and cell temperature (Tcell) per equation (2) in [1].
* I_l_ref - Light-generated current (or photocurrent)
* I_L_ref - Light-generated current (or photocurrent)
in amperes at reference conditions. This value is referred to
as Iph in some literature.
* I_o_ref - diode reverse saturation current in amperes,
Expand Down Expand Up @@ -447,8 +447,8 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
'''

M = np.max(M, 0)
a_ref = module_parameters['A_ref']
IL_ref = module_parameters['I_l_ref']
a_ref = module_parameters['a_ref']
IL_ref = module_parameters['I_L_ref']
I0_ref = module_parameters['I_o_ref']
Rsh_ref = module_parameters['R_sh_ref']
Rs_ref = module_parameters['R_s']
Expand All @@ -472,13 +472,13 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,

def retrieve_sam(name=None, samfile=None):
'''
Retrieve lastest module and inverter info from SAM website.
Retrieve latest module and inverter info from SAM website.

This function will retrieve either:

* CEC module database
* Sandia Module database
* Sandia Inverter database
* CEC Inverter database

and return it as a pandas dataframe.

Expand All @@ -489,7 +489,8 @@ def retrieve_sam(name=None, samfile=None):
Name can be one of:

* 'CECMod' - returns the CEC module database
* 'SandiaInverter' - returns the Sandia Inverter database
* 'CECInverter' - returns the CEC Inverter database
* 'SandiaInverter' - returns the CEC Inverter database (CEC is only current inverter db available; tag kept for backwards compatibility)
* 'SandiaMod' - returns the Sandia Module database

samfile : String
Expand All @@ -503,14 +504,14 @@ def retrieve_sam(name=None, samfile=None):
Returns
-------
A DataFrame containing all the elements of the desired database.
Each column representa a module or inverter, and a specific dataset
can be retreived by the command
Each column represents a module or inverter, and a specific dataset
can be retrieved by the command

Examples
--------

>>> from pvlib import pvsystem
>>> invdb = pvsystem.retrieve_sam(name='SandiaInverter')
>>> invdb = pvsystem.retrieve_sam(name='CECInverter')
>>> inverter = invdb.AE_Solar_Energy__AE6_0__277V__277V__CEC_2012_
>>> inverter
Vac 277.000000
Expand All @@ -534,11 +535,11 @@ def retrieve_sam(name=None, samfile=None):
name = name.lower()

if name == 'cecmod':
url = 'https://sam.nrel.gov/sites/sam.nrel.gov/files/sam-library-cec-modules-2014-1-14.csv'
url = 'https://sam.nrel.gov/sites/sam.nrel.gov/files/sam-library-cec-modules-2015-6-30.csv'
elif name == 'sandiamod':
url = 'https://sam.nrel.gov/sites/sam.nrel.gov/files/sam-library-sandia-modules-2014-1-14.csv'
elif name == 'sandiainverter':
url = 'https://sam.nrel.gov/sites/sam.nrel.gov/files/sam-library-sandia-inverters-2014-1-14.csv'
url = 'https://sam.nrel.gov/sites/sam.nrel.gov/files/sam-library-sandia-modules-2015-6-30.csv'
elif name in ['cecinverter', 'sandiainverter']: # Allowing either, to provide for old code, while aligning with current expectations
url = 'https://sam.nrel.gov/sites/sam.nrel.gov/files/sam-library-cec-inverters-2015-6-30.csv'
elif samfile is None:
raise ValueError('invalid name {}'.format(name))

Expand All @@ -561,13 +562,22 @@ def retrieve_sam(name=None, samfile=None):


def _parse_raw_sam_df(csvdata):
df = pd.read_csv(csvdata, index_col=0)
df = pd.read_csv(csvdata, index_col=0, skiprows=[1,2])
colnames = df.columns.values.tolist()
parsedcolnames = []
for cn in colnames:
parsedcolnames.append(cn.replace(' ', '_'))

df.columns = parsedcolnames

parsedindex = []
for index in df.index:
parsedindex.append(index.replace(' ', '_').replace('-', '_')
.replace('.', '_').replace('(', '_')
.replace(')', '_').replace('[', '_')
.replace(']', '_').replace(':', '_'))
.replace(']', '_').replace(':', '_')
.replace('+', '_').replace('/', '_')
.replace('"', '_').replace(',', '_'))

df.index = parsedindex
df = df.transpose()
Expand Down Expand Up @@ -635,7 +645,7 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
reference condition (1/C)
Aimp Maximum power current temperature coefficient at
reference condition (1/C)
Bvoc Open circuit voltage temperature coefficient at
Bvoco Open circuit voltage temperature coefficient at
reference condition (V/C)
Mbvoc Coefficient providing the irradiance dependence for the BetaVoc
temperature coefficient at reference irradiance (V/C)
Expand All @@ -644,7 +654,7 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
Mbvmp Coefficient providing the irradiance dependence for the
BetaVmp temperature coefficient at reference irradiance (V/C)
N Empirically determined "diode factor" (dimensionless)
#Series Number of cells in series in a module's cell string(s)
Cells_in_Series Number of cells in series in a module's cell string(s)
IXO Ix at reference conditions
IXXO Ixx at reference conditions
FD Fraction of diffuse irradiance used by module
Expand Down Expand Up @@ -693,12 +703,12 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
(1 + module['Aimp']*(temp_cell - T0)) )

dfout['v_oc'] = (( module['Voco'] +
module['#Series']*delta*np.log(Ee) + Bvoco*(temp_cell - T0) )
module['Cells_in_Series']*delta*np.log(Ee) + Bvoco*(temp_cell - T0) )
.clip_lower(0))

dfout['v_mp'] = ( module['Vmpo'] +
module['C2']*module['#Series']*delta*np.log(Ee) +
module['C3']*module['#Series']*((delta*np.log(Ee)) ** 2) +
module['C2']*module['Cells_in_Series']*delta*np.log(Ee) +
module['C3']*module['Cells_in_Series']*((delta*np.log(Ee)) ** 2) +
Bvmpo*(temp_cell - T0) ).clip_lower(0)

dfout['p_mp'] = dfout['i_mp'] * dfout['v_mp']
Expand Down
12 changes: 6 additions & 6 deletions pvlib/test/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_physicaliam():
def test_retrieve_sam_network():
sam_data['cecmod'] = pvsystem.retrieve_sam('cecmod')
sam_data['sandiamod'] = pvsystem.retrieve_sam('sandiamod')
sam_data['sandiainverter'] = pvsystem.retrieve_sam('sandiainverter')
sam_data['cecinverter'] = pvsystem.retrieve_sam('cecinverter')


def test_sapm():
Expand All @@ -117,7 +117,7 @@ def test_calcparams_desoto():
cecmodule = sam_data['cecmod'].Example_Module
pvsystem.calcparams_desoto(irrad_data['ghi'],
temp_cell=25,
alpha_isc=cecmodule['Alpha_sc'],
alpha_isc=cecmodule['alpha_sc'],
module_parameters=cecmodule,
EgRef=1.121,
dEgdT=-0.0002677)
Expand All @@ -133,7 +133,7 @@ def test_singlediode_series():
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
irrad_data['ghi'],
temp_cell=25,
alpha_isc=cecmodule['Alpha_sc'],
alpha_isc=cecmodule['alpha_sc'],
module_parameters=cecmodule,
EgRef=1.121,
dEgdT=-0.0002677)
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_sapm_celltemp_with_index():


def test_snlinverter():
inverters = sam_data['sandiainverter']
inverters = sam_data['cecinverter']
testinv = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'
vdcs = pd.Series(np.linspace(0,50,3))
idcs = pd.Series(np.linspace(0,11,3))
Expand All @@ -191,12 +191,12 @@ def test_snlinverter():


def test_snlinverter_float():
inverters = sam_data['sandiainverter']
inverters = sam_data['cecinverter']
testinv = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'
vdcs = 25.
idcs = 5.5
pdcs = idcs * vdcs

pacs = pvsystem.snlinverter(inverters[testinv], vdcs, pdcs)
assert_almost_equals(pacs, 132.004308, 5)
assert_almost_equals(pacs, 132.004278, 5)