Skip to content

Commit 31240db

Browse files
committed
correct noct function, adjust tests, add comments
1 parent 5bf2eef commit 31240db

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

pvlib/temp_bright_sun_dev.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Wed Feb 3 13:45:02 2021
4+
5+
@author: cliff
6+
"""
7+
8+
import pandas as pd
9+
import pytz
10+
from pvlib import solarposition
11+
12+
tz = pytz.timezone('Etc/GMT+7')
13+
dt = pd.date_range(start='02-01-2021 00:00:00', end='02-27-2021 00:00:00',
14+
freq='1H', tz=tz)
15+
16+
rs_spa = solarposition.sun_rise_set_transit_spa(dt, 35, -116)
17+
18+
rs_pyephem = solarposition.sun_rise_set_transit_ephem(dt, 35, -116)
19+
20+
both = pd.DataFrame(index=dt)
21+
both['rise_spa'] = rs_spa['sunrise']
22+
both['rise_ephem'] = rs_pyephem['sunrise']
23+
both['set_spa'] = rs_spa['sunset']
24+
both['set_ephem'] = rs_pyephem['sunset']

pvlib/temperature.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,19 +708,23 @@ def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
708708
return pd.Series(tmod_array - 273.15, index=poa_global.index, name='tmod')
709709

710710

711-
def _adj_noct(x):
712-
return np.piecewise(x, [x < 0.5, (x >= 0.5) & (x < 1.5),
713-
(x >= 1.5) & (x < 2.5), (x >= 2.5) & (x < 3.5),
714-
x >= 3.5], [18., 11., 6., 2., 0.])
711+
def _adj_for_mounting_standoff(x):
712+
# supports noct cell temperature model.
713+
# the exact division of the range of x into intervals is not specified
714+
# in the SAM code, except for the last interval x > 3.5.
715+
return np.piecewise(x, [x <= 0, (x > 0) & (x < 0.5),
716+
(x >= 0.5) & (x < 1.5), (x >= 1.5) & (x < 2.5),
717+
(x >= 2.5) & (x <= 3.5), x > 3.5],
718+
[0., 18., 11., 6., 2., 0.])
715719

716720

717721
def noct(poa_global, temp_air, wind_speed, noct, eta_m_ref,
718722
effective_irradiance=None, transmittance_absorbtance=0.9,
719-
array_height=1, mount_standoff=3.5):
723+
array_height=1, mount_standoff=4):
720724
'''
721725
Cell temperature model from the System Advisor Model (SAM).
722726
723-
The model is described in [1], Section 10.6.
727+
The model is described in [1]_, Section 10.6.
724728
725729
Parameters
726730
----------
@@ -756,7 +760,7 @@ def noct(poa_global, temp_air, wind_speed, noct, eta_m_ref,
756760
be either 1 or 2. For systems elevated less than one story, use 1.
757761
If system is elevated more than two stories, use 2.
758762
759-
mount_standoff : numeric, default 3.5
763+
mount_standoff : numeric, default 4
760764
Distance between array mounting and mounting surface. Use default
761765
if system is ground-mounted. [inches]
762766
@@ -790,10 +794,12 @@ def noct(poa_global, temp_air, wind_speed, noct, eta_m_ref,
790794
raise ValueError(
791795
f'array_height must be 1 or 2, {array_height} was given')
792796

793-
noct_adj = noct + _adj_noct(mount_standoff)
797+
noct_adj = noct + _adj_for_mounting_standoff(mount_standoff)
794798
tau_alpha = transmittance_absorbtance * irr_ratio
795799

796-
cell_temp_init = ross(poa_global, temp_air, noct_adj)
800+
# [1] Eq. 10.37 isn't clear on exactly what "G" is. SAM SSC code uses
801+
# poa_global where G appears
802+
cell_temp_init = poa_global / 800. * (noct_adj - 20.)
797803
heat_loss = 1 - eta_m_ref / tau_alpha
798804
wind_loss = 9.5 / (5.7 + 3.8 * wind_adj)
799-
return cell_temp_init * heat_loss * wind_loss
805+
return temp_air + cell_temp_init * heat_loss * wind_loss

pvlib/tests/test_temperature.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ def test_fuentes_timezone(tz):
217217
def test_noct():
218218
poa_global, temp_air, wind_speed, noct, eta_m_ref = (1000., 25., 1., 45.,
219219
0.2)
220-
expected = 54.41542289
220+
expected = 54.151119403
221221
result = temperature.noct(poa_global, temp_air, wind_speed, noct,
222222
eta_m_ref)
223-
assert np.isclose(result, expected)
223+
assert assert_allclose(result, expected)
224224
# test with different types
225225
result = temperature.noct(np.array(poa_global), np.array(temp_air),
226226
np.array(wind_speed), np.array(noct),
227227
np.array(eta_m_ref))
228-
assert np.isclose(result, expected)
228+
assert assert_allclose(result, expected)
229229
dr = pd.date_range(start='2020-01-01 12:00:00', end='2020-01-01 13:00:00',
230230
freq='1H')
231231
result = temperature.noct(pd.Series(index=dr, data=poa_global),
@@ -247,8 +247,8 @@ def test_noct_options():
247247
eta_m_ref, effective_irradiance,
248248
transmittance_absorbtance, array_height,
249249
mount_standoff)
250-
expected = 58.36654459
251-
assert np.isclose(result, expected)
250+
expected = 60.477703576
251+
assert_allclose(result, expected)
252252

253253

254254
def test_noct_errors():

0 commit comments

Comments
 (0)