Skip to content

Commit e5473bd

Browse files
authored
note and tests for disc relative vs absolute airmass (#625)
1 parent f8edab9 commit e5473bd

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Enhancements
4444
(:issue:`604`)
4545
* Change :py:func:`pvlib.pvsystem.sapm_spectral_loss` to avoid numpy warning.
4646
* Add warning message when :py:func:`pvlib.spa` is reloaded.
47+
* Add option for :py:func:`pvlib.irradiance.disc` to use relative airmass
48+
by supplying `pressure=None`. (:issue:`449`)
4749

4850

4951
Bug fixes
@@ -69,3 +71,4 @@ Contributors
6971
* Ben Ellis (:ghuser:`bhellis725`)
7072
* Cliff Hansen (:ghuser:`cwhanse`)
7173
* Mark Mikofski (:ghuser:`mikofski`)
74+
* Anton Driesse (:ghuser:`adriesse`)

pvlib/irradiance.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,13 @@ def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,
13061306
13071307
The pvlib implementation limits the clearness index to 1.
13081308
1309+
The original report describing the DISC model [1]_ uses the
1310+
relative airmass rather than the absolute (pressure-corrected)
1311+
airmass. However, the NREL implementation of the DISC model [2]_
1312+
uses absolute airmass. PVLib Matlab also uses the absolute airmass.
1313+
pvlib python defaults to absolute airmass, but the relative airmass
1314+
can be used by supplying `pressure=None`.
1315+
13091316
Parameters
13101317
----------
13111318
ghi : numeric
@@ -1319,8 +1326,9 @@ def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,
13191326
Day of year or array of days of year e.g.
13201327
pd.DatetimeIndex.dayofyear, or pd.DatetimeIndex.
13211328
1322-
pressure : numeric, default 101325
1323-
Site pressure in Pascal.
1329+
pressure : None or numeric, default 101325
1330+
Site pressure in Pascal. If None, relative airmass is used
1331+
instead of absolute (pressure-corrected) airmass.
13241332
13251333
min_cos_zenith : numeric, default 0.065
13261334
Minimum value of cos(zenith) to allow when calculating global
@@ -1344,15 +1352,13 @@ def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,
13441352
13451353
References
13461354
----------
1347-
[1] Maxwell, E. L., "A Quasi-Physical Model for Converting Hourly
1348-
Global Horizontal to Direct Normal Insolation", Technical
1349-
Report No. SERI/TR-215-3087, Golden, CO: Solar Energy Research
1350-
Institute, 1987.
1355+
.. [1] Maxwell, E. L., "A Quasi-Physical Model for Converting Hourly
1356+
Global Horizontal to Direct Normal Insolation", Technical
1357+
Report No. SERI/TR-215-3087, Golden, CO: Solar Energy Research
1358+
Institute, 1987.
13511359
1352-
[2] J.W. "Fourier series representation of the position of the sun".
1353-
Found at:
1354-
http://www.mail-archive.com/[email protected]/msg01050.html on
1355-
January 12, 2012
1360+
.. [2] Maxwell, E. "DISC Model", Excel Worksheet.
1361+
https://www.nrel.gov/grid/solar-resource/disc.html
13561362
13571363
See Also
13581364
--------
@@ -1367,7 +1373,8 @@ def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,
13671373
max_clearness_index=1)
13681374

13691375
am = atmosphere.get_relative_airmass(solar_zenith, model='kasten1966')
1370-
am = atmosphere.get_absolute_airmass(am, pressure)
1376+
if pressure is not None:
1377+
am = atmosphere.get_absolute_airmass(am, pressure)
13711378

13721379
Kn = _disc_kn(kt, am)
13731380
dni = Kn * I0

pvlib/test/test_irradiance.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,23 @@ def test_poa_components(irrad_data, ephem_data, dni_et, relative_airmass):
359359
assert_frame_equal(out, expected)
360360

361361

362-
def test_disc_value():
362+
@pytest.mark.parametrize('pressure,expected', [
363+
(93193, [[830.46567, 0.79742, 0.93505],
364+
[676.09497, 0.63776, 3.02102]]),
365+
(None, [[868.72425, 0.79742, 1.01664],
366+
[680.66679, 0.63776, 3.28463]]),
367+
(101325, [[868.72425, 0.79742, 1.01664],
368+
[680.66679, 0.63776, 3.28463]])
369+
])
370+
def test_disc_value(pressure, expected):
371+
# see GH 449 for pressure=None vs. 101325.
363372
columns = ['dni', 'kt', 'airmass']
364373
times = pd.DatetimeIndex(['2014-06-24T1200', '2014-06-24T1800'],
365374
tz='America/Phoenix')
366375
ghi = pd.Series([1038.62, 254.53], index=times)
367376
zenith = pd.Series([10.567, 72.469], index=times)
368-
pressure = 93193.
369377
out = irradiance.disc(ghi, zenith, times, pressure=pressure)
370-
expected_values = np.array(
371-
[[830.46567, 0.79742, 0.93505],
372-
[676.09497, 0.63776, 3.02102]])
378+
expected_values = np.array(expected)
373379
expected = pd.DataFrame(expected_values, columns=columns, index=times)
374380
# check the pandas dataframe. check_less_precise is weird
375381
assert_frame_equal(out, expected, check_less_precise=True)

0 commit comments

Comments
 (0)