Skip to content

Commit 7120082

Browse files
committed
standardize sapm_celltemp arg names. add dict/Series input
1 parent aa52f5f commit 7120082

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

pvlib/pvsystem.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,8 @@ def sapm(module, poa_direct, poa_diffuse, temp_cell, airmass_absolute, aoi):
10671067
return dfout
10681068

10691069

1070-
def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
1070+
def sapm_celltemp(poa_global, wind_speed, temp_air,
1071+
model='open_rack_cell_glassback'):
10711072
'''
10721073
Estimate cell and module temperatures per the Sandia PV Array
10731074
Performance Model (SAPM, SAND2004-3535), from the incident
@@ -1076,16 +1077,16 @@ def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
10761077
10771078
Parameters
10781079
----------
1079-
irrad : float or Series
1080+
poa_global : float or Series
10801081
Total incident irradiance in W/m^2.
10811082
1082-
wind : float or Series
1083+
wind_speed : float or Series
10831084
Wind speed in m/s at a height of 10 meters.
10841085
1085-
temp : float or Series
1086+
temp_air : float or Series
10861087
Ambient dry bulb temperature in degrees C.
10871088
1088-
model : string or list
1089+
model : string, list, or dict
10891090
Model to be used.
10901091
10911092
If string, can be:
@@ -1097,7 +1098,8 @@ def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
10971098
* 'open_rack_polymer_thinfilm_steel'
10981099
* '22x_concentrator_tracker'
10991100
1100-
If list, supply the following parameters in the following order:
1101+
If dict, supply the following parameters
1102+
(if list, in the following order):
11011103
11021104
* a : float
11031105
SAPM module parameter for establishing the upper
@@ -1136,25 +1138,27 @@ def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
11361138
'open_rack_polymer_thinfilm_steel': [-3.58, -.113, 3],
11371139
'22x_concentrator_tracker': [-3.23, -.130, 13]
11381140
}
1139-
1141+
11401142
if isinstance(model, str):
11411143
model = temp_models[model.lower()]
11421144
elif isinstance(model, list):
11431145
model = model
1144-
1146+
elif isinstance(model, (dict, pd.Series)):
1147+
model = [model['a'], model['b'], model['deltaT']]
1148+
11451149
a = model[0]
11461150
b = model[1]
11471151
deltaT = model[2]
11481152

11491153
E0 = 1000. # Reference irradiance
1150-
1151-
temp_module = pd.Series(irrad*np.exp(a + b*wind) + temp)
11521154

1153-
temp_cell = temp_module + (irrad / E0)*(deltaT)
1155+
temp_module = pd.Series(poa_global*np.exp(a + b*wind_speed) + temp_air)
1156+
1157+
temp_cell = temp_module + (poa_global / E0)*(deltaT)
11541158

11551159
return pd.DataFrame({'temp_cell': temp_cell, 'temp_module': temp_module})
1156-
1157-
1160+
1161+
11581162
def singlediode(module, photocurrent, saturation_current,
11591163
resistance_series, resistance_shunt, nNsVth):
11601164
'''

pvlib/test/test_pvsystem.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ def test_sapm_celltemp():
171171
[-3.47, -.0594, 3]))
172172

173173

174+
def test_sapm_celltemp_dict_like():
175+
default = pvsystem.sapm_celltemp(900, 5, 20)
176+
assert_almost_equals(43.509, default.ix[0, 'temp_cell'], 3)
177+
assert_almost_equals(40.809, default.ix[0, 'temp_module'], 3)
178+
model = {'a':-3.47, 'b':-.0594, 'deltaT':3}
179+
assert_frame_equal(default, pvsystem.sapm_celltemp(900, 5, 20, model))
180+
model = pd.Series(model)
181+
assert_frame_equal(default, pvsystem.sapm_celltemp(900, 5, 20, model))
182+
183+
174184
def test_sapm_celltemp_with_index():
175185
times = pd.DatetimeIndex(start='2015-01-01', end='2015-01-02', freq='12H')
176186
temps = pd.Series([0, 10, 5], index=times)

0 commit comments

Comments
 (0)