Skip to content

Commit a4460db

Browse files
committed
Merge pull request #80 from jforbess/issue75
Updated pointers to current SAM files, updated column names, ...
2 parents 8f8422c + 9250dbd commit a4460db

File tree

3 files changed

+45
-28
lines changed

3 files changed

+45
-28
lines changed

docs/sphinx/source/whatsnew/v0.2.1.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ This is a minor release from 0.2. It includes a large number of bug fixes
77
for the IPython notebook tutorials.
88
We recommend that all users upgrade to this version.
99

10+
Enhancements
11+
~~~~~~~~~~~~
12+
13+
* Update component info from SAM (csvs dated 2015-6-30) (:issue:`75`)
14+
15+
1016
Bug fixes
1117
~~~~~~~~~
1218

@@ -16,4 +22,5 @@ Bug fixes
1622
Contributors
1723
~~~~~~~~~~~~
1824

19-
* Will Holmgren
25+
* Will Holmgren
26+
* Jessica Forbess

pvlib/pvsystem.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
294294
database. The module_parameters dict must contain the
295295
following 5 fields:
296296
297-
* A_ref - modified diode ideality factor parameter at
297+
* a_ref - modified diode ideality factor parameter at
298298
reference conditions (units of eV), a_ref can be calculated
299299
from the usual diode ideality factor (n),
300300
number of cells in series (Ns),
301301
and cell temperature (Tcell) per equation (2) in [1].
302-
* I_l_ref - Light-generated current (or photocurrent)
302+
* I_L_ref - Light-generated current (or photocurrent)
303303
in amperes at reference conditions. This value is referred to
304304
as Iph in some literature.
305305
* I_o_ref - diode reverse saturation current in amperes,
@@ -447,8 +447,8 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
447447
'''
448448

449449
M = np.max(M, 0)
450-
a_ref = module_parameters['A_ref']
451-
IL_ref = module_parameters['I_l_ref']
450+
a_ref = module_parameters['a_ref']
451+
IL_ref = module_parameters['I_L_ref']
452452
I0_ref = module_parameters['I_o_ref']
453453
Rsh_ref = module_parameters['R_sh_ref']
454454
Rs_ref = module_parameters['R_s']
@@ -472,13 +472,13 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
472472

473473
def retrieve_sam(name=None, samfile=None):
474474
'''
475-
Retrieve lastest module and inverter info from SAM website.
475+
Retrieve latest module and inverter info from SAM website.
476476
477477
This function will retrieve either:
478478
479479
* CEC module database
480480
* Sandia Module database
481-
* Sandia Inverter database
481+
* CEC Inverter database
482482
483483
and return it as a pandas dataframe.
484484
@@ -489,7 +489,8 @@ def retrieve_sam(name=None, samfile=None):
489489
Name can be one of:
490490
491491
* 'CECMod' - returns the CEC module database
492-
* 'SandiaInverter' - returns the Sandia Inverter database
492+
* 'CECInverter' - returns the CEC Inverter database
493+
* 'SandiaInverter' - returns the CEC Inverter database (CEC is only current inverter db available; tag kept for backwards compatibility)
493494
* 'SandiaMod' - returns the Sandia Module database
494495
495496
samfile : String
@@ -503,14 +504,14 @@ def retrieve_sam(name=None, samfile=None):
503504
Returns
504505
-------
505506
A DataFrame containing all the elements of the desired database.
506-
Each column representa a module or inverter, and a specific dataset
507-
can be retreived by the command
507+
Each column represents a module or inverter, and a specific dataset
508+
can be retrieved by the command
508509
509510
Examples
510511
--------
511512
512513
>>> from pvlib import pvsystem
513-
>>> invdb = pvsystem.retrieve_sam(name='SandiaInverter')
514+
>>> invdb = pvsystem.retrieve_sam(name='CECInverter')
514515
>>> inverter = invdb.AE_Solar_Energy__AE6_0__277V__277V__CEC_2012_
515516
>>> inverter
516517
Vac 277.000000
@@ -534,11 +535,11 @@ def retrieve_sam(name=None, samfile=None):
534535
name = name.lower()
535536

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

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

562563

