Skip to content

Commit 36871d2

Browse files
committed
fix celltemp keys. make output a df. closes #54
1 parent ba6f7f3 commit 36871d2

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ We recommend that all users upgrade to this version.
1111
API changes
1212
~~~~~~~~~~~
1313

14-
* Change variable names to conform with new `Variables and style rules wiki <https://github.com/pvlib/pvlib-python/wiki/Variables-and-style-rules>`_ (:issue:`37`, :issue:`54`).
14+
* Change variable names to conform with new
15+
`Variables and style rules wiki <https://github.com/pvlib/pvlib-python/wiki/Variables-and-style-rules>`_ (:issue:`37`, :issue:`54`).
16+
* Make output of ``pvsystem.sapm_celltemp`` a DataFrame (:issue:`54`)
1517

1618
Enhancements
1719
~~~~~~~~~~~~

pvlib/pvsystem.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,8 @@ def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
768768
769769
Returns
770770
--------
771-
dict with keys tcell and tmodule. Values in degrees C.
771+
DataFrame with columns 'temp_cell' and 'temp_module'.
772+
Values in degrees C.
772773
773774
References
774775
----------
@@ -799,11 +800,11 @@ def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
799800

800801
E0 = 1000. # Reference irradiance
801802

802-
tmodule = irrad*np.exp(a + b*wind) + temp
803+
temp_module = pd.Series(irrad*np.exp(a + b*wind) + temp)
803804

804-
tcell = tmodule + (irrad / E0)*(deltaT)
805+
temp_cell = temp_module + (irrad / E0)*(deltaT)
805806

806-
return {'tcell':tcell, 'tmodule':tmodule}
807+
return pd.DataFrame({'temp_cell': temp_cell, 'temp_module': temp_module})
807808

808809

809810
def singlediode(module, IL, I0, Rs, Rsh, nNsVth, **kwargs):

pvlib/test/test_pvsystem.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pandas as pd
1010

1111
from nose.tools import assert_equals, assert_almost_equals
12+
from pandas.util.testing import assert_frame_equal
1213

1314
from pvlib import tmy
1415
from pvlib import pvsystem
@@ -135,10 +136,25 @@ def test_singlediode():
135136

136137
def test_sapm_celltemp():
137138
default = pvsystem.sapm_celltemp(900, 5, 20)
138-
assert_almost_equals(43.509, default['tcell'], 3)
139-
assert_almost_equals(40.809, default['tmodule'], 3)
140-
assert_equals(default, pvsystem.sapm_celltemp(900, 5, 20,
141-
[-3.47, -.0594, 3]))
139+
assert_almost_equals(43.509, default.ix[0, 'temp_cell'], 3)
140+
assert_almost_equals(40.809, default.ix[0, 'temp_module'], 3)
141+
assert_frame_equal(default, pvsystem.sapm_celltemp(900, 5, 20,
142+
[-3.47, -.0594, 3]))
143+
144+
145+
def test_sapm_celltemp_with_index():
146+
times = pd.DatetimeIndex(start='2015-01-01', end='2015-01-02', freq='12H')
147+
temps = pd.Series([0, 10, 5], index=times)
148+
irrads = pd.Series([0, 500, 0], index=times)
149+
winds = pd.Series([10, 5, 0], index=times)
150+
151+
pvtemps = pvsystem.sapm_celltemp(irrads, winds, temps)
152+
153+
expected = pd.DataFrame({'temp_cell':[0., 23.06066166, 5.],
154+
'temp_module':[0., 21.56066166, 5.]},
155+
index=times)
156+
157+
assert_frame_equal(expected, pvtemps)
142158

143159

144160
def test_snlinverter():

0 commit comments

Comments
 (0)