Skip to content

Commit fe486ec

Browse files
committed
initial campbellnormal
1 parent 6e5148f commit fe486ec

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

docs/sphinx/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ DNI estimation models
181181
irradiance.dirint
182182
irradiance.dirindex
183183
irradiance.erbs
184+
irradiance.campbellnorman
184185
irradiance.liujordan
185186
irradiance.gti_dirint
186187

docs/sphinx/source/whatsnew/v0.8.1.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Breaking changes
99

1010
Deprecations
1111
~~~~~~~~~~~~
12-
12+
* :py:func:`pvlib.irradiance.liujordan` is deprecated.
1313

1414
Enhancements
1515
~~~~~~~~~~~~
@@ -21,6 +21,10 @@ Enhancements
2121
multiple MPPTs (:issue:`457`, :pull:`1085`)
2222
* Added optional ``attributes`` parameter to :py:func:`pvlib.iotools.get_psm3`
2323
and added the option of fetching 5- and 15-minute PSM3 data. (:pull:`1086`)
24+
* Added :py:func:`pvlib.irradiance.campbellnorman` for estimating DNI, DHI and GHI
25+
from extraterrestrial irradiance. This function replaces :py:func:`pvlib.irradiance.liujordan`;
26+
users of :py:func:`pvlib.irradiance.liujordan` should note that :py:func:`pvlib.irradiance.campbellnorman`
27+
expects different parameters.
2428

2529
Bug fixes
2630
~~~~~~~~~

pvlib/irradiance.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
from pvlib import atmosphere, solarposition, tools
1515

16+
from pvlib._deprecation import deprecated
17+
18+
1619
# see References section of grounddiffuse function
1720
SURFACE_ALBEDOS = {'urban': 0.18,
1821
'grass': 0.20,
@@ -2184,6 +2187,58 @@ def erbs(ghi, zenith, datetime_or_doy, min_cos_zenith=0.065, max_zenith=87):
21842187
return data
21852188

21862189

2190+
def campbellnorman(zenith, transmittance, pressure=101325.0, dni_extra=1367.0):
2191+
'''
2192+
Determine DNI, DHI, GHI from extraterrestrial flux, transmittance,
2193+
and atmospheric pressure.
2194+
2195+
Parameters
2196+
----------
2197+
zenith: pd.Series
2198+
True (not refraction-corrected) zenith angles in decimal
2199+
degrees. If Z is a vector it must be of the same size as all
2200+
other vector inputs. Z must be >=0 and <=180.
2201+
2202+
transmittance: float
2203+
Atmospheric transmittance between 0 and 1.
2204+
2205+
pressure: float, default 101325.0
2206+
Air pressure
2207+
2208+
dni_extra: float, default 1367.0
2209+
Direct irradiance incident at the top of the atmosphere.
2210+
2211+
Returns
2212+
-------
2213+
irradiance: DataFrame
2214+
Modeled direct normal irradiance, direct horizontal irradiance,
2215+
and global horizontal irradiance in W/m^2
2216+
2217+
References
2218+
----------
2219+
.. [1] Campbell, G. S., J. M. Norman (1998) An Introduction to
2220+
Environmental Biophysics. 2nd Ed. New York: Springer.
2221+
'''
2222+
2223+
tau = transmittance
2224+
2225+
airmass = atmosphere.get_relative_airmass(zenith, model='simple')
2226+
airmass = atmosphere.get_absolute_airmass(airmass, pressure=pressure)
2227+
dni = dni_extra*tau**airmass
2228+
dhi = 0.3 * (1.0 - tau**airmass) * dni_extra * np.cos(np.radians(zenith))
2229+
ghi = dhi + dni * np.cos(np.radians(zenith))
2230+
2231+
irrads = OrderedDict()
2232+
irrads['ghi'] = ghi
2233+
irrads['dni'] = dni
2234+
irrads['dhi'] = dhi
2235+
2236+
if isinstance(ghi, pd.Series):
2237+
irrads = pd.DataFrame(irrads)
2238+
2239+
return irrads
2240+
2241+
21872242
def liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
21882243
'''
21892244
Determine DNI, DHI, GHI from extraterrestrial flux, transmittance,
@@ -2242,6 +2297,10 @@ def liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
22422297
return irrads
22432298

22442299

2300+
liujordan = deprecated('0.8', alternative='campbellnormam',
2301+
name='liujordan', removal='0.9')(liujordan)
2302+
2303+
22452304
def _get_perez_coefficients(perezmodel):
22462305
'''
22472306
Find coefficients for the Perez model

pvlib/tests/test_irradiance.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,17 @@ def test_liujordan():
295295
assert_frame_equal(out, expected)
296296

297297

298+
def test_campbellnorman():
299+
expected = pd.DataFrame(np.array(
300+
[[863.859736967, 653.123094076, 220.65905025]]),
301+
columns=['ghi', 'dni', 'dhi'],
302+
index=[0])
303+
out = irradiance.campbellnorman(
304+
pd.Series([10]), pd.Series([0.5]), pd.Series([109764.21013135818]),
305+
dni_extra=1400)
306+
assert_frame_equal(out, expected)
307+
308+
298309
def test_get_total_irradiance(irrad_data, ephem_data, dni_et, relative_airmass):
299310
models = ['isotropic', 'klucher',
300311
'haydavies', 'reindl', 'king', 'perez']

0 commit comments

Comments
 (0)