563564
def _parse_raw_sam_df(csvdata):
564-
df = pd.read_csv(csvdata, index_col=0)
565+
df = pd.read_csv(csvdata, index_col=0, skiprows=[1,2])
566+
colnames = df.columns.values.tolist()
567+
parsedcolnames = []
568+
for cn in colnames:
569+
parsedcolnames.append(cn.replace(' ', '_'))
570+
571+
df.columns = parsedcolnames
572+
565573
parsedindex = []
566574
for index in df.index:
567575
parsedindex.append(index.replace(' ', '_').replace('-', '_')
568576
.replace('.', '_').replace('(', '_')
569577
.replace(')', '_').replace('[', '_')
570-
.replace(']', '_').replace(':', '_'))
578+
.replace(']', '_').replace(':', '_')
579+
.replace('+', '_').replace('/', '_')
580+
.replace('"', '_').replace(',', '_'))
571581

572582
df.index = parsedindex
573583
df = df.transpose()
@@ -635,7 +645,7 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
635645
reference condition (1/C)
636646
Aimp Maximum power current temperature coefficient at
637647
reference condition (1/C)
638-
Bvoc Open circuit voltage temperature coefficient at
648+
Bvoco Open circuit voltage temperature coefficient at
639649
reference condition (V/C)
640650
Mbvoc Coefficient providing the irradiance dependence for the BetaVoc
641651
temperature coefficient at reference irradiance (V/C)
@@ -644,7 +654,7 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
644654
Mbvmp Coefficient providing the irradiance dependence for the
645655
BetaVmp temperature coefficient at reference irradiance (V/C)
646656
N Empirically determined "diode factor" (dimensionless)
647-
#Series Number of cells in series in a module's cell string(s)
657+
Cells_in_Series Number of cells in series in a module's cell string(s)
648658
IXO Ix at reference conditions
649659
IXXO Ixx at reference conditions
650660
FD Fraction of diffuse irradiance used by module
@@ -693,12 +703,12 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
693703
(1 + module['Aimp']*(temp_cell - T0)) )
694704

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

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

704714
dfout['p_mp'] = dfout['i_mp'] * dfout['v_mp']

pvlib/test/test_pvsystem.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_physicaliam():
9999
def test_retrieve_sam_network():
100100
sam_data['cecmod'] = pvsystem.retrieve_sam('cecmod')
101101
sam_data['sandiamod'] = pvsystem.retrieve_sam('sandiamod')
102-
sam_data['sandiainverter'] = pvsystem.retrieve_sam('sandiainverter')
102+
sam_data['cecinverter'] = pvsystem.retrieve_sam('cecinverter')
103103

104104

105105
def test_sapm():
@@ -117,7 +117,7 @@ def test_calcparams_desoto():
117117
cecmodule = sam_data['cecmod'].Example_Module
118118
pvsystem.calcparams_desoto(irrad_data['ghi'],
119119
temp_cell=25,
120-
alpha_isc=cecmodule['Alpha_sc'],
120+
alpha_isc=cecmodule['alpha_sc'],
121121
module_parameters=cecmodule,
122122
EgRef=1.121,
123123
dEgdT=-0.0002677)
@@ -133,7 +133,7 @@ def test_singlediode_series():
133133
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
134134
irrad_data['ghi'],
135135
temp_cell=25,
136-
alpha_isc=cecmodule['Alpha_sc'],
136+
alpha_isc=cecmodule['alpha_sc'],
137137
module_parameters=cecmodule,
138138
EgRef=1.121,
139139
dEgdT=-0.0002677)
@@ -180,7 +180,7 @@ def test_sapm_celltemp_with_index():
180180

181181

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

192192

193193
def test_snlinverter_float():
194-
inverters = sam_data['sandiainverter']
194+
inverters = sam_data['cecinverter']
195195
testinv = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'
196196
vdcs = 25.
197197
idcs = 5.5
198198
pdcs = idcs * vdcs
199199

200200
pacs = pvsystem.snlinverter(inverters[testinv], vdcs, pdcs)
201-
assert_almost_equals(pacs, 132.004308, 5)
201+
assert_almost_equals(pacs, 132.004278, 5)
202202

0 commit comments

Comments
 (0)